[accounts-dialog] Make tooltip appear on click
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [accounts-dialog] Make tooltip appear on click
- Date: Wed, 27 Jan 2010 04:16:09 +0000 (UTC)
commit 79ec2b5782d658995ca096d669d615728e5db0db
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 26 23:13:54 2010 -0500
Make tooltip appear on click
src/um-account-dialog.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/um-account-dialog.c b/src/um-account-dialog.c
index 87887a2..d9135e5 100644
--- a/src/um-account-dialog.c
+++ b/src/um-account-dialog.c
@@ -128,6 +128,46 @@ is_shortname_used (const gchar *shortname)
return pwent != NULL;
}
+static gboolean
+query_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ gpointer user_data)
+{
+ gchar *tip;
+
+ if (GTK_ENTRY_ICON_SECONDARY == gtk_entry_get_icon_at_pos (GTK_ENTRY (widget), x, y)) {
+ tip = gtk_entry_get_icon_tooltip_text (GTK_ENTRY (widget),
+ GTK_ENTRY_ICON_SECONDARY);
+ gtk_tooltip_set_text (tooltip, tip);
+ g_free (tip);
+
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+static void
+icon_released (GtkEntry *entry,
+ GtkEntryIconPosition pos,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GtkSettings *settings;
+ gint timeout;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (entry));
+
+ g_object_get (settings, "gtk-tooltip-timeout", &timeout, NULL);
+ g_object_set (settings, "gtk-tooltip-timeout", 1, NULL);
+ gtk_tooltip_trigger_tooltip_query (gtk_widget_get_display (GTK_WIDGET (entry)));
+ g_object_set (settings, "gtk-tooltip-timeout", timeout, NULL);
+}
+
static void
shortname_changed (GtkComboBox *combo,
UmAccountDialog *um)
@@ -168,6 +208,14 @@ shortname_changed (GtkComboBox *combo,
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
GTK_STOCK_DIALOG_ERROR);
+ gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ TRUE);
+ g_signal_connect (entry, "icon-release",
+ G_CALLBACK (icon_released), FALSE);
+ g_signal_connect (entry, "query-tooltip",
+ G_CALLBACK (query_tooltip), NULL);
+
if (in_use) {
tip = g_strdup_printf (_("A user with the short name '%s' already exists."),
shortname);
@@ -182,12 +230,14 @@ shortname_changed (GtkComboBox *combo,
" \xe2\x9e\xa3 any of the characters '.', '-' and '_'"));
}
+ g_object_set (entry, "has-tooltip", TRUE, NULL);
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
tip);
g_free (tip);
}
else {
+ g_object_set (entry, "has-tooltip", FALSE, NULL);
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]