testcellarea.c 19.7 KB
Newer Older
1 2
#include <gtk/gtk.h>

3 4 5
/*******************************************************
 *                      Simple Test                    *
 *******************************************************/
6 7 8 9 10 11 12
enum {
  SIMPLE_COLUMN_NAME,
  SIMPLE_COLUMN_ICON,
  SIMPLE_COLUMN_DESCRIPTION,
  N_SIMPLE_COLUMNS
};

13 14
static GtkCellRenderer *cell_1 = NULL, *cell_2 = NULL, *cell_3 = NULL;

15 16 17 18 19 20 21 22 23 24 25 26 27
static GtkTreeModel *
simple_list_model (void)
{
  GtkTreeIter   iter;
  GtkListStore *store = 
    gtk_list_store_new (N_SIMPLE_COLUMNS,
			G_TYPE_STRING,  /* name text */
			G_TYPE_STRING,  /* icon name */
			G_TYPE_STRING); /* description text */

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      SIMPLE_COLUMN_NAME, "Alice in wonderland",
28
		      SIMPLE_COLUMN_ICON, "system-run",
29
		      SIMPLE_COLUMN_DESCRIPTION, 
30 31 32 33
		      "Twas brillig, and the slithy toves "
		      "did gyre and gimble in the wabe; "
		      "all mimsy were the borogoves, "
		      "and the mome raths outgrabe",
34 35 36 37 38
		      -1);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      SIMPLE_COLUMN_NAME, "Marry Poppins",
39
		      SIMPLE_COLUMN_ICON, "dialog-information",
40 41 42 43 44 45
		      SIMPLE_COLUMN_DESCRIPTION, "Supercalifragilisticexpialidocious",
		      -1);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      SIMPLE_COLUMN_NAME, "George Bush",
46
		      SIMPLE_COLUMN_ICON, "dialog-warning",
47 48
		      SIMPLE_COLUMN_DESCRIPTION, "It's a very good question, very direct, "
		      "and I'm not going to answer it",
49 50 51 52 53
		      -1);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      SIMPLE_COLUMN_NAME, "Whinnie the pooh",
54
		      SIMPLE_COLUMN_ICON, "process-stop",
55 56 57 58
		      SIMPLE_COLUMN_DESCRIPTION, "The most wonderful thing about tiggers, "
		      "is tiggers are wonderful things",
		      -1);

59 60 61
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      SIMPLE_COLUMN_NAME, "Aleister Crowley",
62
		      SIMPLE_COLUMN_ICON, "help-about",
63 64 65 66 67 68 69
		      SIMPLE_COLUMN_DESCRIPTION, 
		      "Thou shalt do what thou wilt shall be the whole of the law",
		      -1);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      SIMPLE_COLUMN_NAME, "Mark Twain",
70
		      SIMPLE_COLUMN_ICON, "application-exit",
71 72 73 74 75 76
		      SIMPLE_COLUMN_DESCRIPTION, 
		      "Giving up smoking is the easiest thing in the world. "
		      "I know because I've done it thousands of times.",
		      -1);


77 78 79
  return (GtkTreeModel *)store;
}

80
static GtkWidget *
81
simple_iconview (void)
82 83
{
  GtkTreeModel *model;
84
  GtkWidget *iconview;
85 86 87
  GtkCellArea *area;
  GtkCellRenderer *renderer;

88 89
  iconview = gtk_icon_view_new ();
  gtk_widget_show (iconview);
90 91 92

  model = simple_list_model ();

93 94
  gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model);
  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 101
  gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_NAME);

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, "icon-name", SIMPLE_COLUMN_ICON);
106

107
  cell_3 = renderer = gtk_cell_renderer_text_new ();
108 109 110 111
  g_object_set (G_OBJECT (renderer), 
		"wrap-mode", PANGO_WRAP_WORD,
		"wrap-width", 215,
		NULL);
112
  gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
113 114
  gtk_cell_area_attribute_connect (area, renderer, "text", SIMPLE_COLUMN_DESCRIPTION);

115
  return iconview;
116 117 118 119
}

