summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-10-16 11:24:05 +0200
committerraveit65 <[email protected]>2020-11-10 23:03:31 +0100
commitaecd77af5eaf347f6ed8ecc7527431a125ebc2b0 (patch)
tree61013723782578bcfaeb0e23f50eda48af66194f /src
parent02881e81a290b630b8a2b7afe35376e1ea185ba8 (diff)
downloadmate-screensaver-aecd77af5eaf347f6ed8ecc7527431a125ebc2b0.tar.bz2
mate-screensaver-aecd77af5eaf347f6ed8ecc7527431a125ebc2b0.tar.xz
Add Show/Hide password emblem in password entry
Diffstat (limited to 'src')
-rw-r--r--src/gs-lock-plug.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 67b83f3..3283302 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -2104,6 +2104,30 @@ on_note_text_buffer_changed (GtkTextBuffer *buffer,
}
static void
+entry_icon_clicked (GtkEntry *entry,
+ gint position,
+ GdkEventButton *event,
+ gpointer data)
+{
+ (void)data;
+
+ if ((position == GTK_ENTRY_ICON_SECONDARY) && (event->type == GDK_DOUBLE_BUTTON_PRESS))
+ {
+ if (g_strcmp0 (gtk_entry_get_icon_name (entry, position), "emblem-readonly"))
+ {
+ gtk_entry_set_icon_from_icon_name (entry, position, "emblem-readonly");
+ gtk_entry_set_icon_tooltip_text (entry, position, _("Show password"));
+ gtk_entry_set_visibility (entry, FALSE);
+ }
+ else
+ {
+ gtk_entry_set_icon_from_icon_name (entry, position, "emblem-unreadable");
+ gtk_entry_set_icon_tooltip_text (entry, position, _("Hide password"));
+ gtk_entry_set_visibility (entry, TRUE);
+ }
+ }
+}
+static void
gs_lock_plug_init (GSLockPlug *plug)
{
gs_profile_start (NULL);
@@ -2239,6 +2263,10 @@ gs_lock_plug_init (GSLockPlug *plug)
gtk_entry_set_activates_default (GTK_ENTRY (plug->priv->auth_prompt_entry), TRUE);
gtk_entry_set_visibility (GTK_ENTRY (plug->priv->auth_prompt_entry), FALSE);
+ /* show/hide password */
+ g_signal_connect (plug->priv->auth_prompt_entry, "icon-press",
+ G_CALLBACK (entry_icon_clicked), NULL);
+
g_signal_connect (plug->priv->auth_unlock_button, "clicked",
G_CALLBACK (unlock_button_clicked), plug);