[master][PATCH] Use human readable sizes with two decimal spaces in the GUI

Martin Kolman mkolman at redhat.com
Wed Apr 23 11:44:57 UTC 2014


On Wed, 2014-04-16 at 16:06 +0200, Vratislav Podzimek wrote:
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  pyanaconda/ui/gui/spokes/custom.py                     | 15 ++++++++++++---
>  pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py | 13 +++++++++----
>  2 files changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
> index de1a498..bc44d34 100644
> --- a/pyanaconda/ui/gui/spokes/custom.py
> +++ b/pyanaconda/ui/gui/spokes/custom.py
> @@ -148,6 +148,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
>          self._fs_types = []             # list of supported fstypes
>          self._free_space = Size(bytes=0)
>  
> +        self._device_size_text = None
>          self._device_disks = []
>          self._device_container_name = None
>          self._device_container_raid_level = None
> @@ -875,9 +876,16 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
>  
>          # SIZE
>          old_size = device.size
> -        size = size_from_entry(self._sizeEntry)
> +
> +        # we are interested in size human readable representation change because
> +        # that's what the user sees
> +        same_size = self._device_size_text == self._sizeEntry.get_text()
> +        if same_size:
> +            size = old_size
> +        else:
> +            size = size_from_entry(self._sizeEntry)
>          changed_size = ((use_dev.resizable or not use_dev.exists) and
> -                        size != old_size)
> +                        not same_size)
>          old_device_info["size"] = old_size
>          new_device_info["size"] = size
>  
> @@ -1349,7 +1357,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
>              self._labelEntry.set_text("")
>          fancy_set_sensitive(self._labelEntry, True)
>  
> -        self._sizeEntry.set_text(device.size.humanReadable(max_places=None))
> +        self._device_size_text = device.size.humanReadable(max_places=2)
> +        self._sizeEntry.set_text(self._device_size_text)
>  
>          self._reformatCheckbox.set_active(not device.format.exists)
>          fancy_set_sensitive(self._reformatCheckbox, not device.protected and
> diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
> index 892f357..b86f6d1 100644
> --- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
> +++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
> @@ -370,7 +370,9 @@ class ContainerDialog(GUIObject):
>          self._raidStoreFilter.refilter()
>          self._populate_raid()
>  
> -        self._sizeEntry.set_text(self.size.humanReadable(max_places=None))
> +        self._original_size = self.size
> +        self._original_size_text = self.size.humanReadable(max_places=None)
> +        self._sizeEntry.set_text(self._original_size_text)
>          if self.size_policy == SIZE_POLICY_AUTO:
>              self._sizeCombo.set_active(0)
>          elif self.size_policy == SIZE_POLICY_MAX:
> @@ -442,9 +444,12 @@ class ContainerDialog(GUIObject):
>          elif idx == 1:
>              size = SIZE_POLICY_MAX
>          elif idx == 2:
> -            size = size_from_entry(self._sizeEntry)
> -            if size is None:
> -                size = SIZE_POLICY_MAX
> +            if self._original_size_text != self._sizeEntry.get_text():
> +                size = size_from_entry(self._sizeEntry)
> +                if size is None:
> +                    size = SIZE_POLICY_MAX
> +            else:
> +                size = self._original_size
>  
>          # now save the changes
>  
Looks good, I think no-one can really have any use for so many decimal
places. ACK!



More information about the anaconda-patches mailing list