testiconview.c 16.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/* testiconview.c
 * Copyright (C) 2002  Anders Carlsson <andersca@gnu.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <gtk/gtk.h>
#include <sys/types.h>
#include <string.h>
#include "prop-editor.h"

25 26 27
#define NUMBER_OF_ITEMS   10
#define SOME_ITEMS       100
#define MANY_ITEMS     10000
28 29 30 31 32 33 34 35 36

static void
fill_model (GtkTreeModel *model)
{
  GdkPixbuf *pixbuf;
  int i;
  char *str, *str2;
  GtkTreeIter iter;
  GtkListStore *store = GTK_LIST_STORE (model);
37
  gint32 size;
38 39 40 41 42 43 44 45 46 47 48 49
  
  pixbuf = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);

  i = 0;
  
  gtk_list_store_prepend (store, &iter);

  gtk_list_store_set (store, &iter,
		      0, pixbuf,
		      1, "Really really\nreally really loooooooooong item name",
		      2, 0,
		      3, "This is a <b>Test</b> of <i>markup</i>",
Matthias Clasen's avatar
Matthias Clasen committed
50
		      4, TRUE,
51
		      -1);
Matthias Clasen's avatar
Matthias Clasen committed
52

53 54
  while (i < NUMBER_OF_ITEMS - 1)
    {
55 56 57 58
      GdkPixbuf *pb;
      size = g_random_int_range (20, 70);
      pb = gdk_pixbuf_scale_simple (pixbuf, size, size, GDK_INTERP_NEAREST);

59 60 61 62
      str = g_strdup_printf ("Icon %d", i);
      str2 = g_strdup_printf ("Icon <b>%d</b>", i);	
      gtk_list_store_prepend (store, &iter);
      gtk_list_store_set (store, &iter,
63
			  0, pb,
64 65 66
			  1, str,
			  2, i,
			  3, str2,
Matthias Clasen's avatar
Matthias Clasen committed
67
			  4, TRUE,
68 69 70 71 72
			  -1);
      g_free (str);
      g_free (str2);
      i++;
    }
Matthias Clasen's avatar
Matthias Clasen committed
73
  
Matthias Clasen's avatar
Matthias Clasen committed
74
  //  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 2, GTK_SORT_ASCENDING);
75 76 77 78 79 80 81
}

static GtkTreeModel *
create_model (void)
{
  GtkListStore *store;
  
Matthias Clasen's avatar
Matthias Clasen committed
82
  store = gtk_list_store_new (5, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN);
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

  return GTK_TREE_MODEL (store);
}


static void
foreach_selected_remove (GtkWidget *button, GtkIconView *icon_list)
{
  GtkTreeIter iter;
  GtkTreeModel *model;

  GList *list, *selected;

  selected = gtk_icon_view_get_selected_items (icon_list);
  model = gtk_icon_view_get_model (icon_list);
  
  for (list = selected; list; list = list->next)
    {
      GtkTreePath *path = list->data;

      gtk_tree_model_get_iter (model, &iter, path);
      gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
      
      gtk_tree_path_free (path);
    } 
  
  g_list_free (selected);
}


Matthias Clasen's avatar
Matthias Clasen committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
static void
swap_rows (GtkWidget *button, GtkIconView *icon_list)
{
  GtkTreeIter iter, iter2;
  GtkTreeModel *model;

  model = gtk_icon_view_get_model (icon_list);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), -2, GTK_SORT_ASCENDING);

  gtk_tree_model_get_iter_first (model, &iter);
  iter2 = iter;
  gtk_tree_model_iter_next (model, &iter2);
  gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter2);
}

128
static void
129
add_n_items (GtkIconView *icon_list, gint n)
130 131 132 133 134 135 136 137 138 139 140 141 142
{
  static gint count = NUMBER_OF_ITEMS;

  GtkTreeIter iter;
  GtkListStore *store;
  GdkPixbuf *pixbuf;
  gchar *str, *str2;
  gint i;

  store = GTK_LIST_STORE (gtk_icon_view_get_model (icon_list));
  pixbuf = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);


143
  for (i = 0; i < n; i++)
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
    {
      str = g_strdup_printf ("Icon %d", count);
      str2 = g_strdup_printf ("Icon <b>%d</b>", count);	
      gtk_list_store_prepend (store, &iter);
      gtk_list_store_set (store, &iter,
			  0, pixbuf,
			  1, str,
			  2, i,
			  3, str2,
			  -1);
      g_free (str);
      g_free (str2);
      count++;
    }
}

160 161 162 163 164 165 166 167 168 169 170 171
static void
add_some (GtkWidget *button, GtkIconView *icon_list)
{
  add_n_items (icon_list, SOME_ITEMS);
}

static void
add_many (GtkWidget *button, GtkIconView *icon_list)
{
  add_n_items (icon_list, MANY_ITEMS);
}

Matthias Clasen's avatar
Matthias Clasen committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
static void
add_large (GtkWidget *button, GtkIconView *icon_list)
{
  GtkListStore *store;
  GtkTreeIter iter;

  GdkPixbuf *pixbuf, *pb;
  gchar *str;

  store = GTK_LIST_STORE (gtk_icon_view_get_model (icon_list));
  pixbuf = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);

  pb = gdk_pixbuf_scale_simple (pixbuf, 
				2 * gdk_pixbuf_get_width (pixbuf),
				2 * gdk_pixbuf_get_height (pixbuf),
				GDK_INTERP_BILINEAR);

  str = g_strdup_printf ("Some really long text");
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
		      0, pb,
		      1, str,
		      2, 0,
		      3, str,
		      -1);
  g_object_unref (pb);
  g_free (str);
  
  pb = gdk_pixbuf_scale_simple (pixbuf, 
				3 * gdk_pixbuf_get_width (pixbuf),
				3 * gdk_pixbuf_get_height (pixbuf),
				GDK_INTERP_BILINEAR);

  str = g_strdup ("see how long text behaves when placed underneath "
		  "an oversized icon which would allow for long lines");
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
		      0, pb,
		      1, str,
		      2, 1,
		      3, str,
		      -1);
  g_object_unref (pb);
  g_free (str);

  pb = gdk_pixbuf_scale_simple (pixbuf, 
				3 * gdk_pixbuf_get_width (pixbuf),
				3 * gdk_pixbuf_get_height (pixbuf),
				GDK_INTERP_BILINEAR);

  str = g_strdup ("short text");
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
		      0, pb,
		      1, str,
		      2, 2,
		      3, str,
		      -1);
  g_object_unref (pb);
  g_free (str);

  g_object_unref (pixbuf);
}

236 237 238 239 240 241
static void
select_all (GtkWidget *button, GtkIconView *icon_list)
{
  gtk_icon_view_select_all (icon_list);
}

Matthias Clasen's avatar
Matthias Clasen committed
242 243 244 245 246 247 248 249
static void
select_nonexisting (GtkWidget *button, GtkIconView *icon_list)
{  
  GtkTreePath *path = gtk_tree_path_new_from_indices (999999, -1);
  gtk_icon_view_select_path (icon_list, path);
  gtk_tree_path_free (path);
}

250 251 252 253 254
static void
unselect_all (GtkWidget *button, GtkIconView *icon_list)
{
  gtk_icon_view_unselect_all (icon_list);
}
255 256 257 258 259 260 261

static void
selection_changed (GtkIconView *icon_list)
{
  g_print ("Selection changed!\n");
}

262 263 264 265 266 267 268 269 270 271 272 273
typedef struct {
  GtkIconView     *icon_list;
  GtkTreePath     *path;
} ItemData;

static void
free_item_data (ItemData *data)
{
  gtk_tree_path_free (data->path);
  g_free (data);
}

274
static void
275 276
item_activated (GtkIconView *icon_view,
		GtkTreePath *path)
277 278 279 280
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  gchar *text;
281 282 283

  model = gtk_icon_view_get_model (icon_view);
  gtk_tree_model_get_iter (model, &iter, path);
284

285
  gtk_tree_model_get (model, &iter, 1, &text, -1);
286
  g_print ("Item activated, text is %s\n", text);
287
  g_free (text);
288 289 290
  
}

Matthias Clasen's avatar
Matthias Clasen committed
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
static void
toggled (GtkCellRendererToggle *cell,
	 gchar                 *path_string,
	 gpointer               data)
{
  GtkTreeModel *model = GTK_TREE_MODEL (data);
  GtkTreeIter iter;
  GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
  gboolean value;

  gtk_tree_model_get_iter (model, &iter, path);
  gtk_tree_model_get (model, &iter, 4, &value, -1);

  value = !value;
  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 4, value, -1);

  gtk_tree_path_free (path);
}

static void
edited (GtkCellRendererText *cell,
	gchar               *path_string,
	gchar               *new_text,
	gpointer             data)
{
  GtkTreeModel *model = GTK_TREE_MODEL (data);
  GtkTreeIter iter;
  GtkTreePath *path = gtk_tree_path_new_from_string (path_string);

  gtk_tree_model_get_iter (model, &iter, path);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 1, new_text, -1);

  gtk_tree_path_free (path);
}

326 327 328 329 330
static void
item_cb (GtkWidget *menuitem,
	 ItemData  *data)
{
  item_activated (data->icon_list, data->path);
331 332 333 334 335 336
}

static void
do_popup_menu (GtkWidget      *icon_list, 
	       GdkEventButton *event)
{
337
  GtkIconView *icon_view = GTK_ICON_VIEW (icon_list); 
338 339
  GtkWidget *menu;
  GtkWidget *menuitem;
340
  GtkTreePath *path = NULL;
341
  int button, event_time;
342
  ItemData *data;
343
  GList *list;
344

345 346 347 348 349 350 351 352 353
  if (event)
    path = gtk_icon_view_get_path_at_pos (icon_view, event->x, event->y);
  else
    {
      list = gtk_icon_view_get_selected_items (icon_view);

      if (list)
        {
          path = (GtkTreePath*)list->data;
Yevgen Muntyan's avatar
Yevgen Muntyan committed
354
          g_list_foreach (list->next, (GFunc) gtk_tree_path_free, NULL);
355 356 357
          g_list_free (list);
        }
    }
Matthias Clasen's avatar
Matthias Clasen committed
358

359 360 361 362 363
  if (!path)
    return;

  menu = gtk_menu_new ();

364
  data = g_new0 (ItemData, 1);
365
  data->icon_list = icon_view;
366
  data->path = path;
Matthias Clasen's avatar
Matthias Clasen committed
367
  g_object_set_data_full (G_OBJECT (menu), "item-path", data, (GDestroyNotify)free_item_data);
368

369 370 371
  menuitem = gtk_menu_item_new_with_label ("Activate");
  gtk_widget_show (menuitem);
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
372
  g_signal_connect (menuitem, "activate", G_CALLBACK (item_cb), data);
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409

  if (event)
    {
      button = event->button;
      event_time = event->time;
    }
  else
    {
      button = 0;
      event_time = gtk_get_current_event_time ();
    }

  gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 
                  button, event_time);
}
	

static gboolean
button_press_event_handler (GtkWidget      *widget, 
			    GdkEventButton *event)
{
  /* Ignore double-clicks and triple-clicks */
  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
    {
      do_popup_menu (widget, event);
      return TRUE;
    }

  return FALSE;
}

