[gtk+] testframe: Use a generic widget pointer



commit ec5ebf82b661b7cf8e997cc7ddc23d2d87e60d5a
Author: Daniel Boles <dboles src gnome org>
Date:   Mon Mar 6 22:39:01 2017 +0000

    testframe: Use a generic widget pointer

 tests/testframe.c |   55 ++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 28 deletions(-)
---
diff --git a/tests/testframe.c b/tests/testframe.c
index 416380d..f9c6982 100644
--- a/tests/testframe.c
+++ b/tests/testframe.c
@@ -132,8 +132,7 @@ int main (int argc, char **argv)
 {
   GtkStyleContext *context;
   GtkBorder pad;
-  GtkWidget *window, *frame, *xthickness_spin, *ythickness_spin, *vbox;
-  GtkWidget *xalign_spin, *yalign_spin, *button, *grid, *label;
+  GtkWidget *window, *frame, *vbox, *grid, *widget;
   gfloat xalign, yalign;
 
   gtk_init ();
@@ -149,8 +148,8 @@ int main (int argc, char **argv)
   frame = gtk_frame_new ("Testing");
   gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE);
 
-  button = gtk_button_new_with_label ("Hello!");
-  gtk_container_add (GTK_CONTAINER (frame), button);
+  widget = gtk_button_new_with_label ("Hello!");
+  gtk_container_add (GTK_CONTAINER (frame), widget);
 
   grid = gtk_grid_new ();
   gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE);
@@ -162,42 +161,42 @@ int main (int argc, char **argv)
   gtk_style_context_restore (context);
 
   /* Spin to control xthickness */
-  label = gtk_label_new ("xthickness: ");
-  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
+  widget = gtk_label_new ("xthickness: ");
+  gtk_grid_attach (GTK_GRID (grid), widget, 0, 0, 1, 1);
 
-  xthickness_spin = gtk_spin_button_new_with_range (0, 250, 1);
-  g_signal_connect (G_OBJECT (xthickness_spin), "value-changed", G_CALLBACK (spin_xthickness_cb), frame);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (xthickness_spin), pad.left);
-  gtk_grid_attach (GTK_GRID (grid), xthickness_spin, 1, 0, 1, 1);
+  widget = gtk_spin_button_new_with_range (0, 250, 1);
+  g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (spin_xthickness_cb), frame);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), pad.left);
+  gtk_grid_attach (GTK_GRID (grid), widget, 1, 0, 1, 1);
 
   /* Spin to control ythickness */
-  label = gtk_label_new ("ythickness: ");
-  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
+  widget = gtk_label_new ("ythickness: ");
+  gtk_grid_attach (GTK_GRID (grid), widget, 0, 1, 1, 1);
 
-  ythickness_spin = gtk_spin_button_new_with_range (0, 250, 1);
-  g_signal_connect (G_OBJECT (ythickness_spin), "value-changed", G_CALLBACK (spin_ythickness_cb), frame);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (ythickness_spin), pad.top);
-  gtk_grid_attach (GTK_GRID (grid), ythickness_spin, 1, 1, 1, 1);
+  widget = gtk_spin_button_new_with_range (0, 250, 1);
+  g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (spin_ythickness_cb), frame);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), pad.top);
+  gtk_grid_attach (GTK_GRID (grid), widget, 1, 1, 1, 1);
 
   gtk_frame_get_label_align (GTK_FRAME (frame), &xalign, &yalign);
 
   /* Spin to control label xalign */
-  label = gtk_label_new ("xalign: ");
-  gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
+  widget = gtk_label_new ("xalign: ");
+  gtk_grid_attach (GTK_GRID (grid), widget, 0, 2, 1, 1);
 
-  xalign_spin = gtk_spin_button_new_with_range (0.0, 1.0, 0.1);
-  g_signal_connect (G_OBJECT (xalign_spin), "value-changed", G_CALLBACK (spin_xalign_cb), frame);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (xalign_spin), xalign);
-  gtk_grid_attach (GTK_GRID (grid), xalign_spin, 1, 2, 1, 1);
+  widget = gtk_spin_button_new_with_range (0.0, 1.0, 0.1);
+  g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (spin_xalign_cb), frame);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), xalign);
+  gtk_grid_attach (GTK_GRID (grid), widget, 1, 2, 1, 1);
 
   /* Spin to control label yalign */
-  label = gtk_label_new ("yalign: ");
-  gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
+  widget = gtk_label_new ("yalign: ");
+  gtk_grid_attach (GTK_GRID (grid), widget, 0, 3, 1, 1);
 
-  yalign_spin = gtk_spin_button_new_with_range (0.0, 1.0, 0.1);
-  g_signal_connect (G_OBJECT (yalign_spin), "value-changed", G_CALLBACK (spin_yalign_cb), frame);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (yalign_spin), yalign);
-  gtk_grid_attach (GTK_GRID (grid), yalign_spin, 1, 3, 1, 1);
+  widget = gtk_spin_button_new_with_range (0.0, 1.0, 0.1);
+  g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (spin_yalign_cb), frame);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), yalign);
+  gtk_grid_attach (GTK_GRID (grid), widget, 1, 3, 1, 1);
 
   gtk_widget_show (window);
 


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