diff --git a/bottles/frontend/main.py b/bottles/frontend/main.py index 9486c4206e..9874d8b84e 100644 --- a/bottles/frontend/main.py +++ b/bottles/frontend/main.py @@ -29,7 +29,7 @@ gi.require_version("Xdp", "1.0") # gi.require_version("XdpGtk4", "1.0") -from gi.repository import Gtk, Gio, GLib, GObject, Adw, Xdp # type: ignore +from gi.repository import Gtk, Gio, GLib, GObject, Adw # type: ignore from bottles.frontend.params import * from bottles.backend.logger import Logger @@ -251,12 +251,6 @@ def do_activate(self): win = MainWindow(application=self, arg_bottle=self.arg_bottle) self.win = win - # Be VERY explicit that non-sandboxed environments are unsupported - if not Xdp.Portal.running_under_sandbox(): - logging.error(_("Bottles is only supported within a sandboxed format. Official sources of Bottles are available at:")) - logging.error("https://usebottles.com/download/") - quit(1) - win.present() def __quit(self, *args): diff --git a/bottles/frontend/windows/main_window.py b/bottles/frontend/windows/main_window.py index 5fb9a15c29..047fc6a819 100644 --- a/bottles/frontend/windows/main_window.py +++ b/bottles/frontend/windows/main_window.py @@ -21,7 +21,7 @@ from gettext import gettext as _ from typing import Optional -from gi.repository import Gtk, GLib, Gio, Adw, GObject, Gdk +from gi.repository import Gtk, GLib, Gio, Adw, GObject, Gdk, Xdp from bottles.backend.globals import Paths from bottles.backend.health import HealthChecker @@ -96,6 +96,28 @@ def __init__(self, arg_bottle, **kwargs): manager = Adw.StyleManager.get_default() manager.set_color_scheme(Adw.ColorScheme.FORCE_DARK) + # Be VERY explicit that non-sandboxed environments are unsupported + if not Xdp.Portal.running_under_sandbox(): + def response(dialog, response, *args): + if response == "close": + quit(1) + + body = _("Bottles is only supported within a sandboxed environment. Official sources of Bottles are available at") + download_url = "usebottles.com/download" + + error_dialog = Adw.AlertDialog.new( + _("Unsupported Environment"), + f"{body} {download_url}." + ) + + error_dialog.add_response("close", _("Close")) + error_dialog.set_body_use_markup(True) + error_dialog.connect("response", response) + error_dialog.present(self) + logging.error(_("Bottles is only supported within a sandboxed format. Official sources of Bottles are available at:")) + logging.error("https://usebottles.com/download/") + return + # Loading view self.page_loading = LoadingView()