Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plaintext reveal/conceal button #455

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Loading