#include "acidlaunch.h" #include ButtonBar::ButtonBar(LauncherTabNode* tab, bool vert, int xsize, int ysize, int width, int bgcolor) { AppButton* but; unsigned int appwidth, appheight, x, y; list::const_iterator iter; /* create the horizontal or vertical bar to place all the buttons in */ /* create the tooltips object that's used to reference all the tooltips for the bar */ tooltips = gtk_tooltips_new(); for(iter=tab->children().begin(); iter!=tab->children().end(); iter++) { AppIconNode* app = (AppIconNode*)(*iter); but = new AppButton(app, xsize, ysize, bgcolor, tooltips); appicons.push_back(but); } /* calculate width and height (in app icons) of the tab */ if(vert) { appwidth = width; appheight = (appicons.size() / width) + ((appicons.size() % width) ? 1 : 0); } else { appheight = width; appwidth = (appicons.size() / width) + ((appicons.size() % width) ? 1 : 0); } /* create table widget */ box = gtk_table_new(appheight, appwidth, TRUE); /* loop through the widgets and put them all in the table */ for(y=0; y < appheight; y++) { for(x=0; x < appwidth; x++) { unsigned int appnum = (y * appwidth) + x; if(appnum < appicons.size()) { gtk_table_attach_defaults(GTK_TABLE(box), appicons[appnum]->widget(), x, x+1, y, y+1); } } } gtk_widget_show(box); } ButtonBar::~ButtonBar() { for(int i=0; i