Bug 2281 - (int-87441) Accelerator Labels not shown in menus created with GtkUIManager
(int-87441)
: Accelerator Labels not shown in menus created with GtkUIManager
Status: RESOLVED FIXED
Product: Desktop platform
gtk
: 4.1 (4.2008.23-14)
: All Linux
: Low normal (vote)
: 5.0-alpha
Assigned To: Rodrigo Novo
: gtk-bugs
:
: community-diablo, patch
:
:
  Show dependency tree
 
Reported: 2007-11-15 10:40 UTC by mike morrison
Modified: 2009-10-22 07:56 UTC (History)
5 users (show)

See Also:


Attachments
Patch against GTK+ (2.82 KB, patch)
2008-02-13 16:22 UTC, Michael Natterer
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description mike morrison (reporter) 2007-11-15 10:40:26 UTC
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.
Comment 1 Michael Natterer 2008-02-11 16:27:39 UTC
What is "your program"? I'd like to test this bug.
Comment 2 mike morrison (reporter) 2008-02-11 19:49:12 UTC
(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/
Comment 3 Michael Natterer 2008-02-12 17:23:39 UTC
Indeed, I don't see accels in quiver either (very nice app btw :-)

Will investigate this further...
Comment 4 mike morrison (reporter) 2008-02-12 17:47:45 UTC
thanks. it could be related to another bug i've entered (bug #2278).
Comment 5 Michael Natterer 2008-02-12 18:10:07 UTC
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 :)
Comment 6 Michael Natterer 2008-02-12 19:40:18 UTC
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?
Comment 7 mike morrison (reporter) 2008-02-13 03:00:56 UTC
(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));
Comment 8 Michael Natterer 2008-02-13 11:35:09 UTC
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.
Comment 9 Sven Herzberg 2008-02-13 12:14:50 UTC
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
Comment 10 Michael Natterer 2008-02-13 16:22:52 UTC
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.
Comment 11 mike morrison (reporter) 2008-02-21 11:05:48 UTC
(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.
Comment 12 Andre Klapper maemo.org 2008-06-06 17:46:48 UTC
reassigning Tommi's bugs to Rodrigo.
Comment 13 Andre Klapper maemo.org 2008-08-01 17:37:28 UTC
Now is this a downstream (Maemo) only gtk issue, or would it also make sense to
get this in upstream?
Comment 14 Christian Dywan 2008-08-06 13:25:50 UTC
(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
Comment 15 Michael Natterer 2008-10-09 12:14:16 UTC
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.
Comment 16 Lucas Maneos 2009-10-22 07:56:40 UTC
Marking patches of interest to Diablo (Maemo4) community updates, please excuse
the noise.