Hi, I've written a function (attached patch) to take something like "S-C-n" and translate it into the "<shift><control>n" form that GTK wants for its accelerators. However, when I add accelerators to menu elements (not just the ones my function generates, any accelerator will do) runtime errors are generated at quit:
(lyx-gtk:10855): Gtk-CRITICAL **: file gtkaccelgroup.c: line 571 (gtk_accel_group_disconnect): assertion `GTK_IS_ACCEL_GROUP (accel_group)' failed This message is repeated for each accelerator. According to gtkmm docs, I shouldn't have to be creating accel groups for menus as it's done for me. Any suggestions appreciated. John
Index: GMenubar.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GMenubar.C,v retrieving revision 1.14 diff -u -3 -p -r1.14 GMenubar.C --- GMenubar.C 2004/09/26 18:36:07 1.14 +++ GMenubar.C 2004/09/28 02:30:04 @@ -45,6 +45,21 @@ Glib::ustring labelTrans(string const & return Glib::locale_to_utf8(labelN); } +Glib::ustring accelString(string const & binding) +{ + string accelcode = binding; + string::size_type i = accelcode.find("C-"); + if (i != string::npos) + accelcode = accelcode.replace(i, 2, "<control>"); + i = accelcode.find("S-"); + if (i != string::npos) + accelcode = accelcode.replace(i, 2, "<shift>"); + i = accelcode.find("M-"); + if (i != string::npos) + accelcode = accelcode.replace(i, 2, "<alt>"); + + return Glib::locale_to_utf8(accelcode); +} void ClearMenu(Gtk::MenuShell * menu) { @@ -180,9 +195,6 @@ void GMenubar::onSubMenuActivate(MenuIte 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); @@ -200,8 +212,8 @@ void GMenubar::onSubMenuActivate(MenuIte } else { gmenu->items().push_back( Gtk::Menu_Helpers::MenuElem( - labelTrans(i->label(), - i->shortcut()))); + labelTrans(i->label(), i->shortcut()), + Gtk::AccelKey(accelString(i->binding())))); } Gtk::MenuItem & item = gmenu->items().back(); item.signal_activate().connect(