mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
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.
This commit is contained in:
parent
92af3d04b8
commit
7de8660187
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user