Skip to content

Commit

Permalink
fix: what the fuck
Browse files Browse the repository at this point in the history
  • Loading branch information
jardon committed Oct 1, 2024
1 parent dfe079e commit 3a1c3e6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 54 deletions.
3 changes: 2 additions & 1 deletion recipe.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,5 +614,6 @@
}
]
}
}
},
"reboot_condition": "false"
}
3 changes: 2 additions & 1 deletion recipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,6 @@
}
]
}
}
},
"reboot_condition": "false"
}
52 changes: 12 additions & 40 deletions vanilla_first_setup/defaults/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import time
import sys
from gi.repository import Gtk, GLib, Adw
from gettext import translation
from vanilla_first_setup.utils.recipe import RecipeLoader

from vanilla_first_setup.utils.run_async import RunAsync
from vanilla_first_setup.core.languages import all_locale


@Gtk.Template(resource_path="/org/vanillaos/FirstSetup/gtk/default-welcome.ui")
Expand All @@ -29,43 +32,7 @@ class VanillaDefaultWelcome(Adw.Bin):
btn_next = Gtk.Template.Child()
status_page = Gtk.Template.Child()
title_label = Gtk.Template.Child()

welcome = [
"Welcome",
"Benvenuto",
"Bienvenido",
"Bienvenue",
"Willkommen",
"Bem-vindo",
"Добро пожаловать",
"欢迎",
"ようこそ",
"환영합니다",
"أهلا بك",
"ברוך הבא",
"Καλώς ήρθατε",
"Hoşgeldiniz",
"Welkom",
"Witamy",
"Välkommen",
"Tervetuloa",
"Vítejte",
"Üdvözöljük",
"Bun venit",
"Vitajte",
"Tere tulemast",
"Sveiki atvykę",
"Dobrodošli",
"خوش آمدید",
"आपका स्वागत है",
"স্বাগতম",
"வரவேற்கிறோம்",
"స్వాగతం",
"मुबारक हो",
"સુસ્વાગત છે",
"ಸುಸ್ವಾಗತ",
"സ്വാഗതം",
]
welcome_message = Gtk.Template.Child()

def validate_advanced(self):
recipeLoader = RecipeLoader()
Expand Down Expand Up @@ -103,9 +70,14 @@ def step_id(self):
def __start_welcome_animation(self):
def change_langs():
while True:
for lang in self.welcome:
GLib.idle_add(self.title_label.set_text, lang)
time.sleep(1.2)
for locale in all_locale:
translator = translation('vanilla-first-setup', localedir=f"{sys.base_prefix}/share/locale", languages=[locale], fallback=True)
_ = translator.gettext
GLib.idle_add(self.title_label.set_text, _("Welcome!"))
GLib.idle_add(self.btn_next.set_label, _("Next"))
GLib.idle_add(self.btn_advanced.set_label, _("Advanced"))
GLib.idle_add(self.welcome_message.set_label, _("Make your choices, this wizard will take care of everything."))
time.sleep(2.0)

RunAsync(change_langs, None)

Expand Down
4 changes: 2 additions & 2 deletions vanilla_first_setup/gtk/default-welcome.ui
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Make your choices, this wizard will take care of everything</property>
<object class="GtkLabel" id="welcome_message">
<property name="label" translatable="yes">Make your choices, this wizard will take care of everything</property>
<property name="justify">2</property>
</object>
</child>
Expand Down
4 changes: 2 additions & 2 deletions vanilla_first_setup/gtk/done.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<object class="AdwStatusPage" id="status_page">
<property name="icon-name">emblem-default-symbolic</property>
<property name="title" translatable="yes">Finished!</property>
<property name="description" translatable="yes">Restart your device to enjoy your Vanilla OS experience</property>
<property name="description" translatable="yes">You're ready to start experiencing Vanilla OS.</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
Expand Down Expand Up @@ -63,7 +63,7 @@
</child>
<child>
<object class="GtkButton" id="btn_close">
<property name="label">Close</property>
<property name="label">Get Started</property>
<property name="halign">center</property>
<property name="visible">false</property>
<style>
Expand Down
29 changes: 22 additions & 7 deletions vanilla_first_setup/views/done.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class VanillaDone(Adw.Bin):
def __init__(
self,
window,
reboot: bool = True,
title: str = "",
description: str = "",
fail_title: str = "",
Expand All @@ -52,22 +51,36 @@ def __init__(

if not title and not description:
self.status_page.set_description(
_("Restart your device to enjoy your {} experience.").format(
_("You're ready to start experiencing {}.").format(
self.__window.recipe["distro_name"]
)
)
else:
self.status_page.set_title(title)
self.status_page.set_description(description)

if reboot:
self.btn_reboot.connect("clicked", self.__on_reboot_clicked)
else:
self.btn_reboot.set_visible(False)
self.btn_close.set_visible(True)
self.btn_reboot.set_visible(False)
self.btn_close.set_visible(True)

self.btn_close.connect("clicked", self.__on_close_clicked)
self.btn_retry.connect("clicked", self.__on_retry_clicked)
self.btn_reboot.connect("clicked", self.__on_reboot_clicked)

def set_reboot(self):
recipe = RecipeLoader()
if recipe.raw.get("reboot_condition"):
condition = subprocess.run(recipe.raw["reboot_condition"].split())
if condition.returncode == 0:
self.status_page.set_description(
("Restart your device to enjoy your {} experience.").format(
self.__window.recipe["distro_name"]
)
)
self.btn_reboot.set_visible(True)
self.btn_close.set_visible(False)
else:
self.btn_reboot.set_visible(False)
self.btn_close.set_visible(True)

def set_result(self, result, terminal=None):
out = terminal.get_text()[0] if terminal else ""
Expand Down Expand Up @@ -95,6 +108,8 @@ def __on_close_clicked(self, *args):
[recipe.raw["tour_app"]],
flags=GLib.SpawnFlags.SEARCH_PATH,
)
else:
subprocess.run(["gnome-session-quit", "--no-prompt"])

self.__window.close()

Expand Down
2 changes: 1 addition & 1 deletion vanilla_first_setup/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def __init__(self, post_script: str, user: str, new_user: bool = False, **kwargs
# system views
self.__view_done = VanillaDone(
self,
reboot=False,
title=_("Done!"),
description=_("Your device is ready to use."),
fail_title=_("Error!"),
Expand Down Expand Up @@ -167,6 +166,7 @@ def __on_page_changed(self, *args):

# keep the btn_back button locked if this is the last page
if page == self.__view_done:
self.__view_done.set_reboot()
return

# collect all the finals
Expand Down

0 comments on commit 3a1c3e6

Please sign in to comment.