[gtk+/gtk-3-22] testpopover: Sync initial vals of controls & props



commit 1efbcb0f827a1948201f728aca1db07cfd05688e
Author: Daniel Boles <dboles src gnome org>
Date:   Mon Aug 14 23:10:59 2017 +0100

    testpopover: Sync initial vals of controls & props
    
    The ComboBoxes were initially empty, rather than reflecting the initial
    values of the properties. The CheckButtons were only correct by chance.
    Fix this by setting the initial values on the widgets and binding them
    to the properties using SYNC_CREATE, so the two are always synced up.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786209

 tests/testpopover.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/tests/testpopover.c b/tests/testpopover.c
index 306e7c9..5c9e77f 100644
--- a/tests/testpopover.c
+++ b/tests/testpopover.c
@@ -95,21 +95,19 @@ main (int argc, char *argv[])
   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 (check, "active", popover, "hexpand", G_BINDING_DEFAULT);
-  g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT);
+  g_object_bind_property (check, "active", popover, "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);
 
   label = gtk_label_new ("Popover vexpand");
   check = gtk_check_button_new ();
-  g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT);
-  g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT);
+  g_object_bind_property (check, "active", popover, "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);
 
@@ -119,9 +117,9 @@ main (int argc, char *argv[])
   gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down");
   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 (combo, "active", button, "direction", G_BINDING_DEFAULT);
-  g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT);
+  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", 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);
 
@@ -131,7 +129,8 @@ 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 (combo, "active", box, "halign", G_BINDING_DEFAULT);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 2);
+  g_object_bind_property (combo, "active", box, "halign", G_BINDING_SYNC_CREATE);
   gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1);
   gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1);
 
@@ -141,7 +140,8 @@ 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 (combo, "active", box, "valign", G_BINDING_DEFAULT);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1);
+  g_object_bind_property (combo, "active", box, "valign", G_BINDING_SYNC_CREATE);
   gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1);
   gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]