Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

halt vanilla-installer if non-uefi device is returned #322

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vanilla_installer/assets/CREDITS
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions vanilla_installer/assets/unsupported.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions vanilla_installer/gtk/window-unsupported.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="VanillaUnsupportedWindow" parent="AdwWindow">
<property name="default-width">800</property>
<property name="default-height">600</property>
<property name="deletable">False</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="spacing">24</property>
<child>
<object class="AdwClamp">
<property name="maximum-size">450</property>
<child>
<object class="GtkPicture">
<property name="file">resource:///org/vanillaos/Installer/assets/unsupported.svg</property>
<property name="can-shrink">False</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="title_label">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
<property name="label">Cannot Install</property>
<style>
<class name="title"/>
<class name="title-1"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="description_label">
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="justify">center</property>
<style>
<class name="body"/>
<class name="description"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="btn_poweroff">
<property name="margin-top">12</property>
<property name="label" translatable="yes">Power Off...</property>
<property name="halign">center</property>
<style>
<class name="suggested-action"/>
<class name="pill"/>
</style>
</object>
</child>
</object>
</child>
</template>
</interface>
11 changes: 8 additions & 3 deletions vanilla_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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)
2 changes: 2 additions & 0 deletions vanilla_installer/vanilla-installer.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/vanillaos/Installer">
<file>gtk/window.ui</file>
<file>gtk/window-unsupported.ui</file>
<file>gtk/confirm.ui</file>
<file>gtk/done.ui</file>
<file>gtk/progress.ui</file>
Expand Down Expand Up @@ -44,6 +45,7 @@
<file>assets/complete.svg</file>
<file>assets/control-center.svg</file>
<file>assets/containerized.svg</file>
<file>assets/unsupported.svg</file>
</gresource>
<gresource prefix="/org/vanillaos/Installer/icons/scalable/actions/">
<file preprocess="xml-stripblanks">../data/icons/hicolor/symbolic/actions/background-app-ghost-symbolic.svg</file>
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/windows/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sources = [
'dialog_output.py',
'dialog_recovery.py',
'dialog_poweroff.py',
'window_unsupported.py',
]

install_data(sources, install_dir: windowsdir)
39 changes: 39 additions & 0 deletions vanilla_installer/windows/window_unsupported.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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 <http://www.gnu.org/licenses/>.

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")
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):
subprocess.call(["systemctl", "poweroff"])