From dd23724dd08f3ec0e014020a7a52a68891e11ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 23 Sep 2024 11:01:30 -0700 Subject: [PATCH 1/3] Diskbar: take InstallerDaemon.Disk as arg --- src/Views/PartitioningView.vala | 18 ++++-------------- src/Widgets/DiskBar.vala | 18 ++++++++---------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index 3b6b8d0d8..2152fa96f 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -167,19 +167,14 @@ public class Installer.PartitioningView : AbstractInstallerView { } foreach (unowned InstallerDaemon.Disk disk in disks.physical_disks) { - var sector_size = disk.sector_size; - var size = disk.sectors * sector_size; - - unowned string path = disk.device_path; - var partitions = new Gee.ArrayList (); foreach (unowned InstallerDaemon.Partition part in disk.partitions) { - var partition = new PartitionBar (part, path, sector_size, false, this.set_mount, this.unset_mount, this.mount_is_set); + var partition = new PartitionBar (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.name, path, size, (owned) partitions); + var disk_bar = new DiskBar (disk, (owned) partitions); disk_list.append (disk_bar); } @@ -220,19 +215,14 @@ public class Installer.PartitioningView : AbstractInstallerView { } private void add_logical_disk (InstallerDaemon.Disk disk) { - var sector_size = disk.sector_size; - var size = disk.sectors * sector_size; - - unowned string path = disk.device_path; - var partitions = new Gee.ArrayList (); foreach (unowned InstallerDaemon.Partition part in disk.partitions) { - var partition = new PartitionBar (part, path, sector_size, true, this.set_mount, this.unset_mount, this.mount_is_set); + var partition = new PartitionBar (part, disk.device_path, disk.sector_size, true, 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.name, path, size, (owned) partitions); + var disk_bar = new DiskBar (disk, (owned) partitions); disk_list.append (disk_bar); } diff --git a/src/Widgets/DiskBar.vala b/src/Widgets/DiskBar.vala index a0c3a26ec..6b0968285 100644 --- a/src/Widgets/DiskBar.vala +++ b/src/Widgets/DiskBar.vala @@ -6,19 +6,15 @@ */ public class Installer.DiskBar: Gtk.Box { - public string disk_name { get; construct; } - public string disk_path { get; construct; } - public uint64 size { get; construct; } + public InstallerDaemon.Disk disk { get; construct; } public Gee.ArrayList partitions { get; construct; } private Gtk.Box legend_box; - public DiskBar (string disk_name, string disk_path, uint64 size, Gee.ArrayList partitions) { + public DiskBar (InstallerDaemon.Disk disk, Gee.ArrayList partitions) { Object ( - disk_name: disk_name, - disk_path: disk_path, - partitions: partitions, - size: size + disk: disk, + partitions: partitions ); } @@ -27,8 +23,10 @@ public class Installer.DiskBar: Gtk.Box { } construct { - var name_label = new Granite.HeaderLabel (disk_name) { - secondary_text = "%s %s".printf (disk_path, GLib.format_size (size)) + var size = disk.sectors * disk.sector_size; + + var name_label = new Granite.HeaderLabel (disk.name) { + secondary_text = "%s %s".printf (disk.device_path, GLib.format_size (size)) }; var bar = new PartitionContainer (size, partitions); From 96efd52fc31932a0dacb32ac9a0a14093f1a3eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 24 Sep 2024 08:36:25 -0700 Subject: [PATCH 2/3] Widgets: Rename PartitionBar to PartitionBlock (#808) --- po/POTFILES | 2 +- src/Views/PartitioningView.vala | 8 ++++---- src/Widgets/DiskBar.vala | 12 ++++++------ .../{PartitionBar.vala => PartitionBlock.vala} | 8 +++----- src/Widgets/PartitionMenu.vala | 4 ++-- src/meson.build | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) rename src/Widgets/{PartitionBar.vala => PartitionBlock.vala} (93%) diff --git a/po/POTFILES b/po/POTFILES index f8584d027..c36219ab9 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -23,6 +23,6 @@ src/Widgets/DecryptMenu.vala src/Widgets/DiskBar.vala src/Widgets/DiskGrid.vala src/Widgets/InstallTypeGrid.vala -src/Widgets/PartitionBar.vala +src/Widgets/PartitionBlock.vala src/Widgets/PartitionMenu.vala src/Widgets/VariantWidget.vala diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index 3b6b8d0d8..6c030a8f7 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -172,9 +172,9 @@ public class Installer.PartitioningView : AbstractInstallerView { unowned string path = disk.device_path; - var partitions = new Gee.ArrayList (); + var partitions = new Gee.ArrayList (); foreach (unowned InstallerDaemon.Partition part in disk.partitions) { - var partition = new PartitionBar (part, path, sector_size, false, this.set_mount, this.unset_mount, this.mount_is_set); + var partition = new PartitionBlock (part, path, sector_size, false, this.set_mount, this.unset_mount, this.mount_is_set); partition.decrypted.connect (on_partition_decrypted); partitions.add (partition); } @@ -225,9 +225,9 @@ public class Installer.PartitioningView : AbstractInstallerView { unowned string path = disk.device_path; - var partitions = new Gee.ArrayList (); + var partitions = new Gee.ArrayList (); foreach (unowned InstallerDaemon.Partition part in disk.partitions) { - var partition = new PartitionBar (part, path, sector_size, true, this.set_mount, this.unset_mount, this.mount_is_set); + var partition = new PartitionBlock (part, path, sector_size, true, this.set_mount, this.unset_mount, this.mount_is_set); partition.decrypted.connect (on_partition_decrypted); partitions.add (partition); } diff --git a/src/Widgets/DiskBar.vala b/src/Widgets/DiskBar.vala index a0c3a26ec..7981c4891 100644 --- a/src/Widgets/DiskBar.vala +++ b/src/Widgets/DiskBar.vala @@ -9,11 +9,11 @@ public class Installer.DiskBar: Gtk.Box { public string disk_name { get; construct; } public string disk_path { get; construct; } public uint64 size { get; construct; } - public Gee.ArrayList partitions { get; construct; } + public Gee.ArrayList partitions { get; construct; } private Gtk.Box legend_box; - public DiskBar (string disk_name, string disk_path, uint64 size, Gee.ArrayList partitions) { + public DiskBar (string disk_name, string disk_path, uint64 size, Gee.ArrayList partitions) { Object ( disk_name: disk_name, disk_path: disk_path, @@ -37,7 +37,7 @@ public class Installer.DiskBar: Gtk.Box { halign = START }; - foreach (PartitionBar p in partitions) { + foreach (PartitionBlock p in partitions) { add_legend ( p.partition.device_path, p.get_partition_size () * 512, @@ -48,7 +48,7 @@ public class Installer.DiskBar: Gtk.Box { } uint64 used = 0; - foreach (PartitionBar partition in partitions) { + foreach (PartitionBlock partition in partitions) { used += partition.get_partition_size (); } @@ -110,10 +110,10 @@ public class Installer.DiskBar: Gtk.Box { } private class PartitionContainer : Gtk.Widget { - public Gee.ArrayList partitions { get; construct; } + public Gee.ArrayList partitions { get; construct; } public uint64 size { get; construct; } - public PartitionContainer (uint64 size, Gee.ArrayList partitions) { + public PartitionContainer (uint64 size, Gee.ArrayList partitions) { Object ( partitions: partitions, size: size diff --git a/src/Widgets/PartitionBar.vala b/src/Widgets/PartitionBlock.vala similarity index 93% rename from src/Widgets/PartitionBar.vala rename to src/Widgets/PartitionBlock.vala index 0ae7c8743..24ac56531 100644 --- a/src/Widgets/PartitionBar.vala +++ b/src/Widgets/PartitionBlock.vala @@ -5,7 +5,7 @@ * Authored by: Michael Aaron Murphy */ -public class Installer.PartitionBar : Gtk.Box { +public class Installer.PartitionBlock : Adw.Bin { public signal void decrypted (InstallerDaemon.LuksCredentials credential); public Icon? icon { get; set; default = null; } @@ -17,7 +17,7 @@ public class Installer.PartitionBar : Gtk.Box { public string? volume_group { get; private set; } public Gtk.Popover menu { get; private set; } - public PartitionBar ( + public PartitionBlock ( InstallerDaemon.Partition partition, string parent_path, uint64 sector_size, @@ -56,13 +56,11 @@ public class Installer.PartitionBar : Gtk.Box { volume_group = (partition.filesystem == LVM) ? partition.current_lvm_volume_group : null; var image = new Gtk.Image () { - hexpand = true, halign = END, valign = END }; - append (image); - hexpand = true; + child = image; tooltip_text = partition.device_path; add_css_class (partition.filesystem.to_string ()); diff --git a/src/Widgets/PartitionMenu.vala b/src/Widgets/PartitionMenu.vala index 4fa4b446d..b10a319ec 100644 --- a/src/Widgets/PartitionMenu.vala +++ b/src/Widgets/PartitionMenu.vala @@ -38,11 +38,11 @@ public class Installer.PartitionMenu : Gtk.Popover { private Gtk.Label custom_label; private Gtk.Label type_label; // A reference to the parent which owns this menu. - private PartitionBar partition_bar; + private PartitionBlock partition_bar; public PartitionMenu (string path, string parent, InstallerDaemon.FileSystem fs, bool lvm, SetMount set_mount, UnsetMount unset_mount, - MountSetFn mount_set, PartitionBar partition_bar) { + MountSetFn mount_set, PartitionBlock partition_bar) { this.partition_bar = partition_bar; original_filesystem = fs; is_lvm = lvm; diff --git a/src/meson.build b/src/meson.build index e9dcca0cb..504555f76 100644 --- a/src/meson.build +++ b/src/meson.build @@ -26,7 +26,7 @@ vala_files = [ 'Widgets/DiskBar.vala', 'Widgets/DiskGrid.vala', 'Widgets/InstallTypeGrid.vala', - 'Widgets/PartitionBar.vala', + 'Widgets/PartitionBlock.vala', 'Widgets/PartitionMenu.vala', 'Widgets/Terminal.vala', 'Widgets/VariantWidget.vala', From 660a60f8afbdf32d2f07c11a4cde6d2d6ce7cc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 24 Sep 2024 08:42:34 -0700 Subject: [PATCH 3/3] PartitioningView: add test disk/partition data (#812) --- src/Views/PartitioningView.vala | 56 ++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index 6c030a8f7..09a2e76f5 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -159,7 +159,11 @@ public class Installer.PartitioningView : AbstractInstallerView { InstallerDaemon.DiskInfo? disks = null; try { - disks = yield Daemon.get_default ().get_disks (true); + if (!Installer.App.test_mode) { + disks = yield Daemon.get_default ().get_disks (true); + } else { + disks = get_test_diskinfo (); + } } catch (Error e) { critical ("Unable to get disks: %s", e.message); load_stack.set_visible_child_name ("disk"); @@ -343,4 +347,54 @@ public class Installer.PartitioningView : AbstractInstallerView { array[index] = array[array.size - 1]; return array.remove_at (array.size - 1); } + + private InstallerDaemon.DiskInfo get_test_diskinfo () { + InstallerDaemon.Disk[] physical_disks = {}; + InstallerDaemon.Disk[] logical_disks = {}; + + InstallerDaemon.Partition[] partitions = {}; + + var usage_1 = Distinst.PartitionUsage () { + tag = 1, + value = 30312 + }; + + partitions += InstallerDaemon.Partition () { + device_path = "/dev/nvme0n1p1", + filesystem = InstallerDaemon.FileSystem.FAT32, + start_sector = 4096, + end_sector = 542966, + sectors_used = usage_1, + current_lvm_volume_group = "" + }; + + var usage_2 = Distinst.PartitionUsage () { + tag = 0, + value = 0 + }; + + partitions += InstallerDaemon.Partition () { + device_path = "/dev/nvme0n1p2", + filesystem = InstallerDaemon.FileSystem.LVM, + start_sector = 542968, + end_sector = 976769070, + sectors_used = usage_2, + current_lvm_volume_group = "data" + }; + + physical_disks += InstallerDaemon.Disk () { + name = "Samsung SSD 970 EVO 500GB", + device_path = "/dev/nvme0n1", + sectors = 976773168, + sector_size = 512, + rotational = false, + removable = false, + partitions = partitions + }; + + return InstallerDaemon.DiskInfo () { + physical_disks = physical_disks, + logical_disks = logical_disks + }; + } }