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

PartitionBlock: GObject #813

Merged
merged 6 commits into from
Sep 30, 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
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