implement express and advanced modes

main
mirkobrombin 2 years ago
parent 78322eff27
commit 59dba6f6b1

@ -40,16 +40,19 @@
}, },
"steps": { "steps": {
"conn-check": { "conn-check": {
"template": "conn-check" "template": "conn-check",
"protected": true
}, },
"welcome": { "welcome": {
"template": "welcome" "template": "welcome",
"protected": true
}, },
"theme": { "theme": {
"template": "theme" "template": "theme"
}, },
"packages": { "packages": {
"template": "preferences", "template": "preferences",
"is-advanced": true,
"icon": "vanilla-package-symbolic", "icon": "vanilla-package-symbolic",
"title": "Package Manager", "title": "Package Manager",
"description": "Choose one or more package managers to install", "description": "Choose one or more package managers to install",
@ -403,6 +406,9 @@
}, },
"timeshift": { "timeshift": {
"template": "yes-no", "template": "yes-no",
"is-advanced": true,
"advanced_value-type": "bool",
"preset": false,
"icon": "vanilla-history-undo-symbolic", "icon": "vanilla-history-undo-symbolic",
"title": "Timeshift", "title": "Timeshift",
"description": "Choose whether to install Timeshift to create snapshots of your system.", "description": "Choose whether to install Timeshift to create snapshots of your system.",
@ -425,6 +431,8 @@
}, },
"nvidia": { "nvidia": {
"template": "yes-no", "template": "yes-no",
"is-advanced": true,
"preset": false,
"display-conditions": [ "display-conditions": [
"lspci | grep -i '.* nvidia .*'" "lspci | grep -i '.* nvidia .*'"
], ],
@ -453,6 +461,8 @@
}, },
"vm": { "vm": {
"template": "yes-no", "template": "yes-no",
"is-advanced": true,
"preset": true,
"display-conditions": [ "display-conditions": [
"grep 'hypervisor' /proc/cpuinfo" "grep 'hypervisor' /proc/cpuinfo"
], ],
@ -478,6 +488,8 @@
}, },
"codecs": { "codecs": {
"template": "yes-no", "template": "yes-no",
"is-advanced": true,
"preset": true,
"icon": "vanilla-puzzle-piece-symbolic", "icon": "vanilla-puzzle-piece-symbolic",
"title": "Restricted Codecs", "title": "Restricted Codecs",
"description": "Choose whether to install restricted codecs and fonts.", "description": "Choose whether to install restricted codecs and fonts.",
@ -500,6 +512,7 @@
}, },
"extra": { "extra": {
"template": "preferences", "template": "preferences",
"is-advanced": true,
"icon": "dialog-warning-symbolic", "icon": "dialog-warning-symbolic",
"title": "Extra Settings", "title": "Extra Settings",
"description": "The following are optional settings, leave them as they are if you don't know what they do.", "description": "The following are optional settings, leave them as they are if you don't know what they do.",

@ -24,6 +24,7 @@ from vanilla_first_setup.utils.run_async import RunAsync
class VanillaDefaultWelcome(Adw.Bin): class VanillaDefaultWelcome(Adw.Bin):
__gtype_name__ = 'VanillaDefaultWelcome' __gtype_name__ = 'VanillaDefaultWelcome'
btn_advanced = Gtk.Template.Child()
btn_next = Gtk.Template.Child() btn_next = Gtk.Template.Child()
status_page = Gtk.Template.Child() status_page = Gtk.Template.Child()
@ -75,7 +76,8 @@ class VanillaDefaultWelcome(Adw.Bin):
self.__start_welcome_animation() self.__start_welcome_animation()
# signals # 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 # set distro logo
self.status_page.set_icon_name(self.__distro_info["logo"]) self.status_page.set_icon_name(self.__distro_info["logo"])
@ -93,5 +95,11 @@ class VanillaDefaultWelcome(Adw.Bin):
RunAsync(change_langs, None) 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): def get_finals(self):
return {} return {}

@ -12,13 +12,28 @@
<property name="title" translatable="yes">Welcome!</property> <property name="title" translatable="yes">Welcome!</property>
<property name="description" translatable="yes">Make your choices, this wizard will take care of everything.</property> <property name="description" translatable="yes">Make your choices, this wizard will take care of everything.</property>
<child> <child>
<object class="GtkButton" id="btn_next"> <object class="GtkBox">
<property name="label">Let's Start</property> <property name="spacing">8</property>
<property name="halign">center</property> <property name="halign">center</property>
<style> <child>
<class name="pill" /> <object class="GtkButton" id="btn_advanced">
<class name="suggested-action" /> <property name="label">Advanced</property>
</style> <property name="halign">center</property>
<style>
<class name="pill" />
</style>
</object>
</child>
<child>
<object class="GtkButton" id="btn_next">
<property name="label">Start</property>
<property name="halign">center</property>
<style>
<class name="pill" />
<class name="suggested-action" />
</style>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

@ -36,7 +36,7 @@ class VanillaLayoutYesNo(Adw.Bin):
self.__distro_info = distro_info self.__distro_info = distro_info
self.__key = key self.__key = key
self.__step = step self.__step = step
self.__response = False self.__response = self.__get_default()
self.__build_ui() self.__build_ui()
# signals # signals
@ -81,3 +81,9 @@ class VanillaLayoutYesNo(Adw.Bin):
}, },
"funcs": [x for x in self.__step["final"]] "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)

@ -69,6 +69,9 @@ class Builder:
logging.warning("No log will be stored.") logging.warning("No log will be stored.")
for key, step in self.__recipe.raw["steps"].items(): for key, step in self.__recipe.raw["steps"].items():
_status = True
_protected = False
if step.get("display-conditions"): if step.get("display-conditions"):
_condition_met = False _condition_met = False
for command in step["display-conditions"]: for command in step["display-conditions"]:
@ -87,12 +90,17 @@ class Builder:
if not _condition_met: if not _condition_met:
continue continue
_status = not step.get("is-advanced", False)
if step.get("protected"):
_protected = True
if step["template"] in templates: if step["template"] in templates:
_widget = templates[step["template"]](self.__window, self.distro_info, key, step) _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): 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: if widget.step_id == step_id:
return widget.get_finals() return widget.get_finals()
@ -101,7 +109,7 @@ class Builder:
def get_finals(self): def get_finals(self):
self.__register_finals = [] self.__register_finals = []
for widget in self.__register_widgets: for widget, _, _ in self.__register_widgets:
self.__register_finals.append(widget.get_finals()) self.__register_finals.append(widget.get_finals())
return self.__register_finals return self.__register_finals

@ -104,13 +104,28 @@ class VanillaWindow(Adw.ApplicationWindow):
self.btn_back.connect("clicked", self.back) self.btn_back.connect("clicked", self.back)
self.carousel.connect("page-changed", self.__on_page_changed) self.carousel.connect("page-changed", self.__on_page_changed)
def __build_ui(self): def __build_ui(self, mode=0, rebuild=False):
for widget in self.__builder.widgets: 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(widget)
self.carousel.append(self.__view_progress) self.carousel.append(self.__view_progress)
self.carousel.append(self.__view_done) self.carousel.append(self.__view_done)
def rebuild_ui(self, mode=0):
self.__build_ui(mode, rebuild=True)
def __on_page_changed(self, *args): def __on_page_changed(self, *args):
pages_check = [self.__view_done] pages_check = [self.__view_done]
if self.__init_mode == 0: if self.__init_mode == 0:
@ -163,7 +178,10 @@ class VanillaWindow(Adw.ApplicationWindow):
self.__view_done.set_result(result, terminal) self.__view_done.set_result(result, terminal)
self.next() 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: if result is not None:
self.__last_result = result self.__last_result = result

Loading…
Cancel
Save