]> Pileus Git - ~andy/gtk/blob - tests/testorientable.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / tests / testorientable.c
1 /* testorientable.c
2  * Copyright (C) 2004  Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <gtk/gtk.h>
21
22 static void
23 orient_toggled (GtkToggleButton *button, gpointer user_data)
24 {
25   GList *orientables = (GList *) user_data, *ptr;
26   gboolean state = gtk_toggle_button_get_active (button);
27   GtkOrientation orientation;
28
29   if (state)
30     {
31       orientation = GTK_ORIENTATION_VERTICAL;
32       gtk_button_set_label (GTK_BUTTON (button), "Vertical");
33     }
34   else
35     {
36       orientation = GTK_ORIENTATION_HORIZONTAL;
37       gtk_button_set_label (GTK_BUTTON (button), "Horizontal");
38     }
39
40   for (ptr = orientables; ptr; ptr = ptr->next)
41     {
42       GtkOrientable *orientable = GTK_ORIENTABLE (ptr->data);
43
44       gtk_orientable_set_orientation (orientable, orientation);
45     }
46 }
47
48 int
49 main (int argc, char **argv)
50 {
51   GtkWidget *window;
52   GtkWidget *table;
53   GtkWidget *box, *button;
54   GList *orientables = NULL;
55
56   gtk_init (&argc, &argv);
57
58   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
59   table = gtk_table_new (2, 3, FALSE);
60   gtk_table_set_row_spacings (GTK_TABLE (table), 12);
61   gtk_table_set_col_spacings (GTK_TABLE (table), 12);
62
63   /* GtkBox */
64   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
65   orientables = g_list_prepend (orientables, box);
66   gtk_table_attach_defaults (GTK_TABLE (table), box, 0, 1, 1, 2);
67   gtk_box_pack_start (GTK_BOX (box),
68                   gtk_button_new_with_label ("GtkBox 1"),
69                   TRUE, TRUE, 0);
70   gtk_box_pack_start (GTK_BOX (box),
71                   gtk_button_new_with_label ("GtkBox 2"),
72                   TRUE, TRUE, 0);
73   gtk_box_pack_start (GTK_BOX (box),
74                   gtk_button_new_with_label ("GtkBox 3"),
75                   TRUE, TRUE, 0);
76
77   /* GtkButtonBox */
78   box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
79   orientables = g_list_prepend (orientables, box);
80   gtk_table_attach_defaults (GTK_TABLE (table), box, 1, 2, 1, 2);
81   gtk_box_pack_start (GTK_BOX (box),
82                   gtk_button_new_with_label ("GtkButtonBox 1"),
83                   TRUE, TRUE, 0);
84   gtk_box_pack_start (GTK_BOX (box),
85                   gtk_button_new_with_label ("GtkButtonBox 2"),
86                   TRUE, TRUE, 0);
87   gtk_box_pack_start (GTK_BOX (box),
88                   gtk_button_new_with_label ("GtkButtonBox 3"),
89                   TRUE, TRUE, 0);
90
91   /* GtkSeparator */
92   box = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
93   orientables = g_list_prepend (orientables, box);
94   gtk_table_attach_defaults (GTK_TABLE (table), box, 2, 3, 1, 2);
95
96   button = gtk_toggle_button_new_with_label ("Horizontal");
97   gtk_table_attach (GTK_TABLE (table), button, 0, 1, 0, 1,
98                   GTK_FILL, GTK_FILL, 0, 0);
99   g_signal_connect (button, "toggled",
100                   G_CALLBACK (orient_toggled), orientables);
101
102   gtk_container_add (GTK_CONTAINER (window), table);
103   gtk_widget_show_all (window);
104
105   g_signal_connect (window, "destroy",
106                   G_CALLBACK (gtk_main_quit), NULL);
107
108   gtk_main ();
109
110   return 0;
111 }