implement express and advanced modes

main
mirkobrombin 2 years ago
parent 78322eff27
commit 59dba6f6b1

@ -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.",

@ -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 {}

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

@ -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)

@ -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"]:
@ -87,12 +90,17 @@ 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

@ -104,13 +104,28 @@ 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]
if self.__init_mode == 0:
@ -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

Loading…
Cancel
Save