* 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
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,
- const gchar *message)
+ gpointer user_data)
{
+ gchar *message = NULL;
+
g_assert (GTK_IS_WIDGET (widget));
- hildon_banner_show_information (widget, NULL, message);
+ 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
* 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);
+ /* 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);
+ 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), (gpointer) message);
+ 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:
}
+/**
+ *
+ * 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);
+}
+
+
+
+