1#include <gtk/gtk.h>
2
3/*******************************************************
4 * Simple Test *
5 *******************************************************/
6enum {
7 SIMPLE_COLUMN_NAME,
8 SIMPLE_COLUMN_ICON,
9 SIMPLE_COLUMN_DESCRIPTION,
10 N_SIMPLE_COLUMNS
11};
12
13static GtkCellRenderer *cell_1 = NULL, *cell_2 = NULL, *cell_3 = NULL;
14
15static GtkTreeModel *
16simple_list_model (void)
17{
18 GtkTreeIter iter;
19 GtkListStore *store =
20 gtk_list_store_new (n_columns: N_SIMPLE_COLUMNS,
21 G_TYPE_STRING, /* name text */
22 G_TYPE_STRING, /* icon name */
23 G_TYPE_STRING); /* description text */
24
25 gtk_list_store_append (list_store: store, iter: &iter);
26 gtk_list_store_set (list_store: store, iter: &iter,
27 SIMPLE_COLUMN_NAME, "Alice in wonderland",
28 SIMPLE_COLUMN_ICON, "system-run",
29 SIMPLE_COLUMN_DESCRIPTION,
30 "Twas brillig, and the slithy toves "
31 "did gyre and gimble in the wabe; "
32 "all mimsy were the borogoves, "
33 "and the mome raths outgrabe",
34 -1);
35
36 gtk_list_store_append (list_store: store, iter: &iter);
37 gtk_list_store_set (list_store: store, iter: &iter,
38 SIMPLE_COLUMN_NAME, "Marry Poppins",
39 SIMPLE_COLUMN_ICON, "dialog-information",
40 SIMPLE_COLUMN_DESCRIPTION, "Supercalifragilisticexpialidocious",
41 -1);
42
43 gtk_list_store_append (list_store: store, iter: &iter);
44 gtk_list_store_set (list_store: store, iter: &iter,
45 SIMPLE_COLUMN_NAME, "George Bush",
46 SIMPLE_COLUMN_ICON, "dialog-warning",
47 SIMPLE_COLUMN_DESCRIPTION, "It's a very good question, very direct, "
48 "and I'm not going to answer it",
49 -1);
50
51 gtk_list_store_append (list_store: store, iter: &iter);
52 gtk_list_store_set (list_store: store, iter: &iter,
53 SIMPLE_COLUMN_NAME, "Whinnie the pooh",
54 SIMPLE_COLUMN_ICON, "process-stop",
55 SIMPLE_COLUMN_DESCRIPTION, "The most wonderful thing about tiggers, "
56 "is tiggers are wonderful things",
57 -1);
58
59 gtk_list_store_append (list_store: store, iter: &iter);
60 gtk_list_store_set (list_store: store, iter: &iter,
61 SIMPLE_COLUMN_NAME, "Aleister Crowley",
62 SIMPLE_COLUMN_ICON, "help-about",
63 SIMPLE_COLUMN_DESCRIPTION,
64 "Thou shalt do what thou wilt shall be the whole of the law",
65 -1);
66
67 gtk_list_store_append (list_store: store, iter: &iter);
68 gtk_list_store_set (list_store: store, iter: &iter,
69 SIMPLE_COLUMN_NAME, "Mark Twain",
70 SIMPLE_COLUMN_ICON, "application-exit",
71 SIMPLE_COLUMN_DESCRIPTION,
72 "Giving up smoking is the easiest thing in the world. "
73 "I know because I've done it thousands of times.",
74 -1);
75
76
77 return (GtkTreeModel *)store;
78}
79
80static GtkWidget *
81simple_iconview (void)
82{
83 GtkTreeModel *model;
84 GtkWidget *iconview;
85 GtkCellArea *area;
86 GtkCellRenderer *renderer;
87
88 iconview = gtk_icon_view_new ();
89
90 model = simple_list_model ();
91
92 gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model);
93 gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), orientation: GTK_ORIENTATION_HORIZONTAL);
94
95 area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
96
97 cell_1 = renderer = gtk_cell_renderer_text_new ();
98 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, FALSE, FALSE);
99 gtk_cell_area_attribute_connect (area, renderer, attribute: "text", column: SIMPLE_COLUMN_NAME);
100
101 cell_2 = renderer = gtk_cell_renderer_pixbuf_new ();
102 g_object_set (G_OBJECT (renderer), first_property_name: "xalign", 0.0F, NULL);
103 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE);
104 gtk_cell_area_attribute_connect (area, renderer, attribute: "icon-name", column: SIMPLE_COLUMN_ICON);
105
106 cell_3 = renderer = gtk_cell_renderer_text_new ();
107 g_object_set (G_OBJECT (renderer),
108 first_property_name: "wrap-mode", PANGO_WRAP_WORD,
109 "wrap-width", 215,
110 NULL);
111 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
112 gtk_cell_area_attribute_connect (area, renderer, attribute: "text", column: SIMPLE_COLUMN_DESCRIPTION);
113
114 return iconview;
115}
116
117static void
118orientation_changed (GtkComboBox *combo,
119 GtkIconView *iconview)
120{
121 GtkOrientation orientation = gtk_combo_box_get_active (combo_box: combo);
122
123 gtk_icon_view_set_item_orientation (icon_view: iconview, orientation);
124}
125
126static void
127align_cell_2_toggled (GtkCheckButton *toggle,
128 GtkIconView *iconview)
129{
130 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
131 gboolean align = gtk_check_button_get_active (self: toggle);
132
133 gtk_cell_area_cell_set (area, renderer: cell_2, first_prop_name: "align", align, NULL);
134}
135
136static void
137align_cell_3_toggled (GtkCheckButton *toggle,
138 GtkIconView *iconview)
139{
140 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
141 gboolean align = gtk_check_button_get_active (self: toggle);
142
143 gtk_cell_area_cell_set (area, renderer: cell_3, first_prop_name: "align", align, NULL);
144}
145
146static void
147expand_cell_1_toggled (GtkCheckButton *toggle,
148 GtkIconView *iconview)
149{
150 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
151 gboolean expand = gtk_check_button_get_active (self: toggle);
152
153 gtk_cell_area_cell_set (area, renderer: cell_1, first_prop_name: "expand", expand, NULL);
154}
155
156static void
157expand_cell_2_toggled (GtkCheckButton *toggle,
158 GtkIconView *iconview)
159{
160 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
161 gboolean expand = gtk_check_button_get_active (self: toggle);
162
163 gtk_cell_area_cell_set (area, renderer: cell_2, first_prop_name: "expand", expand, NULL);
164}
165
166static void
167expand_cell_3_toggled (GtkCheckButton *toggle,
168 GtkIconView *iconview)
169{
170 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
171 gboolean expand = gtk_check_button_get_active (self: toggle);
172
173 gtk_cell_area_cell_set (area, renderer: cell_3, first_prop_name: "expand", expand, NULL);
174}
175
176static void
177simple_cell_area (void)
178{
179 GtkWidget *window, *widget;
180 GtkWidget *iconview, *frame, *vbox, *hbox;
181
182 window = gtk_window_new ();
183
184 gtk_window_set_title (GTK_WINDOW (window), title: "CellArea expand and alignments");
185
186 iconview = simple_iconview ();
187
188 hbox = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 4);
189 frame = gtk_frame_new (NULL);
190 gtk_widget_set_hexpand (widget: frame, TRUE);
191
192 gtk_widget_set_valign (widget: frame, align: GTK_ALIGN_CENTER);
193 gtk_widget_set_halign (widget: frame, align: GTK_ALIGN_FILL);
194
195 gtk_frame_set_child (GTK_FRAME (frame), child: iconview);
196
197 /* Now add some controls */
198 vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 4);
199 gtk_box_append (GTK_BOX (hbox), child: vbox);
200
201 gtk_box_append (GTK_BOX (hbox), child: frame);
202
203 widget = gtk_combo_box_text_new ();
204 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text: "Horizontal");
205 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text: "Vertical");
206 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), index_: 0);
207 gtk_box_append (GTK_BOX (vbox), child: widget);
208
209 g_signal_connect (G_OBJECT (widget), "changed",
210 G_CALLBACK (orientation_changed), iconview);
211
212 widget = gtk_check_button_new_with_label (label: "Align 2nd Cell");
213 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
214 gtk_box_append (GTK_BOX (vbox), child: widget);
215
216 g_signal_connect (G_OBJECT (widget), "toggled",
217 G_CALLBACK (align_cell_2_toggled), iconview);
218
219 widget = gtk_check_button_new_with_label (label: "Align 3rd Cell");
220 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
221 gtk_box_append (GTK_BOX (vbox), child: widget);
222
223 g_signal_connect (G_OBJECT (widget), "toggled",
224 G_CALLBACK (align_cell_3_toggled), iconview);
225
226
227 widget = gtk_check_button_new_with_label (label: "Expand 1st Cell");
228 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
229 gtk_box_append (GTK_BOX (vbox), child: widget);
230
231 g_signal_connect (G_OBJECT (widget), "toggled",
232 G_CALLBACK (expand_cell_1_toggled), iconview);
233
234 widget = gtk_check_button_new_with_label (label: "Expand 2nd Cell");
235 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
236 gtk_box_append (GTK_BOX (vbox), child: widget);
237
238 g_signal_connect (G_OBJECT (widget), "toggled",
239 G_CALLBACK (expand_cell_2_toggled), iconview);
240
241 widget = gtk_check_button_new_with_label (label: "Expand 3rd Cell");
242 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
243 gtk_box_append (GTK_BOX (vbox), child: widget);
244
245 g_signal_connect (G_OBJECT (widget), "toggled",
246 G_CALLBACK (expand_cell_3_toggled), iconview);
247
248 gtk_window_set_child (GTK_WINDOW (window), child: hbox);
249
250 gtk_widget_show (widget: window);
251}
252
253/*******************************************************
254 * Focus Test *
255 *******************************************************/
256static GtkCellRenderer *focus_renderer, *sibling_renderer;
257
258enum {
259 FOCUS_COLUMN_NAME,
260 FOCUS_COLUMN_CHECK,
261 FOCUS_COLUMN_STATIC_TEXT,
262 N_FOCUS_COLUMNS
263};
264
265static GtkTreeModel *
266focus_list_model (void)
267{
268 GtkTreeIter iter;
269 GtkListStore *store =
270 gtk_list_store_new (n_columns: N_FOCUS_COLUMNS,
271 G_TYPE_STRING, /* name text */
272 G_TYPE_BOOLEAN, /* check */
273 G_TYPE_STRING); /* static text */
274
275 gtk_list_store_append (list_store: store, iter: &iter);
276 gtk_list_store_set (list_store: store, iter: &iter,
277 FOCUS_COLUMN_NAME, "Enter a string",
278 FOCUS_COLUMN_CHECK, TRUE,
279 FOCUS_COLUMN_STATIC_TEXT, "Does it fly ?",
280 -1);
281
282 gtk_list_store_append (list_store: store, iter: &iter);
283 gtk_list_store_set (list_store: store, iter: &iter,
284 FOCUS_COLUMN_NAME, "Enter a string",
285 FOCUS_COLUMN_CHECK, FALSE,
286 FOCUS_COLUMN_STATIC_TEXT, "Would you put it in a toaster ?",
287 -1);
288
289 gtk_list_store_append (list_store: store, iter: &iter);
290 gtk_list_store_set (list_store: store, iter: &iter,
291 FOCUS_COLUMN_NAME, "Type something",
292 FOCUS_COLUMN_CHECK, FALSE,
293 FOCUS_COLUMN_STATIC_TEXT, "Does it feed on cute kittens ?",
294 -1);
295
296 return (GtkTreeModel *)store;
297}
298
299static void
300cell_toggled (GtkCellRendererToggle *cell_renderer,
301 const char *path,
302 GtkIconView *iconview)
303{
304 GtkTreeModel *model = gtk_icon_view_get_model (icon_view: iconview);
305 GtkTreeIter iter;
306 gboolean active;
307
308 g_print (format: "Cell toggled !\n");
309
310 if (!gtk_tree_model_get_iter_from_string (tree_model: model, iter: &iter, path_string: path))
311 return;
312
313 gtk_tree_model_get (tree_model: model, iter: &iter, FOCUS_COLUMN_CHECK, &active, -1);
314 gtk_list_store_set (GTK_LIST_STORE (model), iter: &iter, FOCUS_COLUMN_CHECK, !active, -1);
315}
316
317static void
318cell_edited (GtkCellRendererToggle *cell_renderer,
319 const char *path,
320 const char *new_text,
321 GtkIconView *iconview)
322{
323 GtkTreeModel *model = gtk_icon_view_get_model (icon_view: iconview);
324 GtkTreeIter iter;
325
326 g_print (format: "Cell edited with new text '%s' !\n", new_text);
327
328 if (!gtk_tree_model_get_iter_from_string (tree_model: model, iter: &iter, path_string: path))
329 return;
330
331 gtk_list_store_set (GTK_LIST_STORE (model), iter: &iter, FOCUS_COLUMN_NAME, new_text, -1);
332}
333
334static GtkWidget *
335focus_iconview (gboolean color_bg, GtkCellRenderer **focus, GtkCellRenderer **sibling)
336{
337 GtkTreeModel *model;
338 GtkWidget *iconview;
339 GtkCellArea *area;
340 GtkCellRenderer *renderer, *toggle;
341
342 iconview = gtk_icon_view_new ();
343
344 model = focus_list_model ();
345
346 gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model);
347 gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), orientation: GTK_ORIENTATION_HORIZONTAL);
348
349 area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
350
351 renderer = gtk_cell_renderer_text_new ();
352 g_object_set (G_OBJECT (renderer), first_property_name: "editable", TRUE, NULL);
353 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE);
354 gtk_cell_area_attribute_connect (area, renderer, attribute: "text", column: FOCUS_COLUMN_NAME);
355
356 if (color_bg)
357 g_object_set (G_OBJECT (renderer), first_property_name: "cell-background", "red", NULL);
358
359 g_signal_connect (G_OBJECT (renderer), "edited",
360 G_CALLBACK (cell_edited), iconview);
361
362 toggle = renderer = gtk_cell_renderer_toggle_new ();
363 g_object_set (G_OBJECT (renderer), first_property_name: "xalign", 0.0F, NULL);
364 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
365 gtk_cell_area_attribute_connect (area, renderer, attribute: "active", column: FOCUS_COLUMN_CHECK);
366
367 if (color_bg)
368 g_object_set (G_OBJECT (renderer), first_property_name: "cell-background", "green", NULL);
369
370 if (focus)
371 *focus = renderer;
372
373 g_signal_connect (G_OBJECT (renderer), "toggled",
374 G_CALLBACK (cell_toggled), iconview);
375
376 renderer = gtk_cell_renderer_text_new ();
377 g_object_set (G_OBJECT (renderer),
378 first_property_name: "wrap-mode", PANGO_WRAP_WORD,
379 "wrap-width", 150,
380 NULL);
381
382 if (color_bg)
383 g_object_set (G_OBJECT (renderer), first_property_name: "cell-background", "blue", NULL);
384
385 if (sibling)
386 *sibling = renderer;
387
388 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
389 gtk_cell_area_attribute_connect (area, renderer, attribute: "text", column: FOCUS_COLUMN_STATIC_TEXT);
390
391 gtk_cell_area_add_focus_sibling (area, renderer: toggle, sibling: renderer);
392
393 return iconview;
394}
395
396static void
397focus_sibling_toggled (GtkCheckButton *toggle,
398 GtkIconView *iconview)
399{
400 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
401 gboolean active = gtk_check_button_get_active (self: toggle);
402
403 if (active)
404 gtk_cell_area_add_focus_sibling (area, renderer: focus_renderer, sibling: sibling_renderer);
405 else
406 gtk_cell_area_remove_focus_sibling (area, renderer: focus_renderer, sibling: sibling_renderer);
407
408 gtk_widget_queue_draw (GTK_WIDGET (iconview));
409}
410
411
412static void
413focus_cell_area (void)
414{
415 GtkWidget *window, *widget;
416 GtkWidget *iconview, *frame, *vbox, *hbox;
417
418 window = gtk_window_new ();
419 hbox = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 4);
420
421 gtk_window_set_title (GTK_WINDOW (window), title: "Focus and editable cells");
422
423 iconview = focus_iconview (FALSE, focus: &focus_renderer, sibling: &sibling_renderer);
424
425 frame = gtk_frame_new (NULL);
426 gtk_widget_set_hexpand (widget: frame, TRUE);
427
428 gtk_widget_set_valign (widget: frame, align: GTK_ALIGN_CENTER);
429 gtk_widget_set_halign (widget: frame, align: GTK_ALIGN_FILL);
430
431 gtk_frame_set_child (GTK_FRAME (frame), child: iconview);
432
433 /* Now add some controls */
434 vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 4);
435 gtk_box_append (GTK_BOX (hbox), child: vbox);
436 gtk_box_append (GTK_BOX (hbox), child: frame);
437
438 widget = gtk_combo_box_text_new ();
439 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text: "Horizontal");
440 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text: "Vertical");
441 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), index_: 0);
442 gtk_box_append (GTK_BOX (vbox), child: widget);
443
444 g_signal_connect (G_OBJECT (widget), "changed",
445 G_CALLBACK (orientation_changed), iconview);
446
447 widget = gtk_check_button_new_with_label (label: "Focus Sibling");
448 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
449 gtk_box_append (GTK_BOX (vbox), child: widget);
450
451 g_signal_connect (G_OBJECT (widget), "toggled",
452 G_CALLBACK (focus_sibling_toggled), iconview);
453
454 gtk_window_set_child (GTK_WINDOW (window), child: hbox);
455
456 gtk_widget_show (widget: window);
457}
458
459
460
461/*******************************************************
462 * Background Area *
463 *******************************************************/
464static void
465cell_spacing_changed (GtkSpinButton *spin_button,
466 GtkIconView *iconview)
467{
468 GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
469 int value;
470
471 value = (int)gtk_spin_button_get_value (spin_button);
472
473 gtk_cell_area_box_set_spacing (GTK_CELL_AREA_BOX (area), spacing: value);
474}
475
476static void
477row_spacing_changed (GtkSpinButton *spin_button,
478 GtkIconView *iconview)
479{
480 int value;
481
482 value = (int)gtk_spin_button_get_value (spin_button);
483
484 gtk_icon_view_set_row_spacing (icon_view: iconview, row_spacing: value);
485}
486
487static void
488item_padding_changed (GtkSpinButton *spin_button,
489 GtkIconView *iconview)
490{
491 int value;
492
493 value = (int)gtk_spin_button_get_value (spin_button);
494
495 gtk_icon_view_set_item_padding (icon_view: iconview, item_padding: value);
496}
497
498static void
499background_area (void)
500{
501 GtkWidget *window, *widget, *label, *main_vbox;
502 GtkWidget *iconview, *frame, *vbox, *hbox;
503
504 window = gtk_window_new ();
505 hbox = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 4);
506 main_vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 4);
507 gtk_window_set_child (GTK_WINDOW (window), child: main_vbox);
508
509 gtk_window_set_title (GTK_WINDOW (window), title: "Background Area");
510
511 label = gtk_label_new (str: "In this example, row spacing gets divided into the background area, "
512 "column spacing is added between each background area, item_padding is "
513 "prepended space distributed to the background area.");
514 gtk_label_set_wrap (GTK_LABEL (label), TRUE);
515 gtk_label_set_width_chars (GTK_LABEL (label), n_chars: 40);
516 gtk_box_append (GTK_BOX (main_vbox), child: label);
517
518 iconview = focus_iconview (TRUE, NULL, NULL);
519
520 frame = gtk_frame_new (NULL);
521 gtk_widget_set_hexpand (widget: frame, TRUE);
522
523 gtk_widget_set_valign (widget: frame, align: GTK_ALIGN_CENTER);
524 gtk_widget_set_halign (widget: frame, align: GTK_ALIGN_FILL);
525
526 gtk_frame_set_child (GTK_FRAME (frame), child: iconview);
527
528 /* Now add some controls */
529 vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 4);
530 gtk_box_append (GTK_BOX (hbox), child: vbox);
531 gtk_box_append (GTK_BOX (hbox), child: frame);
532
533 gtk_box_append (GTK_BOX (main_vbox), child: hbox);
534
535 widget = gtk_combo_box_text_new ();
536 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text: "Horizontal");
537 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text: "Vertical");
538 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), index_: 0);
539 gtk_box_append (GTK_BOX (vbox), child: widget);
540
541 g_signal_connect (G_OBJECT (widget), "changed",
542 G_CALLBACK (orientation_changed), iconview);
543
544 widget = gtk_spin_button_new_with_range (min: 0, max: 10, step: 1);
545 label = gtk_label_new (str: "Cell spacing");
546 gtk_widget_set_hexpand (widget: label, TRUE);
547 hbox = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 4);
548 gtk_box_append (GTK_BOX (hbox), child: label);
549 gtk_box_append (GTK_BOX (hbox), child: widget);
550 gtk_box_append (GTK_BOX (vbox), child: hbox);
551
552 g_signal_connect (G_OBJECT (widget), "value-changed",
553 G_CALLBACK (cell_spacing_changed), iconview);
554
555
556 widget = gtk_spin_button_new_with_range (min: 0, max: 10, step: 1);
557 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value: gtk_icon_view_get_row_spacing (GTK_ICON_VIEW (iconview)));
558 label = gtk_label_new (str: "Row spacing");
559 gtk_widget_set_hexpand (widget: label, TRUE);
560 hbox = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 4);
561 gtk_box_append (GTK_BOX (hbox), child: label);
562 gtk_box_append (GTK_BOX (hbox), child: widget);
563 gtk_box_append (GTK_BOX (vbox), child: hbox);
564
565 g_signal_connect (G_OBJECT (widget), "value-changed",
566 G_CALLBACK (row_spacing_changed), iconview);
567
568 widget = gtk_spin_button_new_with_range (min: 0, max: 30, step: 1);
569 label = gtk_label_new (str: "Item padding");
570 gtk_widget_set_hexpand (widget: label, TRUE);
571 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value: gtk_icon_view_get_item_padding (GTK_ICON_VIEW (iconview)));
572 hbox = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 4);
573 gtk_box_append (GTK_BOX (hbox), child: label);
574 gtk_box_append (GTK_BOX (hbox), child: widget);
575 gtk_box_append (GTK_BOX (vbox), child: hbox);
576
577 g_signal_connect (G_OBJECT (widget), "value-changed",
578 G_CALLBACK (item_padding_changed), iconview);
579
580 gtk_widget_show (widget: window);
581}
582
583
584
585
586
587
588int
589main (int argc, char *argv[])
590{
591 gtk_init ();
592
593 if (g_getenv (variable: "RTL"))
594 gtk_widget_set_default_direction (dir: GTK_TEXT_DIR_RTL);
595
596 simple_cell_area ();
597 focus_cell_area ();
598 background_area ();
599
600 while (TRUE)
601 g_main_context_iteration (NULL, TRUE);
602
603 return 0;
604}
605

source code of gtk/tests/testcellarea.c