2 * This file is a part of hildon examples
4 * Copyright (C) 2008 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
27 #include "hildon-program.h"
28 #include "hildon-stackable-window.h"
30 #include "hildon-touch-selector.h"
31 #include "hildon-picker-dialog.h"
32 #include "hildon-picker-button.h"
34 static GtkWidget *create_selector ();
35 static GtkWidget *get_visible_content (GtkWidget * window);
37 static GtkWindow *parent_window = NULL;
39 static GtkWidget *label = NULL;
42 value_changed (HildonPickerButton * button,
45 HildonTouchSelector *selector;
46 gchar *aux_string = NULL;
48 selector = hildon_picker_button_get_selector (button);
49 aux_string = hildon_touch_selector_get_current_text (selector);
50 gtk_label_set_text (GTK_LABEL (label), aux_string);
57 GtkWidget *selector = NULL;
58 GSList *icon_list = NULL;
59 GtkListStore *store_icons = NULL;
61 GtkCellRenderer *renderer = NULL;
63 selector = hildon_touch_selector_new ();
65 icon_list = gtk_stock_list_ids ();
67 store_icons = gtk_list_store_new (1, G_TYPE_STRING);
68 for (item = icon_list; item; item = g_slist_next (item)) {
70 gchar *label = item->data;
72 gtk_list_store_append (store_icons, &iter);
73 gtk_list_store_set (store_icons, &iter, 0, label, -1);
76 g_slist_free (icon_list);
78 renderer = gtk_cell_renderer_pixbuf_new ();
79 gtk_cell_renderer_set_fixed_size (renderer, -1, 100);
81 hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector),
82 GTK_TREE_MODEL (store_icons),
83 renderer, "stock-id", 0, NULL);
85 hildon_touch_selector_set_column_selection_mode (HILDON_TOUCH_SELECTOR (selector),
86 HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE);
92 get_visible_content (GtkWidget * window)
94 GtkWidget *result = NULL;
95 GtkWidget *button = NULL;
98 label = gtk_label_new ("Here we are going to put the selection");
100 button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
101 hildon_button_set_title (HILDON_BUTTON (button), "Click me..");
102 selector = create_selector ();
103 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
104 HILDON_TOUCH_SELECTOR (selector));
106 g_signal_connect (G_OBJECT (button), "value-changed",
107 G_CALLBACK (value_changed), window);
109 result = gtk_vbox_new (FALSE, 6);
111 gtk_container_add (GTK_CONTAINER (result), button);
112 gtk_container_add (GTK_CONTAINER (result), label);
118 main (int argc, char **args)
120 HildonProgram *program = NULL;
121 GtkWidget *window = NULL;
123 gtk_init (&argc, &args);
125 gtk_rc_parse_string ("style \"fremantle-widget\" {\n"
126 " GtkWidget::hildon-mode = 1\n"
127 "} widget \"*.fremantle-widget\" style \"fremantle-widget\""
128 "widget_class \"*<HildonPannableArea>.GtkTreeView\" style \"fremantle-widget\"");
130 program = hildon_program_get_instance ();
131 g_set_application_name
132 ("hildon-touch-selector cell renderer example program");
134 window = hildon_stackable_window_new ();
135 parent_window = GTK_WINDOW (window);
136 hildon_program_add_window (program, HILDON_WINDOW (window));
138 gtk_container_set_border_width (GTK_CONTAINER (window), 6);
140 gtk_rc_parse_string ("style \"fremantle-widget\" {\n"
141 " GtkWidget::hildon-mode = 1 \n"
142 "} widget \"*.fremantle-widget\" style \"fremantle-widget\"\n");
145 GtkWidget *vbox = get_visible_content (window);
147 gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
149 g_signal_connect (G_OBJECT (window), "destroy",
150 G_CALLBACK (gtk_main_quit), NULL);
151 gtk_widget_show_all (GTK_WIDGET (window));