maemo.org Bugzilla – Bug 2281
Accelerator Labels not shown in menus created with GtkUIManager
Last modified: 2009-10-22 07:56:40 UTC
You need to log in before you can comment on or make changes to this bug.
The accelerator labels are not shown in menus created with the GtkUIManager. To test this in the scratchbox, I make sure that /apps/osso/gtk/enable-accels is set to true, then run my program. The accelerators work, but the accelerator labels are not shown in the menus.
What is "your program"? I'd like to test this bug.
(In reply to comment #1) > What is "your program"? I'd like to test this bug. > my program is quiver http://maemo.org/downloads/product/OS2008/quiver/
Indeed, I don't see accels in quiver either (very nice app btw :-) Will investigate this further...
thanks. it could be related to another bug i've entered (bug #2278).
Yes I've seen that one too, but it's actually an enhancement request (separating accel invoking from accel display). If the setting is TRUE, they should simply both work and be displayed. I don't quite understand why not, but as said, I'm investigating :)
How exactly do you create the menu? Can you paste both the ui manager XML and the code that actually uses the XML and puts the menu into the window?
(In reply to comment #6) > How exactly do you create the menu? Can you paste both the ui manager XML > and the code that actually uses the XML and puts the menu into the > window? > you'll have to excuse me, i'm on vacation (until friday) and only have my n810 so this may be incomplete. first i create the ui manager: gtk_ui_manager_new gtk_ui_manager_set_add_tearoffs then i add my ui definitions: gtk_ui_manager_add_ui_from_string then add the corrisponding actions: gtk_action_group_new gtk_action_group_add_actions gtk_ui_manager_insert_action_group then i add the accel group to the window: gtk_window_add_accel_group(..., gtk_ui_manager_get_accel_group(...)); and finally get the menu and add it to the hildon program: menu = gtk_ui_manager_get_widget(...); hildon_program_set_common_menu (program, GTK_MENU(menu));
Thank you. That looks entirely normal. I'm actually more interested in the XML now since i remembered there is this code in gtkuimanager.c: if (in_popup) { /* don't show accels in popups */ GtkWidget *label = GTK_BIN (info->proxy)->child; g_object_set (label, "accel-closure", NULL, NULL); } So if you create your menu with <popup> (which you most likely do since nobody needs a menubar on the device), it will definitely not show accels. Can you confirm this? There is the workaround to have a dummy <menubar> around a normal <menu> (that's what we do in GIMP and it works), but I think since many apps will have this problem we need a nicer solution here.
At least I can confirm it: (Large) Testcase: svn co http://svn.gnome.org/svn/monkey-bubble/trunk monkey-bubble cd monkey-bubble ./autogen.sh --with-platform=maemo make And here's the patch to get the accelerators displayed: http://people.imendio.com/sven/use-menubar.patch And if the reparenting doesn't take place, this warning appears: monkey-bubble[21130]: GLIB WARNING ** Gtk - gtk_menu_attach_to_widget(): menu already attached to GtkImageMenuItem
Created an attachment (id=714) [details] Patch against GTK+ Attached patch allows to say <popup accelerators="true"> in the UI manager XML and seems to work fine.
(In reply to comment #8) Sorry about that. Yes, I am creating it with <popup>. I've tried the workaround and it does the trick. Thanks.
reassigning Tommi's bugs to Rodrigo.
Now is this a downstream (Maemo) only gtk issue, or would it also make sense to get this in upstream?
(In reply to comment #13) > Now is this a downstream (Maemo) only gtk issue, or would it also make sense to > get this in upstream? Patch was filed against and is being worked on for inclusion in upstream Gtk+. See http://bugzilla.gnome.org/show_bug.cgi?id=516425
Fixed in upstream and in Maemo GTK+: 2008-10-09 Michael Natterer <mitch@imendio.com> Fixes NB#87440: Accelerator Labels not shown in menus created with GtkUIManager Merged from upstream trunk: 2008-10-09 Michael Natterer <mitch@imendio.com> Bug 516425 – Optionally display accelerators in popups * gtk/gtkuimanager.h (enum GtkUIManagerItemType): add value GTK_UI_MANAGER_POPUP_WITH_ACCELS which works like _POPUP but shows the actions' accelerators. * gtk/gtkuimanager.c: honor the new enum value for programmatically created UIs, and support <popup accelerators="true"> in the XML for the same purpose. * docs/reference/gtk/tmpl/gtkuimanager.sgml: document the enhanced XML syntax and the new enum value for popups with accelerators. 2008-06-13 Michael Natterer <mitch@imendio.com> * gtk/gtkuimanager.c (start_element_handler): silently skip unknown attributes instead of bailing out with an error in order to be compatible with possible future attribute names. This is related to the discussion in bug #516425 but actually needed for any kind of XML format extension.
Marking patches of interest to Diablo (Maemo4) community updates, please excuse the noise.