[PATCH] Make a couple UI modifications to the resize slider.
Chris Lumens
clumens at redhat.com
Wed Apr 17 20:32:09 UTC 2013
(1) Add tick marks at the end and at every 20%.
(2) Move the current value to the top.
(3) Add an adjustment to make keyboard navigation possible.
(4) Completely hide the slider when the shrink button has not been clicked.
---
pyanaconda/ui/gui/spokes/lib/resize.glade | 7 +++++-
pyanaconda/ui/gui/spokes/lib/resize.py | 40 ++++++++++++++++++++++++-------
2 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/lib/resize.glade b/pyanaconda/ui/gui/spokes/lib/resize.glade
index 0c1ce28..ff8943d 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.glade
+++ b/pyanaconda/ui/gui/spokes/lib/resize.glade
@@ -23,6 +23,11 @@
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkAdjustment" id="resizeAdjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkDialog" id="resizeDialog">
<property name="height_request">550</property>
<property name="can_focus">False</property>
@@ -260,9 +265,9 @@
<property name="can_focus">True</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
+ <property name="adjustment">resizeAdjustment</property>
<property name="round_digits">1</property>
<property name="digits">0</property>
- <property name="value_pos">bottom</property>
<signal name="format-value" handler="resize_slider_format" swapped="no"/>
<signal name="value-changed" handler="on_resize_value_changed" swapped="no"/>
</object>
diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index 7a88d86..eaa7bca 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -50,7 +50,7 @@ SHRINK = N_("Shrink")
DELETE = N_("Delete")
class ResizeDialog(GUIObject):
- builderObjects = ["actionStore", "diskStore", "resizeDialog"]
+ builderObjects = ["actionStore", "diskStore", "resizeDialog", "resizeAdjustment"]
mainWidgetName = "resizeDialog"
uiFile = "spokes/lib/resize.glade"
@@ -213,6 +213,33 @@ class ResizeDialog(GUIObject):
text = _("Total selected space to reclaim: <b>%s</b>") % size_str(selectedReclaimable)
self._selected_label.set_markup(text)
+ def _setup_slider(self, device, value):
+ # Set up the slider for this device, pulling out any previously
+ # given shrink value as the default. Even if the device is not
+ # resizeable, we want to set up the right numbers here so it doesn't
+ # look weird.
+ self._resizeSlider.set_range(device.minSize, device.size)
+ self._resizeSlider.set_value(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 = distance*0.01
+ fivePercent = distance*0.05
+ twentyPercent = distance*0.2
+
+ adjustment = self.builder.get_object("resizeAdjustment")
+ adjustment.configure(value, device.minSize, device.size, onePercent, fivePercent, 0)
+
+ # And then the slider needs a couple tick marks for easier navigation.
+ self._resizeSlider.clear_marks()
+ for i in range(1, 5):
+ self._resizeSlider.add_mark(device.minSize + i*twentyPercent, Gtk.PositionType.BOTTOM, None)
+
+ # Finally, add tick marks for the ends.
+ self._resizeSlider.add_mark(device.minSize, Gtk.PositionType.BOTTOM, size_str(device.minSize))
+ self._resizeSlider.add_mark(device.size, Gtk.PositionType.BOTTOM, size_str(device.size))
+
def _update_action_buttons(self, row):
device = self.storage.devicetree.getDeviceByID(row[DEVICE_ID_COL])
@@ -221,7 +248,7 @@ class ResizeDialog(GUIObject):
self._preserveButton.set_sensitive(row[EDITABLE_COL])
self._shrinkButton.set_sensitive(row[EDITABLE_COL] and not device.isDisk)
self._deleteButton.set_sensitive(row[EDITABLE_COL])
- self._resizeSlider.set_sensitive(False)
+ self._resizeSlider.set_visible(False)
if not row[EDITABLE_COL]:
return
@@ -230,12 +257,7 @@ class ResizeDialog(GUIObject):
# button insensitive.
self._shrinkButton.set_sensitive(device.resizable)
- # Set up the slider for this device, pulling out any previously
- # given shrink value as the default. Even if the device is not
- # resizeable, we want to set up the right numbers here so it doesn't
- # look weird.
- self._resizeSlider.set_range(device.minSize, device.size)
- self._resizeSlider.set_value(row[RESIZE_TARGET_COL])
+ self._setup_slider(device, row[RESIZE_TARGET_COL])
# Then, disable the button for whatever action is currently selected.
# It doesn't make a lot of sense to allow clicking that.
@@ -243,7 +265,7 @@ class ResizeDialog(GUIObject):
self._preserveButton.set_sensitive(False)
elif row[ACTION_COL] == _(SHRINK):
self._shrinkButton.set_sensitive(False)
- self._resizeSlider.set_sensitive(True)
+ self._resizeSlider.set_visible(True)
elif row[ACTION_COL] == _(DELETE):
self._deleteButton.set_sensitive(False)
--
1.8.1.2
More information about the anaconda-patches
mailing list