[PATCH] Fix environment group changes based on ListBox row activation
Vratislav Podzimek
vpodzime at redhat.com
Wed Mar 12 06:52:16 UTC 2014
On Tue, 2014-03-11 at 16:52 -0400, David Shea wrote:
> i.e., clicking somewhere in the environment row that isn't the radio
> button. When we call button.set_active in on_environment_activated, two
> button toggles are emitted: the one for the button becoming active,
> which we block, and the one for the button becoming inactive, which was
> causing us to reactivate the inactive row. Using "clicked" handlers
> instead of "toggled" handlers was probably supposed to get around this,
> but buttons going inactive receive a "clicked" signal as well, because
> nothing means anything.
>
> Switch the button signal handlers to connect to "toggled" instead of
> "clicked" to ensure consistent behavior with the set_active calls,
> use separate the toggled handlers for the environment radio buttons and
> the addon check buttons, and ignore any radio button toggle that is
> toggling to an inactive state. Toggle toggle toggle.
> ---
> pyanaconda/ui/gui/spokes/software.py | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
> index 143b15b..322f8ca 100644
> --- a/pyanaconda/ui/gui/spokes/software.py
> +++ b/pyanaconda/ui/gui/spokes/software.py
> @@ -262,12 +262,12 @@ class SoftwareSelectionSpoke(NormalSpoke):
> hubQ.send_message(self.__class__.__name__, _("No installation source available"))
> return False
>
> - def _add_row(self, listbox, name, desc, button):
> + def _add_row(self, listbox, name, desc, button, clicked):
> row = Gtk.ListBoxRow()
> box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
>
> button.set_valign(Gtk.Align.START)
> - button.connect("clicked", self.on_button_toggled, row)
> + button.connect("toggled", clicked, row)
> box.add(button)
>
> label = Gtk.Label(label="<b>%s</b>\n%s" % (escape_markup(name), escape_markup(desc)),
> @@ -302,7 +302,8 @@ class SoftwareSelectionSpoke(NormalSpoke):
> if active:
> self.environment = environment
>
> - self._add_row(self._environmentListBox, name, desc, radio)
> + self._add_row(self._environmentListBox, name, desc, radio,
> + self.on_radio_button_toggled)
> firstRadio = firstRadio or radio
>
> firstEnvironment = False
> @@ -327,7 +328,7 @@ class SoftwareSelectionSpoke(NormalSpoke):
>
> check = Gtk.CheckButton()
> check.set_active(selected)
> - self._add_row(self._addonListBox, name, desc, check)
> + self._add_row(self._addonListBox, name, desc, check, self.on_checkbox_toggled)
>
> def refreshAddons(self):
> if self.environment and (self.environment in self.payload.environmentAddons):
> @@ -402,7 +403,13 @@ class SoftwareSelectionSpoke(NormalSpoke):
> return self._tx_id == self.payload.txID
>
> # Signal handlers
> - def on_button_toggled(self, radio, row):
> + def on_checkbox_toggled(self, button, row):
> + row.activate()
> +
> + def on_radio_button_toggled(self, radio, row):
> + # If the radio button toggled to inactive, don't reactivate the row
> + if not radio.get_active():
> + return
> row.activate()
>
> def on_environment_activated(self, listbox, row):
> @@ -412,9 +419,9 @@ class SoftwareSelectionSpoke(NormalSpoke):
> box = row.get_children()[0]
> button = box.get_children()[0]
>
> - button.handler_block_by_func(self.on_button_toggled)
> - button.set_active(not button.get_active())
> - button.handler_unblock_by_func(self.on_button_toggled)
> + button.handler_block_by_func(self.on_radio_button_toggled)
> + button.set_active(True)
> + button.handler_unblock_by_func(self.on_radio_button_toggled)
>
> # Remove all the groups that were selected by the previously
> # selected environment.
> @@ -438,9 +445,9 @@ class SoftwareSelectionSpoke(NormalSpoke):
>
> wasActive = group in self.selectedGroups
>
> - button.handler_block_by_func(self.on_button_toggled)
> + button.handler_block_by_func(self.on_checkbox_toggled)
> button.set_active(not wasActive)
> - button.handler_unblock_by_func(self.on_button_toggled)
> + button.handler_unblock_by_func(self.on_checkbox_toggled)
ACK.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list