1 #include <gtk/gtk.h>
2
3 /*******************************************************
4 * Simple Test *
5 *******************************************************/
6 enum {
7 SIMPLE_COLUMN_NAME,
8 SIMPLE_COLUMN_ICON,
9 SIMPLE_COLUMN_DESCRIPTION,
10 N_SIMPLE_COLUMNS
11 };
12
13 static GtkCellRenderer *cell_1 = NULL, *cell_2 = NULL, *cell_3 = NULL;
14
15 static GtkTreeModel *
simple_list_model(void)16 simple_list_model (void)
17 {
18 GtkTreeIter iter;
19 GtkListStore *store =
20 gtk_list_store_new (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 (store, &iter);
26 gtk_list_store_set (store, &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 (store, &iter);
37 gtk_list_store_set (store, &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 (store, &iter);
44 gtk_list_store_set (store, &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 (store, &iter);
52 gtk_list_store_set (store, &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 (store, &iter);
60 gtk_list_store_set (store, &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 (store, &iter);
68 gtk_list_store_set (store, &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
80 static GtkWidget *
simple_iconview(void)81 simple_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), 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, "text", SIMPLE_COLUMN_NAME);
100
101 cell_2 = renderer = gtk_cell_renderer_pixbuf_new ();
102 g_object_set (G_OBJECT (renderer), "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, "icon-name", SIMPLE_COLUMN_ICON);
105
106 cell_3 = renderer = gtk_cell_renderer_text_new ();
107 g_object_set (G_OBJECT (renderer),
108 "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, "text", SIMPLE_COLUMN_DESCRIPTION);
113
114 return iconview;
115 }
116
117 static void
orientation_changed(GtkComboBox * combo,GtkIconView * iconview)118 orientation_changed (GtkComboBox *combo,
119 GtkIconView *iconview)
120 {
121 GtkOrientation orientation = gtk_combo_box_get_active (combo);
122
123 gtk_icon_view_set_item_orientation (iconview, orientation);
124 }
125
126 static void
align_cell_2_toggled(GtkCheckButton * toggle,GtkIconView * iconview)127 align_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 (toggle);
132
133 gtk_cell_area_cell_set (area, cell_2, "align", align, NULL);
134 }
135
136 static void
align_cell_3_toggled(GtkCheckButton * toggle,GtkIconView * iconview)137 align_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 (toggle);
142
143 gtk_cell_area_cell_set (area, cell_3, "align", align, NULL);
144 }
145
146 static void
expand_cell_1_toggled(GtkCheckButton * toggle,GtkIconView * iconview)147 expand_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 (toggle);
152
153 gtk_cell_area_cell_set (area, cell_1, "expand", expand, NULL);
154 }
155
156 static void
expand_cell_2_toggled(GtkCheckButton * toggle,GtkIconView * iconview)157 expand_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 (toggle);
162
163 gtk_cell_area_cell_set (area, cell_2, "expand", expand, NULL);
164 }
165
166 static void
expand_cell_3_toggled(GtkCheckButton * toggle,GtkIconView * iconview)167 expand_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 (toggle);
172
173 gtk_cell_area_cell_set (area, cell_3, "expand", expand, NULL);
174 }
175
176 static void
simple_cell_area(void)177 simple_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), "CellArea expand and alignments");
185
186 iconview = simple_iconview ();
187
188 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
189 frame = gtk_frame_new (NULL);
190 gtk_widget_set_hexpand (frame, TRUE);
191
192 gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
193 gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
194
195 gtk_frame_set_child (GTK_FRAME (frame), iconview);
196
197 /* Now add some controls */
198 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
199 gtk_box_append (GTK_BOX (hbox), vbox);
200
201 gtk_box_append (GTK_BOX (hbox), frame);
202
203 widget = gtk_combo_box_text_new ();
204 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
205 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
206 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
207 gtk_box_append (GTK_BOX (vbox), 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 ("Align 2nd Cell");
213 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
214 gtk_box_append (GTK_BOX (vbox), 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 ("Align 3rd Cell");
220 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
221 gtk_box_append (GTK_BOX (vbox), 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 ("Expand 1st Cell");
228 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
229 gtk_box_append (GTK_BOX (vbox), 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 ("Expand 2nd Cell");
235 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
236 gtk_box_append (GTK_BOX (vbox), 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 ("Expand 3rd Cell");
242 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), FALSE);
243 gtk_box_append (GTK_BOX (vbox), 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), hbox);
249
250 gtk_widget_show (window);
251 }
252
253 /*******************************************************
254 * Focus Test *
255 *******************************************************/
256 static GtkCellRenderer *focus_renderer, *sibling_renderer;
257
258 enum {
259 FOCUS_COLUMN_NAME,
260 FOCUS_COLUMN_CHECK,
261 FOCUS_COLUMN_STATIC_TEXT,
262 N_FOCUS_COLUMNS
263 };
264
265 static GtkTreeModel *
focus_list_model(void)266 focus_list_model (void)
267 {
268 GtkTreeIter iter;
269 GtkListStore *store =
270 gtk_list_store_new (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 (store, &iter);
276 gtk_list_store_set (store, &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 (store, &iter);
283 gtk_list_store_set (store, &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 (store, &iter);
290 gtk_list_store_set (store, &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
299 static void
cell_toggled(GtkCellRendererToggle * cell_renderer,const char * path,GtkIconView * iconview)300 cell_toggled (GtkCellRendererToggle *cell_renderer,
301 const char *path,
302 GtkIconView *iconview)
303 {
304 GtkTreeModel *model = gtk_icon_view_get_model (iconview);
305 GtkTreeIter iter;
306 gboolean active;
307
308 g_print ("Cell toggled !\n");
309
310 if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
311 return;
312
313 gtk_tree_model_get (model, &iter, FOCUS_COLUMN_CHECK, &active, -1);
314 gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_CHECK, !active, -1);
315 }
316
317 static void
cell_edited(GtkCellRendererToggle * cell_renderer,const char * path,const char * new_text,GtkIconView * iconview)318 cell_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 (iconview);
324 GtkTreeIter iter;
325
326 g_print ("Cell edited with new text '%s' !\n", new_text);
327
328 if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
329 return;
330
331 gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_NAME, new_text, -1);
332 }
333
334 static GtkWidget *
focus_iconview(gboolean color_bg,GtkCellRenderer ** focus,GtkCellRenderer ** sibling)335 focus_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), 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), "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, "text", FOCUS_COLUMN_NAME);
355
356 if (color_bg)
357 g_object_set (G_OBJECT (renderer), "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), "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, "active", FOCUS_COLUMN_CHECK);
366
367 if (color_bg)
368 g_object_set (G_OBJECT (renderer), "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 "wrap-mode", PANGO_WRAP_WORD,
379 "wrap-width", 150,
380 NULL);
381
382 if (color_bg)
383 g_object_set (G_OBJECT (renderer), "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, "text", FOCUS_COLUMN_STATIC_TEXT);
390
391 gtk_cell_area_add_focus_sibling (area, toggle, renderer);
392
393 return iconview;
394 }
395
396 static void
focus_sibling_toggled(GtkCheckButton * toggle,GtkIconView * iconview)397 focus_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 (toggle);
402
403 if (active)
404 gtk_cell_area_add_focus_sibling (area, focus_renderer, sibling_renderer);
405 else
406 gtk_cell_area_remove_focus_sibling (area, focus_renderer, sibling_renderer);
407
408 gtk_widget_queue_draw (GTK_WIDGET (iconview));
409 }
410
411
412 static void
focus_cell_area(void)413 focus_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 (GTK_ORIENTATION_HORIZONTAL, 4);
420
421 gtk_window_set_title (GTK_WINDOW (window), "Focus and editable cells");
422
423 iconview = focus_iconview (FALSE, &focus_renderer, &sibling_renderer);
424
425 frame = gtk_frame_new (NULL);
426 gtk_widget_set_hexpand (frame, TRUE);
427
428 gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
429 gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
430
431 gtk_frame_set_child (GTK_FRAME (frame), iconview);
432
433 /* Now add some controls */
434 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
435 gtk_box_append (GTK_BOX (hbox), vbox);
436 gtk_box_append (GTK_BOX (hbox), frame);
437
438 widget = gtk_combo_box_text_new ();
439 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
440 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
441 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
442 gtk_box_append (GTK_BOX (vbox), 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 ("Focus Sibling");
448 gtk_check_button_set_active (GTK_CHECK_BUTTON (widget), TRUE);
449 gtk_box_append (GTK_BOX (vbox), 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), hbox);
455
456 gtk_widget_show (window);
457 }
458
459
460
461 /*******************************************************
462 * Background Area *
463 *******************************************************/
464 static void
cell_spacing_changed(GtkSpinButton * spin_button,GtkIconView * iconview)465 cell_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), value);
474 }
475
476 static void
row_spacing_changed(GtkSpinButton * spin_button,GtkIconView * iconview)477 row_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 (iconview, value);
485 }
486
487 static void
item_padding_changed(GtkSpinButton * spin_button,GtkIconView * iconview)488 item_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 (iconview, value);
496 }
497
498 static void
background_area(void)499 background_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 (GTK_ORIENTATION_HORIZONTAL, 4);
506 main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
507 gtk_window_set_child (GTK_WINDOW (window), main_vbox);
508
509 gtk_window_set_title (GTK_WINDOW (window), "Background Area");
510
511 label = gtk_label_new ("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), 40);
516 gtk_box_append (GTK_BOX (main_vbox), label);
517
518 iconview = focus_iconview (TRUE, NULL, NULL);
519
520 frame = gtk_frame_new (NULL);
521 gtk_widget_set_hexpand (frame, TRUE);
522
523 gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
524 gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
525
526 gtk_frame_set_child (GTK_FRAME (frame), iconview);
527
528 /* Now add some controls */
529 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
530 gtk_box_append (GTK_BOX (hbox), vbox);
531 gtk_box_append (GTK_BOX (hbox), frame);
532
533 gtk_box_append (GTK_BOX (main_vbox), hbox);
534
535 widget = gtk_combo_box_text_new ();
536 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
537 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
538 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
539 gtk_box_append (GTK_BOX (vbox), 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 (0, 10, 1);
545 label = gtk_label_new ("Cell spacing");
546 gtk_widget_set_hexpand (label, TRUE);
547 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
548 gtk_box_append (GTK_BOX (hbox), label);
549 gtk_box_append (GTK_BOX (hbox), widget);
550 gtk_box_append (GTK_BOX (vbox), 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 (0, 10, 1);
557 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), gtk_icon_view_get_row_spacing (GTK_ICON_VIEW (iconview)));
558 label = gtk_label_new ("Row spacing");
559 gtk_widget_set_hexpand (label, TRUE);
560 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
561 gtk_box_append (GTK_BOX (hbox), label);
562 gtk_box_append (GTK_BOX (hbox), widget);
563 gtk_box_append (GTK_BOX (vbox), 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 (0, 30, 1);
569 label = gtk_label_new ("Item padding");
570 gtk_widget_set_hexpand (label, TRUE);
571 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), gtk_icon_view_get_item_padding (GTK_ICON_VIEW (iconview)));
572 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
573 gtk_box_append (GTK_BOX (hbox), label);
574 gtk_box_append (GTK_BOX (hbox), widget);
575 gtk_box_append (GTK_BOX (vbox), hbox);
576
577 g_signal_connect (G_OBJECT (widget), "value-changed",
578 G_CALLBACK (item_padding_changed), iconview);
579
580 gtk_widget_show (window);
581 }
582
583
584
585
586
587
588 int
main(int argc,char * argv[])589 main (int argc, char *argv[])
590 {
591 gtk_init ();
592
593 if (g_getenv ("RTL"))
594 gtk_widget_set_default_direction (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