Skip to content

Commit

Permalink
PartitionBlock: GObject (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Sep 30, 2024
1 parent d9f337b commit eae9af3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
11 changes: 9 additions & 2 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,15 @@ public class Installer.PartitioningView : AbstractInstallerView {
private DiskBar get_disk_bar (InstallerDaemon.Disk disk, bool lvm) {
var partitions = new Gee.ArrayList<PartitionBlock> ();
foreach (unowned InstallerDaemon.Partition part in disk.partitions) {
var partition = new PartitionBlock (part, disk.device_path, disk.sector_size, lvm, this.set_mount, this.unset_mount, this.mount_is_set);
partition.decrypted.connect (on_partition_decrypted);
var partition = new PartitionBlock (part);

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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/DiskBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Installer.DiskBar: Gtk.Box {
p.partition.device_path,
p.get_partition_size () * 512,
p.partition.filesystem.to_string (),
p.volume_group,
p.partition.filesystem == LVM ? p.partition.current_lvm_volume_group : null,
p.menu
);
}
Expand Down
50 changes: 16 additions & 34 deletions src/Widgets/PartitionBlock.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,37 @@
*/

public class Installer.PartitionBlock : Adw.Bin {
public signal void decrypted (InstallerDaemon.LuksCredentials credential);

public Icon? icon { get; set; default = null; }

public bool lvm { get; construct; }
public InstallerDaemon.Partition partition { get; construct; }
public string parent_path { get; construct; }
private Gtk.Popover _menu;
public Gtk.Popover menu {
get {
return _menu;
}

public string? volume_group { get; private set; }
public Gtk.Popover menu { get; private set; }
set {
_menu = value;
_menu.set_parent (this);
_menu.position = BOTTOM;

public PartitionBlock (
InstallerDaemon.Partition partition,
string parent_path,
uint64 sector_size,
bool lvm,
SetMount set_mount,
UnsetMount unset_mount,
MountSetFn mount_set
) {
Object (
lvm: lvm,
parent_path: parent_path,
partition: partition
);
var click_gesture = new Gtk.GestureClick ();
click_gesture.released.connect (_menu.popup);

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);
add_controller (click_gesture);
}
}

menu.set_parent (this);
menu.position = BOTTOM;

var click_gesture = new Gtk.GestureClick ();
click_gesture.released.connect (menu.popup);
public InstallerDaemon.Partition partition { get; construct; }

add_controller (click_gesture);
public PartitionBlock (InstallerDaemon.Partition partition) {
Object (partition: partition);
}

class construct {
set_css_name ("block");
}

construct {
volume_group = (partition.filesystem == LVM) ? partition.current_lvm_volume_group : null;

var image = new Gtk.Image () {
halign = END,
valign = END
Expand Down

0 comments on commit eae9af3

Please sign in to comment.