Implement auto-increment partition numbers
- Remove the (1-4) since GPT partition doesn't have a limit - Calculate the lastpartition value and handle the case where we don't have any at first Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
parent
dce4bcf7aa
commit
dde90cd42d
|
@ -142,7 +142,8 @@ class Blockdev():
|
|||
|
||||
@property
|
||||
def lastpartnumber(self):
|
||||
return self.disk.lastPartitionNumber
|
||||
return self.disk.lastPartitionNumber if \
|
||||
self.disk.lastPartitionNumber > 0 else 0
|
||||
|
||||
def delete_partition(self, partnum=None, sector=None, mountpoint=None):
|
||||
# find part and then call deletePartition()
|
||||
|
|
|
@ -40,8 +40,9 @@ class AddPartitionView(WidgetWrap):
|
|||
self.signal = signal
|
||||
self.selected_disk = self.model.get_disk(selected_disk)
|
||||
|
||||
self.partnum = IntegerEditor(caption="Partition number (1-4): ",
|
||||
default=1)
|
||||
self.partnum = IntegerEditor(
|
||||
caption="Partition number: ",
|
||||
default=self.selected_disk.lastpartnumber + 1)
|
||||
self.size_str = _humanize_size(self.selected_disk.freespace)
|
||||
self.size = StringEditor(
|
||||
caption="Size (max {}): ".format(self.size_str))
|
||||
|
|
Loading…
Reference in New Issue