diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index a8d4880df..7bfe6a782 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -171,19 +171,11 @@ public class Installer.PartitioningView : AbstractInstallerView { } foreach (unowned InstallerDaemon.Disk disk in disks.physical_disks) { - var partitions = new Gee.ArrayList (); - foreach (unowned InstallerDaemon.Partition part in disk.partitions) { - var partition = new PartitionBlock (part, disk.device_path, disk.sector_size, false, this.set_mount, this.unset_mount, this.mount_is_set); - partition.decrypted.connect (on_partition_decrypted); - partitions.add (partition); - } - - var disk_bar = new DiskBar (disk, (owned) partitions); - disk_list.append (disk_bar); + disk_list.append (get_disk_bar (disk, false)); } foreach (unowned InstallerDaemon.Disk disk in disks.logical_disks) { - add_logical_disk (disk); + disk_list.append (get_disk_bar (disk, true)); } load_stack.set_visible_child_name ("disk"); @@ -218,16 +210,22 @@ public class Installer.PartitioningView : AbstractInstallerView { load_disks.begin (); } - private void add_logical_disk (InstallerDaemon.Disk disk) { + private DiskBar get_disk_bar (InstallerDaemon.Disk disk, bool lvm) { var partitions = new Gee.ArrayList (); foreach (unowned InstallerDaemon.Partition part in disk.partitions) { - var partition = new PartitionBlock (part, disk.device_path, disk.sector_size, true, this.set_mount, this.unset_mount, this.mount_is_set); - partition.decrypted.connect (on_partition_decrypted); + var partition = new PartitionBlock (part, disk.device_path, disk.sector_size); + + if (part.filesystem == LUKS) { + partition.menu = new DecryptMenu (part.device_path); + ((DecryptMenu) partition.menu).decrypted.connect (on_partition_decrypted); + } else { + partition.menu = new PartitionMenu (part.device_path, disk.device_path, part.filesystem, lvm, this.set_mount, this.unset_mount, this.mount_is_set, partition); + } + partitions.add (partition); } - var disk_bar = new DiskBar (disk, (owned) partitions); - disk_list.append (disk_bar); + return new DiskBar (disk, (owned) partitions); } private void validate_status () { @@ -269,7 +267,7 @@ public class Installer.PartitioningView : AbstractInstallerView { Daemon.get_default ().get_logical_device.begin (credentials.pv, (obj, res) => { try { var disk = ((Daemon)obj).get_logical_device.end (res); - add_logical_disk (disk); + disk_list.append (get_disk_bar (disk, true)); } catch (Error e) { critical ("Unable to get logical device: %s", e.message); } diff --git a/src/Widgets/PartitionBlock.vala b/src/Widgets/PartitionBlock.vala index 24ac56531..f3aeed35c 100644 --- a/src/Widgets/PartitionBlock.vala +++ b/src/Widgets/PartitionBlock.vala @@ -10,42 +10,34 @@ public class Installer.PartitionBlock : Adw.Bin { public Icon? icon { get; set; default = null; } - public bool lvm { get; construct; } + private Gtk.Popover _menu; + public Gtk.Popover menu { + get { + return _menu; + } + + set { + _menu = value; + _menu.set_parent (this); + _menu.position = BOTTOM; + + var click_gesture = new Gtk.GestureClick (); + click_gesture.released.connect (_menu.popup); + + add_controller (click_gesture); + } + } + public InstallerDaemon.Partition partition { get; construct; } public string parent_path { get; construct; } public string? volume_group { get; private set; } - public Gtk.Popover menu { get; private set; } - - public PartitionBlock ( - InstallerDaemon.Partition partition, - string parent_path, - uint64 sector_size, - bool lvm, - SetMount set_mount, - UnsetMount unset_mount, - MountSetFn mount_set - ) { + + public PartitionBlock (InstallerDaemon.Partition partition, string parent_path, uint64 sector_size) { Object ( - lvm: lvm, parent_path: parent_path, partition: partition ); - - if (partition.filesystem == LUKS) { - menu = new DecryptMenu (partition.device_path); - ((DecryptMenu)menu).decrypted.connect ((creds) => decrypted (creds)); - } else { - menu = new PartitionMenu (partition.device_path, parent_path, partition.filesystem, lvm, set_mount, unset_mount, mount_set, this); - } - - menu.set_parent (this); - menu.position = BOTTOM; - - var click_gesture = new Gtk.GestureClick (); - click_gesture.released.connect (menu.popup); - - add_controller (click_gesture); } class construct {