[PATCH 3/3] Short-circuit Storage spoke leaving when no changes were done

David Lehman dlehman at redhat.com
Tue Sep 16 01:47:19 UTC 2014


On 09/11/2014 09:05 AM, Vratislav Podzimek wrote:
> If user changes nothing in the Storage spoke and hits "Done" we should consider
> that a request to just leave the spoke with no changes.

One comment at the end...

>
> Related: rhbz#1085201
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>   pyanaconda/ui/gui/spokes/storage.py | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
> index 2a48fca..ac90281 100644
> --- a/pyanaconda/ui/gui/spokes/storage.py
> +++ b/pyanaconda/ui/gui/spokes/storage.py
> @@ -270,6 +270,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>                               target=self.run_dasdfmt))
>
>           self._previous_autopart = False
> +        self._previous_selected = None
> +        self._previous_encrypted = None
> +        self._previous_reclaim = None
>
>           self._last_clicked_overview = None
>           self._cur_clicked_overview = None
> @@ -310,6 +313,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>
>       @gtk_action_nowait
>       def execute(self):
> +        if not self._any_change:
> +            return
> +
>           # Spawn storage execution as a separate thread so there's no big delay
>           # going back from this spoke to the hub while StorageChecker.run runs.
>           # Yes, this means there's a thread spawning another thread.  Sorry.
> @@ -400,6 +406,13 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>           return filter(lambda child: isinstance(child, AnacondaWidgets.DiskOverview),
>                         self.specialized_disks_box.get_children())
>
> +    @property
> +    def _any_change(self):
> +        return not(self._previous_autopart is self.autopart and
> +                   self._previous_encrypted is self.encrypted and
> +                   self._previous_reclaim is self._reclaim.get_active() and
> +                   set(self._previous_selected) == set(self.selected_disks))
> +
>       def _on_disk_clicked(self, overview, event):
>           # This handler only runs for these two kinds of events, and only for
>           # activate-type keys (space, enter) in the latter event's case.
> @@ -474,6 +487,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>           self.passphrase = self.data.autopart.passphrase
>
>           self._previous_autopart = self.autopart
> +        self._previous_encrypted = self.encrypted
> +        self._previous_selected = self.selected_disks[:]
> +        self._previous_reclaim = self._reclaim.get_active()
>
>           # First, remove all non-button children.
>           for child in self.localOverviews + self.advancedOverviews:
> @@ -718,6 +734,11 @@ class StorageSpoke(NormalSpoke, StorageChecker):
>           # user might want to change settings presented in the dialogs shown from
>           # within this method.
>
> +        # check if something has changed preventing issues with None == False
> +        if not self._any_change:
> +            # nothing changed, nothing to do
> +            NormalSpoke.on_back_clicked(self, button)
> +            return

This doesn't take into account the possibility that the user wants to 
redo custom storage without changing any of the settings on the main 
storage spoke. Otherwise I like this one.

David


>
>           # hide/unhide disks as requested
>           for disk in self.disks:
>



More information about the anaconda-patches mailing list