static gboolean
popup_menu_handler (GtkWidget *widget)
{
  do_popup_menu (widget, NULL);
  return TRUE;
}
Matthias Clasen's avatar
Matthias Clasen committed
410 411 412 413

static const GtkTargetEntry item_targets[] = {
  { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0 }
};
414 415 416 417
	
gint
main (gint argc, gchar **argv)
{
Matthias Clasen's avatar
Matthias Clasen committed
418
  GtkWidget *paned, *tv;
419 420 421 422 423
  GtkWidget *window, *icon_list, *scrolled_window;
  GtkWidget *vbox, *bbox;
  GtkWidget *button;
  GtkWidget *prop_editor;
  GtkTreeModel *model;
Matthias Clasen's avatar
Matthias Clasen committed
424
  GtkCellRenderer *cell;
Matthias Clasen's avatar
Matthias Clasen committed
425
  GtkTreeViewColumn *tvc;
426 427 428 429 430 431 432 433 434 435
  
  gtk_init (&argc, &argv);

  /* to test rtl layout, set RTL=1 in the environment */
  if (g_getenv ("RTL"))
    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 700, 400);

Matthias Clasen's avatar
Matthias Clasen committed
436 437 438
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);

439
  paned = gtk_hpaned_new ();
Matthias Clasen's avatar
Matthias Clasen committed
440
  gtk_box_pack_start (GTK_BOX (vbox), paned, TRUE, TRUE, 0);
