From ac0934cba5cdf1947aec615babe913b4a15e8363 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Thu, 5 Jan 2023 16:29:07 +0100 Subject: [PATCH] misc: Do not process finals for applications if no pkg manager --- recipe.json | 7 +++++++ vanilla_first_setup/defaults/applications.py | 13 ++++++++++++- vanilla_first_setup/utils/processor.py | 3 ++- vanilla_first_setup/window.py | 12 +++++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/recipe.json b/recipe.json index c10cb9f..c486e5b 100644 --- a/recipe.json +++ b/recipe.json @@ -81,6 +81,13 @@ "title": "AppImage", "subtitle": "Install necessary dependencies to run AppImages.", "default": true + }, + { + "id": "-", + "title": "-", + "subtitle": "-", + "disabled": true, + "default": true } ], "final": [ diff --git a/vanilla_first_setup/defaults/applications.py b/vanilla_first_setup/defaults/applications.py index b9b20ba..3572ebd 100644 --- a/vanilla_first_setup/defaults/applications.py +++ b/vanilla_first_setup/defaults/applications.py @@ -38,6 +38,7 @@ class VanillaLayoutApplications(Adw.Bin): # signals self.btn_next.connect("clicked", self.__next_step) + self.__window.connect("page-changed", self.__on_page_changed) @property def step_id(self): @@ -152,8 +153,18 @@ class VanillaLayoutApplications(Adw.Bin): self.__register_widgets.append((item["id"], _switcher, _index)) _index += 1 + + def __on_page_changed(self, widget, page): + if page == self.__key: + if True not in [ + self.__window.builder.get_temp_finals("packages")["vars"]["flatpak"], + self.__window.builder.get_temp_finals("packages")["vars"]["snap"] + ]: + self.bundles_list.set_sensitive(False) + else: + self.bundles_list.set_sensitive(True) - def __next_step(self, widget): + def __next_step(self, *args): self.__window.next() def get_finals(self): diff --git a/vanilla_first_setup/utils/processor.py b/vanilla_first_setup/utils/processor.py index 78a804a..702d35a 100644 --- a/vanilla_first_setup/utils/processor.py +++ b/vanilla_first_setup/utils/processor.py @@ -111,7 +111,8 @@ class Processor: # fake the process if VANILLA_FAKE is set if "VANILLA_FAKE" in os.environ: - return True, "" + logger.info("VANILLA_FAKE is set, skipping the commands") + return True, "" cmd = ["pkexec", "sh", f.name] if abroot_bin := shutil.which("abroot"): diff --git a/vanilla_first_setup/window.py b/vanilla_first_setup/window.py index 9e181dd..672489e 100644 --- a/vanilla_first_setup/window.py +++ b/vanilla_first_setup/window.py @@ -15,7 +15,8 @@ # along with this program. If not, see . import time -from gi.repository import Gtk, Adw +import contextlib +from gi.repository import Gtk, GObject, Adw from vanilla_first_setup.utils.builder import Builder from vanilla_first_setup.utils.parser import Parser @@ -30,6 +31,9 @@ from vanilla_first_setup.views.post_script import VanillaPostScript @Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/window.ui') class VanillaWindow(Adw.ApplicationWindow): __gtype_name__ = 'VanillaWindow' + __gsignals__ = { + "page-changed": (GObject.SignalFlags.RUN_FIRST, None, (str,)), + } carousel = Gtk.Template.Child() carousel_indicator_dots = Gtk.Template.Child() @@ -108,6 +112,7 @@ class VanillaWindow(Adw.ApplicationWindow): self.carousel.append(self.__view_done) def __on_page_changed(self, *args): + def process(): # this parses the finals to compatible commands, by replacing the # placeholders with the actual values and generating shell commands @@ -132,6 +137,11 @@ class VanillaWindow(Adw.ApplicationWindow): cur_index = self.carousel.get_position() page = self.carousel.get_nth_page(cur_index) + with contextlib.suppress(AttributeError): + self.emit("page-changed", page.step_id) + + print("Page changed to", cur_index, page) + if page not in pages_check: self.btn_back.set_visible(cur_index != 0.0) self.carousel_indicator_dots.set_visible(cur_index != 0.0)