[gtk+/wip/gmenu: 21/87] testgmenu: Initial attempt at section headings
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/gmenu: 21/87] testgmenu: Initial attempt at section headings
- Date: Sat, 3 Dec 2011 23:49:55 +0000 (UTC)
commit 41117d95433a63d9fee4306f84a4927b4d7b1b4c
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Nov 26 13:27:18 2011 -0500
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.
tests/testgmenu.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/tests/testgmenu.c b/tests/testgmenu.c
index 48b5086..faa35e2 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]