aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-slice.c
blob: b7d6f1ca0d7279fc592ee285fa34e2681107161d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <gtk/gtk.h>
#include "owltreemodelslice.h"

static GtkTreeModel *
create_tree (void)
{
  GtkTreeModel *model;
  GtkTreeIter iter, child;
  GtkIconTheme *icons;

  icons = gtk_icon_theme_get_default ();

  model = (GtkTreeModel*)gtk_tree_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
  gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
  gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
                      0, gtk_icon_theme_load_icon (icons, "gnome-applications", 48, 0, NULL),
                      1, "Applications",
                      -1);
  gtk_tree_store_append (GTK_TREE_STORE (model), &child, &iter);
  gtk_tree_store_set (GTK_TREE_STORE (model), &child,
                      0, gtk_icon_theme_load_icon (icons, "sound-juicer", 48, 0, NULL),
                      1, "Sound Juicer",
                      -1);
  gtk_tree_store_append (GTK_TREE_STORE (model), &child, &iter);
  gtk_tree_store_set (GTK_TREE_STORE (model), &child,
                      0, gtk_icon_theme_load_icon (icons, "gnome-terminal", 48, 0, NULL),
                      1, "Terminal",
                      -1);
  gtk_tree_store_append (GTK_TREE_STORE (model), &child, &iter);
  gtk_tree_store_set (GTK_TREE_STORE (model), &child,
                      0, gtk_icon_theme_load_icon (icons, "web-browser", 48, 0, NULL),
                      1, "Web Browser",
                      -1);

  gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
  gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
                      0, gtk_icon_theme_load_icon (icons, "gnome-settings", 48, 0, NULL),
                      1, "Preferences",
                      -1);

  return model;
}

int
main(int argc, char ** argv)
{
  GtkWidget *window, *box, *treeview, *iconview;
  GtkTreeModel *model, *slicer;
  GtkTreeViewColumn *column;

  gtk_init (&argc, &argv);

  model = create_tree ();
  slicer = owl_tree_model_slice_new (model, gtk_tree_path_new_first());

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", gtk_main_quit, NULL);
  box = gtk_hbox_new (FALSE, 6);

  treeview = gtk_tree_view_new_with_model (model);
  column = gtk_tree_view_column_new_with_attributes ("Icon",
                                                     gtk_cell_renderer_pixbuf_new (),
                                                     "pixbuf", 0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
  column = gtk_tree_view_column_new_with_attributes ("String",
                                                     gtk_cell_renderer_text_new (),
                                                     "text", 1, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

  iconview = gtk_icon_view_new_with_model (slicer);
  gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (iconview), 0);
  gtk_icon_view_set_text_column (GTK_ICON_VIEW (iconview), 1);
  
  gtk_container_add (GTK_CONTAINER (box), treeview);
  gtk_container_add (GTK_CONTAINER (box), iconview);
  gtk_container_add (GTK_CONTAINER (window), box);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}