Skip to content

Commit

Permalink
unlock dialog: Allow password visibility to be toggled.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwebster committed Jul 25, 2024
1 parent f54ad03 commit e32b611
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions src/passwordEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self):
self.set_placeholder_text (placeholder_text)
self.set_can_default(True)

self.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, "cinnamon-screensaver-view-reveal")
trackers.con_tracker_get().connect(self, "icon-press", self.on_icon_pressed)

self.placeholder_text = placeholder_text
self.current_icon_name = None
self.current_flag_id = 0
Expand Down Expand Up @@ -174,6 +177,16 @@ def on_config_changed(self, controller):
def on_icon_pressed(self, entry, icon_pos, event):
if icon_pos == Gtk.EntryIconPosition.PRIMARY:
self.keyboard_controller.next_group()
elif icon_pos == Gtk.EntryIconPosition.SECONDARY:
if self.get_input_purpose() == Gtk.InputPurpose.FREE_FORM:
self.set_visibility(False)
self.set_input_purpose(Gtk.InputPurpose.PASSWORD)
self.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, "cinnamon-screensaver-view-reveal")
else:
self.set_visibility(True)
self.set_input_purpose(Gtk.InputPurpose.FREE_FORM)
self.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, "cinnamon-screensaver-view-conceal")
self.queue_draw()

def update_layout_icon(self):
"""
Expand Down Expand Up @@ -222,10 +235,6 @@ def set_lockscreen_keyboard_layout(self):
self.update_saved_group(new_group)
self.update_layout_icon()

trackers.con_tracker_get().connect(self,
"icon-press",
self.on_icon_pressed)

trackers.con_tracker_get().connect(self,
"draw",
self.on_draw)
Expand Down

0 comments on commit e32b611

Please sign in to comment.