[gtk+/wip/baedert/drawing: 89/142] tests: Fix some toggle-/checkbutton API mixups



commit 3e11b5925d00035f7a4fe11671fe8084041b5287
Author: Timm Bäder <mail baedert org>
Date:   Tue May 16 11:44:32 2017 +0200

    tests: Fix some toggle-/checkbutton API mixups

 tests/gdkgears.c        |   14 +++++++-------
 tests/testactionbar.c   |    6 ++++--
 tests/testappchooser.c  |    4 ++--
 tests/testfilechooser.c |    2 +-
 tests/testflowbox.c     |   26 +++++++++++++-------------
 tests/testmenubutton.c  |    2 +-
 tests/teststack.c       |   12 ++++++------
 tests/testwindowsize.c  |    2 +-
 8 files changed, 35 insertions(+), 33 deletions(-)
---
diff --git a/tests/gdkgears.c b/tests/gdkgears.c
index ab9ab33..2a80105 100644
--- a/tests/gdkgears.c
+++ b/tests/gdkgears.c
@@ -12,7 +12,7 @@ toggle_alpha (GtkWidget *checkbutton,
               GtkWidget *gears)
 {
   gtk_gl_area_set_has_alpha (GTK_GL_AREA (gears),
-                             gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton)));
+                             gtk_check_button_get_active (GTK_CHECK_BUTTON(checkbutton)));
 }
 
 static void
@@ -20,14 +20,14 @@ toggle_overlay (GtkWidget *checkbutton,
                GtkWidget *revealer)
 {
   gtk_revealer_set_reveal_child (GTK_REVEALER (revealer),
-                                gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton)));
+                                 gtk_check_button_get_active (GTK_CHECK_BUTTON(checkbutton)));
 }
 
 static void
 toggle_spin (GtkWidget *checkbutton,
              GtkWidget *spinner)
 {
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton)))
+  if (gtk_check_button_get_active (GTK_CHECK_BUTTON(checkbutton)))
     gtk_spinner_start (GTK_SPINNER (spinner));
   else
     gtk_spinner_stop (GTK_SPINNER (spinner));
@@ -115,7 +115,7 @@ main (int argc, char *argv[])
   gtk_init ();
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_titlebar (GTK_WINDOW (window), g_object_new (GTK_TYPE_HEADER_BAR, "visible", TRUE, "title", 
"GdkGears", NULL));
+  gtk_window_set_titlebar (GTK_WINDOW (window), g_object_new (GTK_TYPE_HEADER_BAR, "visible", TRUE, "title", 
"GdkGears", "show-close-button", TRUE, NULL));
   gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
   g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
 
@@ -181,21 +181,21 @@ main (int argc, char *argv[])
 
   check = gtk_check_button_new_with_label ("Animate spinner");
   gtk_box_pack_end (GTK_BOX (hbox), check);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
   gtk_widget_show (check);
   g_signal_connect (check, "toggled",
                     G_CALLBACK (toggle_spin), spinner);
 
   check = gtk_check_button_new_with_label ("Alpha");
   gtk_box_pack_end (GTK_BOX (hbox), check);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (check), FALSE);
   gtk_widget_show (check);
   g_signal_connect (check, "toggled",
                     G_CALLBACK (toggle_alpha), gears);
 
   check = gtk_check_button_new_with_label ("Overlay");
   gtk_box_pack_end (GTK_BOX (hbox), check);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (check), FALSE);
   gtk_widget_show (check);
   g_signal_connect (check, "toggled",
                     G_CALLBACK (toggle_overlay), revealer);
