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, see <http://www.gnu.org/licenses/>.
24 on_toggle_hexpand (GtkToggleButton *toggle,
28 "hexpand", gtk_toggle_button_get_active (toggle),
33 on_toggle_vexpand (GtkToggleButton *toggle,
37 "vexpand", gtk_toggle_button_get_active (toggle),
42 create_box_window (void)
45 GtkWidget *box1, *box2, *box3;
51 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
52 gtk_window_set_title (GTK_WINDOW (window), "Boxes");
54 box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
55 box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
56 box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
58 gtk_box_pack_start (GTK_BOX (box1),
59 gtk_label_new ("VBox 1 Top"),
61 gtk_box_pack_start (GTK_BOX (box1),
64 gtk_box_pack_end (GTK_BOX (box1),
65 gtk_label_new ("VBox 1 Bottom"),
68 gtk_box_pack_start (GTK_BOX (box2),
69 gtk_label_new ("HBox 2 Left"),
71 gtk_box_pack_start (GTK_BOX (box2),
74 gtk_box_pack_end (GTK_BOX (box2),
75 gtk_label_new ("HBox 2 Right"),
78 gtk_box_pack_start (GTK_BOX (box3),
79 gtk_label_new ("VBox 3 Top"),
81 gtk_box_pack_end (GTK_BOX (box3),
82 gtk_label_new ("VBox 3 Bottom"),
85 gdk_rgba_parse (&red, "red");
86 gdk_rgba_parse (&blue, "blue");
88 colorbox = gtk_event_box_new ();
89 gtk_widget_override_background_color (colorbox, 0, &red);
91 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
92 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
93 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
95 toggle = gtk_toggle_button_new_with_label ("H Expand");
96 g_signal_connect (G_OBJECT (toggle), "toggled",
97 G_CALLBACK (on_toggle_hexpand), NULL);
98 gtk_container_add (GTK_CONTAINER (alignment), toggle);
100 gtk_box_pack_start (GTK_BOX (box3),
104 colorbox = gtk_event_box_new ();
105 gtk_widget_override_background_color (colorbox, 0, &blue);
107 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
108 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
109 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
111 toggle = gtk_toggle_button_new_with_label ("V Expand");
112 g_signal_connect (G_OBJECT (toggle), "toggled",
113 G_CALLBACK (on_toggle_vexpand), NULL);
114 gtk_container_add (GTK_CONTAINER (alignment), toggle);
115 gtk_box_pack_start (GTK_BOX (box3),
119 gtk_container_add (GTK_CONTAINER (window), box1);
120 gtk_widget_show_all (window);
124 create_grid_window (void)
129 GtkWidget *alignment;
133 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
134 gtk_window_set_title (GTK_WINDOW (window), "Grid");
136 grid = gtk_grid_new ();
138 gtk_grid_attach (GTK_GRID (grid),
139 gtk_label_new ("Top"),
141 gtk_grid_attach (GTK_GRID (grid),
142 gtk_label_new ("Bottom"),
144 gtk_grid_attach (GTK_GRID (grid),
145 gtk_label_new ("Left"),
147 gtk_grid_attach (GTK_GRID (grid),
148 gtk_label_new ("Right"),
151 gdk_rgba_parse (&red, "red");
152 gdk_rgba_parse (&blue, "blue");
154 colorbox = gtk_event_box_new ();
155 gtk_widget_override_background_color (colorbox, GTK_STATE_NORMAL, &red);
157 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
158 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
159 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
161 toggle = gtk_toggle_button_new_with_label ("H Expand");
162 g_signal_connect (G_OBJECT (toggle), "toggled",
163 G_CALLBACK (on_toggle_hexpand), NULL);
164 gtk_container_add (GTK_CONTAINER (alignment), toggle);
166 gtk_grid_attach (GTK_GRID (grid),
170 colorbox = gtk_event_box_new ();
171 gtk_widget_override_background_color (colorbox, 0, &blue);
173 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
174 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
175 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
177 toggle = gtk_toggle_button_new_with_label ("V Expand");
178 g_signal_connect (G_OBJECT (toggle), "toggled",
179 G_CALLBACK (on_toggle_vexpand), NULL);
180 gtk_container_add (GTK_CONTAINER (alignment), toggle);
182 gtk_grid_attach (GTK_GRID (grid),
186 gtk_container_add (GTK_CONTAINER (window), grid);
187 gtk_widget_show_all (window);
191 main (int argc, char *argv[])
193 gtk_init (&argc, &argv);
195 if (g_getenv ("RTL"))
196 gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
198 create_box_window ();
199 create_grid_window ();