static void
orientation_changed (GtkComboBox      *combo,
120
		     GtkIconView *iconview)
121 122 123
{
  GtkOrientation orientation = gtk_combo_box_get_active (combo);

124
  gtk_icon_view_set_item_orientation (iconview, orientation);
125 126
}

127 128
static void
align_cell_2_toggled (GtkToggleButton  *toggle,
129
		      GtkIconView *iconview)
130
{
131
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
132 133 134 135 136 137 138
  gboolean     align = gtk_toggle_button_get_active (toggle);

  gtk_cell_area_cell_set (area, cell_2, "align", align, NULL);
}

static void
align_cell_3_toggled (GtkToggleButton  *toggle,
139
		      GtkIconView *iconview)
140
{
141
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
142 143 144 145 146 147 148
  gboolean     align = gtk_toggle_button_get_active (toggle);

  gtk_cell_area_cell_set (area, cell_3, "align", align, NULL);
}

static void
expand_cell_1_toggled (GtkToggleButton  *toggle,
149
		       GtkIconView *iconview)
150
{
151
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
152 153 154 155 156 157 158
  gboolean     expand = gtk_toggle_button_get_active (toggle);

  gtk_cell_area_cell_set (area, cell_1, "expand", expand, NULL);
}

static void
expand_cell_2_toggled (GtkToggleButton  *toggle,
159
		       GtkIconView *iconview)
160
{
161
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
162 163 164 165 166 167 168
  gboolean     expand = gtk_toggle_button_get_active (toggle);

  gtk_cell_area_cell_set (area, cell_2, "expand", expand, NULL);
}

static void
expand_cell_3_toggled (GtkToggleButton  *toggle,
169
		       GtkIconView *iconview)
170
{
171
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
172 173 174 175 176
  gboolean     expand = gtk_toggle_button_get_active (toggle);

  gtk_cell_area_cell_set (area, cell_3, "expand", expand, NULL);
}

177 178 179 180
static void
simple_cell_area (void)
{
  GtkWidget *window, *widget;
181
  GtkWidget *iconview, *frame, *vbox, *hbox;
182 183 184

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

185 186
  gtk_window_set_title (GTK_WINDOW (window), "CellArea expand and alignments");

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 193
  gtk_widget_show (frame);

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 200 201

  gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

  /* Now add some controls */
202
  vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
203 204 205 206 207 208 209 210 211 212 213
  gtk_widget_show (vbox);
  gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
214
                    G_CALLBACK (orientation_changed), iconview);
215

216 217 218 219 220 221
  widget = gtk_check_button_new_with_label ("Align 2nd Cell");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  
  g_signal_connect (G_OBJECT (widget), "toggled",
222
                    G_CALLBACK (align_cell_2_toggled), iconview);
223 224 225 226 227 228 229

  widget = gtk_check_button_new_with_label ("Align 3rd Cell");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  
  g_signal_connect (G_OBJECT (widget), "toggled",
230
                    G_CALLBACK (align_cell_3_toggled), iconview);
231 232 233 234 235 236 237 238


  widget = gtk_check_button_new_with_label ("Expand 1st Cell");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  
  g_signal_connect (G_OBJECT (widget), "toggled",
239
                    G_CALLBACK (expand_cell_1_toggled), iconview);
240 241 242 243 244 245 246

  widget = gtk_check_button_new_with_label ("Expand 2nd Cell");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  
  g_signal_connect (G_OBJECT (widget), "toggled",
247
                    G_CALLBACK (expand_cell_2_toggled), iconview);
248 249 250 251 252 253 254

  widget = gtk_check_button_new_with_label ("Expand 3rd Cell");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  
  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 260 261

  gtk_widget_show (window);
}

262 263 264
/*******************************************************
 *                      Focus Test                     *
 *******************************************************/
265 266
static GtkCellRenderer *focus_renderer, *sibling_renderer;

267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
enum {
  FOCUS_COLUMN_NAME,
  FOCUS_COLUMN_CHECK,
  FOCUS_COLUMN_STATIC_TEXT,
  N_FOCUS_COLUMNS
};

