diff --git a/daemon/Daemon.vala b/daemon/Daemon.vala index 040373011..bc83e5712 100644 --- a/daemon/Daemon.vala +++ b/daemon/Daemon.vala @@ -4,6 +4,9 @@ */ public class InstallerDaemon.Application : GLib.Application { + // We have to do it step by step because the vala compiler has overflows with big numbers. + public const uint64 ONE_GB = 1000 * 1000 * 1000; + public Application () { Object ( application_id: "io.elementary.InstallerDaemon", diff --git a/daemon/DistinstBackend.vala b/daemon/DistinstBackend.vala index 31837378e..9002fff1e 100644 --- a/daemon/DistinstBackend.vala +++ b/daemon/DistinstBackend.vala @@ -35,6 +35,10 @@ public class InstallerDaemon.DistinstBackend : GLib.Object { return to_common_usage_bootloader (Distinst.bootloader_detect ()); } + public uint64 get_minimum_disk_size () throws GLib.Error { + return 15 * Application.ONE_GB; + } + public DiskInfo get_disks (bool get_partitions = false) throws GLib.Error { disks = Distinst.Disks.probe (); diff --git a/src/Helpers/InstallerDaemon.vala b/src/Helpers/InstallerDaemon.vala index 25cdbec16..7cd5f7fbd 100644 --- a/src/Helpers/InstallerDaemon.vala +++ b/src/Helpers/InstallerDaemon.vala @@ -30,6 +30,7 @@ public class Installer.Daemon { public abstract InstallerDaemon.PartitionTable bootloader_detect () throws GLib.Error; public async abstract InstallerDaemon.DiskInfo get_disks (bool get_partitions = false) throws GLib.Error; + public async abstract uint64 get_minimum_disk_size () throws GLib.Error; public async abstract int decrypt_partition (string path, string pv, string password) throws GLib.Error; public async abstract InstallerDaemon.Disk get_logical_device (string pv) throws GLib.Error; public async abstract void install_with_default_disk_layout (InstallerDaemon.InstallConfig config, string disk, bool encrypt, string encryption_password) throws GLib.Error; @@ -104,6 +105,14 @@ public class Installer.Daemon { return yield daemon.get_logical_device (pv); } + public async uint64 get_minimum_disk_size () throws GLib.Error { + if (daemon == null) { + throw new GLib.IOError.FAILED ("Not connected to installer daemon"); + } + + return yield daemon.get_minimum_disk_size (); + } + public async void install_with_default_disk_layout (InstallerDaemon.InstallConfig config, string disk, bool encrypt, string encryption_password) throws GLib.Error { if (daemon == null) { throw new GLib.IOError.FAILED ("Not connected to installer daemon"); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 183a4d367..1eb616c82 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -23,11 +23,6 @@ public interface UPower : GLib.Object { } public class Installer.MainWindow : Gtk.ApplicationWindow, PantheonWayland.ExtendedBehavior { - // We have to do it step by step because the vala compiler has overflows with big numbers. - private const uint64 ONE_GB = 1000 * 1000 * 1000; - // Minimum 15 GB - private const uint64 MINIMUM_SPACE = 15 * ONE_GB; - private Adw.NavigationView navigation_view; private LanguageView language_view; private TryInstallView try_install_view; @@ -155,7 +150,6 @@ public class Installer.MainWindow : Gtk.ApplicationWindow, PantheonWayland.Exten var disk_view = new DiskView (); navigation_view.push (disk_view); - disk_view.load.begin (MINIMUM_SPACE); disk_view.next_step.connect (() => load_encrypt_view ()); } @@ -186,7 +180,7 @@ public class Installer.MainWindow : Gtk.ApplicationWindow, PantheonWayland.Exten } private void load_partitioning_view () { - var partitioning_view = new PartitioningView (MINIMUM_SPACE); + var partitioning_view = new PartitioningView (); navigation_view.push (partitioning_view); partitioning_view.next_step.connect (() => { diff --git a/src/Views/DiskView.vala b/src/Views/DiskView.vala index 41579380a..f6fc1acb0 100644 --- a/src/Views/DiskView.vala +++ b/src/Views/DiskView.vala @@ -103,13 +103,15 @@ public class Installer.DiskView : AbstractInstallerView { action_box_end.append (next_button); } - public async void load (uint64 minimum_disk_size) { + public async void load () { + uint64 minimum_disk_size; DiskButton[] enabled_buttons = {}; DiskButton[] disabled_buttons = {}; InstallerDaemon.DiskInfo? disks; try { disks = yield Daemon.get_default ().get_disks (); + minimum_disk_size = yield Daemon.get_default ().get_minimum_disk_size (); } catch (Error e) { critical ("Unable to get disks list: %s", e.message); load_stack.set_visible_child_name ("disk"); diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index eeb4bac28..ee7c0bcd4 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -28,10 +28,7 @@ public class Installer.PartitioningView : AbstractInstallerView { public Gee.ArrayList mounts; public Gee.ArrayList luks; - public static uint64 minimum_disk_size; - - public PartitioningView (uint64 size) { - minimum_disk_size = size; + public PartitioningView () { Object (cancellable: false); }