aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-16 23:34:58 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-30 18:53:16 +0800
commit34667825a2bf494807755558b33e58512db5caee (patch)
tree7c3c7d5e662e16939b0f5cc89c1cd83925ad2df8
parentea4d3e69aa11e413f83e418ea640cab31ac07269 (diff)
downloadgsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.tar
gsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.tar.gz
gsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.tar.bz2
gsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.tar.lz
gsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.tar.xz
gsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.tar.zst
gsoc2013-empathy-34667825a2bf494807755558b33e58512db5caee.zip
Add clear icon in entry containing password (#608104)
-rw-r--r--libempathy-gtk/empathy-account-widget.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 733fa383b..1c20e9fe3 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -355,6 +355,36 @@ account_widget_combobox_changed_cb (GtkWidget *widget,
empathy_account_widget_changed (self);
}
+static void
+clear_icon_released_cb (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ const gchar *param_name;
+
+ param_name = g_object_get_data (G_OBJECT (entry), "param_name");
+
+ DEBUG ("Unset %s", param_name);
+ empathy_account_settings_unset (priv->settings, param_name);
+ gtk_entry_set_text (entry, "");
+
+ empathy_account_widget_changed (self);
+}
+
+static void
+password_entry_changed_cb (GtkEditable *entry,
+ EmpathyAccountWidget *self)
+{
+ const gchar *str;
+
+ str = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
+}
+
void
empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
GtkWidget *widget,
@@ -419,6 +449,18 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
if (strstr (param_name, "password"))
{
gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
+
+ /* Add 'clear' icon */
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (widget),
+ GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (widget),
+ GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
+
+ g_signal_connect (widget, "icon-release",
+ G_CALLBACK (clear_icon_released_cb), self);
+ g_signal_connect (widget, "changed",
+ G_CALLBACK (password_entry_changed_cb), self);
}
g_signal_connect (widget, "changed",