From: David Shea dshea@redhat.com
Use different signal handlers for different widgets in the advanced user dialog so that unrelated portions of the UI do not need to be checked for every change. Remove an unnecessary call to the advanced user button signal handler that is handled by the initial state of the dialog. Use the arguments passed in to the signal handlers. --- pyanaconda/ui/gui/spokes/advanced_user.glade | 4 ++-- pyanaconda/ui/gui/spokes/user.py | 28 ++++++++++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/advanced_user.glade b/pyanaconda/ui/gui/spokes/advanced_user.glade index 8bec496..c2252d6 100644 --- a/pyanaconda/ui/gui/spokes/advanced_user.glade +++ b/pyanaconda/ui/gui/spokes/advanced_user.glade @@ -165,7 +165,7 @@ <property name="xalign">0</property> <property name="draw_indicator">True</property> <signal name="mnemonic-activate" handler="on_uid_mnemonic_activate" swapped="no"/> - <signal name="toggled" handler="_apply_checkboxes" swapped="no"/> + <signal name="toggled" handler="on_uid_checkbox_toggled" swapped="no"/> </object> <packing> <property name="left_attach">0</property> @@ -182,7 +182,7 @@ <property name="xalign">0</property> <property name="draw_indicator">True</property> <signal name="mnemonic-activate" handler="on_gid_mnemonic_activate" swapped="no"/> - <signal name="toggled" handler="_apply_checkboxes" swapped="no"/> + <signal name="toggled" handler="on_gid_checkbox_toggled" swapped="no"/> </object> <packing> <property name="left_attach">0</property> diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py index 317aeba..5c20e3e 100644 --- a/pyanaconda/ui/gui/spokes/user.py +++ b/pyanaconda/ui/gui/spokes/user.py @@ -99,17 +99,6 @@ def initialize(self): # Validate the group input box self.add_check(self._tGroups, self._validateGroups)
- def _apply_checkboxes(self, _editable=None, data=None): - """Update the state of this screen according to the - checkbox states on the screen. It is called from - the toggled Gtk event. - """ - c_uid = self._cUid.get_active() - c_gid = self._cGid.get_active() - - self._spinUid.set_sensitive(c_uid) - self._spinGid.set_sensitive(c_gid) - def refresh(self): if self._user.homedir: homedir = self._user.homedir @@ -121,7 +110,6 @@ def refresh(self):
self._cUid.set_active(bool(self._user.uid)) self._cGid.set_active(bool(self._user.gid)) - self._apply_checkboxes()
self._spinUid.update() self._spinGid.update() @@ -170,6 +158,14 @@ def run(self): self.window.hide() return rc
+ def on_uid_checkbox_toggled(self, togglebutton, data=None): + # Set the UID spinner sensitivity based on the UID checkbox + self._spinUid.set_sensitive(togglebutton.get_active()) + + def on_gid_checkbox_toggled(self, togglebutton, data=None): + # Same as above, for GID + self._spinGid.set_sensitive(togglebutton.get_active()) + def on_uid_mnemonic_activate(self, widget, group_cycling, user_data=None): # If this is the only widget with the mnemonic (group_cycling is False), # and the checkbox is not currently toggled, toggle the checkbox and @@ -427,8 +423,8 @@ def usepassword_toggled(self, togglebutton=None, data=None): """Called by Gtk callback when the "Use password" check button is toggled. It will make password entries in/sensitive."""
- self.pw.set_sensitive(self.usepassword.get_active()) - self.confirm.set_sensitive(self.usepassword.get_active()) + self.pw.set_sensitive(togglebutton.get_active()) + self.confirm.set_sensitive(togglebutton.get_active())
# Re-check the password self.pw.emit("changed") @@ -467,11 +463,11 @@ def username_changed(self, editable, data=None): self.pw.emit("changed") self.confirm.emit("changed")
- def full_name_changed(self, editable=None, data=None): + def full_name_changed(self, editable, data=None): """Called by Gtk callback when the full name field changes."""
if self.guesser: - fullname = self.fullname.get_text() + fullname = editable.get_text() username = guess_username(fullname)
with blockedHandler(self.username, self.on_username_set_by_user):