[gtk+/wip/toolbar-regions] Test box and toolbar regions in parallel



commit 3894905a243dbbbfe88367f51d0d1e1c9ca3a526
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 18 13:14:18 2011 -0400

    Test box and toolbar regions in parallel
    
    This makes it easy to see discrepancies.
    Plus, it is fun

 tests/testboxcss.c |   60 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 14 deletions(-)
---
diff --git a/tests/testboxcss.c b/tests/testboxcss.c
index 4a5d439..2ae081b 100644
--- a/tests/testboxcss.c
+++ b/tests/testboxcss.c
@@ -30,7 +30,6 @@
   "  background-image: none;\n" \
   "  background-color: red;\n" \
   "  border-color: black;\n" \
-  "  color: red;\n" \
   "  border-radius: 0;\n" \
   "}\n" \
   "\n" \
@@ -97,15 +96,16 @@ remove_widget (GtkWidget *widget)
   gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
 }
 
+static int count = 0;
+
 static void
-add_widget (GtkToolbar *box)
+add_button (GtkBox *box)
 {
-  static int count = 0;
   GtkWidget* button;
   char *text;
 
   text = g_strdup_printf ("Remove %d", ++count);
-  button = (GtkWidget *)gtk_tool_button_new (NULL, text);
+  button = (GtkWidget *)gtk_button_new_from_stock (text);
   g_free (text);
   gtk_style_context_add_class (gtk_widget_get_style_context (button), "play");
   g_signal_connect_swapped (button,
@@ -114,7 +114,24 @@ add_widget (GtkToolbar *box)
                             button);
   gtk_widget_show (button);
   gtk_container_add (GTK_CONTAINER (box), button);
-  g_print ("path:  %s\n", gtk_widget_path_to_string (gtk_widget_get_path (button)));
+}
+
+static void
+add_toolbutton (GtkToolbar *toolbar)
+{
+  GtkWidget* button;
+  char *text;
+
+  text = g_strdup_printf ("Remove %d", ++count);
+  button = (GtkWidget *)gtk_tool_button_new (NULL, text);
+  g_free (text);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "play");
+  g_signal_connect_swapped (button,
+                            "clicked",
+                            G_CALLBACK (remove_widget),
+                            button);
+  gtk_widget_show (button);
+  gtk_container_add (GTK_CONTAINER (toolbar), button);
 }
 
 static void
@@ -126,7 +143,8 @@ set_orientation (GtkSwitch *switch_)
 gint
 main (gint argc, gchar **argv)
 {
-  GtkWidget *window, *main_box, *box, *container, *child;
+  GtkWidget *window, *main_box, *container, *child;
+  GtkWidget *box, *toolbar;
   GtkStyleProvider *provider;
   GtkTextBuffer *css;
   
@@ -155,8 +173,11 @@ main (gint argc, gchar **argv)
   main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_container_add (GTK_CONTAINER (window), main_box);
 
-  box = gtk_toolbar_new ();
-  gtk_toolbar_set_style (GTK_TOOLBAR (box), GTK_TOOLBAR_TEXT);
+  toolbar = gtk_toolbar_new ();
+  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT);
+  gtk_box_pack_start (GTK_BOX (main_box), toolbar, FALSE, TRUE, 0);
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_box_pack_start (GTK_BOX (main_box), box, FALSE, TRUE, 0);
 
   container = gtk_scrolled_window_new (NULL, NULL);
@@ -188,17 +209,28 @@ main (gint argc, gchar **argv)
   gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0);
   child = gtk_label_new ("left-to-right");
   gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0);
-  child = gtk_button_new_with_label ("Add widget");
+  child = gtk_button_new_with_label ("Add button");
   g_signal_connect_swapped (child,
                             "clicked",
-                            G_CALLBACK (add_widget),
+                            G_CALLBACK (add_button),
                             box);
   gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0);
+  child = gtk_button_new_with_label ("Add toolbutton");
+  g_signal_connect_swapped (child,
+                            "clicked",
+                            G_CALLBACK (add_toolbutton),
+                            toolbar);
+  gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0);
+
+  add_toolbutton (GTK_TOOLBAR (toolbar));
+  add_toolbutton (GTK_TOOLBAR (toolbar));
+  add_toolbutton (GTK_TOOLBAR (toolbar));
+  add_toolbutton (GTK_TOOLBAR (toolbar));
 
-  add_widget (GTK_TOOLBAR (box));
-  add_widget (GTK_TOOLBAR (box));
-  add_widget (GTK_TOOLBAR (box));
-  add_widget (GTK_TOOLBAR (box));
+  add_button (GTK_BOX (box));
+  add_button (GTK_BOX (box));
+  add_button (GTK_BOX (box));
+  add_button (GTK_BOX (box));
 
   gtk_widget_show_all (window);
 



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