void updateWorkspaces(Fl_Widget*,void*) { bool showapplet; pGlobalConfig.get("Panel", "Workspaces", showapplet, true); if (!showapplet) { return; } mWorkspace->clear(); mWorkspace->begin(); char **names=0; int count = Fl_WM::get_workspace_count(); int names_count = Fl_WM::get_workspace_names(names); int current = Fl_WM::get_current_workspace(); for(int n=0; n<count; n++) { Fl_Item *i = new Fl_Item(); i->callback(setWorkspace, (long)n); i->type(Fl_Item::RADIO); if(n<names_count && names[n]) { i->label(names[n]); free(names[n]); } else { Fl_String tmp; i->label(tmp.printf(tmp, "%s %d", _("Workspace") ,n+1)); } if(current==n) i->set_value(); } // add a divider if there are no workspaces if (count<1) { new Fl_Menu_Divider(); } if(names) delete []names; mWorkspace->end(); }
void Fl_Tool_Bar::layout() { if(!opened()) { Fl_Widget::layout(); return; } int X=0,Y=0,W=w(),H=h(); box()->inset(X,Y,W,H); X+=glyph_size()+layout_spacing(); H=0; int hoff = layout_spacing()*2 + box()->dh(); int out=-1; for(int n=0; n<children(); n++) { Fl_Widget *w = child(n); if(w==m_menu || w==m_menubut || w==m_right) continue; w->show(); int ww = w->w(); int wh = h()-hoff; w->preferred_size(ww, wh); w->resize(X, box()->dy()+layout_spacing(), ww, wh); w->layout(); if(H < w->h()+hoff) H = w->h()+hoff; X += w->w()+layout_spacing(); if(X>W - (m_menubut->visible()?15:0) ) { out=n; //w->hide(); break; } } if(m_menu->children()) m_menu->clear(); if(out>=0) { m_menubut->resize(W-15, Y+2, 14, H-box()->dh()-4); m_menu->resize(W-15, Y, 15, H-box()->dh()); m_menubut->show(); m_menu->begin(); for(int n=out; n<children(); n++) { Fl_Widget *w = child(n); if(w==m_menu || w==m_menubut || w==m_right) continue; if(n>out) w->hide(); if(w->is_group()) continue; if(w->type()==Fl_Divider::VERTICAL) { // Create divider, only if not first in menu if(n>out) new Fl_Divider(1, 5); } else { Fl_Item *i = new Fl_Item(); // Tooltip as a label, if theres one i->label(w->tooltip().empty() ? w->label() : w->tooltip()); i->image(w->image()); i->user_data(w); i->activate(w->active()); i->type(w->type()); if(w->value()) i->set_value(); else i->clear_value(); } } m_menu->end(); } else { m_menubut->hide(); } if(h() != H) { h(H); } Fl_Widget::layout(); }