Web lists-archives.com

Re: gtk_menu_item_set_accel_path()




On Donnerstag, 8. Februar 2018 16:32:05 CET Christian Schoenebeck wrote:
> And in fact that C code works perfectly even with Gtk 3, but gtkmm3 is doing
> something differently than in above's C code: in the Gtk::MenuItem
> constructor they explicitly create an acceleration label for the menu item
> and I am not sure whether they should not do that, or whether gtk should
> rather be able to handle that:
> 
> 	https://github.com/GNOME/gtkmm/blob/gtkmm-3-22/gtk/src/menuitem.ccg
> 	(line 46 and line 51-61 being the relevant ones)
> 
> As far as I can read from the gtk sources, gtk automatically creates the
> menu item's acceleration label (even if no accelerators are used at all).
> But right now I cannot judge which side is wrong here (gtkmm3 or gtk3).

Ok, the attached quick hack (on gtkmm3) fixed that issue for me. With that 
patch the acceleration keys are now correctly displayed again with gtkmm3.
But obviously I have no idea whether the acceleration label was created 
explicitly there for some reason by gtkmm, whether it is still used by any 
Gtkmm subclass or something, or whether it was simply some left over of 
something.

I guess I just move this discussion onto the gtkmm list now.

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)
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list