[PATCH] Add signal handlers for controlling password entry visibility.
Chris Lumens
clumens at redhat.com
Tue Apr 9 19:43:49 UTC 2013
It'd be nice to have passwords readable when editing them, and then hidden
when done editing. Since this is a thing we might want to do all over the
place, I've added signal handlers pretty high up in the object hierarchy.
---
pyanaconda/ui/gui/__init__.py | 18 ++++++++++++++++++
pyanaconda/ui/gui/spokes/custom.glade | 2 ++
pyanaconda/ui/gui/spokes/lib/passphrase.glade | 4 ++++
pyanaconda/ui/gui/spokes/lib/passphrase.py | 2 +-
pyanaconda/ui/gui/spokes/password.glade | 4 ++++
pyanaconda/ui/gui/spokes/source.glade | 4 ++++
pyanaconda/ui/gui/spokes/user.glade | 4 ++++
7 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index f8efb7f..1a5a3b5 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -198,6 +198,24 @@ class GUIObject(common.UIObject):
"""
self.window.set_warning(msg)
+ def on_password_focused(self, entry, event, *args):
+ """When a password entry is focused, this callback allows for showing
+ the contents of the entry. Along with on_password_unfocused, this
+ has the effect of hiding the entry when the user's not directly
+ editing it, and showing it when they are.
+ """
+ entry.set_visibility(True)
+ return False
+
+ def on_password_unfocused(self, entry, event, *args):
+ """When a password entry is unfocused, this callback allows for hiding
+ the contents of the entry. Along with on_password_focused, this
+ has the effect of hiding the entry when the user's not directly
+ editing it, and showing it when they are.
+ """
+ entry.set_visibility(False)
+ return False
+
class QuitDialog(GUIObject):
builderObjects = ["quitDialog"]
mainWidgetName = "quitDialog"
diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index a91e505..e400211 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -1072,6 +1072,8 @@ until you click on the main menu's 'Begin Installation' button.</property>
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<accelerator key="p" signal="grab-focus" modifiers="GDK_MOD1_MASK"/>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.glade b/pyanaconda/ui/gui/spokes/lib/passphrase.glade
index cb08899..145ba71 100644
--- a/pyanaconda/ui/gui/spokes/lib/passphrase.glade
+++ b/pyanaconda/ui/gui/spokes/lib/passphrase.glade
@@ -116,6 +116,8 @@
<property name="width_chars">32</property>
<signal name="changed" handler="on_passphrase_changed" swapped="no"/>
<signal name="focus-out-event" handler="on_passphrase_editing_done" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -149,6 +151,8 @@
<property name="width_chars">32</property>
<signal name="changed" handler="on_confirm_changed" swapped="no"/>
<signal name="focus-out-event" handler="on_confirm_editing_done" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py
index ecf2484..3ae8616 100644
--- a/pyanaconda/ui/gui/spokes/lib/passphrase.py
+++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py
@@ -155,7 +155,7 @@ class PassphraseDialog(GUIObject):
if sensitive:
self._confirm_entry.grab_focus()
- return True
+ return False
def on_confirm_changed(self, entry):
if not self._save_button.get_sensitive() and \
diff --git a/pyanaconda/ui/gui/spokes/password.glade b/pyanaconda/ui/gui/spokes/password.glade
index 75ac957..7670f09 100644
--- a/pyanaconda/ui/gui/spokes/password.glade
+++ b/pyanaconda/ui/gui/spokes/password.glade
@@ -85,6 +85,8 @@
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">●</property>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -100,6 +102,8 @@
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<property name="activates_default">True</property>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/pyanaconda/ui/gui/spokes/source.glade b/pyanaconda/ui/gui/spokes/source.glade
index 44cd9e3..78ec539 100644
--- a/pyanaconda/ui/gui/spokes/source.glade
+++ b/pyanaconda/ui/gui/spokes/source.glade
@@ -437,6 +437,8 @@
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">●</property>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1149,6 +1151,8 @@
<property name="invisible_char">●</property>
<property name="invisible_char_set">True</property>
<signal name="changed" handler="on_repoProxy_changed" swapped="no"/>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/pyanaconda/ui/gui/spokes/user.glade b/pyanaconda/ui/gui/spokes/user.glade
index 64098b3..60b1a7b 100644
--- a/pyanaconda/ui/gui/spokes/user.glade
+++ b/pyanaconda/ui/gui/spokes/user.glade
@@ -173,6 +173,8 @@
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="_checkPassword" swapped="no"/>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -188,6 +190,8 @@
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<signal name="changed" handler="_checkPassword" swapped="no"/>
+ <signal name="focus-in-event" handler="on_password_focused" swapped="no"/>
+ <signal name="focus-out-event" handler="on_password_unfocused" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
--
1.8.1.2
More information about the anaconda-patches
mailing list