feat(partitioning): support fat32 and add validation for system partition name
This commit is contained in:
@@ -504,6 +504,11 @@ class PartitioningPage(Adw.Bin):
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12, margin_top=24, margin_bottom=24, margin_start=24, margin_end=24)
|
||||
win.set_content(box)
|
||||
|
||||
# Name entry
|
||||
name_entry = Gtk.Entry(text="Linux filesystem")
|
||||
box.append(Gtk.Label(label="Partition Name:"))
|
||||
box.append(name_entry)
|
||||
|
||||
# Size entry
|
||||
size_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
|
||||
size_entry = Gtk.Entry(text=str(int(data["bytes"] / (1024*1024))))
|
||||
@@ -519,11 +524,45 @@ class PartitioningPage(Adw.Bin):
|
||||
box.append(Gtk.Label(label="Partition Type:"))
|
||||
box.append(type_dropdown)
|
||||
|
||||
# Filesystem dropdown
|
||||
fs_options = ["ext4", "fat32", "swap"]
|
||||
fs_dropdown = Gtk.DropDown.new_from_strings(fs_options)
|
||||
box.append(Gtk.Label(label="Filesystem:"))
|
||||
box.append(fs_dropdown)
|
||||
|
||||
# Auto-update FS and Name based on Type
|
||||
def on_type_changed(dropdown, pspec):
|
||||
selected_type = type_names[dropdown.get_selected()]
|
||||
if selected_type == "EFI System":
|
||||
fs_dropdown.set_selected(1) # fat32
|
||||
name_entry.set_text("EFI System")
|
||||
elif selected_type == "Swap":
|
||||
fs_dropdown.set_selected(2) # swap
|
||||
name_entry.set_text("Swap")
|
||||
else:
|
||||
fs_dropdown.set_selected(0) # ext4
|
||||
name_entry.set_text("Linux filesystem")
|
||||
|
||||
type_dropdown.connect("notify::selected", on_type_changed)
|
||||
|
||||
error_label = Gtk.Label(label="")
|
||||
error_label.add_css_class("error")
|
||||
box.append(error_label)
|
||||
|
||||
def on_create(b):
|
||||
from ...backend.disk import create_partition
|
||||
name = name_entry.get_text()
|
||||
selected_type = type_names[type_dropdown.get_selected()]
|
||||
|
||||
if selected_type == "EFI System" and name == "Linux filesystem":
|
||||
error_label.set_text("Can't set partition name to Linux filesystem")
|
||||
return
|
||||
|
||||
size_mb = int(size_entry.get_text())
|
||||
type_code = types[type_names[type_dropdown.get_selected()]]
|
||||
create_partition(self.current_disk_path, size_mb, type_code)
|
||||
type_code = types[selected_type]
|
||||
fstype = fs_options[fs_dropdown.get_selected()]
|
||||
|
||||
create_partition(self.current_disk_path, size_mb, type_code, name, fstype)
|
||||
win.close()
|
||||
self.load_partitions(self.current_disk_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user