GNOME Bugzilla – Bug 673243
GtkRadioMenuItem accelerators no longer appear
Last modified: 2013-02-19 02:06:37 UTC
This is a regression in the 3.3.x series. To recreate, make a program with a menu using: GtkWidget* widget = gtk_radio_menu_item_new_with_label (di->longname); gtk_menu_shell_append (GTK_MENU_SHELL (shell), GTK_WIDGET (widget)); gtk_widget_add_accelerator (GTK_WIDGET (widget), "activate", accelgroup, (GDK_KEY_A), GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); gtk_widget_show (widget); The accelerator works. It is just not visible. If you change gtk_radio_menu_item_new_with_label to gtk_menu_item_new_with_label, the accel will appear as it should.
Confirmed in gtk 3.4 - key shortcuts do not appear in the menu for radio items, but they do emit the activate signal. Since this bug is almost a year old, is there any support for gtk3 or has it been abandoned?
Created attachment 236165 [details] [review] Use property label as in other menu items I'm not sure why GtkRadioMenuItem-s are still adding accel_label on their own, whereas other menu items simply use the property label; Might have been an oversight when the new API was introduced. The patch switch to using properties, which seems to fix the problem.
Review of attachment 236165 [details] [review]: good patch; it may be possible to do better, tho. :-) ::: gtk/gtkradiomenuitem.c @@ +254,2 @@ radio_menu_item = gtk_radio_menu_item_new (group); + g_object_set (radio_menu_item, "label", label, NULL); can't we do: return g_object_new (GTK_TYPE_RADIO_MENU_ITEM, "group", group != NULL ? group->data : NULL, "label", label, NULL); instead? usually, the less a constructor function does on top of g_object_new() (ideally, nothing at all), the better. @@ +279,2 @@ radio_menu_item = gtk_radio_menu_item_new (group); + g_object_set (radio_menu_item, "label", label, "use-underline", TRUE, NULL); same as above, we should be able to just call g_object_new().
Created attachment 236181 [details] [review] Use property label as in other menu items New version using only g_object_new() to create the widget. Also fixes a bug in set_property handler, where setting group to NULL would cause a warning.
Review of attachment 236181 [details] [review]: Looks good to me.
Pushed to master for 3.7.10.
Thanks for addressing this.