On Fri, 2004-10-22 at 13:49, Jean-Marc Lasgouttes wrote: > Also, this status() method returns the right value for a submenu too. > Therefore submenuDisabled is not needed at all. Wonderful! This makes the code much shorter.
I'll commit the attached patch if nobody objects. John
Index: GMenubar.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GMenubar.C,v retrieving revision 1.16 diff -u -p -r1.16 GMenubar.C --- GMenubar.C 2004/10/04 11:32:34 1.16 +++ GMenubar.C 2004/10/22 13:19:23 @@ -122,35 +122,6 @@ void GMenubar::openByName(string const & } -bool GMenubar::submenuDisabled(MenuItem const * item) -{ - Menu * from = item->submenu(); - Menu to; - menubackend.expand(*from, to, view_); - Menu::const_iterator i = to.begin(); - Menu::const_iterator end = to.end(); - for (; i != end; ++i) { - switch (i->kind()) { - case MenuItem::Submenu: - if (!submenuDisabled(&(*i))) - return false; - break; - case MenuItem::Command: - { - FuncStatus const flag = - view_->getLyXFunc().getStatus(i->func()); - if (flag.enabled()) - return false; - break; - } - default: - break; - } - } - return true; -} - - void GMenubar::onSubMenuActivate(MenuItem const * item, Gtk::MenuItem * gitem) { @@ -178,7 +149,7 @@ void GMenubar::onSubMenuActivate(MenuIte sigc::bind(sigc::mem_fun(*this, &GMenubar::onSubMenuActivate), &(*i), &gmenu->items().back())); - if (submenuDisabled(&(*i))) + if (!(*i).status().enabled()) gmenu->items().back().set_sensitive(false); break; case MenuItem::Command: Index: GMenubar.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GMenubar.h,v retrieving revision 1.6 diff -u -p -r1.6 GMenubar.h --- GMenubar.h 2004/09/26 18:36:07 1.6 +++ GMenubar.h 2004/10/22 13:19:23 @@ -33,7 +33,6 @@ public: private: void onCommandActivate(MenuItem const * item, Gtk::MenuItem * gitem); void onSubMenuActivate(MenuItem const * item, Gtk::MenuItem * gitem); - bool submenuDisabled(MenuItem const * item); Gtk::MenuBar menubar_; LyXView * view_; std::vector<Glib::ustring> mainMenuNames_;