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_grid_window (void)
131 GtkWidget *alignment;
135 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
136 gtk_window_set_title (GTK_WINDOW (window), "Grid");
138 grid = gtk_grid_new ();
140 gtk_grid_attach (GTK_GRID (grid),
141 gtk_label_new ("Top"),
143 gtk_grid_attach (GTK_GRID (grid),
144 gtk_label_new ("Bottom"),
146 gtk_grid_attach (GTK_GRID (grid),
147 gtk_label_new ("Left"),
149 gtk_grid_attach (GTK_GRID (grid),
150 gtk_label_new ("Right"),
153 gdk_rgba_parse (&red, "red");
154 gdk_rgba_parse (&blue, "blue");
156 colorbox = gtk_event_box_new ();
157 gtk_widget_override_background_color (colorbox, GTK_STATE_NORMAL, &red);
159 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
160 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
161 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
163 toggle = gtk_toggle_button_new_with_label ("H Expand");
164 g_signal_connect (G_OBJECT (toggle), "toggled",
165 G_CALLBACK (on_toggle_hexpand), NULL);
166 gtk_container_add (GTK_CONTAINER (alignment), toggle);
168 gtk_grid_attach (GTK_GRID (grid),
172 colorbox = gtk_event_box_new ();
173 gtk_widget_override_background_color (colorbox, 0, &blue);
175 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
176 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
177 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
179 toggle = gtk_toggle_button_new_with_label ("V Expand");
180 g_signal_connect (G_OBJECT (toggle), "toggled",
181 G_CALLBACK (on_toggle_vexpand), NULL);
182 gtk_container_add (GTK_CONTAINER (alignment), toggle);
184 gtk_grid_attach (GTK_GRID (grid),
188 gtk_container_add (GTK_CONTAINER (window), grid);
189 gtk_widget_show_all (window);
193 main (int argc, char *argv[])
195 gtk_init (&argc, &argv);
197 if (g_getenv ("RTL"))
198 gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
200 create_box_window ();
201 create_grid_window ();