forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
7b68c234b1
commit
1efbcb0f82
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user