441 442 443 444

  icon_list = gtk_icon_view_new ();
  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_list), GTK_SELECTION_MULTIPLE);

Matthias Clasen's avatar
Matthias Clasen committed
445 446 447 448
  tv = gtk_tree_view_new ();
  tvc = gtk_tree_view_column_new ();
  gtk_tree_view_append_column (GTK_TREE_VIEW (tv), tvc);

449 450 451 452 453 454 455 456
  g_signal_connect_after (icon_list, "button_press_event",
			  G_CALLBACK (button_press_event_handler), NULL);
  g_signal_connect (icon_list, "selection_changed",
		    G_CALLBACK (selection_changed), NULL);
  g_signal_connect (icon_list, "popup_menu",
		    G_CALLBACK (popup_menu_handler), NULL);

  g_signal_connect (icon_list, "item_activated",
457
		    G_CALLBACK (item_activated), NULL);
458 459 460
  
  model = create_model ();
  gtk_icon_view_set_model (GTK_ICON_VIEW (icon_list), model);
Matthias Clasen's avatar
Matthias Clasen committed
461
  gtk_tree_view_set_model (GTK_TREE_VIEW (tv), model);
462
  fill_model (model);
Matthias Clasen's avatar
Matthias Clasen committed
463 464 465

#if 0

