X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fgtk%2FGMenubar.C;h=45a2159d62a9fb364c1ee93ce843ac7691ff6338;hb=005955b52744830d3531b78b671a325b5ba8f41a;hp=80d211577ea3740ffce0699e2469e0305f5e54cf;hpb=e68157b7741f9195ce277c467a99b7c86a05daa7;p=lyx.git diff --git a/src/frontends/gtk/GMenubar.C b/src/frontends/gtk/GMenubar.C index 80d211577e..45a2159d62 100644 --- a/src/frontends/gtk/GMenubar.C +++ b/src/frontends/gtk/GMenubar.C @@ -9,7 +9,6 @@ */ #include -#include #include "GMenubar.h" #include "GView.h" @@ -18,11 +17,13 @@ using std::string; +namespace lyx { +namespace frontend { + namespace { -class LyxMenu : public Gtk::Menu -{ +class LyxMenu : public Gtk::Menu { public: LyxMenu() { menu_.reset(new ::Menu); } @@ -47,9 +48,8 @@ Glib::ustring labelTrans(string const & label, string const & shortcut) void ClearMenu(Gtk::MenuShell * menu) { - Gtk::Menu_Helpers::MenuList::iterator m, end; - m = menu->items().begin(); - end = menu->items().end(); + Gtk::Menu_Helpers::MenuList::iterator m = menu->items().begin(); + Gtk::Menu_Helpers::MenuList::iterator end = menu->items().end(); Gtk::Menu * subMenu; for (; m != end; ++m) { if ((subMenu = m->get_submenu()) != 0) { @@ -64,7 +64,7 @@ void ClearMenu(Gtk::MenuShell * menu) } -GMenubar::GMenubar(LyXView *lyxView, MenuBackend const & /*menuBackend*/) : +GMenubar::GMenubar(LyXView * lyxView, MenuBackend const & /*menuBackend*/) : view_(lyxView) { GView * gview = static_cast(lyxView); @@ -84,7 +84,7 @@ GMenubar::GMenubar(LyXView *lyxView, MenuBackend const & /*menuBackend*/) : labelTrans(i->label(), i->shortcut()), *gmenu)); menubar_.items().back().signal_activate().connect( - SigC::bind(SigC::slot(*this, &GMenubar::onSubMenuActivate), &(*i), + sigc::bind(sigc::mem_fun(*this, &GMenubar::onSubMenuActivate), &(*i), &menubar_.items().back())); mainMenuNames_.push_back(i->submenuname()); } @@ -172,7 +172,7 @@ void GMenubar::onSubMenuActivate(MenuItem const * item, labelTrans(i->label(), i->shortcut()), *gmenu_new)); gmenu->items().back().signal_activate().connect( - SigC::bind(SigC::slot(*this, &GMenubar::onSubMenuActivate), + sigc::bind(sigc::mem_fun(*this, &GMenubar::onSubMenuActivate), &(*i), &gmenu->items().back())); if (submenuDisabled(&(*i))) @@ -180,9 +180,6 @@ void GMenubar::onSubMenuActivate(MenuItem const * item, break; case MenuItem::Command: { -#ifdef WITH_WARNINGS -#warning Bindings are not inserted into the menu labels here. (Lgb) -#endif FuncStatus const flag = view_->getLyXFunc().getStatus(i->func()); bool on = flag.onoff(true); @@ -198,14 +195,25 @@ void GMenubar::onSubMenuActivate(MenuItem const * item, gmenu->items().back()); citem.set_active(on); } else { - gmenu->items().push_back( - Gtk::Menu_Helpers::MenuElem( - labelTrans(i->label(), - i->shortcut()))); + //This is necessary because add_accel_label is protected, + //and even if you subclass Gtk::MenuItem then add_accel_label + //doesn't do what you'd expect. + Gtk::MenuItem * item = Gtk::manage(new Gtk::MenuItem); + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox); + Gtk::Label * label1 = Gtk::manage(new Gtk::Label( + labelTrans(i->label(), i->shortcut()), true)); + Gtk::Label * label2 = Gtk::manage(new Gtk::Label( + " " + i->binding(), false)); + hbox->pack_start(*label1, false, false, 0); + hbox->pack_end(*label2, false, false, 0); + item->add(*hbox); + + gmenu->append(*item); + item->show_all(); } Gtk::MenuItem & item = gmenu->items().back(); item.signal_activate().connect( - SigC::bind(SigC::slot(*this, &GMenubar::onCommandActivate), + sigc::bind(sigc::mem_fun(*this, &GMenubar::onCommandActivate), &(*i), &item)); if (!flag.enabled()) item.set_sensitive(false); @@ -229,3 +237,6 @@ void GMenubar::onCommandActivate(MenuItem const * item, { view_->getLyXFunc().dispatch(item->func(), true); } + +} // namespace frontend +} // namespace lyx