Add powerbox hook
[gtk-with-powerbox.git] / perf / treeview.c
blob4c5c2d7999815f398bc844110c9696f7d4be1619
1 #include <gtk/gtk.h>
2 #include "widgets.h"
4 struct row_data {
5 char *stock_id;
6 char *text1;
7 char *text2;
8 };
10 static const struct row_data row_data[] = {
11 { GTK_STOCK_NEW, "First", "Here bygynneth the Book of the tales of Caunterbury." },
12 { GTK_STOCK_OPEN, "Second", "Whan that Aprille, with hise shoures soote," },
13 { GTK_STOCK_ABOUT, "Third", "The droghte of March hath perced to the roote" },
14 { GTK_STOCK_ADD, "Fourth", "And bathed every veyne in swich licour," },
15 { GTK_STOCK_APPLY, "Fifth", "Of which vertu engendred is the flour;" },
16 { GTK_STOCK_BOLD, "Sixth", "Whan Zephirus eek with his swete breeth" },
17 { GTK_STOCK_CANCEL, "Seventh", "Inspired hath in every holt and heeth" },
18 { GTK_STOCK_CDROM, "Eighth", "The tendre croppes, and the yonge sonne" },
19 { GTK_STOCK_CLEAR, "Ninth", "Hath in the Ram his halfe cours yronne," },
20 { GTK_STOCK_CLOSE, "Tenth", "And smale foweles maken melodye," },
21 { GTK_STOCK_COLOR_PICKER, "Eleventh", "That slepen al the nyght with open eye-" },
22 { GTK_STOCK_CONVERT, "Twelfth", "So priketh hem Nature in hir corages-" },
23 { GTK_STOCK_CONNECT, "Thirteenth", "Thanne longen folk to goon on pilgrimages" },
24 { GTK_STOCK_COPY, "Fourteenth", "And palmeres for to seken straunge strondes" },
25 { GTK_STOCK_CUT, "Fifteenth", "To ferne halwes, kowthe in sondry londes;" },
26 { GTK_STOCK_DELETE, "Sixteenth", "And specially, from every shires ende" },
27 { GTK_STOCK_DIRECTORY, "Seventeenth", "Of Engelond, to Caunturbury they wende," },
28 { GTK_STOCK_DISCONNECT, "Eighteenth", "The hooly blisful martir for the seke" },
29 { GTK_STOCK_EDIT, "Nineteenth", "That hem hath holpen, whan that they were seeke." },
30 { GTK_STOCK_EXECUTE, "Twentieth", "Bifil that in that seson, on a day," },
31 { GTK_STOCK_FILE, "Twenty-first", "In Southwerk at the Tabard as I lay," },
32 { GTK_STOCK_FIND, "Twenty-second", "Redy to wenden on my pilgrymage" },
33 { GTK_STOCK_FIND_AND_REPLACE, "Twenty-third", "To Caunterbury, with ful devout corage," },
34 { GTK_STOCK_FLOPPY, "Twenty-fourth", "At nyght were come into that hostelrye" },
35 { GTK_STOCK_FULLSCREEN, "Twenty-fifth", "Wel nyne and twenty in a compaignye" },
36 { GTK_STOCK_GOTO_BOTTOM, "Twenty-sixth", "Of sondry folk, by aventure yfalle" },
39 static GtkTreeModel *
40 tree_model_new (void)
42 GtkListStore *list;
43 int i;
45 list = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
47 for (i = 0; i < G_N_ELEMENTS (row_data); i++)
49 GtkTreeIter iter;
51 gtk_list_store_append (list, &iter);
52 gtk_list_store_set (list,
53 &iter,
54 0, row_data[i].stock_id,
55 1, row_data[i].text1,
56 2, row_data[i].text2,
57 -1);
60 return GTK_TREE_MODEL (list);
63 GtkWidget *
64 tree_view_new (void)
66 GtkWidget *sw;
67 GtkWidget *tree;
68 GtkTreeModel *model;
69 GtkTreeViewColumn *column;
71 sw = gtk_scrolled_window_new (NULL, NULL);
72 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
74 model = tree_model_new ();
75 tree = gtk_tree_view_new_with_model (model);
76 g_object_unref (model);
78 gtk_widget_set_size_request (tree, 300, 100);
80 column = gtk_tree_view_column_new_with_attributes ("Icon",
81 gtk_cell_renderer_pixbuf_new (),
82 "stock-id", 0,
83 NULL);
84 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
86 column = gtk_tree_view_column_new_with_attributes ("Index",
87 gtk_cell_renderer_text_new (),
88 "text", 1,
89 NULL);
90 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
92 column = gtk_tree_view_column_new_with_attributes ("Canterbury Tales",
93 gtk_cell_renderer_text_new (),
94 "text", 2,
95 NULL);
96 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
98 gtk_container_add (GTK_CONTAINER (sw), tree);
100 return sw;