[PATCH] Pass ints to Gtk resize functions (#1065021)

Vratislav Podzimek vpodzime at redhat.com
Fri Feb 14 07:10:34 UTC 2014


On Thu, 2014-02-13 at 16:05 -0800, Brian C. Lane wrote:
> When we pass Size objects to Gtk it ends up trying to use their human
> readable string instead of an integer. Convert them before we use them.
> ---
>  pyanaconda/ui/gui/spokes/lib/resize.py | 35 +++++++++++++++++++++-------------
>  1 file changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
> index 64c11e7..4557523 100644
> --- a/pyanaconda/ui/gui/spokes/lib/resize.py
> +++ b/pyanaconda/ui/gui/spokes/lib/resize.py
> @@ -21,7 +21,6 @@
>  
>  from __future__ import division
>  from collections import namedtuple
> -from math import ceil
>  
>  from gi.repository import Gdk, Gtk
>  
> @@ -244,30 +243,40 @@ class ResizeDialog(GUIObject):
>             slider and keyboard support.  Any devices that are not resizable
>             will not have a slider displayed, so they do not need to be worried
>             with here.
> +
> +           :param device: The device
> +           :type device: PartitionDevice
> +           :param value: default value to set
> +           :type value: Size
>          """
> -        self._resizeSlider.handler_block_by_func(self.on_resize_value_changed)
> -        self._resizeSlider.set_range(int(ceil(device.minSize)), int(device.size))
> -        self._resizeSlider.handler_unblock_by_func(self.on_resize_value_changed)
> -        self._resizeSlider.set_value(value)
> +        # Convert the Sizes to ints
> +        minSize = int(device.minSize)
> +        size = int(device.size)
> +        default_value = int(value)
>  
>          # The slider needs to be keyboard-accessible.  We'll make small movements change in
>          # 1% increments, and large movements in 5% increments.
> -        distance = device.size - device.minSize
> -        onePercent = Size(bytes=distance / 100)
> -        fivePercent = Size(bytes=distance / 20)
> -        twentyPercent = Size(bytes=distance / 5)
> +        distance = size - minSize
> +        onePercent = int(distance / 100)
> +        fivePercent = int(distance / 20)
> +        twentyPercent = int(distance / 5)
Are these three really necessary? Otherwise this looks good to me
althought it's quite ugly and we may need some pylint check to prevent
the same issue in the lines added in the future.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list