summaryrefslogtreecommitdiff
path: root/tests/testexpand.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-10-11 13:26:11 -0400
committerMatthias Clasen <mclasen@redhat.com>2010-10-13 10:49:06 -0400
commit29ce9e679a502c35e52d9ab87d7c4dbc4664258b (patch)
treed0185352d9f6272a14303ddc908164262aa15d5e /tests/testexpand.c
parent8abb18f910ba26f8dd536b28150b85e1616eb1aa (diff)
downloadgtk+-29ce9e679a502c35e52d9ab87d7c4dbc4664258b.tar.gz
Add a GtkTable testcase
Diffstat (limited to 'tests/testexpand.c')
-rw-r--r--tests/testexpand.c95
1 files changed, 81 insertions, 14 deletions
diff --git a/tests/testexpand.c b/tests/testexpand.c
index c28bcd85ce..c4a874ddbe 100644
--- a/tests/testexpand.c
+++ b/tests/testexpand.c
@@ -50,8 +50,8 @@ on_toggle_vexpand (GtkToggleButton *toggle,
NULL);
}
-static GtkWidget*
-create_window (void)
+static void
+create_box_window (void)
{
GtkWidget *window;
GtkWidget *box1, *box2, *box3;
@@ -61,6 +61,7 @@ create_window (void)
GdkColor red, blue;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "Boxes");
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0);
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
@@ -100,6 +101,7 @@ create_window (void)
gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &red);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
gtk_container_add (GTK_CONTAINER (colorbox), alignment);
toggle = gtk_toggle_button_new_with_label ("H Expand");
@@ -115,6 +117,7 @@ create_window (void)
gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &blue);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
gtk_container_add (GTK_CONTAINER (colorbox), alignment);
toggle = gtk_toggle_button_new_with_label ("V Expand");
@@ -125,26 +128,90 @@ create_window (void)
colorbox,
FALSE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (window),
- box1);
- gtk_widget_show_all (box1);
-
- return window;
+ gtk_container_add (GTK_CONTAINER (window), box1);
+ gtk_widget_show_all (window);
}
-int
-main (int argc, char *argv[])
+static void
+create_table_window (void)
{
GtkWidget *window;
+ GtkWidget *table;
+ GtkWidget *toggle;
+ GtkWidget *alignment;
+ GtkWidget *colorbox;
+ GdkColor red, blue;
- gtk_init (&argc, &argv);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "Table");
+
+ table = gtk_table_new (4, 3, FALSE);
+
+ gtk_table_attach (GTK_TABLE (table),
+ gtk_label_new ("Top"),
+ 1, 2, 0, 1,
+ GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table),
+ gtk_label_new ("Bottom"),
+ 1, 2, 3, 4,
+ GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table),
+ gtk_label_new ("Left"),
+ 0, 1, 1, 3,
+ GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table),
+ gtk_label_new ("Right"),
+ 2, 3, 1, 3,
+ GTK_FILL, GTK_FILL, 0, 0);
- window = create_window ();
+ gdk_color_parse ("red", &red);
+ gdk_color_parse ("blue", &blue);
+
+ colorbox = gtk_event_box_new ();
+ gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &red);
- g_signal_connect (window, "delete-event",
- G_CALLBACK (gtk_main_quit), window);
+ alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
+ gtk_container_add (GTK_CONTAINER (colorbox), alignment);
+
+ toggle = gtk_toggle_button_new_with_label ("H Expand");
+ g_signal_connect (G_OBJECT (toggle), "toggled",
+ G_CALLBACK (on_toggle_hexpand), NULL);
+ gtk_container_add (GTK_CONTAINER (alignment), toggle);
+
+ gtk_table_attach (GTK_TABLE (table),
+ colorbox,
+ 1, 2, 1, 2,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ colorbox = gtk_event_box_new ();
+ gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &blue);
+
+ alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
+ gtk_container_add (GTK_CONTAINER (colorbox), alignment);
+
+ toggle = gtk_toggle_button_new_with_label ("V Expand");
+ g_signal_connect (G_OBJECT (toggle), "toggled",
+ G_CALLBACK (on_toggle_vexpand), NULL);
+ gtk_container_add (GTK_CONTAINER (alignment), toggle);
+
+ gtk_table_attach (GTK_TABLE (table),
+ colorbox,
+ 1, 2, 2, 3,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ gtk_container_add (GTK_CONTAINER (window), table);
+ gtk_widget_show_all (window);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_init (&argc, &argv);
- gtk_widget_show (window);
+ create_box_window ();
+ create_table_window ();
gtk_main ();