diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-08-27 09:28:29 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-09-08 19:02:06 -0400 |
commit | ea44eade21a896c75b02bf8a148ba726f248f965 (patch) | |
tree | 8a5200d378ca87d7beab9aeeb1340bb2befcb317 /tests/testpopover.c | |
parent | c75a368bab66180c2ebd2ca9483b419fa64840d9 (diff) | |
download | gtk+-ea44eade21a896c75b02bf8a148ba726f248f965.tar.gz |
Add nesting popover menus
Add a variant of popover menus that are nesting
like traditional menus. This is a better fit for
replacing traditional main menus.
Diffstat (limited to 'tests/testpopover.c')
-rw-r--r-- | tests/testpopover.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/testpopover.c b/tests/testpopover.c index 3ece11139b..ce23dc0636 100644 --- a/tests/testpopover.c +++ b/tests/testpopover.c @@ -37,6 +37,7 @@ main (int argc, char *argv[]) GtkWidget *win; GtkWidget *box; GtkWidget *button; + GtkWidget *button1; GtkWidget *button2; GtkBuilder *builder; GMenuModel *model; @@ -44,6 +45,7 @@ main (int argc, char *argv[]) GtkWidget *overlay; GtkWidget *grid; GtkWidget *popover; + GtkWidget *popover1; GtkWidget *popover2; GtkWidget *label; GtkWidget *check; @@ -93,6 +95,8 @@ main (int argc, char *argv[]) box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); button = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button); + button1 = gtk_menu_button_new (); + gtk_container_add (GTK_CONTAINER (box), button1); button2 = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button2); @@ -100,6 +104,9 @@ main (int argc, char *argv[]) gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE); popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button))); + popover1 = gtk_popover_menu_new_from_model_full (NULL, model, GTK_POPOVER_MENU_NESTED); + gtk_menu_button_set_popover (GTK_MENU_BUTTON (button1), popover1); + builder = gtk_builder_new_from_file ("popover2.ui"); popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover"); gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2); @@ -110,6 +117,7 @@ main (int argc, char *argv[]) label = gtk_label_new ("Popover hexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_SYNC_CREATE); + g_object_bind_property (check, "active", popover1, "hexpand", G_BINDING_SYNC_CREATE); g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1); @@ -117,6 +125,7 @@ main (int argc, char *argv[]) label = gtk_label_new ("Popover vexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_SYNC_CREATE); + g_object_bind_property (check, "active", popover1, "vexpand", G_BINDING_SYNC_CREATE); g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1); @@ -129,6 +138,7 @@ main (int argc, char *argv[]) gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right"); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1); g_object_bind_property (combo, "active", button, "direction", G_BINDING_SYNC_CREATE); + g_object_bind_property (combo, "active", button1, "direction", G_BINDING_SYNC_CREATE); g_object_bind_property (combo, "active", button2, "direction", G_BINDING_SYNC_CREATE); gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1); |