diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-11-26 13:27:18 -0500 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-12-19 12:45:51 -0500 |
commit | 7de8660187c1ac1d714bb493afd54a7f3b019a68 (patch) | |
tree | 85e04f7c66d04418d513dee1d111d94d794cbb5a /tests/testgmenu.c | |
parent | 92af3d04b88adcfea5170cd69ddc992cb8ec7c97 (diff) | |
download | gtk+-7de8660187c1ac1d714bb493afd54a7f3b019a68.tar.gz |
testgmenu: Initial attempt at section headings
This should be redone to show the label together with the
separator line, somehow. For now, just put the label below
the separator, as a separate item.
Diffstat (limited to 'tests/testgmenu.c')
-rw-r--r-- | tests/testgmenu.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/testgmenu.c b/tests/testgmenu.c index 48b508649d..faa35e204b 100644 --- a/tests/testgmenu.c +++ b/tests/testgmenu.c @@ -185,6 +185,7 @@ create_menuitem_from_model (GMenuModel *model, const GVariantType *type; GVariant *v; + label = NULL; g_menu_model_get_item_attribute (model, item, G_MENU_ATTRIBUTE_LABEL, "s", &label); action = NULL; @@ -270,7 +271,8 @@ static void append_items_from_model (GtkWidget *menu, GMenuModel *model, GActionGroup *group, - gboolean *need_separator) + gboolean *need_separator, + const gchar *heading) { gint n; gint i; @@ -278,6 +280,7 @@ append_items_from_model (GtkWidget *menu, GtkWidget *menuitem; GtkWidget *submenu; GMenuModel *m; + gchar *label; n = g_menu_model_get_n_items (model); @@ -290,12 +293,28 @@ append_items_from_model (GtkWidget *menu, *need_separator = FALSE; } + if (heading != NULL) + { + w = gtk_menu_item_new_with_label (heading); + gtk_widget_show (w); + gtk_widget_set_sensitive (w, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), w); +#if 0 + /* FIXME: this interferes with toggle spacing */ + w = gtk_bin_get_child (GTK_BIN (w)); + gtk_misc_set_alignment (GTK_MISC (w), 0.5, 0.5); +#endif + } + for (i = 0; i < n; i++) { if ((m = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION))) { - append_items_from_model (menu, m, group, need_separator); + label = NULL; + g_menu_model_get_item_attribute (model, i, G_MENU_ATTRIBUTE_LABEL, "s", &label); + append_items_from_model (menu, m, group, need_separator, label); g_object_unref (m); + g_free (label); continue; } @@ -324,7 +343,7 @@ create_menu_from_model (GMenuModel *model, w = gtk_menu_new (); need_separator = FALSE; - append_items_from_model (w, model, group, &need_separator); + append_items_from_model (w, model, group, &need_separator, NULL); return w; } |