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

Integrate with distinst's new autoinstall features #126

Merged
merged 9 commits into from May 29, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions po/POTFILES
Expand Up @@ -9,6 +9,7 @@ src/Dialogs/EndSessionDialog.vala
src/Dialogs/HelpDialog.vala
src/Objects/org.freedesktop.udisks2.vala
src/Objects/Configuration.vala
src/Objects/InstallOptions.vala
src/Objects/Mount.vala
src/Objects/Recovery.vala
src/Views/AbstractInstallerView.vala
Expand Down
8 changes: 5 additions & 3 deletions src/Helpers/KeyboardLayoutHelper.vala
Expand Up @@ -36,12 +36,14 @@ namespace KeyboardLayoutHelper {
var variants = layout.get_variants ();
if (variants != null) {
foreach (unowned Distinst.KeyboardVariant variant in variants) {
variant_map[variant.get_name ()] = dgettext ("xkeyboard-config", variant.get_description ());
var name = Utils.string_from_utf8 (variant.get_name ());
var desc = Utils.string_from_utf8 (variant.get_description ());
variant_map[name] = dgettext ("xkeyboard-config", desc);
}
}
layouts.add (Layout () {
name = layout.get_name (),
description = dgettext ("xkeyboard-config", layout.get_description ()),
name = Utils.string_from_utf8 (layout.get_name ()),
description = dgettext ("xkeyboard-config", Utils.string_from_utf8 (layout.get_description ())),
variants = variant_map
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/LocaleHelper.vala
Expand Up @@ -100,9 +100,9 @@ namespace LocaleHelper {
}

public static string? get_main_country (string lang_prefix) {
string? main = Distinst.locale_get_main_country (lang_prefix);
uint8[]? main = Distinst.locale_get_main_country (lang_prefix);
if (main != null) {
return main;
return Utils.string_from_utf8 (main);
}

// We fallback to whatever is available in the lang list.
Expand Down
9 changes: 5 additions & 4 deletions src/MainWindow.vala
Expand Up @@ -61,6 +61,7 @@ public class Installer.MainWindow : Gtk.Dialog {
get_style_context ().add_class ("os-installer");

minimum_disk_size = Distinst.minimum_disk_size (5000000000);
InstallOptions.get_default ().set_minimum_size (minimum_disk_size);

language_view.next_step.connect (() => load_keyboard_view ());
}
Expand All @@ -81,8 +82,8 @@ public class Installer.MainWindow : Gtk.Dialog {
stack.visible_child = keyboard_layout_view;

keyboard_layout_view.next_step.connect (() => {
var recovery = Recovery.get_default ();
if (recovery == null || !recovery.oem_mode) {
var options = InstallOptions.get_default ();
if (!options.is_oem_mode ()) {
load_try_install_view ();
} else {
load_encrypt_view ();
Expand All @@ -100,6 +101,7 @@ public class Installer.MainWindow : Gtk.Dialog {
stack.add (try_install_view);
stack.visible_child = try_install_view;

try_install_view.custom_step.connect (() => load_partitioning_view ());
try_install_view.next_step.connect (() => load_disk_view ());
}

Expand Down Expand Up @@ -156,7 +158,6 @@ public class Installer.MainWindow : Gtk.Dialog {
stack.visible_child = try_install_view;
});

disk_view.custom_step.connect (() => load_partitioning_view ());
disk_view.next_step.connect (() => load_encrypt_view ());

load_check_view ();
Expand All @@ -168,7 +169,7 @@ public class Installer.MainWindow : Gtk.Dialog {
}

partitioning_view = new PartitioningView (minimum_disk_size);
partitioning_view.previous_view = disk_view;
partitioning_view.previous_view = try_install_view;
stack.add (partitioning_view);
stack.visible_child = partitioning_view;

Expand Down
1 change: 1 addition & 0 deletions src/Objects/Configuration.vala
Expand Up @@ -35,6 +35,7 @@ public class Configuration : GLib.Object {
public string? encryption_password { get; set; default = null; }
public string disk { get; set; }
public bool recovery { get; set; default = false; }
public bool retain_home { get; set; default = false; }
public Gee.ArrayList<Installer.Mount>? mounts { get; set; default = null; }
public Gee.ArrayList<Installer.LuksCredentials>? luks { get; set; default = null; }

Expand Down
81 changes: 81 additions & 0 deletions src/Objects/InstallOptions.vala
@@ -0,0 +1,81 @@
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
/*-
* Copyright (c) 2018 elementary LLC. (https://elementary.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Michael Aaron Murphy <michael@system76.com>
*/

public class InstallOptions : GLib.Object {
private static InstallOptions _options_object;
private uint64 minimum_size;
private uint64 layout_hash;
private Distinst.InstallOptions _options;
private Distinst.Disks disks;
public Distinst.InstallOption? selected_option;

public static unowned InstallOptions get_default () {
if (_options_object == null) {
_options_object = new InstallOptions ();
}

return _options_object;
}

public void set_minimum_size (uint64 size) {
minimum_size = size;
}

public bool has_recovery () {
return null != get_options().get_recovery_option ();
}

public bool is_oem_mode () {
var recovery = get_options().get_recovery_option ();
return null != recovery && recovery.get_oem_mode ();
}

public unowned Distinst.InstallOptions get_options () {
if (null == _options) {
disks = Distinst.Disks.probe ();
disks.initialize_volume_groups ();
layout_hash = Distinst.device_layout_hash ();
_options = new Distinst.InstallOptions (disks, minimum_size);
}

return _options;
}

// Returns an updated option if the device layout has changed.
public unowned Distinst.InstallOptions get_updated_options () {
var new_hash = Distinst.device_layout_hash ();
if (layout_hash != new_hash) {
layout_hash = new_hash;
disks = Distinst.Disks.probe ();
_options = new Distinst.InstallOptions (disks, minimum_size);
selected_option = null;
}

return _options;
}

public Distinst.Disks get_disks () {
return (owned) disks;
}

public unowned Distinst.InstallOption? get_selected_option () {
return selected_option;
}
}
205 changes: 0 additions & 205 deletions src/Objects/Recovery.vala

This file was deleted.