[calls] sip-account-widget: Add switch to display password
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] sip-account-widget: Add switch to display password
- Date: Tue, 29 Mar 2022 13:37:15 +0000 (UTC)
commit 86beb37e53b8d85a203fad8bef3043d97fe58ddc
Author: Andrey Skvortsov <andrej skvortzov gmail com>
Date: Sun Feb 27 22:17:27 2022 +0300
sip-account-widget: Add switch to display password
plugins/sip/calls-sip-account-widget.c | 36 ++++++++++++++++++++++++++++++++++
plugins/sip/sip-account-widget.ui | 5 +++++
2 files changed, 41 insertions(+)
---
diff --git a/plugins/sip/calls-sip-account-widget.c b/plugins/sip/calls-sip-account-widget.c
index 92194669..e93df376 100644
--- a/plugins/sip/calls-sip-account-widget.c
+++ b/plugins/sip/calls-sip-account-widget.c
@@ -119,6 +119,40 @@ on_user_changed (CallsSipAccountWidget *self)
}
+static void
+set_password_visibility (CallsSipAccountWidget *self, gboolean visible)
+{
+ const char* icon_name;
+
+ g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self));
+ g_assert (GTK_IS_ENTRY (self->password));
+
+ icon_name = visible ?
+ "view-conceal-symbolic" :
+ "view-reveal-symbolic";
+
+ gtk_entry_set_visibility (self->password, visible);
+ gtk_entry_set_icon_from_icon_name (self->password, GTK_ENTRY_ICON_SECONDARY,
+ icon_name);
+}
+
+
+static void
+on_password_visibility_changed(CallsSipAccountWidget *self,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ GtkEntry *entry)
+{
+ gboolean visible;
+
+ g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self));
+ g_assert (GTK_IS_ENTRY (entry));
+ g_assert (icon_pos == GTK_ENTRY_ICON_SECONDARY);
+
+ visible = !gtk_entry_get_visibility (entry);
+ set_password_visibility (self, visible);
+}
+
/*
* Stop "insert-text" signal emission if any undesired port
* value occurs
@@ -327,6 +361,7 @@ edit_form (CallsSipAccountWidget *self,
gtk_entry_set_text (self->display_name, display_name ?: "");
gtk_entry_set_text (self->user, user);
gtk_entry_set_text (self->password, password);
+ set_password_visibility (self, FALSE);
gtk_entry_set_text (self->port, port_str);
hdy_combo_row_set_selected_index (self->protocol, protocol_index);
gtk_switch_set_state (self->tel_switch, can_tel);
@@ -515,6 +550,7 @@ calls_sip_account_widget_class_init (CallsSipAccountWidgetClass *klass)
gtk_widget_class_bind_template_callback (widget_class, on_delete_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_apply_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_user_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_password_visibility_changed);
gtk_widget_class_bind_template_callback (widget_class, on_port_entry_insert_text);
gtk_widget_class_bind_template_callback (widget_class, on_port_entry_after_insert_text);
}
diff --git a/plugins/sip/sip-account-widget.ui b/plugins/sip/sip-account-widget.ui
index b7cf477a..3b9ba577 100644
--- a/plugins/sip/sip-account-widget.ui
+++ b/plugins/sip/sip-account-widget.ui
@@ -145,7 +145,12 @@
<property name="valign">center</property>
<property name="input-purpose">password</property>
<property name="visibility">False</property>
+ <property name="primary_icon_sensitive">False</property>
+ <property name="secondary_icon_activatable">True</property>
+ <property name="secondary_icon_name">view-reveal-symbolic</property>
+ <property name="secondary_icon_sensitive">True</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
+ <signal name="icon-press" handler="on_password_visibility_changed" swapped="yes"/>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]