Hi,
I just investigated a bug in gtkmm3 (which did not exist with gtkmm2 before)
which happens when using Gtk::MenuItem::set_accel_path() to assign a global
keyboard accelerator to a menu item. Since gtkmm3 the respective keyboard
accelerator action is still triggered, but the accelerator keys were no longer
displayed in the menu.
I first thought this to be a bug in Gtk(3), so I started the discussion about
this issue there:
https://mail.gnome.org/archives/gtk-devel-list/2018-February/msg00025.html
https://mail.gnome.org/archives/gtk-devel-list/2018-February/msg00027.html
https://mail.gnome.org/archives/gtk-devel-list/2018-February/msg00028.html
https://mail.gnome.org/archives/gtk-devel-list/2018-February/msg00029.html
But meanwhile it rather looks like a bug in gtkmm3 to me. Attached you find a
quick hack against gtkmm3 which resolved this bug for me. Like I mentioned in
the last post on the gtk list, I have no idea why that acceleration label was
created explicitly in the gtkmm "MenuItem" class there. Was it still there for
purpose or was it just some legacy code?
Note that (in gtk3 at least) a GtkAccelerationLabel is automatically always
created as child widget by GtkMenuItem even if no acceleration keys are used
at all for the menu item.
CU
Christian
diff -ruN gtkmm-3-22.old/gtk/src/menuitem.ccg gtkmm-3-22.new/gtk/src/menuitem.ccg
--- gtkmm-3-22.old/gtk/src/menuitem.ccg 2018-02-08 20:09:55.000000000 +0100
+++ gtkmm-3-22.new/gtk/src/menuitem.ccg 2018-02-08 20:10:46.000000000 +0100
@@ -48,17 +48,9 @@
void MenuItem::add_accel_label(const Glib::ustring& label, bool mnemonic)
{
- auto pLabel = manage(new AccelLabel(label, mnemonic));
-
- //Labels are centered by default, but in menus they should be left-aligned.
- pLabel->set_halign(ALIGN_START);
-
- add(*pLabel);
-
- //Note that we have to unset the accel_widget in MenuList::remove() to avoid
- //a memory leak due to the extra reference:
- pLabel->set_accel_widget(*this);
- pLabel->show();
+ GtkMenuItem* menu_item = (GtkMenuItem*) gobj();
+ gtk_menu_item_set_label(menu_item, label.c_str());
+ gtk_menu_item_set_use_underline(menu_item, mnemonic);
}
void MenuItem::set_accel_key(const AccelKey& accel_key)
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list