Skip to content

Commit

Permalink
Diskbar: take InstallerDaemon.Disk as arg
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Sep 23, 2024
1 parent 595e771 commit dd23724
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
18 changes: 4 additions & 14 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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<PartitionBar> ();
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);
}

Expand Down Expand Up @@ -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<PartitionBar> ();
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);
}

Expand Down
18 changes: 8 additions & 10 deletions src/Widgets/DiskBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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<PartitionBar> partitions { get; construct; }

private Gtk.Box legend_box;

public DiskBar (string disk_name, string disk_path, uint64 size, Gee.ArrayList<PartitionBar> partitions) {
public DiskBar (InstallerDaemon.Disk disk, Gee.ArrayList<PartitionBar> partitions) {
Object (
disk_name: disk_name,
disk_path: disk_path,
partitions: partitions,
size: size
disk: disk,
partitions: partitions
);
}

Expand All @@ -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);
Expand Down

0 comments on commit dd23724

Please sign in to comment.