summaryrefslogtreecommitdiff
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
parent02881e81a290b630b8a2b7afe35376e1ea185ba8 (diff)
downloadmate-screensaver-aecd77af5eaf347f6ed8ecc7527431a125ebc2b0.tar.bz2
mate-screensaver-aecd77af5eaf347f6ed8ecc7527431a125ebc2b0.tar.xz
Add Show/Hide password emblem in password entry
-rw-r--r--data/lock-dialog-default.ui5
-rw-r--r--src/gs-lock-plug.c28
2 files changed, 31 insertions, 2 deletions
diff --git a/data/lock-dialog-default.ui b/data/lock-dialog-default.ui
index dc4e51d..4ae6fc6 100644
--- a/data/lock-dialog-default.ui
+++ b/data/lock-dialog-default.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<object class="GtkFrame" id="lock-dialog">
@@ -151,8 +151,9 @@
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="activates_default">True</property>
+ <property name="secondary_icon_name">emblem-readonly</property>
<property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
+ <property name="secondary_icon_tooltip_text" translatable="yes">Show password</property>
<property name="input_purpose">password</property>
</object>
<packing>
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);