X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon-helper.c;h=22c5af8230268e10088d52d254a7ec32aaa7e51c;hb=82f05c50afc0d4bd363c7282011378656f2544ca;hp=b675f5cd1d6a626339b3c4eed7a3dc6eb17bf5fa;hpb=5c31147b11d0029cbf41445b50da58bff9241b00;p=hildon diff --git a/src/hildon-helper.c b/src/hildon-helper.c index b675f5c..22c5af8 100644 --- a/src/hildon-helper.c +++ b/src/hildon-helper.c @@ -8,7 +8,7 @@ * 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. + * 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 @@ -38,6 +38,7 @@ #include #include "hildon-helper.h" +#include "hildon-banner.h" #define HILDON_FINGER_PRESSURE_THRESHOLD 0.4 @@ -233,6 +234,33 @@ hildon_helper_set_logical_font (GtkWidget *widget, return signum; } +static GQuark +hildon_helper_insensitive_message_quark (void) +{ + static GQuark quark = 0; + + if (G_UNLIKELY (quark == 0)) + quark = g_quark_from_static_string ("hildon-insensitive-message"); + + return quark; +} + +static void +show_insensitive_message (GtkWidget *widget, + gpointer user_data) +{ + gchar *message = NULL; + + g_assert (GTK_IS_WIDGET (widget)); + + message = (gchar*) g_object_get_qdata (G_OBJECT (widget), + hildon_helper_insensitive_message_quark ()); + + if (message) + hildon_banner_show_information (widget, NULL, message); +} + + /** * hildon_helper_set_insensitive_message * @widget : A @GtkWidget to assign a banner to @@ -243,16 +271,58 @@ hildon_helper_set_logical_font (GtkWidget *widget, * using a standard @HildonBanner. * **/ + void hildon_helper_set_insensitive_message (GtkWidget *widget, const gchar *message) { g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (message != NULL); - g_warning ("FIXME: I'm not implemented yet!"); + /* Clean up any previous instance of the insensitive message */ + g_signal_handlers_disconnect_matched (G_OBJECT (widget), G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, + G_CALLBACK (show_insensitive_message), NULL); + + /* We need to dup the string because the pointer might not be valid when the + insensitive-press signal callback is executed */ + g_object_set_qdata_full (G_OBJECT (widget), hildon_helper_insensitive_message_quark (), + (gpointer)g_strdup (message), + g_free); + + if (message != NULL) { + g_signal_connect (G_OBJECT (widget), "insensitive-press", + G_CALLBACK (show_insensitive_message), NULL); + } } +/** + * hildon_helper_set_insensitive_messagef + * @widget : A @GtkWidget to assign a banner to + * @format : a printf-like format string + * @varargs : arguments for the format string + * + * A version of hildon_helper_set_insensitive_message with string formatting. + * + **/ + +void +hildon_helper_set_insensitive_messagef (GtkWidget *widget, + const gchar *format, + ...) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + gchar *message; + va_list args; + + va_start (args, format); + message = g_strdup_vprintf (format, args); + va_end (args); + + hildon_helper_set_insensitive_message (widget, message); + + g_free (message); +} /** * hildon_helper_set_logical_color: @@ -309,3 +379,30 @@ hildon_helper_set_logical_color (GtkWidget *widget, } +/** + * + * hildon_helper_set_thumb_scrollbar + * @win: A @GtkScrolledWindow to use as target + * @thumb: TRUE to enable the thumb scrollbar, FALSE to disable + * + * This function enables a thumb scrollbar on a given scrolled window. It'll convert the + * existing normal scrollbar into a larger, finger-usable scrollbar that works without a stylus. + * As fingerable list rows are fairly high, consider using the whole available vertical space + * of your application for the content in order to have as many rows as possible + * visible on the screen at once. + * + * Finger-Sized scrollbar should always be used together with finger-sized content. + **/ +void +hildon_helper_set_thumb_scrollbar (GtkScrolledWindow *win, + gboolean thumb) +{ + g_return_if_fail (GTK_IS_SCROLLED_WINDOW (win)); + + if (win->vscrollbar) + gtk_widget_set_name (win->vscrollbar, (thumb) ? "hildon-thumb-scrollbar" : NULL); +} + + + +