From 04bcee1fb440b3196d09a7ceaeaa97462b959e8f Mon Sep 17 00:00:00 2001 From: Michael Dominic Kostrzewa Date: Mon, 5 Feb 2007 15:16:54 +0000 Subject: [PATCH] Example for the insensitive message setting. Insensitive implementation by Xan Lopez. --- ChangeLog.2 | 8 +++++ examples/Makefile.am | 9 +++++- examples/hildon-insensitive-example.c | 53 +++++++++++++++++++++++++++++++++ src/hildon-helper.c | 19 +++++++++++- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 examples/hildon-insensitive-example.c diff --git a/ChangeLog.2 b/ChangeLog.2 index c105209..1551853 100644 --- a/ChangeLog.2 +++ b/ChangeLog.2 @@ -1,5 +1,13 @@ 2007-02-05 Michael Dominic Kostrzewa + * examples/Makefile.am: + * examples/hildon-insensitive-example.c: Example for the insensitive + message setting. + + * src/hildon-helper.c: Insensitive implementation by Xan Lopez. + +2007-02-05 Michael Dominic Kostrzewa + * examples/hildon-controlbar-example.c: * src/hildon-controlbar.c: Fixing the controlbar to behave as if minimal-bars-visible (old 2.6 mod) was equal 1. diff --git a/examples/Makefile.am b/examples/Makefile.am index 9fea62a..97b4add 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -13,7 +13,8 @@ noinst_PROGRAMS = hildon-window-example \ hildon-color-button-example \ hildon-login-dialog-example \ hildon-time-editor-example \ - hildon-icon-sizes-example + hildon-icon-sizes-example \ + hildon-insensitive-example # HIldon window hildon_window_example_LDADD = $(HILDON_OBJ_LIBS) @@ -80,4 +81,10 @@ hildon_icon_sizes_example_LDADD = $(HILDON_OBJ_LIBS) hildon_icon_sizes_example_CFLAGS = $(HILDON_OBJ_CFLAGS) hildon_icon_sizes_example_SOURCES = hildon-icon-sizes-example.c +# HIldon insensitive example +hildon_insensitive_example_LDADD = $(HILDON_OBJ_LIBS) +hildon_insensitive_example_CFLAGS = $(HILDON_OBJ_CFLAGS) +hildon_insensitive_example_SOURCES = hildon-insensitive-example.c + + endif diff --git a/examples/hildon-insensitive-example.c b/examples/hildon-insensitive-example.c new file mode 100644 index 0000000..fedcc96 --- /dev/null +++ b/examples/hildon-insensitive-example.c @@ -0,0 +1,53 @@ +/* + * This file is a part of hildon examples + * + * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved. + * + * Author: Michael Dominic Kostrzewa + * + * 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. + * + * 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 +#include +#include +#include +#include "hildon.h" + +int +main (int argc, + char **args) +{ + gtk_init (&argc, &args); + + GtkDialog *dialog = GTK_DIALOG (gtk_dialog_new ()); + GtkWidget *button = gtk_button_new_with_label ("Click me"); + + hildon_helper_set_insensitive_message (button, "Do not poke me!"); + gtk_widget_set_sensitive (button, FALSE); + + gtk_box_pack_start (GTK_BOX (dialog->vbox), button, TRUE, TRUE, 0); + + gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CLOSE); + + gtk_widget_show_all (GTK_WIDGET (dialog)); + gtk_dialog_run (dialog); + + return 0; +} + + diff --git a/src/hildon-helper.c b/src/hildon-helper.c index b675f5c..839693a 100644 --- a/src/hildon-helper.c +++ b/src/hildon-helper.c @@ -38,6 +38,7 @@ #include #include "hildon-helper.h" +#include "hildon-banner.h" #define HILDON_FINGER_PRESSURE_THRESHOLD 0.4 @@ -233,6 +234,15 @@ hildon_helper_set_logical_font (GtkWidget *widget, return signum; } +static void +show_insensitive_message (GtkWidget *widget, + const gchar *message) +{ + g_assert (GTK_IS_WIDGET (widget)); + + hildon_banner_show_information (widget, NULL, message); +} + /** * hildon_helper_set_insensitive_message * @widget : A @GtkWidget to assign a banner to @@ -250,7 +260,14 @@ hildon_helper_set_insensitive_message (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (message != NULL); - g_warning ("FIXME: I'm not implemented yet!"); + g_signal_handlers_disconnect_matched (G_OBJECT (widget), G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, + G_CALLBACK (show_insensitive_message), NULL); + + if (message != NULL) { + g_signal_connect (G_OBJECT (widget), "insensitive-press", + G_CALLBACK (show_insensitive_message), (gpointer) message); + } } -- 1.7.9.5