1#include <gtk/gtk.h>
2
3static GtkWidget *
4oriented_test_widget (const char *label, const char *color)
5{
6 GtkWidget *box;
7 GtkWidget *widget;
8 GtkCssProvider *provider;
9 char *data;
10
11 widget = gtk_label_new (str: label);
12 box = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 0);
13 provider = gtk_css_provider_new ();
14 data = g_strdup_printf (format: "box { background: %s; }", color);
15 gtk_css_provider_load_from_data (css_provider: provider, data, length: -1);
16 gtk_style_context_add_provider (context: gtk_widget_get_style_context (widget: box),
17 GTK_STYLE_PROVIDER (provider),
18 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
19 g_free (mem: data);
20 g_object_unref (object: provider);
21 gtk_box_append (GTK_BOX (box), child: widget);
22
23 return box;
24}
25
26static GtkWidget *
27test_widget (const char *label, const char *color)
28{
29 return oriented_test_widget (label, color);
30}
31
32static GtkOrientation o;
33
34static void
35toggle_orientation (GtkGestureClick *gesture,
36 guint n_press,
37 double x,
38 double y,
39 GtkGrid *grid)
40{
41 o = 1 - o;
42 gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), orientation: o);
43}
44
45static void
46simple_grid (void)
47{
48 GtkWidget *window;
49 GtkWidget *grid;
50 GtkWidget *test1, *test2, *test3, *test4, *test5, *test6;
51 GtkGesture *gesture;
52
53 window = gtk_window_new ();
54 gtk_window_set_title (GTK_WINDOW (window), title: "Orientation");
55 grid = gtk_grid_new ();
56 gtk_window_set_child (GTK_WINDOW (window), child: grid);
57
58 gesture = gtk_gesture_click_new ();
59 g_signal_connect (gesture, "pressed", G_CALLBACK (toggle_orientation), grid);
60 gtk_widget_add_controller (widget: window, GTK_EVENT_CONTROLLER (gesture));
61
62 gtk_grid_set_column_spacing (GTK_GRID (grid), spacing: 5);
63 gtk_grid_set_row_spacing (GTK_GRID (grid), spacing: 5);
64 test1 = test_widget (label: "1", color: "red");
65 gtk_grid_attach (GTK_GRID (grid), child: test1, column: 0, row: 0, width: 1, height: 1);
66 test2 = test_widget (label: "2", color: "green");
67 gtk_grid_attach (GTK_GRID (grid), child: test2, column: 1, row: 0, width: 1, height: 1);
68 test3 = test_widget (label: "3", color: "blue");
69 gtk_grid_attach (GTK_GRID (grid), child: test3, column: 2, row: 0, width: 1, height: 1);
70 test4 = test_widget (label: "4", color: "green");
71 gtk_grid_attach (GTK_GRID (grid), child: test4, column: 0, row: 1, width: 1, height: 1);
72 gtk_widget_set_vexpand (widget: test4, TRUE);
73 test5 = test_widget (label: "5", color: "blue");
74 gtk_grid_attach_next_to (GTK_GRID (grid), child: test5, sibling: test4, side: GTK_POS_RIGHT, width: 2, height: 1);
75 test6 = test_widget (label: "6", color: "yellow");
76 gtk_grid_attach (GTK_GRID (grid), child: test6, column: -1, row: 0, width: 1, height: 2);
77 gtk_widget_set_hexpand (widget: test6, TRUE);
78
79 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 0, -1) == NULL);
80 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 0, 0) == test1);
81 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 1, 0) == test2);
82 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 0, 1) == test4);
83 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), -1, 0) == test6);
84 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), -1, 1) == test6);
85 g_assert (gtk_grid_get_child_at (GTK_GRID (grid), -1, 2) == NULL);
86 gtk_widget_show (widget: window);
87}
88
89static void
90text_grid (void)
91{
92 GtkWidget *window;
93 GtkWidget *grid;
94 GtkWidget *paned1;
95 GtkWidget *box;
96 GtkWidget *label;
97
98 window = gtk_window_new ();
99 gtk_window_set_title (GTK_WINDOW (window), title: "Height-for-Width");
100 paned1 = gtk_paned_new (orientation: GTK_ORIENTATION_HORIZONTAL);
101 gtk_window_set_child (GTK_WINDOW (window), child: paned1);
102
103 box = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 0);
104 gtk_paned_set_start_child (GTK_PANED (paned1), child: box);
105 gtk_paned_set_resize_start_child (GTK_PANED (paned1), TRUE);
106 gtk_paned_set_shrink_start_child (GTK_PANED (paned1), FALSE);
107 gtk_paned_set_end_child (GTK_PANED (paned1), child: gtk_label_new (str: "Space"));
108 gtk_paned_set_resize_end_child (GTK_PANED (paned1), TRUE);
109 gtk_paned_set_shrink_end_child (GTK_PANED (paned1), FALSE);
110
111 grid = gtk_grid_new ();
112 gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), orientation: GTK_ORIENTATION_VERTICAL);
113 gtk_box_append (GTK_BOX (box), child: gtk_label_new (str: "Above"));
114 gtk_box_append (GTK_BOX (box), child: gtk_separator_new (orientation: GTK_ORIENTATION_HORIZONTAL));
115 gtk_box_append (GTK_BOX (box), child: grid);
116 gtk_box_append (GTK_BOX (box), child: gtk_separator_new (orientation: GTK_ORIENTATION_HORIZONTAL));
117 gtk_box_append (GTK_BOX (box), child: gtk_label_new (str: "Below"));
118
119 label = gtk_label_new (str: "Some text that may wrap if it has to");
120 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 10);
121 gtk_label_set_wrap (GTK_LABEL (label), TRUE);
122 gtk_grid_attach (GTK_GRID (grid), child: label, column: 0, row: 0, width: 1, height: 1);
123
124 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "1", color: "red"), column: 1, row: 0, width: 1, height: 1);
125 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "2", color: "blue"), column: 0, row: 1, width: 1, height: 1);
126
127 label = gtk_label_new (str: "Some text that may wrap if it has to");
128 gtk_label_set_ellipsize (GTK_LABEL (label), mode: PANGO_ELLIPSIZE_END);
129 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 10);
130 gtk_grid_attach (GTK_GRID (grid), child: label, column: 1, row: 1, width: 1, height: 1);
131
132 gtk_widget_show (widget: window);
133}
134
135static void
136box_comparison (void)
137{
138 GtkWidget *window;
139 GtkWidget *vbox;
140 GtkWidget *box;
141 GtkWidget *label;
142 GtkWidget *grid;
143
144 window = gtk_window_new ();
145 gtk_window_set_title (GTK_WINDOW (window), title: "Grid vs. Box");
146 vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 5);
147 gtk_window_set_child (GTK_WINDOW (window), child: vbox);
148
149 gtk_box_append (GTK_BOX (vbox), child: gtk_label_new (str: "Above"));
150 gtk_box_append (GTK_BOX (vbox), child: gtk_separator_new (orientation: GTK_ORIENTATION_HORIZONTAL));
151
152 box = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 0);
153 gtk_box_append (GTK_BOX (vbox), child: box);
154
155 gtk_box_append (GTK_BOX (box), child: test_widget (label: "1", color: "white"));
156
157 label = gtk_label_new (str: "Some ellipsizing text");
158 gtk_label_set_ellipsize (GTK_LABEL (label), mode: PANGO_ELLIPSIZE_END);
159 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 10);
160 gtk_box_append (GTK_BOX (box), child: label);
161
162 gtk_box_append (GTK_BOX (box), child: test_widget (label: "2", color: "green"));
163
164 label = gtk_label_new (str: "Some text that may wrap if needed");
165 gtk_label_set_wrap (GTK_LABEL (label), TRUE);
166 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 10);
167 gtk_box_append (GTK_BOX (box), child: label);
168
169 gtk_box_append (GTK_BOX (box), child: test_widget (label: "3", color: "red"));
170
171 grid = gtk_grid_new ();
172 gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), orientation: GTK_ORIENTATION_VERTICAL);
173 gtk_box_append (GTK_BOX (vbox), child: gtk_separator_new (orientation: GTK_ORIENTATION_HORIZONTAL));
174 gtk_box_append (GTK_BOX (vbox), child: grid);
175
176 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "1", color: "white"), column: 0, row: 0, width: 1, height: 1);
177
178 label = gtk_label_new (str: "Some ellipsizing text");
179 gtk_label_set_ellipsize (GTK_LABEL (label), mode: PANGO_ELLIPSIZE_END);
180 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 10);
181 gtk_grid_attach (GTK_GRID (grid), child: label, column: 1, row: 0, width: 1, height: 1);
182 gtk_widget_set_hexpand (widget: label, TRUE);
183
184 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "2", color: "green"), column: 2, row: 0, width: 1, height: 1);
185
186 label = gtk_label_new (str: "Some text that may wrap if needed");
187 gtk_label_set_wrap (GTK_LABEL (label), TRUE);
188 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 10);
189 gtk_grid_attach (GTK_GRID (grid), child: label, column: 3, row: 0, width: 1, height: 1);
190 gtk_widget_set_hexpand (widget: label, TRUE);
191
192 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "3", color: "red"), column: 4, row: 0, width: 1, height: 1);
193
194 gtk_box_append (GTK_BOX (vbox), child: gtk_separator_new (orientation: GTK_ORIENTATION_HORIZONTAL));
195 gtk_box_append (GTK_BOX (vbox), child: gtk_label_new (str: "Below"));
196
197 gtk_widget_show (widget: window);
198}
199
200static void
201empty_line (void)
202{
203 GtkWidget *window;
204 GtkWidget *grid;
205 GtkWidget *child;
206
207 window = gtk_window_new ();
208 gtk_window_set_title (GTK_WINDOW (window), title: "Empty row");
209 grid = gtk_grid_new ();
210 gtk_window_set_child (GTK_WINDOW (window), child: grid);
211
212 gtk_grid_set_row_spacing (GTK_GRID (grid), spacing: 10);
213 gtk_grid_set_column_spacing (GTK_GRID (grid), spacing: 10);
214
215 child = test_widget (label: "(0, 0)", color: "red");
216 gtk_grid_attach (GTK_GRID (grid), child, column: 0, row: 0, width: 1, height: 1);
217 gtk_widget_set_hexpand (widget: child, TRUE);
218 gtk_widget_set_vexpand (widget: child, TRUE);
219
220 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 1)", color: "blue"), column: 0, row: 1, width: 1, height: 1);
221
222 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(10, 0)", color: "green"), column: 10, row: 0, width: 1, height: 1);
223 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(10, 1)", color: "magenta"), column: 10, row: 1, width: 1, height: 1);
224
225 gtk_widget_show (widget: window);
226}
227
228static void
229empty_grid (void)
230{
231 GtkWidget *window;
232 GtkWidget *grid;
233 GtkWidget *child;
234
235 window = gtk_window_new ();
236 gtk_window_set_title (GTK_WINDOW (window), title: "Empty grid");
237 grid = gtk_grid_new ();
238 gtk_window_set_child (GTK_WINDOW (window), child: grid);
239
240 gtk_grid_set_row_spacing (GTK_GRID (grid), spacing: 10);
241 gtk_grid_set_column_spacing (GTK_GRID (grid), spacing: 10);
242 gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
243
244 child = test_widget (label: "(0, 0)", color: "red");
245 gtk_grid_attach (GTK_GRID (grid), child, column: 0, row: 0, width: 1, height: 1);
246 gtk_widget_set_hexpand (widget: child, TRUE);
247 gtk_widget_set_vexpand (widget: child, TRUE);
248
249 gtk_widget_show (widget: window);
250 gtk_widget_hide (widget: child);
251}
252
253static void
254scrolling (void)
255{
256 GtkWidget *window;
257 GtkWidget *sw;
258 GtkWidget *viewport;
259 GtkWidget *grid;
260 GtkWidget *child;
261 int i;
262
263 window = gtk_window_new ();
264 gtk_window_set_title (GTK_WINDOW (window), title: "Scrolling");
265 sw = gtk_scrolled_window_new ();
266 viewport = gtk_viewport_new (NULL, NULL);
267 grid = gtk_grid_new ();
268
269 gtk_window_set_child (GTK_WINDOW (window), child: sw);
270 gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), child: viewport);
271 gtk_viewport_set_child (GTK_VIEWPORT (viewport), child: grid);
272
273 child = oriented_test_widget (label: "#800080", color: "#800080");
274 gtk_grid_attach (GTK_GRID (grid), child, column: 0, row: 0, width: 1, height: 1);
275 gtk_widget_set_hexpand (widget: child, TRUE);
276 gtk_widget_set_vexpand (widget: child, TRUE);
277
278 for (i = 1; i < 16; i++)
279 {
280 char *color;
281 color = g_strdup_printf (format: "#%02x00%02x", 128 + 8*i, 128 - 8*i);
282 child = test_widget (label: color, color);
283 gtk_grid_attach (GTK_GRID (grid), child, column: 0, row: i, width: i + 1, height: 1);
284 gtk_widget_set_hexpand (widget: child, TRUE);
285 g_free (mem: color);
286 }
287
288 for (i = 1; i < 16; i++)
289 {
290 char *color;
291 color = g_strdup_printf (format: "#%02x00%02x", 128 - 8*i, 128 + 8*i);
292 child = oriented_test_widget (label: color, color);
293 gtk_grid_attach (GTK_GRID (grid), child, column: i, row: 0, width: 1, height: i);
294 gtk_widget_set_vexpand (widget: child, TRUE);
295 g_free (mem: color);
296 }
297
298 gtk_widget_show (widget: window);
299}
300
301static void
302insert_cb (GtkButton *button, GtkWidget *window)
303{
304 GtkGrid *g, *g1, *g2, *g3, *g4;
305 GtkWidget *child;
306 gboolean inserted;
307
308 g = GTK_GRID (gtk_window_get_child (GTK_WINDOW (window)));
309 g1 = GTK_GRID (gtk_grid_get_child_at (g, 0, 0));
310 g2 = GTK_GRID (gtk_grid_get_child_at (g, 1, 0));
311 g3 = GTK_GRID (gtk_grid_get_child_at (g, 0, 1));
312 g4 = GTK_GRID (gtk_grid_get_child_at (g, 1, 1));
313
314 inserted = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "inserted"));
315
316 if (inserted)
317 {
318 gtk_grid_remove_row (grid: g1, position: 1);
319 gtk_grid_remove_column (grid: g2, position: 1);
320 gtk_grid_remove_row (grid: g3, position: 1);
321 gtk_grid_remove_column (grid: g4, position: 1);
322 }
323 else
324 {
325 gtk_grid_insert_row (grid: g1, position: 1);
326 gtk_grid_attach (grid: g1, child: test_widget (label: "(0, 1)", color: "red"), column: 0, row: 1, width: 1, height: 1);
327 gtk_grid_attach (grid: g1, child: test_widget (label: "(2, 1)", color: "red"), column: 2, row: 1, width: 1, height: 1);
328
329 gtk_grid_insert_column (grid: g2, position: 1);
330 gtk_grid_attach (grid: g2, child: test_widget (label: "(1, 0)", color: "red"), column: 1, row: 0, width: 1, height: 1);
331 gtk_grid_attach (grid: g2, child: test_widget (label: "(1, 2)", color: "red"), column: 1, row: 2, width: 1, height: 1);
332
333 child = gtk_grid_get_child_at (grid: g3, column: 0, row: 0);
334 gtk_grid_insert_next_to (grid: g3, sibling: child, side: GTK_POS_BOTTOM);
335 gtk_grid_attach (grid: g3, child: test_widget (label: "(0, 1)", color: "red"), column: 0, row: 1, width: 1, height: 1);
336 gtk_grid_attach (grid: g3, child: test_widget (label: "(2, 1)", color: "red"), column: 2, row: 1, width: 1, height: 1);
337
338 child = gtk_grid_get_child_at (grid: g4, column: 0, row: 0);
339 gtk_grid_insert_next_to (grid: g4, sibling: child, side: GTK_POS_RIGHT);
340 gtk_grid_attach (grid: g4, child: test_widget (label: "(1, 0)", color: "red"), column: 1, row: 0, width: 1, height: 1);
341 gtk_grid_attach (grid: g4, child: test_widget (label: "(1, 2)", color: "red"), column: 1, row: 2, width: 1, height: 1);
342 }
343
344 gtk_button_set_label (button, label: inserted ? "Insert" : "Remove");
345 g_object_set_data (G_OBJECT (button), key: "inserted", GINT_TO_POINTER (!inserted));
346}
347
348static void
349insert (void)
350{
351 GtkWidget *window;
352 GtkWidget *g;
353 GtkWidget *grid;
354 GtkWidget *child;
355 GtkWidget *button;
356
357 window = gtk_window_new ();
358 gtk_window_set_title (GTK_WINDOW (window), title: "Insertion / Removal");
359
360 g = gtk_grid_new ();
361 gtk_grid_set_row_spacing (GTK_GRID (g), spacing: 10);
362 gtk_grid_set_column_spacing (GTK_GRID (g), spacing: 10);
363 gtk_window_set_child (GTK_WINDOW (window), child: g);
364
365 grid = gtk_grid_new ();
366 gtk_grid_attach (GTK_GRID (g), child: grid, column: 0, row: 0, width: 1, height: 1);
367
368 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 0)", color: "blue"), column: 0, row: 0, width: 1, height: 1);
369 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 1)", color: "blue"), column: 0, row: 1, width: 1, height: 1);
370 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(1, 0)", color: "green"), column: 1, row: 0, width: 1, height: 2);
371 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(2, 0)", color: "yellow"), column: 2, row: 0, width: 1, height: 1);
372 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(2, 1)", color: "yellow"), column: 2, row: 1, width: 1, height: 1);
373
374 grid = gtk_grid_new ();
375 gtk_grid_attach (GTK_GRID (g), child: grid, column: 1, row: 0, width: 1, height: 1);
376
377 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 0)", color: "blue"), column: 0, row: 0, width: 1, height: 1);
378 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(1, 0)", color: "blue"), column: 1, row: 0, width: 1, height: 1);
379 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 1)", color: "green"), column: 0, row: 1, width: 2, height: 1);
380 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 2)", color: "yellow"), column: 0, row: 2, width: 1, height: 1);
381 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(1, 2)", color: "yellow"), column: 1, row: 2, width: 1, height: 1);
382
383 grid = gtk_grid_new ();
384 gtk_grid_attach (GTK_GRID (g), child: grid, column: 0, row: 1, width: 1, height: 1);
385
386 child = test_widget (label: "(0, 0)", color: "blue");
387 gtk_grid_attach (GTK_GRID (grid), child, column: 0, row: 0, width: 1, height: 1);
388 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 1)", color: "blue"), column: 0, row: 1, width: 1, height: 1);
389 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(1, 0)", color: "green"), column: 1, row: 0, width: 1, height: 2);
390 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(2, 0)", color: "yellow"), column: 2, row: 0, width: 1, height: 1);
391 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(2, 1)", color: "yellow"), column: 2, row: 1, width: 1, height: 1);
392
393 grid = gtk_grid_new ();
394 gtk_grid_attach (GTK_GRID (g), child: grid, column: 1, row: 1, width: 1, height: 1);
395
396 child = test_widget (label: "(0, 0)", color: "blue");
397 gtk_grid_attach (GTK_GRID (grid), child, column: 0, row: 0, width: 1, height: 1);
398 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(1, 0)", color: "blue"), column: 1, row: 0, width: 1, height: 1);
399 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 1)", color: "green"), column: 0, row: 1, width: 2, height: 1);
400 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(0, 2)", color: "yellow"), column: 0, row: 2, width: 1, height: 1);
401 gtk_grid_attach (GTK_GRID (grid), child: test_widget (label: "(1, 2)", color: "yellow"), column: 1, row: 2, width: 1, height: 1);
402
403 button = gtk_button_new_with_label (label: "Insert");
404 g_signal_connect (button, "clicked", G_CALLBACK (insert_cb), window);
405 gtk_grid_attach (GTK_GRID (g), child: button, column: 0, row: 2, width: 2, height: 1);
406
407 gtk_widget_show (widget: window);
408}
409
410static void
411spanning_grid (void)
412{
413 GtkWidget *window;
414 GtkWidget *g;
415 GtkWidget *c;
416
417 /* inspired by bug 698660
418 * the row/column that are empty except for the spanning
419 * child need to stay collapsed
420 */
421
422 window = gtk_window_new ();
423 gtk_window_set_title (GTK_WINDOW (window), title: "Spanning");
424
425 g = gtk_grid_new ();
426 gtk_window_set_child (GTK_WINDOW (window), child: g);
427
428 c = test_widget (label: "0", color: "blue");
429 gtk_widget_set_hexpand (widget: c, TRUE);
430 gtk_grid_attach (GTK_GRID (g), child: c, column: 0, row: 4, width: 4, height: 1);
431
432 c = test_widget (label: "1", color: "green");
433 gtk_widget_set_vexpand (widget: c, TRUE);
434 gtk_grid_attach (GTK_GRID (g), child: c, column: 4, row: 0, width: 1, height: 4);
435
436 c = test_widget (label: "2", color: "red");
437 gtk_widget_set_hexpand (widget: c, TRUE);
438 gtk_widget_set_vexpand (widget: c, TRUE);
439 gtk_grid_attach (GTK_GRID (g), child: c, column: 3, row: 3, width: 1, height: 1);
440
441 c = test_widget (label: "3", color: "yellow");
442 gtk_grid_attach (GTK_GRID (g), child: c, column: 0, row: 3, width: 2, height: 1);
443
444 c = test_widget (label: "4", color: "orange");
445 gtk_grid_attach (GTK_GRID (g), child: c, column: 3, row: 0, width: 1, height: 2);
446
447 c = test_widget (label: "5", color: "purple");
448 gtk_grid_attach (GTK_GRID (g), child: c, column: 1, row: 1, width: 1, height: 1);
449
450 c = test_widget (label: "6", color: "white");
451 gtk_grid_attach (GTK_GRID (g), child: c, column: 0, row: 1, width: 1, height: 1);
452
453 c = test_widget (label: "7", color: "cyan");
454 gtk_grid_attach (GTK_GRID (g), child: c, column: 1, row: 0, width: 1, height: 1);
455
456 gtk_widget_show (widget: window);
457}
458
459int
460main (int argc, char *argv[])
461{
462 gtk_init ();
463
464 if (g_getenv (variable: "RTL"))
465 gtk_widget_set_default_direction (dir: GTK_TEXT_DIR_RTL);
466
467 simple_grid ();
468 text_grid ();
469 box_comparison ();
470 empty_line ();
471 scrolling ();
472 insert ();
473 empty_grid ();
474 spanning_grid ();
475
476 while (TRUE)
477 g_main_context_iteration (NULL, TRUE);
478
479 return 0;
480}
481

source code of gtk/tests/testgrid.c