diff --git a/recipe.json b/recipe.json index 0a0314b..a4d26f8 100644 --- a/recipe.json +++ b/recipe.json @@ -40,16 +40,19 @@ }, "steps": { "conn-check": { - "template": "conn-check" + "template": "conn-check", + "protected": true }, "welcome": { - "template": "welcome" + "template": "welcome", + "protected": true }, "theme": { "template": "theme" }, "packages": { "template": "preferences", + "is-advanced": true, "icon": "vanilla-package-symbolic", "title": "Package Manager", "description": "Choose one or more package managers to install", @@ -403,6 +406,9 @@ }, "timeshift": { "template": "yes-no", + "is-advanced": true, + "advanced_value-type": "bool", + "preset": false, "icon": "vanilla-history-undo-symbolic", "title": "Timeshift", "description": "Choose whether to install Timeshift to create snapshots of your system.", @@ -425,6 +431,8 @@ }, "nvidia": { "template": "yes-no", + "is-advanced": true, + "preset": false, "display-conditions": [ "lspci | grep -i '.* nvidia .*'" ], @@ -453,6 +461,8 @@ }, "vm": { "template": "yes-no", + "is-advanced": true, + "preset": true, "display-conditions": [ "grep 'hypervisor' /proc/cpuinfo" ], @@ -478,6 +488,8 @@ }, "codecs": { "template": "yes-no", + "is-advanced": true, + "preset": true, "icon": "vanilla-puzzle-piece-symbolic", "title": "Restricted Codecs", "description": "Choose whether to install restricted codecs and fonts.", @@ -500,6 +512,7 @@ }, "extra": { "template": "preferences", + "is-advanced": true, "icon": "dialog-warning-symbolic", "title": "Extra Settings", "description": "The following are optional settings, leave them as they are if you don't know what they do.", diff --git a/vanilla_first_setup/defaults/welcome.py b/vanilla_first_setup/defaults/welcome.py index 881f156..9ac64a4 100644 --- a/vanilla_first_setup/defaults/welcome.py +++ b/vanilla_first_setup/defaults/welcome.py @@ -24,6 +24,7 @@ from vanilla_first_setup.utils.run_async import RunAsync class VanillaDefaultWelcome(Adw.Bin): __gtype_name__ = 'VanillaDefaultWelcome' + btn_advanced = Gtk.Template.Child() btn_next = Gtk.Template.Child() status_page = Gtk.Template.Child() @@ -75,7 +76,8 @@ class VanillaDefaultWelcome(Adw.Bin): self.__start_welcome_animation() # signals - self.btn_next.connect("clicked", self.__window.next) + self.btn_advanced.connect("clicked", self.__advanced) + self.btn_next.connect("clicked", self.__next) # set distro logo self.status_page.set_icon_name(self.__distro_info["logo"]) @@ -93,5 +95,11 @@ class VanillaDefaultWelcome(Adw.Bin): RunAsync(change_langs, None) + def __advanced(self, widget): + self.__window.next(rebuild=True, mode=1) + + def __next(self, widget): + self.__window.next(rebuild=True, mode=0) + def get_finals(self): return {} diff --git a/vanilla_first_setup/gtk/default-welcome.ui b/vanilla_first_setup/gtk/default-welcome.ui index 2c40ac8..2483721 100644 --- a/vanilla_first_setup/gtk/default-welcome.ui +++ b/vanilla_first_setup/gtk/default-welcome.ui @@ -12,13 +12,28 @@ Welcome! Make your choices, this wizard will take care of everything. - - Let's Start + + 8 center - + + + Advanced + center + + + + + + Start + center + + + diff --git a/vanilla_first_setup/layouts/yes_no.py b/vanilla_first_setup/layouts/yes_no.py index 11d7526..8b926bc 100644 --- a/vanilla_first_setup/layouts/yes_no.py +++ b/vanilla_first_setup/layouts/yes_no.py @@ -36,7 +36,7 @@ class VanillaLayoutYesNo(Adw.Bin): self.__distro_info = distro_info self.__key = key self.__step = step - self.__response = False + self.__response = self.__get_default() self.__build_ui() # signals @@ -81,3 +81,9 @@ class VanillaLayoutYesNo(Adw.Bin): }, "funcs": [x for x in self.__step["final"]] } + + def __get_default(self): + if not self.__step.get("is-advanced"): + return False + + return self.__step.get("preset", False) diff --git a/vanilla_first_setup/utils/builder.py b/vanilla_first_setup/utils/builder.py index 56cb4ca..0a99670 100644 --- a/vanilla_first_setup/utils/builder.py +++ b/vanilla_first_setup/utils/builder.py @@ -69,6 +69,9 @@ class Builder: logging.warning("No log will be stored.") for key, step in self.__recipe.raw["steps"].items(): + _status = True + _protected = False + if step.get("display-conditions"): _condition_met = False for command in step["display-conditions"]: @@ -86,13 +89,18 @@ class Builder: if not _condition_met: continue + + _status = not step.get("is-advanced", False) + + if step.get("protected"): + _protected = True if step["template"] in templates: _widget = templates[step["template"]](self.__window, self.distro_info, key, step) - self.__register_widgets.append(_widget) + self.__register_widgets.append((_widget, _status, _protected)) def get_temp_finals(self, step_id: str): - for widget in self.__register_widgets: + for widget, _, _ in self.__register_widgets: if widget.step_id == step_id: return widget.get_finals() @@ -101,7 +109,7 @@ class Builder: def get_finals(self): self.__register_finals = [] - for widget in self.__register_widgets: + for widget, _, _ in self.__register_widgets: self.__register_finals.append(widget.get_finals()) return self.__register_finals diff --git a/vanilla_first_setup/window.py b/vanilla_first_setup/window.py index 4e746bb..3540b99 100644 --- a/vanilla_first_setup/window.py +++ b/vanilla_first_setup/window.py @@ -104,12 +104,27 @@ class VanillaWindow(Adw.ApplicationWindow): self.btn_back.connect("clicked", self.back) self.carousel.connect("page-changed", self.__on_page_changed) - def __build_ui(self): - for widget in self.__builder.widgets: + def __build_ui(self, mode=0, rebuild=False): + if rebuild: + self.carousel.remove(self.__view_progress) + self.carousel.remove(self.__view_done) + + for widget, status, protected in self.__builder.widgets: + if rebuild: + if protected: + continue + self.carousel.remove(widget) + + if mode == 0 and not status: + continue + self.carousel.append(widget) self.carousel.append(self.__view_progress) self.carousel.append(self.__view_done) + + def rebuild_ui(self, mode=0): + self.__build_ui(mode, rebuild=True) def __on_page_changed(self, *args): pages_check = [self.__view_done] @@ -163,7 +178,10 @@ class VanillaWindow(Adw.ApplicationWindow): self.__view_done.set_result(result, terminal) self.next() - def next(self, widget: Gtk.Widget=None, result: bool=None, *args): + def next(self, widget: Gtk.Widget=None, result: bool=None, rebuild: bool=False, mode: int=0, *args): + if rebuild: + self.rebuild_ui(mode) + if result is not None: self.__last_result = result