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,
31 /* get the event box with color set on it */
32 parent = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (toggle)));
35 "hexpand", gtk_toggle_button_get_active (toggle),
40 on_toggle_vexpand (GtkToggleButton *toggle,
45 /* get the event box with color set on it */
46 parent = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (toggle)));
49 "vexpand", gtk_toggle_button_get_active (toggle),
54 create_box_window (void)
57 GtkWidget *box1, *box2, *box3;
63 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
64 gtk_window_set_title (GTK_WINDOW (window), "Boxes");
66 box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
67 box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
68 box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
70 gtk_box_pack_start (GTK_BOX (box1),
71 gtk_label_new ("VBox 1 Top"),
73 gtk_box_pack_start (GTK_BOX (box1),
76 gtk_box_pack_end (GTK_BOX (box1),
77 gtk_label_new ("VBox 1 Bottom"),
80 gtk_box_pack_start (GTK_BOX (box2),
81 gtk_label_new ("HBox 2 Left"),
83 gtk_box_pack_start (GTK_BOX (box2),
86 gtk_box_pack_end (GTK_BOX (box2),
87 gtk_label_new ("HBox 2 Right"),
90 gtk_box_pack_start (GTK_BOX (box3),
91 gtk_label_new ("VBox 3 Top"),
93 gtk_box_pack_end (GTK_BOX (box3),
94 gtk_label_new ("VBox 3 Bottom"),
97 gdk_color_parse ("red", &red);
98 gdk_color_parse ("blue", &blue);
100 colorbox = gtk_event_box_new ();
101 gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &red);
103 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
104 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
105 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
107 toggle = gtk_toggle_button_new_with_label ("H Expand");
108 g_signal_connect (G_OBJECT (toggle), "toggled",
109 G_CALLBACK (on_toggle_hexpand), NULL);
110 gtk_container_add (GTK_CONTAINER (alignment), toggle);
112 gtk_box_pack_start (GTK_BOX (box3),
116 colorbox = gtk_event_box_new ();
117 gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &blue);
119 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
120 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
121 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
123 toggle = gtk_toggle_button_new_with_label ("V Expand");
124 g_signal_connect (G_OBJECT (toggle), "toggled",
125 G_CALLBACK (on_toggle_vexpand), NULL);
126 gtk_container_add (GTK_CONTAINER (alignment), toggle);
127 gtk_box_pack_start (GTK_BOX (box3),
131 gtk_container_add (GTK_CONTAINER (window), box1);
132 gtk_widget_show_all (window);
136 create_table_window (void)
141 GtkWidget *alignment;
145 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
146 gtk_window_set_title (GTK_WINDOW (window), "Table");
148 table = gtk_table_new (4, 3, FALSE);
150 gtk_table_attach (GTK_TABLE (table),
151 gtk_label_new ("Top"),
153 GTK_FILL, GTK_FILL, 0, 0);
154 gtk_table_attach (GTK_TABLE (table),
155 gtk_label_new ("Bottom"),
157 GTK_FILL, GTK_FILL, 0, 0);
158 gtk_table_attach (GTK_TABLE (table),
159 gtk_label_new ("Left"),
161 GTK_FILL, GTK_FILL, 0, 0);
162 gtk_table_attach (GTK_TABLE (table),
163 gtk_label_new ("Right"),
165 GTK_FILL, GTK_FILL, 0, 0);
167 gdk_color_parse ("red", &red);
168 gdk_color_parse ("blue", &blue);
170 colorbox = gtk_event_box_new ();
171 gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &red);
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 ("H Expand");
178 g_signal_connect (G_OBJECT (toggle), "toggled",
179 G_CALLBACK (on_toggle_hexpand), NULL);
180 gtk_container_add (GTK_CONTAINER (alignment), toggle);
182 gtk_table_attach (GTK_TABLE (table),
185 GTK_FILL, GTK_FILL, 0, 0);
187 colorbox = gtk_event_box_new ();
188 gtk_widget_modify_bg (colorbox, GTK_STATE_NORMAL, &blue);
190 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
191 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 5, 5, 5, 5);
192 gtk_container_add (GTK_CONTAINER (colorbox), alignment);
194 toggle = gtk_toggle_button_new_with_label ("V Expand");
195 g_signal_connect (G_OBJECT (toggle), "toggled",
196 G_CALLBACK (on_toggle_vexpand), NULL);
197 gtk_container_add (GTK_CONTAINER (alignment), toggle);
199 gtk_table_attach (GTK_TABLE (table),
202 GTK_FILL, GTK_FILL, 0, 0);
204 gtk_container_add (GTK_CONTAINER (window), table);
205 gtk_widget_show_all (window);
209 main (int argc, char *argv[])
211 gtk_init (&argc, &argv);
213 create_box_window ();
214 create_table_window ();