2
* This file is a part of hildon examples
4
* Copyright (C) 2008 Nokia Corporation, all rights reserved.
6
* Based in hildon-pannable-area-example.c
7
* by Karl Lattimer <karl.lattimer@nokia.com>
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public License
11
* as published by the Free Software Foundation; version 2.1 of
12
* the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
31
on_button_clicked (GtkWidget *widget, gpointer data)
33
g_debug ("Button %d clicked", GPOINTER_TO_INT (data));
38
find_button_clicked (GtkButton *button,
41
HildonPannableArea *panarea;
43
panarea = HILDON_PANNABLE_AREA (user_data);
45
hildon_pannable_area_scroll_to_child (panarea, btn);
49
main (int argc, char **argv)
52
HildonProgram *program;
53
GtkWidget *window, *panarea, *button;
54
GtkWidget *hbox, *vbox;
56
hildon_gtk_init (&argc, &argv);
58
program = hildon_program_get_instance ();
60
/* Create the main window */
61
window = hildon_window_new ();
62
hildon_program_add_window (program, HILDON_WINDOW (window));
63
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
65
/* Create a VBox and pack some buttons */
66
vbox = gtk_vbox_new (FALSE, 1);
67
for (i = 0; i < 80; i++) {
68
gchar *label = g_strdup_printf ("Button number %d", i);
70
button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
71
gtk_button_set_label (GTK_BUTTON (button), label);
72
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
73
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_button_clicked), GINT_TO_POINTER (i));
77
/* Put everything in a pannable area */
78
panarea = hildon_pannable_area_new ();
79
hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA (panarea), GTK_WIDGET (vbox));
81
vbox = gtk_vbox_new (FALSE, 10);
82
hbox = gtk_hbox_new (FALSE, 10);
84
button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
85
gtk_button_set_label (GTK_BUTTON (button), "Find the latest clicked button");
86
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (find_button_clicked), panarea);
87
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
89
g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
91
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 10);
92
gtk_box_pack_start (GTK_BOX (vbox), panarea, TRUE, TRUE, 0);
94
gtk_container_add (GTK_CONTAINER (window), vbox);
96
gtk_widget_show_all (GTK_WIDGET (window));