2 * Copyright (C) 2010 Havoc Pennington
5 * Havoc Pennington <hp@pobox.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
26 on_toggle_hexpand (GtkToggleButton *toggle,
30 "hexpand", gtk_toggle_button_get_active (toggle),
35 on_toggle_vexpand (GtkToggleButton *toggle,
39 "vexpand", gtk_toggle_button_get_active (toggle),
44 create_box_window (void)
47 GtkWidget *box1, *box2, *box3;
53 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
54 gtk_window_set_title (GTK_WINDOW (window), "Boxes");
56 box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
57 box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
58 box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
60 gtk_box_pack_start (GTK_BOX (box1),
61 gtk_label_new ("VBox 1 Top"),
63 gtk_box_pack_start (GTK_BOX (box1),
66 gtk_box_pack_end (GTK_BOX (box1),
67 gtk_label_new ("VBox 1 Bottom"),
70 gtk_box_pack_start (GTK_BOX (box2),
71 gtk_label_new ("HBox 2 Left"),
73 gtk_box_pack_start (GTK_BOX (box2),
76 gtk_box_pack_end (GTK_BOX (box2),
77 gtk_label_new ("HBox 2 Right"),
80 gtk_box_pack_start (GTK_BOX (box3),
81 gtk_label_new ("VBox 3 Top"),
83 gtk_box_pack_end (GTK_BOX (box3),
84 gtk_label_new ("VBox 3 Bottom"),
87 gdk_rgba_parse (&red, "red");
88 gdk_rgba_parse (&blue, "blue");
90 colorbox = gtk_event_box_new ();
91 gtk_widget_override_background_color (colorbox, 0, &red);
93 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
94 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
95 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
97 toggle = gtk_toggle_button_new_with_label ("H Expand");
98 g_signal_connect (G_OBJECT (toggle), "toggled",
99 G_CALLBACK (on_toggle_hexpand), NULL);
100 gtk_container_add (GTK_CONTAINER (alignment), toggle);
102 gtk_box_pack_start (GTK_BOX (box3),
106 colorbox = gtk_event_box_new ();
107 gtk_widget_override_background_color (colorbox, 0, &blue);
109 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
110 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
111 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
113 toggle = gtk_toggle_button_new_with_label ("V Expand");
114 g_signal_connect (G_OBJECT (toggle), "toggled",
115 G_CALLBACK (on_toggle_vexpand), NULL);
116 gtk_container_add (GTK_CONTAINER (alignment), toggle);
117 gtk_box_pack_start (GTK_BOX (box3),
121 gtk_container_add (GTK_CONTAINER (window), box1);
122 gtk_widget_show_all (window);
126 create_table_window (void)
131 GtkWidget *alignment;
135 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
136 gtk_window_set_title (GTK_WINDOW (window), "Table");
138 table = gtk_table_new (4, 3, FALSE);
140 gtk_table_attach (GTK_TABLE (table),
141 gtk_label_new ("Top"),
143 GTK_FILL, GTK_FILL, 0, 0);
144 gtk_table_attach (GTK_TABLE (table),
145 gtk_label_new ("Bottom"),
147 GTK_FILL, GTK_FILL, 0, 0);
148 gtk_table_attach (GTK_TABLE (table),
149 gtk_label_new ("Left"),
151 GTK_FILL, GTK_FILL, 0, 0);
152 gtk_table_attach (GTK_TABLE (table),
153 gtk_label_new ("Right"),
155 GTK_FILL, GTK_FILL, 0, 0);
157 gdk_rgba_parse (&red, "red");
158 gdk_rgba_parse (&blue, "blue");
160 colorbox = gtk_event_box_new ();
161 gtk_widget_override_background_color (colorbox, GTK_STATE_NORMAL, &red);
163 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
164 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
165 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
167 toggle = gtk_toggle_button_new_with_label ("H Expand");
168 g_signal_connect (G_OBJECT (toggle), "toggled",
169 G_CALLBACK (on_toggle_hexpand), NULL);
170 gtk_container_add (GTK_CONTAINER (alignment), toggle);
172 gtk_table_attach (GTK_TABLE (table),
175 GTK_FILL, GTK_FILL, 0, 0);
177 colorbox = gtk_event_box_new ();
178 gtk_widget_override_background_color (colorbox, 0, &blue);
180 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
181 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
182 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
184 toggle = gtk_toggle_button_new_with_label ("V Expand");
185 g_signal_connect (G_OBJECT (toggle), "toggled",
186 G_CALLBACK (on_toggle_vexpand), NULL);
187 gtk_container_add (GTK_CONTAINER (alignment), toggle);
189 gtk_table_attach (GTK_TABLE (table),
192 GTK_FILL, GTK_FILL, 0, 0);
194 gtk_container_add (GTK_CONTAINER (window), table);
195 gtk_widget_show_all (window);
199 main (int argc, char *argv[])
201 gtk_init (&argc, &argv);
203 if (g_getenv ("RTL"))
204 gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
206 create_box_window ();
207 create_table_window ();