[PATCHv2, tweaked a bit] Remove magic from the passphrase dialog (#921948)

Radek Vykydal rvykydal at redhat.com
Tue Sep 10 13:06:57 UTC 2013


Looks ok to me.

On 09/09/2013 09:36 AM, Vratislav Podzimek wrote:
> Playing with sensitivity and jumping between widgets based on equality of the
> password and confirmation entries is confusing and may cause problems. The
> confirmation entry cannot be clicked when the password entry is being eddited,
> only TAB works for switching into it. And jumping to the save button when the
> confirmation entry equals the password entry may lead in an incomplete password
> entered and "confirmed".
>
> Hitting ENTER in one of the entries may click the Save button if both entries
> have the same non-empty string.
>
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>   pyanaconda/ui/gui/spokes/lib/passphrase.glade |  2 ++
>   pyanaconda/ui/gui/spokes/lib/passphrase.py    | 34 ++++++++++-----------------
>   2 files changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.glade b/pyanaconda/ui/gui/spokes/lib/passphrase.glade
> index ccff718..731019a 100644
> --- a/pyanaconda/ui/gui/spokes/lib/passphrase.glade
> +++ b/pyanaconda/ui/gui/spokes/lib/passphrase.glade
> @@ -117,6 +117,7 @@
>                   <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="activate" handler="on_entry_activated" swapped="no"/>
>                 </object>
>                 <packing>
>                   <property name="left_attach">1</property>
> @@ -149,6 +150,7 @@
>                   <property name="invisible_char">●</property>
>                   <property name="width_chars">32</property>
>                   <signal name="changed" handler="on_confirm_changed" swapped="no"/>
> +                <signal name="activate" handler="on_entry_activated" swapped="no"/>
>                   <signal name="focus-out-event" handler="on_confirm_editing_done" swapped="no"/>
>                 </object>
>                 <packing>
> diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py
> index 83379ef..9c77c18 100644
> --- a/pyanaconda/ui/gui/spokes/lib/passphrase.py
> +++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py
> @@ -84,7 +84,6 @@ class PassphraseDialog(GUIObject):
>   
>           if not self.passphrase:
>               self._save_button.set_sensitive(False)
> -            self._confirm_entry.set_sensitive(False)
>   
>           self._passphrase_entry.set_text(self.passphrase)
>           self._confirm_entry.set_text(self.passphrase)
> @@ -129,37 +128,27 @@ class PassphraseDialog(GUIObject):
>   
>       def on_passphrase_changed(self, entry):
>           self._update_passphrase_strength()
> -        if self._confirm_entry.get_text():
> -            self._confirm_entry.set_text("")
> +        if entry.get_text() and entry.get_text() == self._confirm_entry.get_text():
>               self._set_entry_icon(self._confirm_entry, "", "")
> +            self._save_button.set_sensitive(True)
> +        else:
> +            self._save_button.set_sensitive(False)
>   
>           if not self._pwq_error:
>               self._set_entry_icon(entry, "", "")
>   
> -        self._save_button.set_sensitive(False)
> -        self._confirm_entry.set_sensitive(False)
> -
>       def on_passphrase_editing_done(self, entry, *args):
> -        sensitive = True
>           if self._pwq_error:
>               icon = "gtk-dialog-error"
>               msg = _(ERROR_WEAK) % self._pwq_error
> -            sensitive = False
>               self._set_entry_icon(entry, icon, msg)
>   
> -        self._confirm_entry.set_sensitive(sensitive)
> -        if sensitive:
> -            self._confirm_entry.grab_focus()
> -
> -        return True
> -
>       def on_confirm_changed(self, entry):
> -        if not self._save_button.get_sensitive() and \
> -           entry.get_text() == self._passphrase_entry.get_text():
> -            self._save_button.set_sensitive(True)
> -            self._save_button.grab_focus()
> -            self._save_button.grab_default()
> +        if entry.get_text() and entry.get_text() == self._passphrase_entry.get_text():
>               self._set_entry_icon(entry, "", "")
> +            self._save_button.set_sensitive(True)
> +        else:
> +            self._save_button.set_sensitive(False)
>   
>       def on_confirm_editing_done(self, entry, *args):
>           passphrase = self._passphrase_entry.get_text()
> @@ -170,9 +159,12 @@ class PassphraseDialog(GUIObject):
>               self._set_entry_icon(entry, icon, _(msg))
>               self._save_button.set_sensitive(False)
>           else:
> -            self._save_button.grab_focus()
> -            self._save_button.grab_default()
> +            self._set_entry_icon(entry, "", "")
>   
>       def on_save_clicked(self, button):
>           self.passphrase = self._passphrase_entry.get_text()
>   
> +    def on_entry_activated(self, entry):
> +        if self._save_button.get_sensitive() and \
> +           entry.get_text() == self._passphrase_entry.get_text():
> +            self._save_button.emit("clicked")



More information about the anaconda-patches mailing list