diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-01-24 22:25:35 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-01-24 22:25:35 -0500 |
commit | 4240bfb74abf53adb07afc4135dadde4ab866b1f (patch) | |
tree | dda211c241eb4fb3ea3498f7dce76b357d7cdd69 /gtk/gtkmodelmenuitem.c | |
parent | e7d6400149e05d6f9643c33292b5e9d18bfb6b53 (diff) | |
download | gtk+-4240bfb74abf53adb07afc4135dadde4ab866b1f.tar.gz |
Add API to create menus from models
This is needed to bring context menus, etc into the GAction world.
Diffstat (limited to 'gtk/gtkmodelmenuitem.c')
-rw-r--r-- | gtk/gtkmodelmenuitem.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gtk/gtkmodelmenuitem.c b/gtk/gtkmodelmenuitem.c index eb7b8f3596..e6dd987cac 100644 --- a/gtk/gtkmodelmenuitem.c +++ b/gtk/gtkmodelmenuitem.c @@ -235,15 +235,19 @@ gtk_model_menu_item_setup (GtkModelMenuItem *item, /* observer already causes us to hold a hard ref on the group */ item->actions = G_ACTION_GROUP (actions); - g_action_observable_register_observer (actions, item->action_name, G_ACTION_OBSERVER (item)); - - if (g_action_group_query_action (G_ACTION_GROUP (actions), item->action_name, &enabled, &type, NULL, NULL, &state)) + if (actions) { - gtk_model_menu_item_action_added (G_ACTION_OBSERVER (item), actions, item->action_name, type, enabled, state); - if (state != NULL) - g_variant_unref (state); + g_action_observable_register_observer (actions, item->action_name, G_ACTION_OBSERVER (item)); + + if (g_action_group_query_action (G_ACTION_GROUP (actions), item->action_name, &enabled, &type, NULL, NULL, &state)) + { + gtk_model_menu_item_action_added (G_ACTION_OBSERVER (item), actions, item->action_name, type, enabled, state); + if (state != NULL) + g_variant_unref (state); + } + else + gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); } - else gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); |