diff --git a/tests/testactionbar.c b/tests/testactionbar.c
index bd34bef..cd54a0c 100644
--- a/tests/testactionbar.c
+++ b/tests/testactionbar.c
@@ -5,7 +5,7 @@ toggle_center (GtkCheckButton *button,
                GParamSpec     *pspec,
                GtkActionBar   *bar)
 {
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+  if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
     {
       GtkWidget *button;
 
@@ -24,7 +24,7 @@ toggle_visibility (GtkCheckButton *button,
                    GParamSpec     *pspec,
                    GtkActionBar   *bar)
 {
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+  if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
     gtk_action_bar_set_revealed (bar, TRUE);
   else
     gtk_action_bar_set_revealed (bar, FALSE);
@@ -130,6 +130,7 @@ activate (GApplication *gapp)
   label = gtk_label_new ("Center");
   gtk_widget_set_halign (label, GTK_ALIGN_END);
   check = gtk_check_button_new ();
+  gtk_widget_set_halign (check, GTK_ALIGN_START);
   g_signal_connect (check, "notify::active",
                     G_CALLBACK (toggle_center), bar);
   gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
@@ -146,6 +147,7 @@ activate (GApplication *gapp)
   label = gtk_label_new ("Visible");
   gtk_widget_set_halign (label, GTK_ALIGN_END);
   check = gtk_check_button_new ();
+  gtk_widget_set_halign (check, GTK_ALIGN_START);
   g_signal_connect (check, "notify::active",
                     G_CALLBACK (toggle_visibility), bar);
   gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
diff --git a/tests/testappchooser.c b/tests/testappchooser.c
index 1030f92..064af47 100644
--- a/tests/testappchooser.c
+++ b/tests/testappchooser.c
@@ -81,9 +81,9 @@ prepare_dialog (void)
   gboolean use_file = FALSE;
   gchar *content_type = NULL;
 
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_file)))
+  if (gtk_check_button_get_active (GTK_CHECK_BUTTON (radio_file)))
     use_file = TRUE;
-  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_content)))
+  else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (radio_content)))
     use_file = FALSE;
 
   if (use_file)
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index 2906a24..938ed1f 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -678,7 +678,7 @@ main (int argc, char **argv)
   /* Extra widget */
 
   extra = gtk_check_button_new_with_mnemonic ("Lar_t whoever asks about this button");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extra), TRUE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (extra), TRUE);
   gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), extra);
 
   /* Shortcuts */
diff --git a/tests/testflowbox.c b/tests/testflowbox.c
index 7ce5d22..e8b21d8 100644
--- a/tests/testflowbox.c
+++ b/tests/testflowbox.c
@@ -289,10 +289,10 @@ items_changed (GtkComboBox   *box,
 }
 
 static void
-homogeneous_toggled (GtkToggleButton *button,
-                     GtkFlowBox      *flowbox)
+homogeneous_toggled (GtkCheckButton *button,
+                     GtkFlowBox     *flowbox)
 {
-  gboolean state = gtk_toggle_button_get_active (button);
+  gboolean state = gtk_check_button_get_active (button);
 
   gtk_flow_box_set_homogeneous (flowbox, state);
 }
@@ -337,10 +337,10 @@ filter_func (GtkFlowBoxChild *child, gpointer user_data)
 }
 
 static void
-filter_toggled (GtkToggleButton *button,
-                GtkFlowBox      *flowbox)
+filter_toggled (GtkCheckButton *button,
+                GtkFlowBox     *flowbox)
 {
-  gboolean state = gtk_toggle_button_get_active (button);
+  gboolean state = gtk_check_button_get_active (button);
 
   if (state)
     gtk_flow_box_set_filter_func (flowbox, filter_func, NULL, NULL);
@@ -361,10 +361,10 @@ sort_func (GtkFlowBoxChild *a,
 }
 
 static void
-sort_toggled (GtkToggleButton *button,
-              GtkFlowBox      *flowbox)
+sort_toggled (GtkCheckButton *button,
+              GtkFlowBox     *flowbox)
 {
-  gboolean state = gtk_toggle_button_get_active (button);
+  gboolean state = gtk_check_button_get_active (button);
 
   if (state)
     gtk_flow_box_set_sort_func (flowbox, sort_func, NULL, NULL);
@@ -425,7 +425,7 @@ create_window (void)
   gtk_box_pack_start (GTK_BOX (vbox), expander);
 
   widget = gtk_check_button_new_with_label ("Homogeneous");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
   gtk_widget_show (widget);
 
   gtk_widget_set_tooltip_text (widget, "Set whether the items should be displayed at the same size");
@@ -435,7 +435,7 @@ create_window (void)
                     G_CALLBACK (homogeneous_toggled), flowbox);
 
   widget = gtk_check_button_new_with_label ("Activate on single click");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
   g_object_bind_property (widget, "active",
                           flowbox, "activate-on-single-click",
                           G_BINDING_SYNC_CREATE);
@@ -571,7 +571,7 @@ create_window (void)
   /* filtering and sorting */
 
   widget = gtk_check_button_new_with_label ("Filter");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
   gtk_widget_show (widget);
 
   gtk_widget_set_tooltip_text (widget, "Set whether some items should be filtered out");
@@ -581,7 +581,7 @@ create_window (void)
                     G_CALLBACK (filter_toggled), flowbox);
 
   widget = gtk_check_button_new_with_label ("Sort");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
   gtk_widget_show (widget);
 
   gtk_widget_set_tooltip_text (widget, "Set whether items should be sorted");
