From d6f5005261fc9ef0978c9384d44984f901c8f079 Mon Sep 17 00:00:00 2001 From: PacketFiend Date: Mon, 22 Apr 2024 14:16:52 -0400 Subject: [PATCH] Add plaintext reveal/conceal button --- src/unlock.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/unlock.py b/src/unlock.py index ed7b3550..dbf79e51 100644 --- a/src/unlock.py +++ b/src/unlock.py @@ -97,11 +97,17 @@ def __init__(self): trackers.con_tracker_get().connect(self.auth_unlock_button, "clicked", self.on_unlock_clicked) - button_box.pack_start(self.auth_unlock_button, False, False, 4) status.focusWidgets = [self.password_entry, self.auth_unlock_button] + self.auth_reveal_password_button = TransparentButton("view-reveal-symbolic", Gtk.IconSize.LARGE_TOOLBAR) + trackers.con_tracker_get().connect(self.auth_reveal_password_button, + "clicked", + self.auth_reveal_password_clicked) + button_box.pack_start(self.auth_reveal_password_button, False, False, 4) + status.focusWidgets.append(self.auth_reveal_password_button) + if not settings.get_boolean("disable-user-switching"): self.auth_switch_button = TransparentButton("screensaver-switch-users-symbolic", Gtk.IconSize.LARGE_TOOLBAR) self.auth_switch_button.set_tooltip_text(_("Switch User")) @@ -288,6 +294,19 @@ def on_password_entry_button_press(self, widget, event): return Gdk.EVENT_PROPAGATE + def auth_reveal_password(self, widget, button=None): + """ + Reveals the plaintext password to the user" + """ + if self.password_entry.get_visibility() == False: + self.password_entry.set_visibility(True) + new_image = Gtk.Image.new_from_icon_name("view-conceal-symbolic", Gtk.IconSize.LARGE_TOOLBAR) + self.auth_reveal_password_button.set_image(new_image) + else: + self.password_entry.set_visibility(False) + new_image = Gtk.Image.new_from_icon_name("view-reveal-symbolic", Gtk.IconSize.LARGE_TOOLBAR) + self.auth_reveal_password_button.set_image(new_image) + def on_unlock_clicked(self, button=None): """ Callback for the unlock button. Activates the 'progress' animation @@ -318,6 +337,12 @@ def on_switch_user_clicked(self, widget): """ utils.do_user_switch() + def auth_reveal_password_clicked(self, widget): + """ + Callback for the auth-reveal-password button + """ + self.auth_reveal_password(self) + def clear_entry(self): """ Clear the password entry widget.