Comment 25 for bug 849732

Revision history for this message
Marco Trevisan (TreviƱo) (3v1n0) wrote :

Ok, I've made some more testing and I've also found a solution, but before checking if that's right let's discuss a little.

Basically the issue we're always reproducing when using a gtkbuilder-based app, can also happening when manually programming our interface and basically when we're doing something like this in our menu widgets tree:
 - GtkMenubar { GtkMenuItem { GtkMenu { GtkMenuItem } } }

In this case, the inner GtkMenuItem won't be sensible to accelerators.
You can see a test example here: https://gist.github.com/1288553#file_badunitymenus_std.vala

GtkBuilder seems to use a structure like this one every time (and I also guess that gcalctool uses that too), and this cause the menu items not to be sensible to our accelerator keys.

Now, the possible solutions, everything here seems to start from gtkmenuitem.c's gtk_menu_item_can_activate_accel which checks if the parent widgets can manage an accelerator.
When using the ubuntu menubar the process stops returning false, due to the fact that the GtkMenuBar isn't drawn and so isn't activable according to gtk_widget_can_activate_accel(). So we have some possible solution:
 - In gtk_menu_item_can_activate_accel we just try to go back to all the parent widgets, just checking if they are sensitive
 - In gtk_menu_item_can_activate_accel we check if the parent widget is a GtkMenuBar and in the case, if it's sensitive we just skip it, and we pass to its own parent
 - override the can_activate_accel function in the class GtkMenuBar making that check only if the menu bar is sensitive.

The last one is of course the best one solution imho, and so I think that's the one I'll propose as soon as I can...

I think we must definitely fix this issue, since it could happen to all the apps not designed as we figured until now.

Finally, looking for this I also found another issue: if someone programmatically wants to hide a menubar, it's not possible in ubuntu. I guess we should track the show hide/status of that widget and check that to export the menu or not or to restore the visibility status when the menus are shown again as standard menus.

PS: from my tests this doesn't seem to affect gtk+2.0 programs, can you confirm this?