2008-07-29 Claudio Saavedra <csaavedra@igalia.com>
[hildon] / examples / hildon-picker-button-example.c
1 /*
2  * This file is a part of hildon
3  *
4  * Copyright (C) 2008 Nokia Corporation, all rights reserved.
5  *
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.
9  *
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.
14  *
15  */
16
17 #include <glib.h>
18 #include <gtk/gtk.h>
19
20 #include "hildon-program.h"
21 #include "hildon-stackable-window.h"
22
23 #include "hildon-picker-button.h"
24
25 static void
26 on_picker_value_changed (HildonPickerButton * button, gpointer data)
27 {
28   g_print ("Newly selected value: %s\n",
29            hildon_button_get_value (HILDON_BUTTON (button)));
30 }
31
32 int
33 main (int argc, char **args)
34 {
35   HildonProgram *program = NULL;
36   GtkWidget *window = NULL;
37   GtkWidget *button;
38
39   gtk_init (&argc, &args);
40
41   program = hildon_program_get_instance ();
42   g_set_application_name ("hildon-picker-button-example");
43
44   window = hildon_stackable_window_new ();
45   gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
46   hildon_program_add_window (program, HILDON_WINDOW (window));
47
48   button = hildon_picker_button_new_text (HILDON_BUTTON_WITH_VERTICAL_VALUE);
49   hildon_button_set_title (HILDON_BUTTON (button), "Continent");
50
51   hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "America");
52   hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "Europe");
53   hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "Asia");
54   hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button), "Africa");
55   hildon_picker_button_append_text (HILDON_PICKER_BUTTON (button),
56                                     "Australia");
57
58   g_signal_connect (G_OBJECT (button), "value-changed",
59                     G_CALLBACK (on_picker_value_changed), NULL);
60
61   gtk_container_add (GTK_CONTAINER (window), button);
62
63   g_signal_connect (G_OBJECT (window), "delete-event", 
64                     G_CALLBACK (gtk_main_quit), NULL);
65
66   gtk_widget_show_all (window);
67
68   gtk_main ();
69
70   return 0;
71 }