466 467
  gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_list), 0);
  gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_list), 1);
Matthias Clasen's avatar
Matthias Clasen committed
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496

#else

  cell = gtk_cell_renderer_toggle_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_list), cell, FALSE);
  g_object_set (cell, "activatable", TRUE, NULL);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list),
				  cell, "active", 4, NULL);
  g_signal_connect (cell, "toggled", G_CALLBACK (toggled), model);

  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_list), cell, FALSE);
  g_object_set (cell, 
		"follow-state", TRUE, 
		NULL);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list),
				  cell, "pixbuf", 0, NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_list), cell, FALSE);
  g_object_set (cell, 
		"editable", TRUE, 
		"xalign", 0.5,
		"wrap-mode", PANGO_WRAP_WORD_CHAR,
		"wrap-width", 100,
		NULL);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_list),
				  cell, "text", 1, NULL);
  g_signal_connect (cell, "edited", G_CALLBACK (edited), model);
Matthias Clasen's avatar
Matthias Clasen committed
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519

  /* now the tree view... */
  cell = gtk_cell_renderer_toggle_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE);
  g_object_set (cell, "activatable", TRUE, NULL);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc),
				  cell, "active", 4, NULL);
  g_signal_connect (cell, "toggled", G_CALLBACK (toggled), model);

  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE);
  g_object_set (cell, 
		"follow-state", TRUE, 
		NULL);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc),
				  cell, "pixbuf", 0, NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tvc), cell, FALSE);
  g_object_set (cell, "editable", TRUE, NULL);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tvc),
				  cell, "text", 1, NULL);
  g_signal_connect (cell, "edited", G_CALLBACK (edited), model);
