2 * This file is a part of hildon
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser Public License as published by
8 * the Free Software Foundation; version 2 of the license.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser Public License for more details.
19 #include <hildon/hildon.h>
22 create_touch_selector (void)
27 HildonTouchSelectorColumn *column = NULL;
29 selector = hildon_touch_selector_new ();
31 model = gtk_list_store_new (1, G_TYPE_STRING);
33 gtk_list_store_append (model, &iter);
34 gtk_list_store_set (model, &iter, 0, "IMAP", -1);
36 gtk_list_store_append (model, &iter);
37 gtk_list_store_set (model, &iter, 0, "IMAP4", -1);
39 gtk_list_store_append (model, &iter);
40 gtk_list_store_set (model, &iter, 0, "POP3", -1);
42 gtk_list_store_append (model, &iter);
43 gtk_list_store_set (model, &iter, 0, "Mailbox", -1);
45 column = hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
46 GTK_TREE_MODEL (model), TRUE);
47 hildon_touch_selector_column_set_text_column (column, 0);
49 model = gtk_list_store_new (1, G_TYPE_STRING);
51 gtk_list_store_append (model, &iter);
52 gtk_list_store_set (model, &iter, 0, "SMTP", -1);
54 gtk_list_store_append (model, &iter);
55 gtk_list_store_set (model, &iter, 0, "SMTPS", -1);
57 gtk_list_store_append (model, &iter);
58 gtk_list_store_set (model, &iter, 0, "Smoke signals", -1);
60 column = hildon_touch_selector_append_text_column (HILDON_TOUCH_SELECTOR (selector),
61 GTK_TREE_MODEL (model), TRUE);
62 hildon_touch_selector_column_set_text_column (column, 0);
68 on_picker_value_changed (HildonPickerButton * button, gpointer data)
70 g_print ("Newly selected value: %s\n",
71 hildon_button_get_value (HILDON_BUTTON (button)));
75 main (int argc, char **argv)
77 HildonProgram *program = NULL;
78 GtkWidget *window = NULL;
82 hildon_gtk_init (&argc, &argv);
84 program = hildon_program_get_instance ();
85 g_set_application_name ("hildon-picker-button-example");
87 window = hildon_stackable_window_new ();
88 gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
89 hildon_program_add_window (program, HILDON_WINDOW (window));
90 selector = create_touch_selector ();
92 button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
93 hildon_picker_button_set_done_button_text (HILDON_PICKER_BUTTON (button),
96 hildon_button_set_title (HILDON_BUTTON (button), "Protocol");
97 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
98 HILDON_TOUCH_SELECTOR (selector));
99 g_signal_connect (G_OBJECT (button), "value-changed",
100 G_CALLBACK (on_picker_value_changed), NULL);
102 gtk_container_add (GTK_CONTAINER (window), button);
104 gtk_widget_show_all (window);
106 g_signal_connect (G_OBJECT (window), "destroy",
107 G_CALLBACK (gtk_main_quit), NULL);
108 gtk_widget_show_all (GTK_WIDGET (window));