even more translatable strings in the fs view and some more flexibility wrt string lengths
This commit is contained in:
parent
47b5acab92
commit
febc40cd45
|
@ -54,6 +54,15 @@ class DiskPartitionView(BaseView):
|
||||||
def _build_model_inputs(self):
|
def _build_model_inputs(self):
|
||||||
partitioned_disks = []
|
partitioned_disks = []
|
||||||
|
|
||||||
|
if self.disk.free > 0:
|
||||||
|
if len(self.disk.partitions()) > 0:
|
||||||
|
final_label = _("Add another partition")
|
||||||
|
else:
|
||||||
|
final_label = _("Add first partition")
|
||||||
|
label_width = max(25, len(final_label) + 4)
|
||||||
|
else:
|
||||||
|
label_width = 25
|
||||||
|
|
||||||
def format_volume(label, part):
|
def format_volume(label, part):
|
||||||
size = humanize_size(part.size)
|
size = humanize_size(part.size)
|
||||||
if part.fs() is None:
|
if part.fs() is None:
|
||||||
|
@ -70,27 +79,23 @@ class DiskPartitionView(BaseView):
|
||||||
else:
|
else:
|
||||||
part_btn = menu_btn(label, on_press=self._click_part, user_arg=part)
|
part_btn = menu_btn(label, on_press=self._click_part, user_arg=part)
|
||||||
return Columns([
|
return Columns([
|
||||||
(25, part_btn),
|
(label_width, part_btn),
|
||||||
(9, Text(size, align="right")),
|
(9, Text(size, align="right")),
|
||||||
Text(fstype),
|
Text(fstype),
|
||||||
Text(mountpoint),
|
Text(mountpoint),
|
||||||
], 2)
|
], 2)
|
||||||
if self.disk.fs() is not None:
|
if self.disk.fs() is not None:
|
||||||
partitioned_disks.append(format_volume("entire disk", self.disk))
|
partitioned_disks.append(format_volume(_("entire disk"), self.disk))
|
||||||
else:
|
else:
|
||||||
for part in self.disk.partitions():
|
for part in self.disk.partitions():
|
||||||
partitioned_disks.append(format_volume("Partition {}".format(part._number), part))
|
partitioned_disks.append(format_volume(_("Partition {}").format(part._number), part))
|
||||||
if self.disk.free > 0:
|
if self.disk.free > 0:
|
||||||
free_space = humanize_size(self.disk.free)
|
free_space = humanize_size(self.disk.free)
|
||||||
if len(self.disk.partitions()) > 0:
|
add_btn = menu_btn(final_label, on_press=self.add_partition)
|
||||||
label = "Add another partition"
|
|
||||||
else:
|
|
||||||
label = "Add first partition"
|
|
||||||
add_btn = menu_btn(label, on_press=self.add_partition)
|
|
||||||
partitioned_disks.append(Columns([
|
partitioned_disks.append(Columns([
|
||||||
(25, add_btn),
|
(label_width, add_btn),
|
||||||
(9, Text(free_space, align="right")),
|
(9, Text(free_space, align="right")),
|
||||||
Text("free space"),
|
Text(_("free space")),
|
||||||
], 2))
|
], 2))
|
||||||
if self.model.bootable():
|
if self.model.bootable():
|
||||||
for p in self.disk.partitions():
|
for p in self.disk.partitions():
|
||||||
|
@ -102,8 +107,7 @@ class DiskPartitionView(BaseView):
|
||||||
button_pile([other_btn(label=_("Select as boot disk"), on_press=self.make_boot_disk)]))
|
button_pile([other_btn(label=_("Select as boot disk"), on_press=self.make_boot_disk)]))
|
||||||
if len(self.disk.partitions()) == 0 and \
|
if len(self.disk.partitions()) == 0 and \
|
||||||
self.disk.available:
|
self.disk.available:
|
||||||
text = ("Format or create swap on entire "
|
text = _("Format or create swap on entire device (unusual, advanced)")
|
||||||
"device (unusual, advanced)")
|
|
||||||
partitioned_disks.append(Text(""))
|
partitioned_disks.append(Text(""))
|
||||||
partitioned_disks.append(
|
partitioned_disks.append(
|
||||||
menu_btn(label=text, on_press=self.format_entire))
|
menu_btn(label=text, on_press=self.format_entire))
|
||||||
|
@ -119,7 +123,7 @@ class DiskPartitionView(BaseView):
|
||||||
def show_disk_info_w(self):
|
def show_disk_info_w(self):
|
||||||
""" Runs hdparm against device and displays its output
|
""" Runs hdparm against device and displays its output
|
||||||
"""
|
"""
|
||||||
text = ("Show disk information")
|
text = _("Show disk information")
|
||||||
return menu_btn(
|
return menu_btn(
|
||||||
label=text,
|
label=text,
|
||||||
on_press=self.show_disk_info)
|
on_press=self.show_disk_info)
|
||||||
|
|
|
@ -137,14 +137,18 @@ class FilesystemView(BaseView):
|
||||||
if len(cols) == 0:
|
if len(cols) == 0:
|
||||||
return Pile([Color.info_minor(
|
return Pile([Color.info_minor(
|
||||||
Text(_("No disks or partitions mounted.")))])
|
Text(_("No disks or partitions mounted.")))])
|
||||||
cols.insert(0, (None, mount_point_text, _("SIZE"), _("TYPE"), _("DEVICE TYPE")))
|
size_text = _("SIZE")
|
||||||
|
type_text = _("TYPE")
|
||||||
|
size_width = max(len(size_text), 9)
|
||||||
|
type_width = max(len(type_text), self.model.longest_fs_name)
|
||||||
|
cols.insert(0, (None, mount_point_text, size_text, type_text, _("DEVICE TYPE")))
|
||||||
pl = []
|
pl = []
|
||||||
for dummy, a, b, c, d in cols:
|
for dummy, a, b, c, d in cols:
|
||||||
if b == "SIZE":
|
if b == "SIZE":
|
||||||
b = Text(b, align='center')
|
b = Text(b, align='center')
|
||||||
else:
|
else:
|
||||||
b = Text(b, align='right')
|
b = Text(b, align='right')
|
||||||
pl.append(Columns([(longest_path, Text(a)), (9, b), (self.model.longest_fs_name, Text(c)), Text(d)], 4))
|
pl.append(Columns([(longest_path, Text(a)), (size_width, b), (type_width, Text(c)), Text(d)], 4))
|
||||||
return Pile(pl)
|
return Pile(pl)
|
||||||
|
|
||||||
def _build_buttons(self):
|
def _build_buttons(self):
|
||||||
|
@ -166,11 +170,11 @@ class FilesystemView(BaseView):
|
||||||
r = []
|
r = []
|
||||||
|
|
||||||
def col3(col1, col2, col3):
|
def col3(col1, col2, col3):
|
||||||
inputs.append(Columns([(40, col1), (10, col2), (10, col3)], 2))
|
inputs.append(Columns([(42, col1), (10, col2), col3], 2))
|
||||||
def col2(col1, col2):
|
def col2(col1, col2):
|
||||||
inputs.append(Columns([(40, col1), col2], 2))
|
inputs.append(Columns([(42, col1), col2], 2))
|
||||||
def col1(col1):
|
def col1(col1):
|
||||||
inputs.append(Columns([(40, col1)], 1))
|
inputs.append(Columns([(42, col1)], 1))
|
||||||
|
|
||||||
inputs = []
|
inputs = []
|
||||||
col3(Text(_("DEVICE")), Text(_("SIZE"), align="center"), Text(_("TYPE")))
|
col3(Text(_("DEVICE")), Text(_("SIZE"), align="center"), Text(_("TYPE")))
|
||||||
|
|
Loading…
Reference in New Issue