Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diskbar: construct with InstallerDaemon.Disk #810

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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