2 * This file is a part of hildon examples
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * Author: Karl Lattimer <karl.lattimer@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
31 enum { TEXT_COLUMN, N_COLUMNS };
34 get_sawtooth_label (gchar **label, guint num)
36 static gchar *sawtooth = NULL;
37 gchar *label_aux, *sawtooth_aux;
40 sawtooth_aux = g_strconcat (" ", sawtooth, NULL);
43 sawtooth = sawtooth_aux;
48 sawtooth = g_strdup (" ");
51 label_aux = g_strconcat (sawtooth, *label, NULL);
58 main (int argc, char **argv)
61 HildonProgram *program;
62 GtkWidget *window, *tv, *panarea;
63 GtkTreeViewColumn *col;
64 GtkCellRenderer *renderer;
67 hildon_gtk_init (&argc, &argv);
69 program = hildon_program_get_instance ();
71 /* Create the main window */
72 window = hildon_window_new ();
73 hildon_program_add_window (program, HILDON_WINDOW (window));
75 gtk_container_set_border_width (GTK_CONTAINER (window), 5);
77 /* Create a treeview */
78 tv = gtk_tree_view_new ();
79 renderer = gtk_cell_renderer_text_new ();
80 col = gtk_tree_view_column_new_with_attributes ("Title", renderer, "text", TEXT_COLUMN, NULL);
81 gtk_tree_view_append_column (GTK_TREE_VIEW(tv), col);
83 /* Add some rows to the treeview */
84 store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING);
85 for (i = 0; i < 100; i++) {
87 gchar *label = g_strdup_printf ("Row number %d", i);
89 get_sawtooth_label (&label, i);
91 gtk_list_store_append (store, &iter);
92 gtk_list_store_set (store, &iter, TEXT_COLUMN, label, -1);
95 gtk_tree_view_set_model (GTK_TREE_VIEW (tv), GTK_TREE_MODEL (store));
96 g_object_unref (store);
98 /* Put everything in a pannable area */
99 panarea = hildon_pannable_area_new ();
100 gtk_container_add (GTK_CONTAINER (panarea), GTK_WIDGET (tv));
101 gtk_container_add (GTK_CONTAINER (window), panarea);
103 g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
105 gtk_widget_show_all (GTK_WIDGET (window));