diff --git a/tests/Makefile.am b/tests/Makefile.am index b8355cfa25..b54084b290 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,7 +9,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/gdk \ $(GTK_DEBUG_FLAGS) \ $(GTK_DEP_CFLAGS) \ - $(GDK_DEP_CFLAGS) + $(GDK_DEP_CFLAGS) \ + -pthread DEPS = \ $(top_builddir)/gtk/libgtk-3.la @@ -19,8 +20,12 @@ LDADD = \ $(top_builddir)/gdk/libgdk-3.la \ $(GTK_DEP_LIBS) \ $(GDK_DEP_LIBS) \ + -lgmodule-2.0 \ -lm +AM_LDFLAGS = -Wl,--export-dynamic -pthread + + if USE_X11 testsocket_programs = testsocket testsocket_child endif diff --git a/tests/popover2.ui b/tests/popover2.ui new file mode 100644 index 0000000000..64896bdcc2 --- /dev/null +++ b/tests/popover2.ui @@ -0,0 +1,598 @@ + + + + + + True + False + slide-left-right + + + True + vertical + fill + 10 + + + True + vertical + 12 + 12 + 6 + 3 + + + True + start + Edit + + + + + + True + horizontal + + + + + + + True + top.cut + Cut + + + + + True + top.copy + Copy + + + + + True + top.paste + Paste + + + + + True + horizontal + 12 + 12 + 3 + 3 + + + + + True + action1 + No action + + + + + True + top.action2 + check + Toggle + + + + + True + top.action2a + check + Another Toggle + + + + + True + vertical + 12 + 12 + 6 + 3 + + + True + start + Middle Section + + + + + + True + horizontal + + + + + + + True + top.action3 + 'three' + radio + Radio 1 + + + + + True + top.action3 + 'four' + radio + Radio 2 + + + + + True + Submenu 1 + True + + + + + + True + Submenu 2 + True + + + + + + True + vertical + 12 + 12 + 6 + 3 + + + True + start + End Section + + + + + + True + horizontal + + + + + + + True + top.action9 + Another Item 9 + icon9 + + + + + True + top.action10 + Another Item 10 + + + + + main + + + + + + True + vertical + 10 + + + + True + Submenu 1 + True + True + True + + + + + + True + vertical + 12 + 12 + 6 + 3 + + + True + start + 5555 + + + + + + True + horizontal + + + + + + + True + top.action5 + Item 5 + + + + + True + top.action5 + Item 5a + + + + + True + top.action5 + Item 5b + + + + + True + horizontal + fill + 10 + + + + True + List + top.set-view + 'list' + radio + True + True + icon-list + + + True + + + + + True + Grid + top.set-view + 'grid' + radio + True + True + icon-grid + + + True + + + + + + + True + top.action5 + Item 5c + + + + + True + top.action5 + Item 5d + + + + + True + vertical + 12 + 12 + 6 + 3 + + + True + start + Format + + + + + + True + horizontal + + + + + + + True + horizontal + fill + 10 + + + + True + Bold + top.bold + check + True + True + + + True + + + + + True + Italic + top.italic + check + True + True + icon-italic + + + True + + + + + True + Strikethrough + top.strikethrough + check + True + True + icon-strikethrough + + + True + + + + + True + Underline + top.underline + check + True + True + icon-underline + + + True + + + + + + + True + vertical + 12 + 12 + 6 + 3 + + + True + start + 6666 + + + + + + True + horizontal + + + + + + + True + top.action6 + Item 6 + + + + + True + top.action6 + Item 6a + + + + + True + top.action6 + Item 6b + + + + + True + top.action6 + Item 6c + + + + + True + top.action6 + Item 6d + + + + + submenu1 + + + + + + True + vertical + 10 + + + True + Submenu 2 + True + True + True + + + + + + True + top.action7 + Item 7 + + + + + True + Subsubmenu + icon9 + True + + + + + + submenu2 + + + + + + True + vertical + 10 + + + + True + Subsubmenu + True + True + True + + + + + + True + action8 + Item 8 + + + + + True + horizontal + 12 + 12 + 3 + 3 + + + + + True + top.action9 + Item 9 + + + + + True + top.action10 + Item 10 + + + + + + subsubmenu + + + + + + + + preferences-desktop-font + + + view-grid-symbolic + + + view-list-symbolic + + + format-text-italic-symbolic + + + format-text-strikethrough-symbolic + + + format-text-underline-symbolic + + + horizontal + + + + + + diff --git a/tests/testpopover.c b/tests/testpopover.c index bcae42a7bb..da6ae8cca7 100644 --- a/tests/testpopover.c +++ b/tests/testpopover.c @@ -30,16 +30,53 @@ static GActionEntry entries[] = { { "action10", activate, NULL, NULL, NULL } }; -int main (int argc, char *argv[]) +static void +open_menu (GtkWidget *button, const gchar *name) +{ + GtkWidget *stack; + g_print ("open %s\n", name); + stack = gtk_widget_get_ancestor (button, GTK_TYPE_STACK); + gtk_stack_set_visible_child_name (GTK_STACK (stack), name); +} + +void +open_main (GtkWidget *button) +{ + open_menu (button, "main"); +} + +void +open_submenu1 (GtkWidget *button) +{ + open_menu (button, "submenu1"); +} + +void +open_submenu2 (GtkWidget *button) +{ + open_menu (button, "submenu2"); +} + +void +open_subsubmenu (GtkWidget *button) +{ + open_menu (button, "subsubmenu"); +} + +int +main (int argc, char *argv[]) { GtkWidget *win; + GtkWidget *box; GtkWidget *button; + GtkWidget *button2; GtkBuilder *builder; GMenuModel *model; GSimpleActionGroup *actions; GtkWidget *overlay; GtkWidget *grid; GtkWidget *popover; + GtkWidget *popover2; GtkWidget *label; GtkWidget *check; GtkWidget *combo; @@ -76,30 +113,37 @@ int main (int argc, char *argv[]) builder = gtk_builder_new_from_file ("popover.ui"); model = (GMenuModel *)gtk_builder_get_object (builder, "menu"); + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); button = gtk_menu_button_new (); + gtk_container_add (GTK_CONTAINER (box), button); + button2 = gtk_menu_button_new (); + gtk_container_add (GTK_CONTAINER (box), button2); + gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model); gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE); - popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button))); - g_object_set (button, "margin", 10, NULL); - gtk_widget_set_halign (button, GTK_ALIGN_END); - gtk_widget_set_valign (button, GTK_ALIGN_START); - gtk_overlay_add_overlay (GTK_OVERLAY (overlay), button); + builder = gtk_builder_new_from_file ("popover2.ui"); + gtk_builder_connect_signals (builder, NULL); + popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover"); + gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2); + + g_object_set (box, "margin", 10, NULL); + gtk_widget_set_halign (box, GTK_ALIGN_END); + gtk_widget_set_valign (box, GTK_ALIGN_START); + gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box); label = gtk_label_new ("Popover hexpand"); check = gtk_check_button_new (); - g_object_bind_property (popover, "hexpand", - check, "active", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_DEFAULT); + g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1); label = gtk_label_new ("Popover vexpand"); check = gtk_check_button_new (); - g_object_bind_property (popover, "vexpand", - check, "active", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT); + g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1); @@ -110,9 +154,8 @@ int main (int argc, char *argv[]) gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right"); - g_object_bind_property (button, "direction", - combo, "active", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property (combo, "active", button, "direction", G_BINDING_DEFAULT); + g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1); @@ -122,9 +165,7 @@ int main (int argc, char *argv[]) gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); - g_object_bind_property (button, "halign", - combo, "active", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property (combo, "active", box, "halign", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1); @@ -134,9 +175,7 @@ int main (int argc, char *argv[]) gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); - g_object_bind_property (button, "valign", - combo, "active", - G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property (combo, "active", box, "valign", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1);