diff --git a/tests/testmenubutton.c b/tests/testmenubutton.c
index 8de76a4..0c654c7 100644
--- a/tests/testmenubutton.c
+++ b/tests/testmenubutton.c
@@ -131,7 +131,7 @@ int main (int argc, char **argv)
        gtk_grid_attach (GTK_GRID (grid), button, 1, row++, 1, 1);
 
         check = gtk_check_button_new_with_label ("Popover");
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
+        gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
        gtk_grid_attach (GTK_GRID (grid), check, 0, row, 1, 1);
 
        /* Button with GMenuModel */
diff --git a/tests/teststack.c b/tests/teststack.c
index e5d61eb..98de133 100644
--- a/tests/teststack.c
+++ b/tests/teststack.c
@@ -20,14 +20,14 @@ set_visible_child_name (GtkWidget *button, gpointer data)
 static void
 toggle_hhomogeneous (GtkWidget *button, gpointer data)
 {
-  gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  gboolean active = gtk_check_button_get_active (GTK_CHECK_BUTTON (button));
   gtk_stack_set_hhomogeneous (GTK_STACK (stack), active);
 }
 
 static void
 toggle_vhomogeneous (GtkWidget *button, gpointer data)
 {
-  gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  gboolean active = gtk_check_button_get_active (GTK_CHECK_BUTTON (button));
   gtk_stack_set_vhomogeneous (GTK_STACK (stack), active);
 }
 
@@ -219,16 +219,16 @@ main (gint argc,
   g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "3");
 
   button = gtk_check_button_new ();
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (button),
                                gtk_stack_get_hhomogeneous (GTK_STACK (stack)));
   gtk_container_add (GTK_CONTAINER (hbox), button);
-  g_signal_connect (button, "clicked", (GCallback) toggle_hhomogeneous, NULL);
+  g_signal_connect (button, "toggled", (GCallback) toggle_hhomogeneous, NULL);
 
   button = gtk_check_button_new_with_label ("homogeneous");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (button),
                                gtk_stack_get_vhomogeneous (GTK_STACK (stack)));
   gtk_container_add (GTK_CONTAINER (hbox), button);
-  g_signal_connect (button, "clicked", (GCallback) toggle_vhomogeneous, NULL);
+  g_signal_connect (button, "toggled", (GCallback) toggle_vhomogeneous, NULL);
 
   button = gtk_toggle_button_new_with_label ("Add icon");
   g_signal_connect (button, "toggled", (GCallback) toggle_icon_name, NULL);
diff --git a/tests/testwindowsize.c b/tests/testwindowsize.c
index 495307e..9064527 100644
--- a/tests/testwindowsize.c
+++ b/tests/testwindowsize.c
@@ -34,7 +34,7 @@ show_dialog (void)
   max_width_chars = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (max_width_chars_spin));
   default_width = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (default_width_spin));
   default_height = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (default_height_spin));
-  resizable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (resizable_check));
+  resizable = gtk_check_button_get_active (GTK_CHECK_BUTTON (resizable_check));
 
   dialog = gtk_dialog_new_with_buttons ("Test", GTK_WINDOW (window),
                                         GTK_DIALOG_MODAL,


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