]> Pileus Git - ~andy/gtk/blob - tests/testcellarea.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testcellarea.c
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 *
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, "gtk-execute",
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, "gtk-yes",
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, "gtk-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, "gtk-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, "gtk-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, "gtk-quit",
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 *
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   gtk_widget_show (iconview);
90
91   model = simple_list_model ();
92
93   gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model);
94   gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), GTK_ORIENTATION_HORIZONTAL);
95
96   area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
97
98   cell_1 = renderer = gtk_cell_renderer_text_new ();
99   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, FALSE, FALSE);
100   gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_NAME);
101
102   cell_2 = renderer = gtk_cell_renderer_pixbuf_new ();
103   g_object_set (G_OBJECT (renderer), "xalign", 0.0F, NULL);
104   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE);
105   gtk_cell_area_attribute_connect (area, renderer, "stock-id", SIMPLE_COLUMN_ICON);
106
107   cell_3 = renderer = gtk_cell_renderer_text_new ();
108   g_object_set (G_OBJECT (renderer), 
109                 "wrap-mode", PANGO_WRAP_WORD,
110                 "wrap-width", 215,
111                 NULL);
112   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
113   gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_DESCRIPTION);
114
115   return iconview;
116 }
117
118 static void
119 orientation_changed (GtkComboBox      *combo,
120                      GtkIconView *iconview)
121 {
122   GtkOrientation orientation = gtk_combo_box_get_active (combo);
123
124   gtk_icon_view_set_item_orientation (iconview, orientation);
125 }
126
127 static void
128 align_cell_2_toggled (GtkToggleButton  *toggle,
129                       GtkIconView *iconview)
130 {
131   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
132   gboolean     align = gtk_toggle_button_get_active (toggle);
133
134   gtk_cell_area_cell_set (area, cell_2, "align", align, NULL);
135 }
136
137 static void
138 align_cell_3_toggled (GtkToggleButton  *toggle,
139                       GtkIconView *iconview)
140 {
141   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
142   gboolean     align = gtk_toggle_button_get_active (toggle);
143
144   gtk_cell_area_cell_set (area, cell_3, "align", align, NULL);
145 }
146
147 static void
148 expand_cell_1_toggled (GtkToggleButton  *toggle,
149                        GtkIconView *iconview)
150 {
151   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
152   gboolean     expand = gtk_toggle_button_get_active (toggle);
153
154   gtk_cell_area_cell_set (area, cell_1, "expand", expand, NULL);
155 }
156
157 static void
158 expand_cell_2_toggled (GtkToggleButton  *toggle,
159                        GtkIconView *iconview)
160 {
161   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
162   gboolean     expand = gtk_toggle_button_get_active (toggle);
163
164   gtk_cell_area_cell_set (area, cell_2, "expand", expand, NULL);
165 }
166
167 static void
168 expand_cell_3_toggled (GtkToggleButton  *toggle,
169                        GtkIconView *iconview)
170 {
171   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
172   gboolean     expand = gtk_toggle_button_get_active (toggle);
173
174   gtk_cell_area_cell_set (area, cell_3, "expand", expand, NULL);
175 }
176
177 static void
178 simple_cell_area (void)
179 {
180   GtkWidget *window, *widget;
181   GtkWidget *iconview, *frame, *vbox, *hbox;
182
183   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
184
185   gtk_window_set_title (GTK_WINDOW (window), "CellArea expand and alignments");
186
187   iconview = simple_iconview ();
188
189   hbox  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
190   frame = gtk_frame_new (NULL);
191   gtk_widget_show (hbox);
192   gtk_widget_show (frame);
193
194   gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
195   gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
196
197   gtk_container_add (GTK_CONTAINER (frame), iconview);
198
199   gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
200
201   /* Now add some controls */
202   vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
203   gtk_widget_show (vbox);
204   gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
205
206   widget = gtk_combo_box_text_new ();
207   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
208   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
209   gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
210   gtk_widget_show (widget);
211   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
212
213   g_signal_connect (G_OBJECT (widget), "changed",
214                     G_CALLBACK (orientation_changed), iconview);
215
216   widget = gtk_check_button_new_with_label ("Align 2nd Cell");
217   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
218   gtk_widget_show (widget);
219   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
220   
221   g_signal_connect (G_OBJECT (widget), "toggled",
222                     G_CALLBACK (align_cell_2_toggled), iconview);
223
224   widget = gtk_check_button_new_with_label ("Align 3rd Cell");
225   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
226   gtk_widget_show (widget);
227   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
228   
229   g_signal_connect (G_OBJECT (widget), "toggled",
230                     G_CALLBACK (align_cell_3_toggled), iconview);
231
232
233   widget = gtk_check_button_new_with_label ("Expand 1st Cell");
234   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
235   gtk_widget_show (widget);
236   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
237   
238   g_signal_connect (G_OBJECT (widget), "toggled",
239                     G_CALLBACK (expand_cell_1_toggled), iconview);
240
241   widget = gtk_check_button_new_with_label ("Expand 2nd Cell");
242   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
243   gtk_widget_show (widget);
244   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
245   
246   g_signal_connect (G_OBJECT (widget), "toggled",
247                     G_CALLBACK (expand_cell_2_toggled), iconview);
248
249   widget = gtk_check_button_new_with_label ("Expand 3rd Cell");
250   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
251   gtk_widget_show (widget);
252   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
253   
254   g_signal_connect (G_OBJECT (widget), "toggled",
255                     G_CALLBACK (expand_cell_3_toggled), iconview);
256
257   gtk_container_add (GTK_CONTAINER (window), hbox);
258
259   gtk_widget_show (window);
260 }
261
262 /*******************************************************
263  *                      Focus Test                     *
264  *******************************************************/
265 static GtkCellRenderer *focus_renderer, *sibling_renderer;
266
267 enum {
268   FOCUS_COLUMN_NAME,
269   FOCUS_COLUMN_CHECK,
270   FOCUS_COLUMN_STATIC_TEXT,
271   N_FOCUS_COLUMNS
272 };
273
274 static GtkTreeModel *
275 focus_list_model (void)
276 {
277   GtkTreeIter   iter;
278   GtkListStore *store = 
279     gtk_list_store_new (N_FOCUS_COLUMNS,
280                         G_TYPE_STRING,  /* name text */
281                         G_TYPE_BOOLEAN, /* check */
282                         G_TYPE_STRING); /* static text */
283
284   gtk_list_store_append (store, &iter);
285   gtk_list_store_set (store, &iter, 
286                       FOCUS_COLUMN_NAME, "Enter a string",
287                       FOCUS_COLUMN_CHECK, TRUE,
288                       FOCUS_COLUMN_STATIC_TEXT, "Does it fly ?",
289                       -1);
290
291   gtk_list_store_append (store, &iter);
292   gtk_list_store_set (store, &iter, 
293                       FOCUS_COLUMN_NAME, "Enter a string",
294                       FOCUS_COLUMN_CHECK, FALSE,
295                       FOCUS_COLUMN_STATIC_TEXT, "Would you put it in a toaster ?",
296                       -1);
297
298   gtk_list_store_append (store, &iter);
299   gtk_list_store_set (store, &iter, 
300                       FOCUS_COLUMN_NAME, "Type something",
301                       FOCUS_COLUMN_CHECK, FALSE,
302                       FOCUS_COLUMN_STATIC_TEXT, "Does it feed on cute kittens ?",
303                       -1);
304
305   return (GtkTreeModel *)store;
306 }
307
308 static void
309 cell_toggled (GtkCellRendererToggle *cell_renderer,
310               const gchar           *path,
311               GtkIconView      *iconview)
312 {
313   GtkTreeModel *model = gtk_icon_view_get_model (iconview);
314   GtkTreeIter   iter;
315   gboolean      active;
316
317   g_print ("Cell toggled !\n");
318
319   if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
320     return;
321
322   gtk_tree_model_get (model, &iter, FOCUS_COLUMN_CHECK, &active, -1);
323   gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_CHECK, !active, -1);
324 }
325
326 static void
327 cell_edited (GtkCellRendererToggle *cell_renderer,
328              const gchar           *path,
329              const gchar           *new_text,
330              GtkIconView      *iconview)
331 {
332   GtkTreeModel *model = gtk_icon_view_get_model (iconview);
333   GtkTreeIter   iter;
334
335   g_print ("Cell edited with new text '%s' !\n", new_text);
336
337   if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
338     return;
339
340   gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_NAME, new_text, -1);
341 }
342
343 static GtkWidget *
344 focus_iconview (gboolean color_bg, GtkCellRenderer **focus, GtkCellRenderer **sibling)
345 {
346   GtkTreeModel *model;
347   GtkWidget *iconview;
348   GtkCellArea *area;
349   GtkCellRenderer *renderer, *toggle;
350
351   iconview = gtk_icon_view_new ();
352   gtk_widget_show (iconview);
353
354   model = focus_list_model ();
355
356   gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model);
357   gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (iconview), GTK_ORIENTATION_HORIZONTAL);
358
359   area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
360
361   renderer = gtk_cell_renderer_text_new ();
362   g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
363   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, TRUE, FALSE, FALSE);
364   gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_NAME);
365
366   if (color_bg)
367     g_object_set (G_OBJECT (renderer), "cell-background", "red", NULL);
368
369   g_signal_connect (G_OBJECT (renderer), "edited",
370                     G_CALLBACK (cell_edited), iconview);
371
372   toggle = renderer = gtk_cell_renderer_toggle_new ();
373   g_object_set (G_OBJECT (renderer), "xalign", 0.0F, NULL);
374   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
375   gtk_cell_area_attribute_connect (area, renderer, "active", FOCUS_COLUMN_CHECK);
376
377   if (color_bg)
378     g_object_set (G_OBJECT (renderer), "cell-background", "green", NULL);
379
380   if (focus)
381     *focus = renderer;
382
383   g_signal_connect (G_OBJECT (renderer), "toggled",
384                     G_CALLBACK (cell_toggled), iconview);
385
386   renderer = gtk_cell_renderer_text_new ();
387   g_object_set (G_OBJECT (renderer), 
388                 "wrap-mode", PANGO_WRAP_WORD,
389                 "wrap-width", 150,
390                 NULL);
391
392   if (color_bg)
393     g_object_set (G_OBJECT (renderer), "cell-background", "blue", NULL);
394
395   if (sibling)
396     *sibling = renderer;
397
398   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
399   gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_STATIC_TEXT);
400
401   gtk_cell_area_add_focus_sibling (area, toggle, renderer);
402
403   return iconview;
404 }
405
406 static void
407 focus_sibling_toggled (GtkToggleButton  *toggle,
408                        GtkIconView *iconview)
409 {
410   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
411   gboolean     active = gtk_toggle_button_get_active (toggle);
412
413   if (active)
414     gtk_cell_area_add_focus_sibling (area, focus_renderer, sibling_renderer);
415   else
416     gtk_cell_area_remove_focus_sibling (area, focus_renderer, sibling_renderer);
417
418   gtk_widget_queue_draw (GTK_WIDGET (iconview));
419 }
420
421
422 static void
423 focus_cell_area (void)
424 {
425   GtkWidget *window, *widget;
426   GtkWidget *iconview, *frame, *vbox, *hbox;
427
428   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
429   hbox  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
430   gtk_widget_show (hbox);
431
432   gtk_window_set_title (GTK_WINDOW (window), "Focus and editable cells");
433
434   iconview = focus_iconview (FALSE, &focus_renderer, &sibling_renderer);
435
436   frame = gtk_frame_new (NULL);
437   gtk_widget_show (frame);
438
439   gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
440   gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
441
442   gtk_container_add (GTK_CONTAINER (frame), iconview);
443
444   gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
445
446   /* Now add some controls */
447   vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
448   gtk_widget_show (vbox);
449   gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
450
451   widget = gtk_combo_box_text_new ();
452   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
453   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
454   gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
455   gtk_widget_show (widget);
456   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
457
458   g_signal_connect (G_OBJECT (widget), "changed",
459                     G_CALLBACK (orientation_changed), iconview);
460
461   widget = gtk_check_button_new_with_label ("Focus Sibling");
462   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
463   gtk_widget_show (widget);
464   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
465
466   g_signal_connect (G_OBJECT (widget), "toggled",
467                     G_CALLBACK (focus_sibling_toggled), iconview);
468
469   gtk_container_add (GTK_CONTAINER (window), hbox);
470
471   gtk_widget_show (window);
472 }
473
474
475
476 /*******************************************************
477  *                  Background Area                    *
478  *******************************************************/
479 static void
480 cell_spacing_changed (GtkSpinButton    *spin_button,
481                       GtkIconView *iconview)
482 {
483   GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
484   gint        value;
485
486   value = (gint)gtk_spin_button_get_value (spin_button);
487
488   gtk_cell_area_box_set_spacing (GTK_CELL_AREA_BOX (area), value);
489 }
490
491 static void
492 row_spacing_changed (GtkSpinButton    *spin_button,
493                      GtkIconView *iconview)
494 {
495   gint value;
496
497   value = (gint)gtk_spin_button_get_value (spin_button);
498
499   gtk_icon_view_set_row_spacing (iconview, value);
500 }
501
502 static void
503 item_padding_changed (GtkSpinButton    *spin_button,
504                      GtkIconView *iconview)
505 {
506   gint value;
507
508   value = (gint)gtk_spin_button_get_value (spin_button);
509
510   gtk_icon_view_set_item_padding (iconview, value);
511 }
512
513 static void
514 background_area (void)
515 {
516   GtkWidget *window, *widget, *label, *main_vbox;
517   GtkWidget *iconview, *frame, *vbox, *hbox;
518
519   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
520   hbox  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
521   main_vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
522   gtk_widget_show (hbox);
523   gtk_widget_show (main_vbox);
524   gtk_container_add (GTK_CONTAINER (window), main_vbox);
525
526   gtk_window_set_title (GTK_WINDOW (window), "Background Area");
527
528   label = gtk_label_new ("In this example, row spacing gets devided into the background area, "
529                          "column spacing is added between each background area, item_padding is "
530                          "prepended space distributed to the background area.");
531   gtk_label_set_line_wrap  (GTK_LABEL (label), TRUE);
532   gtk_label_set_width_chars  (GTK_LABEL (label), 40);
533   gtk_widget_show (label);
534   gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
535
536   iconview = focus_iconview (TRUE, NULL, NULL);
537
538   frame = gtk_frame_new (NULL);
539   gtk_widget_show (frame);
540
541   gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
542   gtk_widget_set_halign (frame, GTK_ALIGN_FILL);
543
544   gtk_container_add (GTK_CONTAINER (frame), iconview);
545
546   gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
547
548   /* Now add some controls */
549   vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
550   gtk_widget_show (vbox);
551   gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
552   gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
553
554   widget = gtk_combo_box_text_new ();
555   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
556   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
557   gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
558   gtk_widget_show (widget);
559   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
560
561   g_signal_connect (G_OBJECT (widget), "changed",
562                     G_CALLBACK (orientation_changed), iconview);
563
564   widget = gtk_spin_button_new_with_range (0, 10, 1);
565   label = gtk_label_new ("Cell spacing");
566   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
567   gtk_widget_show (hbox);
568   gtk_widget_show (label);
569   gtk_widget_show (widget);
570   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
571   gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
572   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
573
574   g_signal_connect (G_OBJECT (widget), "value-changed",
575                     G_CALLBACK (cell_spacing_changed), iconview);
576
577
578   widget = gtk_spin_button_new_with_range (0, 10, 1);
579   gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), gtk_icon_view_get_row_spacing (GTK_ICON_VIEW (iconview)));
580   label = gtk_label_new ("Row spacing");
581   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
582   gtk_widget_show (hbox);
583   gtk_widget_show (label);
584   gtk_widget_show (widget);
585   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
586   gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
587   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
588
589   g_signal_connect (G_OBJECT (widget), "value-changed",
590                     G_CALLBACK (row_spacing_changed), iconview);
591
592   widget = gtk_spin_button_new_with_range (0, 30, 1);
593   label = gtk_label_new ("Item padding");
594   gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), gtk_icon_view_get_item_padding (GTK_ICON_VIEW (iconview)));
595   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
596   gtk_widget_show (hbox);
597   gtk_widget_show (label);
598   gtk_widget_show (widget);
599   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
600   gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
601   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
602
603   g_signal_connect (G_OBJECT (widget), "value-changed",
604                     G_CALLBACK (item_padding_changed), iconview);
605
606   gtk_widget_show (window);
607 }
608
609
610
611
612
613
614 int
615 main (int argc, char *argv[])
616 {
617   gtk_init (NULL, NULL);
618
619   if (g_getenv ("RTL"))
620     gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
621
622   simple_cell_area ();
623   focus_cell_area ();
624   background_area ();
625
626   gtk_main ();
627
628   return 0;
629 }