static GtkTreeModel *
focus_list_model (void)
{
  GtkTreeIter   iter;
  GtkListStore *store = 
    gtk_list_store_new (N_FOCUS_COLUMNS,
			G_TYPE_STRING,  /* name text */
			G_TYPE_BOOLEAN, /* check */
			G_TYPE_STRING); /* static text */

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      FOCUS_COLUMN_NAME, "Enter a string",
		      FOCUS_COLUMN_CHECK, TRUE,
		      FOCUS_COLUMN_STATIC_TEXT, "Does it fly ?",
		      -1);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      FOCUS_COLUMN_NAME, "Enter a string",
		      FOCUS_COLUMN_CHECK, FALSE,
		      FOCUS_COLUMN_STATIC_TEXT, "Would you put it in a toaster ?",
		      -1);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 
		      FOCUS_COLUMN_NAME, "Type something",
		      FOCUS_COLUMN_CHECK, FALSE,
		      FOCUS_COLUMN_STATIC_TEXT, "Does it feed on cute kittens ?",
		      -1);

  return (GtkTreeModel *)store;
}

308 309
static void
cell_toggled (GtkCellRendererToggle *cell_renderer,
310
	      const gchar           *path,
311
	      GtkIconView      *iconview)
312
{
313
  GtkTreeModel *model = gtk_icon_view_get_model (iconview);
314 315 316 317 318 319 320 321 322 323 324 325
  GtkTreeIter   iter;
  gboolean      active;

  g_print ("Cell toggled !\n");

  if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
    return;

  gtk_tree_model_get (model, &iter, FOCUS_COLUMN_CHECK, &active, -1);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_CHECK, !active, -1);
}

326 327 328 329
static void
cell_edited (GtkCellRendererToggle *cell_renderer,
	     const gchar           *path,
	     const gchar           *new_text,
330
	     GtkIconView      *iconview)
331
{
332
  GtkTreeModel *model = gtk_icon_view_get_model (iconview);
333 334 335 336 337 338 339 340 341 342
  GtkTreeIter   iter;

  g_print ("Cell edited with new text '%s' !\n", new_text);

  if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
    return;

  gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_NAME, new_text, -1);
}

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 352
  iconview = gtk_icon_view_new ();
  gtk_widget_show (iconview);
353 354 355

  model = focus_list_model ();

356 357
  gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), model);
  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 362

  renderer = gtk_cell_renderer_text_new ();
  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 365
  gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_NAME);

366 367 368
  if (color_bg)
    g_object_set (G_OBJECT (renderer), "cell-background", "red", NULL);

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 376
  gtk_cell_area_attribute_connect (area, renderer, "active", FOCUS_COLUMN_CHECK);

377 378
  if (color_bg)
    g_object_set (G_OBJECT (renderer), "cell-background", "green", NULL);
379 380 381

  if (focus)
    *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 388 389 390
  g_object_set (G_OBJECT (renderer), 
		"wrap-mode", PANGO_WRAP_WORD,
		"wrap-width", 150,
		NULL);
391 392 393

  if (color_bg)
    g_object_set (G_OBJECT (renderer), "cell-background", "blue", NULL);
394 395 396

  if (sibling)
    *sibling = renderer;
397

398
  gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE, FALSE);
399 400
  gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_STATIC_TEXT);

401
  gtk_cell_area_add_focus_sibling (area, toggle, renderer);
402

403
  return iconview;
404 405
}

406 407
static void
focus_sibling_toggled (GtkToggleButton  *toggle,
408
		       GtkIconView *iconview)
409
{
410
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
411 412 413 414 415 416 417
  gboolean     active = gtk_toggle_button_get_active (toggle);

  if (active)
    gtk_cell_area_add_focus_sibling (area, focus_renderer, sibling_renderer);
  else
    gtk_cell_area_remove_focus_sibling (area, focus_renderer, sibling_renderer);

418
  gtk_widget_queue_draw (GTK_WIDGET (iconview));
419 420
}

421 422 423 424 425

