From cfd458b7b2a46866ff3bab53eb818a324dacb46d Mon Sep 17 00:00:00 2001 From: Muqtxdir Date: Sat, 23 Dec 2023 03:05:25 +0530 Subject: [PATCH 1/2] feat: #319 - add unsupported window for non-uefi devices. --- vanilla_installer/assets/CREDITS | 2 + vanilla_installer/assets/unsupported.svg | 1 + vanilla_installer/gtk/window-unsupported.ui | 74 +++++++++++++++++++ vanilla_installer/main.py | 11 ++- .../vanilla-installer.gresource.xml | 2 + vanilla_installer/windows/meson.build | 1 + .../windows/window_unsupported.py | 36 +++++++++ 7 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 vanilla_installer/assets/unsupported.svg create mode 100644 vanilla_installer/gtk/window-unsupported.ui create mode 100644 vanilla_installer/windows/window_unsupported.py diff --git a/vanilla_installer/assets/CREDITS b/vanilla_installer/assets/CREDITS index 21a8bbe0..84cd8bbe 100644 --- a/vanilla_installer/assets/CREDITS +++ b/vanilla_installer/assets/CREDITS @@ -1,2 +1,4 @@ Computer illustration from GNOME Initial Setup by Tobias Bernard licensed under the GNU General Public License Version 2. App icons from various GNOME projects. + +Unsupported.svg is extracted from Toggle's mockup and is provided by the illustrator(Brage: https://bragefuglseth.dev/) such that it can be re-used in vanilla-installer diff --git a/vanilla_installer/assets/unsupported.svg b/vanilla_installer/assets/unsupported.svg new file mode 100644 index 00000000..3dc71c04 --- /dev/null +++ b/vanilla_installer/assets/unsupported.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/vanilla_installer/gtk/window-unsupported.ui b/vanilla_installer/gtk/window-unsupported.ui new file mode 100644 index 00000000..509d446f --- /dev/null +++ b/vanilla_installer/gtk/window-unsupported.ui @@ -0,0 +1,74 @@ + + + + + + diff --git a/vanilla_installer/main.py b/vanilla_installer/main.py index ea83e183..d90fb626 100644 --- a/vanilla_installer/main.py +++ b/vanilla_installer/main.py @@ -31,12 +31,14 @@ from gi.repository import Adw, Gio from vanilla_installer.windows.main_window import VanillaWindow +from vanilla_installer.windows.window_unsupported import VanillaUnsupportedWindow +from vanilla_installer.core.system import Systeminfo logging.basicConfig(level=logging.INFO) -class FirstSetupApplication(Adw.Application): +class VanillaInstaller(Adw.Application): """The main application singleton class.""" def __init__(self): @@ -57,7 +59,10 @@ def do_activate(self): win = self.props.active_window if not win: - win = VanillaWindow(application=self) + if Systeminfo.is_uefi(): + win = VanillaWindow(application=self) + else: + win = VanillaUnsupportedWindow(application=self) win.present() def create_action(self, name, callback, shortcuts=None): @@ -82,5 +87,5 @@ def close(self, *args): def main(version): """The application's entry point.""" - app = FirstSetupApplication() + app = VanillaInstaller() return app.run(sys.argv) diff --git a/vanilla_installer/vanilla-installer.gresource.xml b/vanilla_installer/vanilla-installer.gresource.xml index 4ccf2ce7..2cc007b2 100644 --- a/vanilla_installer/vanilla-installer.gresource.xml +++ b/vanilla_installer/vanilla-installer.gresource.xml @@ -2,6 +2,7 @@ gtk/window.ui + gtk/window-unsupported.ui gtk/confirm.ui gtk/done.ui gtk/progress.ui @@ -44,6 +45,7 @@ assets/complete.svg assets/control-center.svg assets/containerized.svg + assets/unsupported.svg ../data/icons/hicolor/symbolic/actions/background-app-ghost-symbolic.svg diff --git a/vanilla_installer/windows/meson.build b/vanilla_installer/windows/meson.build index 0828161d..9336889a 100644 --- a/vanilla_installer/windows/meson.build +++ b/vanilla_installer/windows/meson.build @@ -8,6 +8,7 @@ sources = [ 'dialog_output.py', 'dialog_recovery.py', 'dialog_poweroff.py', + 'window_unsupported.py', ] install_data(sources, install_dir: windowsdir) diff --git a/vanilla_installer/windows/window_unsupported.py b/vanilla_installer/windows/window_unsupported.py new file mode 100644 index 00000000..a1ab81be --- /dev/null +++ b/vanilla_installer/windows/window_unsupported.py @@ -0,0 +1,36 @@ +# window_unsupported.py +# +# Copyright 2023 muqtadir +# +# 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 Foundationat version 3 of the License. +# +# 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 . + +from gettext import gettext as _ +import subprocess +from gi.repository import Adw, Gtk + + +@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/window-unsupported.ui") +class VanillaUnsupportedWindow(Adw.Window): + __gtype_name__ = "VanillaUnsupportedWindow" + + btn_poweroff = Gtk.Template.Child() + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + self.btn_poweroff.connect("clicked", self.__on_poweroff) + + def __on_poweroff(self, btn): + subprocess.call(["systemctl", "poweroff"]) + + From ce08b67326c3e2d54742743295613e668f0952f7 Mon Sep 17 00:00:00 2001 From: Muqtxdir Date: Sun, 24 Dec 2023 00:17:52 +0530 Subject: [PATCH 2/2] minor tweaks: - change wording for description and title - align the svg resource with grid scale. --- vanilla_installer/assets/unsupported.svg | 2 +- vanilla_installer/gtk/window-unsupported.ui | 113 +++++++++--------- .../windows/window_unsupported.py | 3 + 3 files changed, 58 insertions(+), 60 deletions(-) diff --git a/vanilla_installer/assets/unsupported.svg b/vanilla_installer/assets/unsupported.svg index 3dc71c04..45d4f399 100644 --- a/vanilla_installer/assets/unsupported.svg +++ b/vanilla_installer/assets/unsupported.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/vanilla_installer/gtk/window-unsupported.ui b/vanilla_installer/gtk/window-unsupported.ui index 509d446f..8bcf56f5 100644 --- a/vanilla_installer/gtk/window-unsupported.ui +++ b/vanilla_installer/gtk/window-unsupported.ui @@ -7,67 +7,62 @@ 600 False - - - - - - - - vertical - 12 - - - 450 - - - resource:///org/vanillaos/Installer/assets/unsupported.svg - False - - - - - - - True - word-char - center - Unsupported Device - - - - - - True - word-char - center - True - Vanilla OS can only be installed on devices that make use of UEFI Firmware. - - - - - - 12 - Power Off... - center - - - - - + + vertical + center + 24 + + + 450 + + + resource:///org/vanillaos/Installer/assets/unsupported.svg + False - + - + + + + vertical + center + 12 + + + True + word-char + center + Cannot Install + + + + + + True + word-char + center + + + + + + + + 12 + Power Off... + center + + + diff --git a/vanilla_installer/windows/window_unsupported.py b/vanilla_installer/windows/window_unsupported.py index a1ab81be..54804748 100644 --- a/vanilla_installer/windows/window_unsupported.py +++ b/vanilla_installer/windows/window_unsupported.py @@ -17,6 +17,7 @@ from gettext import gettext as _ import subprocess from gi.repository import Adw, Gtk +from vanilla_installer.utils.recipe import RecipeLoader @Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/window-unsupported.ui") @@ -24,10 +25,12 @@ class VanillaUnsupportedWindow(Adw.Window): __gtype_name__ = "VanillaUnsupportedWindow" btn_poweroff = Gtk.Template.Child() + description_label = Gtk.Template.Child() def __init__(self, **kwargs): super().__init__(**kwargs) + self.description_label.set_label(f"{RecipeLoader().raw['distro_name']} requires UEFI to install") self.btn_poweroff.connect("clicked", self.__on_poweroff) def __on_poweroff(self, btn):