2 * This file is a part of hildon examples
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; version 2.1 of
9 * the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 button_toggled_cb (HildonCheckButton *button,
29 gboolean active = hildon_check_button_get_active (button);
30 const gchar *labeltext = gtk_button_get_label (GTK_BUTTON (button));
31 char *text = g_strconcat (labeltext, active ? " (checked)" : " (unchecked)", NULL);
32 gtk_label_set_text (label, text);
46 hildon_gtk_init (&argc, &argv);
48 win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
49 vbox = GTK_BOX (gtk_vbox_new (FALSE, 10));
50 table = gtk_table_new (3, 2, TRUE);
51 label = gtk_label_new ("none");
53 gtk_table_set_row_spacings (GTK_TABLE (table), 10);
54 gtk_table_set_col_spacings (GTK_TABLE (table), 10);
56 gtk_box_pack_start (vbox, gtk_label_new ("Hildon check button example"), TRUE, TRUE, 0);
58 for (i = 0; i < 6; i++) {
60 GtkWidget *button = hildon_check_button_new (HILDON_SIZE_HALFSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
61 text = g_strdup_printf ("Button %d", i+1);
62 gtk_button_set_label (GTK_BUTTON (button), text);
64 gtk_table_attach_defaults (GTK_TABLE (table), button, i/2, (i/2) + 1, i%2, (i%2) + 1);
65 g_signal_connect (button, "toggled", G_CALLBACK (button_toggled_cb), label);
68 gtk_box_pack_start (vbox, table, TRUE, TRUE, 0);
69 gtk_box_pack_start (vbox, gtk_label_new ("Last toggled:"), TRUE, TRUE, 0);
70 gtk_box_pack_start (vbox, label, TRUE, TRUE, 0);
72 gtk_container_set_border_width (GTK_CONTAINER (win), 20);
73 gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox));
75 g_signal_connect (win, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
77 gtk_widget_show_all (win);