[empathy] Add clear icon in entry containing password (#608104)
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Add clear icon in entry containing password (#608104)
- Date: Tue, 30 Mar 2010 10:53:28 +0000 (UTC)
commit 34667825a2bf494807755558b33e58512db5caee
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Mar 16 16:34:58 2010 +0100
Add clear icon in entry containing password (#608104)
libempathy-gtk/empathy-account-widget.c | 42 +++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 733fa38..1c20e9f 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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]