Matthias Clasen's avatar
Matthias Clasen committed
520
#endif
Matthias Clasen's avatar
Matthias Clasen committed
521 522
  /* Allow DND between the icon view and the tree view */
  
523
  gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (icon_list),
Matthias Clasen's avatar
Matthias Clasen committed
524 525 526 527
					  GDK_BUTTON1_MASK,
					  item_targets,
					  G_N_ELEMENTS (item_targets),
					  GDK_ACTION_MOVE);
528
  gtk_icon_view_enable_model_drag_dest (GTK_ICON_VIEW (icon_list),
Matthias Clasen's avatar
Matthias Clasen committed
529 530 531 532
					item_targets,
					G_N_ELEMENTS (item_targets),
					GDK_ACTION_MOVE);

533
  gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
Matthias Clasen's avatar
Matthias Clasen committed
534 535 536 537
					  GDK_BUTTON1_MASK,
					  item_targets,
					  G_N_ELEMENTS (item_targets),
					  GDK_ACTION_MOVE);
538
  gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
Matthias Clasen's avatar
Matthias Clasen committed
539 540 541 542
					item_targets,
					G_N_ELEMENTS (item_targets),
					GDK_ACTION_MOVE);

Matthias Clasen's avatar
Matthias Clasen committed
543
			      
544 545 546 547 548 549 550
  prop_editor = create_prop_editor (G_OBJECT (icon_list), 0);
  gtk_widget_show_all (prop_editor);
  
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
  				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
Matthias Clasen's avatar
Matthias Clasen committed
551 552

  gtk_paned_add1 (GTK_PANED (paned), scrolled_window);
Matthias Clasen's avatar
Matthias Clasen committed
553

Matthias Clasen's avatar
Matthias Clasen committed
554 555 556 557 558 559 560
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scrolled_window), tv);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
  				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  gtk_paned_add2 (GTK_PANED (paned), scrolled_window);

561 562 563 564
  bbox = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
  gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);

565 566 567 568
  button = gtk_button_new_with_label ("Add some");
  g_signal_connect (button, "clicked", G_CALLBACK (add_some), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);

569 570 571 572
  button = gtk_button_new_with_label ("Add many");
  g_signal_connect (button, "clicked", G_CALLBACK (add_many), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);

Matthias Clasen's avatar
Matthias Clasen committed
573 574 575 576
  button = gtk_button_new_with_label ("Add large");
  g_signal_connect (button, "clicked", G_CALLBACK (add_large), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);

577 578 579
  button = gtk_button_new_with_label ("Remove selected");
  g_signal_connect (button, "clicked", G_CALLBACK (foreach_selected_remove), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);
580

Matthias Clasen's avatar
Matthias Clasen committed
581 582 583 584
  button = gtk_button_new_with_label ("Swap");
  g_signal_connect (button, "clicked", G_CALLBACK (swap_rows), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);

Matthias Clasen's avatar
Matthias Clasen committed
585 586 587 588
  bbox = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
  gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);

589 590 591 592 593 594 595
  button = gtk_button_new_with_label ("Select all");
  g_signal_connect (button, "clicked", G_CALLBACK (select_all), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);

  button = gtk_button_new_with_label ("Unselect all");
  g_signal_connect (button, "clicked", G_CALLBACK (unselect_all), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);
596
  
Matthias Clasen's avatar
Matthias Clasen committed
597 598 599 600
  button = gtk_button_new_with_label ("Select nonexisting");
  g_signal_connect (button, "clicked", G_CALLBACK (select_nonexisting), icon_list);
  gtk_box_pack_start_defaults (GTK_BOX (bbox), button);

601 602 603 604 605 606
  icon_list = gtk_icon_view_new ();
  
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
Matthias Clasen's avatar
Matthias Clasen committed
607
  gtk_paned_add2 (GTK_PANED (paned), scrolled_window);
608 609 610 611 612 613 614

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}