From: Alberto Garcia Date: Mon, 11 Aug 2008 18:39:24 +0000 (+0000) Subject: 2008-08-11 Alberto Garcia X-Git-Tag: 2.1.66-1~595 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=0d32d1248e400441a0477fc9d3a7b2e0ad6a7257;p=hildon 2008-08-11 Alberto Garcia * examples/Makefile.am * examples/hildon-check-button-example.c: Example of the hildon check button. --- diff --git a/ChangeLog b/ChangeLog index 57b19ad..055379d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-08-11 Alberto Garcia + * examples/Makefile.am + * examples/hildon-check-button-example.c: Example of the hildon + check button. + +2008-08-11 Alberto Garcia + * src/hildon-window.h * src/hildon-window.c (hildon_window_class_init) (hildon_window_unset_program): Don't make diff --git a/examples/Makefile.am b/examples/Makefile.am index 9020b84..8593819 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -54,6 +54,7 @@ noinst_PROGRAMS = hildon-window-example \ hildon-picker-button-example \ hildon-picker-button-multicolumn-example \ hildon-time-button-example \ + hildon-check-button-example \ hildon-touch-selector-example \ hildon-touch-selector-entry-example @@ -322,6 +323,11 @@ hildon_time_button_example_LDADD = $(HILDON_OBJ_LIBS) hildon_time_button_example_CFLAGS = $(HILDON_OBJ_CFLAGS) hildon_time_button_example_SOURCES = hildon-time-button-example.c +# Hildon check button +hildon_check_button_example_LDADD = $(HILDON_OBJ_LIBS) +hildon_check_button_example_CFLAGS = $(HILDON_OBJ_CFLAGS) +hildon_check_button_example_SOURCES = hildon-check-button-example.c + # Hildon touch picker with multiselection hildon_touch_selector_example_LDADD = $(HILDON_OBJ_LIBS) hildon_touch_selector_example_CFLAGS = $(HILDON_OBJ_CFLAGS) diff --git a/examples/hildon-check-button-example.c b/examples/hildon-check-button-example.c new file mode 100644 index 0000000..fb2e8a9 --- /dev/null +++ b/examples/hildon-check-button-example.c @@ -0,0 +1,82 @@ +/* + * This file is a part of hildon examples + * + * Copyright (C) 2008 Nokia Corporation, all rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include + +static void +button_clicked_cb (GtkButton *button, + GtkLabel *label) +{ + gboolean active = hildon_check_button_get_active (button); + const gchar *labeltext = hildon_check_button_get_label (button); + char *text = g_strconcat (labeltext, active ? " (checked)" : " (unchecked)", NULL); + gtk_label_set_text (label, text); + g_free (text); +} + +int +main (int argc, + char **argv) +{ + GtkWidget *win; + GtkBox *vbox; + GtkWidget *label; + GtkWidget *table; + int i; + + gtk_init (&argc, &argv); + + win = gtk_window_new (GTK_WINDOW_TOPLEVEL); + vbox = GTK_BOX (gtk_vbox_new (FALSE, 10)); + table = gtk_table_new (3, 2, TRUE); + label = gtk_label_new ("none"); + + gtk_table_set_row_spacings (GTK_TABLE (table), 10); + gtk_table_set_col_spacings (GTK_TABLE (table), 10); + + gtk_box_pack_start (vbox, gtk_label_new ("Hildon check button example"), TRUE, TRUE, 0); + + for (i = 0; i < 6; i++) { + char *text; + GtkWidget *button = hildon_check_button_new (HILDON_SIZE_HALFSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT); + text = g_strdup_printf ("Button %d", i+1); + hildon_check_button_set_label (GTK_BUTTON (button), text); + g_free (text); + gtk_table_attach_defaults (GTK_TABLE (table), button, i/2, (i/2) + 1, i%2, (i%2) + 1); + g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), label); + } + + gtk_box_pack_start (vbox, table, TRUE, TRUE, 0); + gtk_box_pack_start (vbox, gtk_label_new ("Last clicked:"), TRUE, TRUE, 0); + gtk_box_pack_start (vbox, label, TRUE, TRUE, 0); + + gtk_container_set_border_width (GTK_CONTAINER (win), 20); + gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox)); + + g_signal_connect (win, "delete_event", G_CALLBACK (gtk_main_quit), NULL); + + gtk_widget_show_all (win); + + gtk_main (); + + return 0; +}