1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-04 23:51:17 +00:00

sip-account-widget: Add switch to display password

This commit is contained in:
Andrey Skvortsov 2022-02-27 22:17:27 +03:00
parent 1923d106c0
commit 86beb37e53
2 changed files with 41 additions and 0 deletions

View file

@ -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);
}

View file

@ -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>