2 * This file is a part of hildon examples
4 * Copyright (C) 2009 Nokia Corporation, all rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; version 2.1 of
10 * the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 #include <hildon/hildon.h>
31 enum { TEXT_COLUMN, N_COLUMNS };
34 on_button_clicked (GtkButton *button,
37 GtkListStore *store = NULL;
41 store = GTK_LIST_STORE (user_data);
43 for (i = 0; i < 5; i++) {
44 gtk_list_store_append (store, &iter);
45 gtk_list_store_set (store, &iter,
46 TEXT_COLUMN, "Extra row", -1);
55 GtkWidget *panarea = NULL;
56 GtkWidget *button = NULL;;
57 GtkTreeViewColumn *col = NULL;
58 GtkCellRenderer *renderer = NULL;
59 GtkListStore *store = NULL;
60 GtkWidget *vbox = NULL;
62 /* Create a treeview */
64 tv = hildon_gtk_tree_view_new (HILDON_UI_MODE_NORMAL);
66 tv = GTK_TREE_VIEW (gtk_tree_view_new ());
67 #endif /* MAEMO_GTK */
69 renderer = gtk_cell_renderer_text_new ();
70 g_object_set (renderer, "width", 1, "xalign", 0.5, NULL);
72 col = gtk_tree_view_column_new ();
73 gtk_tree_view_column_set_title (col, "Title");
75 gtk_tree_view_column_pack_start (col, renderer, TRUE);
76 gtk_tree_view_column_set_attributes (col, renderer, "text", TEXT_COLUMN, NULL);
78 gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
80 /* Add some rows to the treeview */
81 store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING);
83 for (i = 0; i < 3; i++) {
86 gtk_list_store_append (store, &iter);
87 gtk_list_store_set (store, &iter,
88 TEXT_COLUMN, "One row", -1);
91 gtk_tree_view_set_model (GTK_TREE_VIEW (tv), GTK_TREE_MODEL (store));
92 g_object_unref (store);
94 /* Put everything in a pannable area */
95 panarea = hildon_pannable_area_new ();
96 gtk_container_add (GTK_CONTAINER (panarea), GTK_WIDGET (tv));
98 vbox = gtk_vbox_new (FALSE, 5);
100 button = gtk_button_new_with_label ("Add some rows");
101 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_button_clicked), store);
103 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
104 gtk_box_pack_start (GTK_BOX (vbox), panarea, TRUE, TRUE, 6);
110 main (int argc, char **argv)
112 HildonProgram *program = NULL;
113 GtkWidget *window = NULL;
114 GtkWidget *content = NULL;
116 hildon_gtk_init (&argc, &argv);
118 program = hildon_program_get_instance ();
120 /* Create the main window */
121 window = hildon_window_new ();
122 hildon_program_add_window (program, HILDON_WINDOW (window));
123 gtk_container_set_border_width (GTK_CONTAINER (window), 5);
125 content = create_content ();
127 gtk_container_add (GTK_CONTAINER (window), content);
129 g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
131 gtk_widget_show_all (GTK_WIDGET (window));