From e32b611286398cf31c8dfa0977beb723f68e190f Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Thu, 25 Jul 2024 13:16:26 -0400 Subject: [PATCH] unlock dialog: Allow password visibility to be toggled. --- .../cinnamon-screensaver-view-conceal.svg | 40 +++++++++++++++++++ .../cinnamon-screensaver-view-reveal.svg | 40 +++++++++++++++++++ src/passwordEntry.py | 17 ++++++-- 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 data/icons/hicolor/scalable/status/cinnamon-screensaver-view-conceal.svg create mode 100644 data/icons/hicolor/scalable/status/cinnamon-screensaver-view-reveal.svg diff --git a/data/icons/hicolor/scalable/status/cinnamon-screensaver-view-conceal.svg b/data/icons/hicolor/scalable/status/cinnamon-screensaver-view-conceal.svg new file mode 100644 index 000000000..a7167699f --- /dev/null +++ b/data/icons/hicolor/scalable/status/cinnamon-screensaver-view-conceal.svg @@ -0,0 +1,40 @@ + + + + + + diff --git a/data/icons/hicolor/scalable/status/cinnamon-screensaver-view-reveal.svg b/data/icons/hicolor/scalable/status/cinnamon-screensaver-view-reveal.svg new file mode 100644 index 000000000..8e8f9db9c --- /dev/null +++ b/data/icons/hicolor/scalable/status/cinnamon-screensaver-view-reveal.svg @@ -0,0 +1,40 @@ + + + + + + diff --git a/src/passwordEntry.py b/src/passwordEntry.py index 96fe004a3..42c15f4a8 100644 --- a/src/passwordEntry.py +++ b/src/passwordEntry.py @@ -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 @@ -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): """ @@ -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)