static void
focus_cell_area (void)
{
  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 433
  gtk_window_set_title (GTK_WINDOW (window), "Focus and editable cells");

434
  iconview = focus_iconview (FALSE, &focus_renderer, &sibling_renderer);
435 436 437 438 439 440 441

  frame = gtk_frame_new (NULL);
  gtk_widget_show (frame);

  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
  gtk_widget_set_halign (frame, GTK_ALIGN_FILL);

442
  gtk_container_add (GTK_CONTAINER (frame), iconview);
443

444 445 446
  gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

  /* Now add some controls */
447
  vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
448 449 450
  gtk_widget_show (vbox);
  gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

451 452 453 454 455 456 457 458
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);

  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 464 465
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);

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 472 473 474

  gtk_widget_show (window);
}


475 476 477 478 479 480

/*******************************************************
 *                  Background Area                    *
 *******************************************************/
static void
cell_spacing_changed (GtkSpinButton    *spin_button,
481
		      GtkIconView *iconview)
482
{
483
  GtkCellArea *area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (iconview));
484 485 486 487 488 489 490 491 492
  gint        value;

  value = (gint)gtk_spin_button_get_value (spin_button);

  gtk_cell_area_box_set_spacing (GTK_CELL_AREA_BOX (area), value);
}

static void
row_spacing_changed (GtkSpinButton    *spin_button,
493
		     GtkIconView *iconview)
494 495 496 497 498
{
  gint value;

  value = (gint)gtk_spin_button_get_value (spin_button);

499
  gtk_icon_view_set_row_spacing (iconview, value);
500 501 502
}

static void
503 504
item_padding_changed (GtkSpinButton    *spin_button,
		     GtkIconView *iconview)
505 506 507 508 509
{
  gint value;

  value = (gint)gtk_spin_button_get_value (spin_button);

510
  gtk_icon_view_set_item_padding (iconview, value);
511 512 513 514 515 516
}

static void
background_area (void)
{
  GtkWidget *window, *widget, *label, *main_vbox;
517
  GtkWidget *iconview, *frame, *vbox, *hbox;
518 519

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
520 521
  hbox  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
  main_vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
522 523 524 525 526 527 528
  gtk_widget_show (hbox);
  gtk_widget_show (main_vbox);
  gtk_container_add (GTK_CONTAINER (window), main_vbox);

  gtk_window_set_title (GTK_WINDOW (window), "Background Area");

  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 532 533 534 535
  gtk_label_set_line_wrap  (GTK_LABEL (label), TRUE);
  gtk_label_set_width_chars  (GTK_LABEL (label), 40);
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);

536
  iconview = focus_iconview (TRUE, NULL, NULL);
537 538 539 540 541 542 543

  frame = gtk_frame_new (NULL);
  gtk_widget_show (frame);

  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
  gtk_widget_set_halign (frame, GTK_ALIGN_FILL);

544
  gtk_container_add (GTK_CONTAINER (frame), iconview);
545 546 547 548

  gtk_box_pack_end (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

  /* Now add some controls */
549
  vbox  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
550 551 552 553 554 555 556 557 558 559 560 561
  gtk_widget_show (vbox);
  gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);

  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
562
                    G_CALLBACK (orientation_changed), iconview);
563 564 565

  widget = gtk_spin_button_new_with_range (0, 10, 1);
  label = gtk_label_new ("Cell spacing");
566
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
567 568 569 570 571 572 573 574
  gtk_widget_show (hbox);
  gtk_widget_show (label);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  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 583 584 585 586 587 588 589
  gtk_widget_show (hbox);
  gtk_widget_show (label);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  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 594
  label = gtk_label_new ("Item padding");
  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 597 598 599 600 601 602 603
  gtk_widget_show (hbox);
  gtk_widget_show (label);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "value-changed",
604
                    G_CALLBACK (item_padding_changed), iconview);
605 606 607 608 609 610 611 612 613

  gtk_widget_show (window);
}






614 615 616 617 618
int
main (int argc, char *argv[])
{
  gtk_init (NULL, NULL);

619 620 621
  if (g_getenv ("RTL"))
    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);

622
  simple_cell_area ();
623
  focus_cell_area ();
624
  background_area ();
625 626 627 628 629

  gtk_main ();

  return 0;
}