On Thu, 2012-10-04 at 12:19 -0400, Chris Lumens wrote:
---
pyanaconda/ui/gui/spokes/lib/cart.glade | 71 +++++++++++++++++++++------
pyanaconda/ui/gui/spokes/lib/cart.py | 86 ++++++++++++++++++++++++---------
pyanaconda/ui/gui/spokes/storage.py | 2 +-
3 files changed, 122 insertions(+), 37 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/lib/cart.py b/pyanaconda/ui/gui/spokes/lib/cart.py
index 2c1f025..b3d437c 100644
--- a/pyanaconda/ui/gui/spokes/lib/cart.py
+++ b/pyanaconda/ui/gui/spokes/lib/cart.py
@@ -31,6 +31,13 @@ P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y,
z)
__all__ = ["SelectedDisksDialog"]
+IS_BOOT_COL = 0
+DESCRIPTION_COL = 1
+SIZE_COL = 2
+FREE_SPACE_COL = 3
+SERIAL_COL = 4
+ID_COL = 5
+
def size_str(mb):
if isinstance(mb, Size):
spec = str(mb)
@@ -44,9 +51,14 @@ class SelectedDisksDialog(GUIObject):
mainWidgetName = "selected_disks_dialog"
uiFile = "spokes/lib/cart.glade"
+ def __init__(self, data, storage):
+ GUIObject.__init__(self, data)
+ self.storage = storage
+
def initialize(self, disks, free, showRemove=True):
for disk in disks:
- self._store.append([disk.description,
+ self._store.append([False,
+ disk.description,
size_str(disk.size),
size_str(free[disk.name][0]),
disk.serial,
@@ -57,6 +69,19 @@ class SelectedDisksDialog(GUIObject):
if not showRemove:
self.builder.get_object("remove_button").hide()
+ # Set up the default boot device. Use what's in the ksdata if anything,
+ # then fall back to the first device.
+ if self.data.bootloader.bootDrive:
+ dev =
self.storage.devicetree.getDeviceByName(self.data.bootloader.bootDrive)
+ default_id = dev.id
+ else:
+ default_id = self.storage.disks[0].id
Do we want to consider disks that are not currently selected? I think
not. If I'm right, this lends itself to just iterating over disks here
and self.disks elsewhere in the dialog instead of adding the storage arg
to the constructor.
Dave
+
+ for row in self._store:
+ if row[ID_COL] == default_id:
+ row[IS_BOOT_COL] = True
+ break
+
def refresh(self, disks, free, showRemove=True):
super(SelectedDisksDialog, self).refresh()
@@ -88,8 +113,8 @@ class SelectedDisksDialog(GUIObject):
free = 0
for row in self._store:
count += 1
- size += Size(spec=row[1])
- free += Size(spec=row[2])
+ size += Size(spec=row[SIZE_COL])
+ free += Size(spec=row[FREE_SPACE_COL])
size = str(Size(bytes=long(size))).upper()
free = str(Size(bytes=long(free))).upper()
@@ -103,31 +128,48 @@ class SelectedDisksDialog(GUIObject):
# signal handlers
def on_remove_clicked(self, button):
- # remove the selected disk(s) from the list and update the summary label
- #selected_refs = self._get_selection_refs()
- #for ref in selected_refs:
- # path = ref.get_path()
- # itr = model.get_iter_from_string(path)
- # self._store.remove(itr)
model, itr = self._selection.get_selected()
- if itr:
- disk = None
- for d in self.disks:
- if d.id == self._store[itr][4]:
- disk = d
- break
+ if not itr:
+ return
+
+ disk = self.storage.devicetree.getDeviceByID(self._store[itr][ID_COL])
+ if not disk:
+ return
+
+ # If this disk was marked as the boot device, just change to the first one
+ # instead.
+ resetBootDevice = self._store[itr][IS_BOOT_COL]
- if not disk:
- return
+ # remove the selected disk(s) from the list and update the summary label
+ self._store.remove(itr)
+ self.disks.remove(disk)
+
+ if resetBootDevice and len(self._store) > 0:
+ self._store[0][IS_BOOT_COL] = True
- self._store.remove(itr)
- self.disks.remove(disk)
- self._update_summary()
+ self._update_summary()
def on_close_clicked(self, button):
- print "CLOSE CLICKED"
+ # Save the boot device setting.
+ for row in self._store:
+ if row[IS_BOOT_COL]:
+ dev = self.storage.devicetree.getDeviceByID(row[ID_COL])
+ self.data.bootloader.bootDrive = dev.name
+ break
def on_selection_changed(self, *args):
model, itr = self._selection.get_selected()
if itr:
- print "new selection: %s" % model.get_value(itr, 3)
+ print "new selection: %s" % model.get_value(itr, SERIAL_COL)
+
+ def on_set_as_boot_clicked(self, button):
+ model, itr = self._selection.get_selected()
+ if not itr:
+ return
+
+ # First make sure the previous device is unselected.
+ for row in self._store:
+ row[IS_BOOT_COL] = False
+
+ # Now set the currently selected device to be the boot target.
+ self._store[itr][IS_BOOT_COL] = True
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 3deeae2..ac19c9b 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -516,7 +516,7 @@ class StorageSpoke(NormalSpoke, StorageChecker):
# show the selected disks dialog
# pass in our disk list so hidden disks' free space is available
free_space = self.storage.getFreeSpace(disks=self.disks)
- dialog = SelectedDisksDialog(self.data,)
+ dialog = SelectedDisksDialog(self.data, self.storage)
dialog.refresh([d for d in self.disks if d.name in self.selected_disks],
free_space)
rc = self.run_lightbox_dialog(dialog)