ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #01693
[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 118: Fixing the getting accel from a menu item.
Merge authors:
Cody Russell (bratsche)
Related merge proposals:
https://code.launchpad.net/~bratsche/dbusmenu/fix-shortcut-from-gtkmenuitem/+merge/28204
proposed by: Cody Russell (bratsche)
------------------------------------------------------------
revno: 118 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-06-22 11:10:13 -0500
message:
Fixing the getting accel from a menu item.
modified:
libdbusmenu-gtk/menuitem.c
--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-gtk/menuitem.c'
--- libdbusmenu-gtk/menuitem.c 2010-06-15 04:48:51 +0000
+++ libdbusmenu-gtk/menuitem.c 2010-06-22 16:03:42 +0000
@@ -246,19 +246,20 @@
g_return_val_if_fail(GTK_IS_MENU_ITEM(gmi), FALSE);
GClosure * closure = NULL;
- GList * clist;
-
- clist = gtk_widget_list_accel_closures(GTK_WIDGET(gmi));
- if (clist == NULL) {
- g_warning("Menuitem does not have any closures.");
- return FALSE;
- }
-
- closure = (GClosure *)clist->data;
- g_list_free(clist);
+ GtkWidget *label = GTK_BIN (gmi)->child;
+
+ if (GTK_IS_ACCEL_LABEL (label))
+ {
+ g_object_get (label,
+ "accel-closure", &closure,
+ NULL);
+ }
+
+ if (closure == NULL)
+ return FALSE;
GtkAccelGroup * group = gtk_accel_group_from_accel_closure(closure);
-
+
/* Seriously, if this returns NULL something is seriously
wrong in GTK. */
g_return_val_if_fail(group != NULL, FALSE);
@@ -267,6 +268,9 @@
/* Again, not much we can do except complain loudly. */
g_return_val_if_fail(key != NULL, FALSE);
+ if (!gtk_accelerator_valid (key->accel_key, key->accel_mods))
+ return FALSE;
+
return dbusmenu_menuitem_property_set_shortcut(menuitem, key->accel_key, key->accel_mods);
}