Example for the insensitive message setting. Insensitive implementation by Xan Lopez.
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Mon, 5 Feb 2007 15:16:54 +0000 (15:16 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Mon, 5 Feb 2007 15:16:54 +0000 (15:16 +0000)
ChangeLog.2
examples/Makefile.am
examples/hildon-insensitive-example.c [new file with mode: 0644]
src/hildon-helper.c

index c105209..1551853 100644 (file)
@@ -1,5 +1,13 @@
 2007-02-05  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
+       * 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  <michael.kostrzewa@nokia.com> 
+
        * 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.
index 9fea62a..97b4add 100644 (file)
@@ -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 (file)
index 0000000..fedcc96
--- /dev/null
@@ -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 <michael.kostrzewa@nokia.com>
+ *
+ * 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                                        <stdio.h>
+#include                                        <stdlib.h>
+#include                                        <glib.h>
+#include                                        <gtk/gtk.h>
+#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;
+}
+
+
index b675f5c..839693a 100644 (file)
@@ -38,6 +38,7 @@
 
 #include                                        <gtk/gtk.h>
 #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);
+    }
 }