/** * dbusmenu_menuitem_property_set_shortcut_menuitem: * @menuitem: The #DbusmenuMenuitem to set the shortcut on * @gmi: A menu item to steal the shortcut off of * * Takes the shortcut that is installed on a menu item and calls * #dbusmenu_menuitem_property_set_shortcut with it. It also sets * up listeners to watch it change. * * Return value: Whether it was successful at setting the property. */ gboolean dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, const GtkMenuItem * gmi) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE); g_return_val_if_fail(GTK_IS_MENU_ITEM(gmi), FALSE); GClosure * closure = NULL; GtkWidget *label = gtk_bin_get_child(GTK_BIN (gmi)); if (GTK_IS_ACCEL_LABEL (label)) { g_object_get (label, "accel-closure", &closure, NULL); } if (closure == NULL) { /* As a fallback, check for a closure in the related menu item. This actually happens with SWT menu items. */ GList * closures = gtk_widget_list_accel_closures (GTK_WIDGET (gmi)); if (closures == NULL) return FALSE; closure = closures->data; g_list_free (closures); } GtkAccelGroup * group = gtk_accel_group_from_accel_closure(closure); /* Apparently this is more common than I thought. */ if (group == NULL) { return FALSE; } GtkAccelKey * key = gtk_accel_group_find(group, find_closure, closure); /* 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); }
static VALUE rg_accel_closures(VALUE self) { return GLIST2ARY2F(gtk_widget_list_accel_closures(_SELF(self)), G_TYPE_CLOSURE); }