From a29a948577886319896333aba6703d868e3fc518 Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Sat, 17 Dec 2022 13:30:46 +0100 Subject: [PATCH 01/19] Add apps UI --- recipe.json | 57 ++++++++ vanilla_first_setup/defaults/theme.py | 3 +- vanilla_first_setup/defaults/welcome.py | 2 +- .../gtk/layout-applications.ui | 41 ++++++ vanilla_first_setup/layouts/applications.py | 128 ++++++++++++++++++ vanilla_first_setup/layouts/meson.build | 1 + vanilla_first_setup/layouts/preferences.py | 4 +- vanilla_first_setup/utils/builder.py | 7 +- vanilla_first_setup/utils/parser.py | 2 - vanilla_first_setup/utils/recipe.py | 2 - .../vanilla-first-setup.gresource.xml | 1 + vanilla_first_setup/window.py | 2 +- 12 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 vanilla_first_setup/gtk/layout-applications.ui create mode 100644 vanilla_first_setup/layouts/applications.py diff --git a/recipe.json b/recipe.json index 6ff27f9..95a053a 100644 --- a/recipe.json +++ b/recipe.json @@ -25,6 +25,63 @@ } }, "steps": { + "apps": { + "template": "applications", + "icon": "org.gnome.Software-symbolic", + "title": "Applications", + "description": "Choose which applications to install.", + "bundles": [ + { + "id": "essential-apps", + "title": "Essential Applications", + "subtitle": "Core GNOME apps like Calendar or Calculator.", + "default": true, + "applications" : [ + { + "name" : "Calendar", + "icon" : "org.gnome.Calendar-symbolic" + }, + { + "name" : "Calculator", + "icon" : "org.gnome.Calculator-symbolic" + }, + { + "name" : "Cheese", + "icon" : "org.gnome.Cheese-symbolic" + } + ] + }, + { + "id": "utilities", + "title": "Common Utilities", + "subtitle": "Useful utilities like Disks or Fonts.", + "default": true, + "applications" : [ + { + "name" : "Disks", + "icon" : "org.gnome.DiskUtility-symbolic" + }, + { + "name" : "Fonts", + "icon" : "org.gnome.font-viewer-symbolic" + } + ] + } + ], + "final": [ + { + "if": "essential-apps", + "type": "command", + "commands": ["flatpak install org.gnome.Geary || snap install snapd"] + }, + { + "if": "utilities", + "type": "command", + "commands": ["flatpak install org.gnome.Geary || snap install snapd"] + } + ] + }, + "welcome": { "template": "welcome" }, diff --git a/vanilla_first_setup/defaults/theme.py b/vanilla_first_setup/defaults/theme.py index 0423474..a2310e1 100644 --- a/vanilla_first_setup/defaults/theme.py +++ b/vanilla_first_setup/defaults/theme.py @@ -14,8 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import time -from gi.repository import Gtk, Gio, GLib, Adw +from gi.repository import Gtk, Gio @Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/default-theme.ui') diff --git a/vanilla_first_setup/defaults/welcome.py b/vanilla_first_setup/defaults/welcome.py index a1217fe..14cbd2a 100644 --- a/vanilla_first_setup/defaults/welcome.py +++ b/vanilla_first_setup/defaults/welcome.py @@ -15,7 +15,7 @@ # along with this program. If not, see . import time -from gi.repository import Gtk, Gio, GLib, Adw +from gi.repository import Gtk, GLib, Adw from vanilla_first_setup.utils.run_async import RunAsync diff --git a/vanilla_first_setup/gtk/layout-applications.ui b/vanilla_first_setup/gtk/layout-applications.ui new file mode 100644 index 0000000..152a07d --- /dev/null +++ b/vanilla_first_setup/gtk/layout-applications.ui @@ -0,0 +1,41 @@ + + + + + \ No newline at end of file diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py new file mode 100644 index 0000000..ff9ccd2 --- /dev/null +++ b/vanilla_first_setup/layouts/applications.py @@ -0,0 +1,128 @@ +# applications.py +# +# Copyright 2022 mirkobrombin +# +# 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 gi.repository import Gtk, Adw + +from vanilla_first_setup.dialog import VanillaDialog + + +@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/layout-applications.ui') +class VanillaLayoutApplications(Adw.Bin): + __gtype_name__ = 'VanillaLayoutApplications' + + status_page = Gtk.Template.Child() + bundles_list = Gtk.Template.Child() + btn_next = Gtk.Template.Child() + + def __init__(self, window, distro_info, key, step, **kwargs): + super().__init__(**kwargs) + self.__window = window + self.__distro_info = distro_info + self.__key = key + self.__step = step + self.__register_widgets = [] + self.__build_ui() + + # signals + self.btn_next.connect("clicked", self.__next_step) + + def __build_ui(self): + self.status_page.set_icon_name(self.__step["icon"]) + self.status_page.set_title(self.__step["title"]) + self.status_page.set_description(self.__step["description"]) + selection_dialogs = [] + + for item in self.__step["bundles"]: + + _selection_dialog = Adw.Window() + + _cancel_button = Gtk.Button() + _apply_button = Gtk.Button() + _cancel_button.set_label("Cancel") + _apply_button.set_label("Apply") + _apply_button.add_css_class("suggested-action") + + _header_bar = Adw.HeaderBar() + _header_bar.pack_start(_cancel_button) + _header_bar.pack_end(_apply_button) + _header_bar.set_show_end_title_buttons(False) + _header_bar.set_show_start_title_buttons(False) + + _apps_list = Adw.PreferencesGroup() + _apps_page = Adw.PreferencesPage() + _apps_page.add(_apps_list) + + _box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) + _box.append(_header_bar) + _box.append(_apps_page) + + _selection_dialog.set_content(_box) + _selection_dialog.set_modal(True) + _selection_dialog.set_title("Choose Applications") + _selection_dialog.set_transient_for(self.__window) + + selection_dialogs.append(_selection_dialog) + + def present_customize(widget, dialog): + dialog.present() + + def close_customize(widget, dialog): + dialog.close() + + _action_row = Adw.ActionRow( + title=item["title"], + subtitle=item.get("subtitle", "") + ) + _switcher = Gtk.Switch() + _switcher.set_active(item.get("default", False)) + _switcher.set_valign(Gtk.Align.CENTER) + _action_row.add_suffix(_switcher) + + _customize = Gtk.Button() + _customize.set_icon_name("go-next-symbolic") + _customize.set_valign(Gtk.Align.CENTER) + _customize.add_css_class("flat") + _action_row.add_suffix(_customize) + + _customize.connect("clicked", present_customize, selection_dialogs[-1]) + _cancel_button.connect("clicked", close_customize, selection_dialogs[-1]) + + for app in item["applications"]: + _apps_action_row = Adw.ActionRow( + title=app["name"], + icon_name=app["icon"] + ) + _app_switcher = Gtk.Switch() + _app_switcher.set_active(True) + _app_switcher.set_valign(Gtk.Align.CENTER) + _apps_action_row.add_suffix(_app_switcher) + _apps_list.add(_apps_action_row) + + self.bundles_list.add(_action_row) + + self.__register_widgets.append((item["id"], _switcher)) + + + def __next_step(self, widget): + self.__window.next() + + def get_finals(self): + finals = {"vars": {}, "funcs": [x for x in self.__step["final"]]} + + for _id, switcher in self.__register_widgets: + finals["vars"][_id] = switcher.get_active() + + return finals \ No newline at end of file diff --git a/vanilla_first_setup/layouts/meson.build b/vanilla_first_setup/layouts/meson.build index 964f228..c70981c 100644 --- a/vanilla_first_setup/layouts/meson.build +++ b/vanilla_first_setup/layouts/meson.build @@ -5,6 +5,7 @@ sources = [ '__init__.py', 'preferences.py', 'yes_no.py', + 'applications.py' ] install_data(sources, install_dir: layoutsdir) \ No newline at end of file diff --git a/vanilla_first_setup/layouts/preferences.py b/vanilla_first_setup/layouts/preferences.py index bcc43a4..57296c6 100644 --- a/vanilla_first_setup/layouts/preferences.py +++ b/vanilla_first_setup/layouts/preferences.py @@ -14,10 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import time -from gi.repository import Gtk, Gio, GLib, Adw +from gi.repository import Gtk, Adw -from vanilla_first_setup.utils.run_async import RunAsync from vanilla_first_setup.dialog import VanillaDialog diff --git a/vanilla_first_setup/utils/builder.py b/vanilla_first_setup/utils/builder.py index 1adc551..8a9b4b5 100644 --- a/vanilla_first_setup/utils/builder.py +++ b/vanilla_first_setup/utils/builder.py @@ -18,9 +18,6 @@ import os import sys import logging import subprocess -import json - -from gi.repository import Gio from vanilla_first_setup.utils.recipe import RecipeLoader @@ -29,6 +26,7 @@ from vanilla_first_setup.defaults.theme import VanillaDefaultTheme from vanilla_first_setup.layouts.preferences import VanillaLayoutPreferences from vanilla_first_setup.layouts.yes_no import VanillaLayoutYesNo +from vanilla_first_setup.layouts.applications import VanillaLayoutApplications logger = logging.getLogger("FirstSetup::Builder") @@ -38,7 +36,8 @@ templates = { "welcome": VanillaDefaultWelcome, "theme": VanillaDefaultTheme, "preferences": VanillaLayoutPreferences, - "yes-no": VanillaLayoutYesNo + "yes-no": VanillaLayoutYesNo, + "applications": VanillaLayoutApplications } diff --git a/vanilla_first_setup/utils/parser.py b/vanilla_first_setup/utils/parser.py index 211874c..7855b32 100644 --- a/vanilla_first_setup/utils/parser.py +++ b/vanilla_first_setup/utils/parser.py @@ -14,10 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os import sys import logging -import json logger = logging.getLogger("FirstSetup::Parser") diff --git a/vanilla_first_setup/utils/recipe.py b/vanilla_first_setup/utils/recipe.py index 36da611..1b510fc 100644 --- a/vanilla_first_setup/utils/recipe.py +++ b/vanilla_first_setup/utils/recipe.py @@ -19,8 +19,6 @@ import sys import logging import json -from gi.repository import Gio - logger = logging.getLogger("FirstSetup::RecipeLoader") diff --git a/vanilla_first_setup/vanilla-first-setup.gresource.xml b/vanilla_first_setup/vanilla-first-setup.gresource.xml index 0ba114c..6098082 100644 --- a/vanilla_first_setup/vanilla-first-setup.gresource.xml +++ b/vanilla_first_setup/vanilla-first-setup.gresource.xml @@ -12,6 +12,7 @@ gtk/layout-preferences.ui gtk/layout-yes-no.ui + gtk/layout-applications.ui ../data/icons/hicolor/symbolic/actions/vanilla-package-symbolic.svg diff --git a/vanilla_first_setup/window.py b/vanilla_first_setup/window.py index 8ef90ed..01c1498 100644 --- a/vanilla_first_setup/window.py +++ b/vanilla_first_setup/window.py @@ -15,7 +15,7 @@ # along with this program. If not, see . import time -from gi.repository import Gtk, Gio, GLib, Adw +from gi.repository import Gtk, Adw from vanilla_first_setup.utils.builder import Builder from vanilla_first_setup.utils.parser import Parser From 373939dc4442688d3c37dc59644719b743cfa3ff Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Sat, 17 Dec 2022 17:47:17 +0100 Subject: [PATCH 02/19] Fix close + add shortcut controller --- vanilla_first_setup/dialog.py | 7 +++++++ vanilla_first_setup/layouts/applications.py | 22 ++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/vanilla_first_setup/dialog.py b/vanilla_first_setup/dialog.py index 660052a..d0e1e31 100644 --- a/vanilla_first_setup/dialog.py +++ b/vanilla_first_setup/dialog.py @@ -28,3 +28,10 @@ class VanillaDialog(Adw.Window): self.set_transient_for(window) self.set_title(title) self.label_text.set_text(text) + + def hide(action, callback=None): + self.hide() + + shortcut_controller = Gtk.ShortcutController.new() + shortcut_controller.add_shortcut(Gtk.Shortcut.new(Gtk.ShortcutTrigger.parse_string('Escape'), Gtk.CallbackAction.new(hide))) + self.add_controller(shortcut_controller) \ No newline at end of file diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py index ff9ccd2..7fb8b4b 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/layouts/applications.py @@ -45,9 +45,19 @@ class VanillaLayoutApplications(Adw.Bin): self.status_page.set_description(self.__step["description"]) selection_dialogs = [] + def present_customize(widget, dialog): + dialog.show() + + def close_customize(widget, dialog): + dialog.hide() + for item in self.__step["bundles"]: - _selection_dialog = Adw.Window() + _selection_dialog = VanillaDialog( + self.__window, + "Select Applications", + "Description", + ) _cancel_button = Gtk.Button() _apply_button = Gtk.Button() @@ -70,18 +80,8 @@ class VanillaLayoutApplications(Adw.Bin): _box.append(_apps_page) _selection_dialog.set_content(_box) - _selection_dialog.set_modal(True) - _selection_dialog.set_title("Choose Applications") - _selection_dialog.set_transient_for(self.__window) - selection_dialogs.append(_selection_dialog) - def present_customize(widget, dialog): - dialog.present() - - def close_customize(widget, dialog): - dialog.close() - _action_row = Adw.ActionRow( title=item["title"], subtitle=item.get("subtitle", "") From 98dbea3455f87d3ab1098c53cccb6f6724a9eabf Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Sat, 17 Dec 2022 18:30:33 +0100 Subject: [PATCH 03/19] Add apps and update UI --- recipe.json | 106 ++++++++++++++++++-- vanilla_first_setup/layouts/applications.py | 2 + 2 files changed, 97 insertions(+), 11 deletions(-) diff --git a/recipe.json b/recipe.json index 0e3a3bd..cca8a05 100644 --- a/recipe.json +++ b/recipe.json @@ -37,33 +37,117 @@ "subtitle": "Core GNOME apps like Calendar or Calculator.", "default": true, "applications" : [ + { + "name" : "Calculator", + "icon" : "org.gnome.Calculator", + "flatpak-id" : "org.gnome.Calculator", + "snap-id" : "gnome-calculator" + }, { "name" : "Calendar", - "icon" : "org.gnome.Calendar-symbolic" + "icon" : "org.gnome.Calendar", + "flatpak-id" : "org.gnome.Calendar" }, { - "name" : "Calculator", - "icon" : "org.gnome.Calculator-symbolic" + "name" : "Characters", + "icon" : "org.gnome.Characters", + "flatpak-id" : "org.gnome.Characters", + "snap-id" : "gnome-characters" }, { "name" : "Cheese", - "icon" : "org.gnome.Cheese-symbolic" + "icon" : "org.gnome.Cheese", + "flatpak-id" : "org.gnome.Cheese", + "snap-id" : "cheese" + }, + { + "name" : "Clocks", + "icon" : "org.gnome.clocks", + "flatpak-id" : "org.gnome.clocks", + "snap-id" : "gnome-clocks" + }, + { + "name" : "Contacts", + "icon" : "org.gnome.Contacts", + "flatpak-id" : "org.gnome.Contacts", + "snap-id" : "gnome-contacts" + }, + { + "name" : "Disk Usage Analyzer", + "icon" : "org.gnome.baobab", + "flatpak-id" : "org.gnome.baobab" + }, + { + "name" : "Document Viewer", + "icon" : "org.gnome.Evince", + "flatpak-id" : "org.gnome.Evince", + "snap-id" : "evince" + }, + { + "name" : "Extensions", + "icon" : "org.gnome.Extensions", + "flatpak-id" : "org.gnome.Extensions" + }, + { + "name" : "Fonts", + "icon" : "org.gnome.font-viewer", + "flatpak-id" : "org.gnome.font-viewer" + }, + { + "name" : "Image Viewer", + "icon" : "org.gnome.eog", + "flatpak-id" : "org.gnome.eog", + "snap-id" : "eog" + }, + { + "name" : "Logs", + "icon" : "org.gnome.Logs", + "flatpak-id" : "org.gnome.Logs", + "snap-id" : "gnome-logs" + }, + { + "name" : "Maps", + "icon" : "org.gnome.Maps", + "flatpak-id" : "org.gnome.Maps" + }, + { + "name" : "Music", + "icon" : "org.gnome.Music", + "flatpak-id" : "org.gnome.Music" + }, + { + "name" : "Photos", + "icon" : "org.gnome.Photos", + "flatpak-id" : "org.gnome.Photos" + }, + { + "name" : "Text Editor", + "icon" : "org.gnome.TextEditor", + "flatpak-id" : "org.gnome.TextEditor" + }, + { + "name" : "Videos", + "icon" : "org.gnome.Totem", + "flatpak-id" : "org.gnome.Totem" + }, + { + "name" : "Weather", + "icon" : "org.gnome.Weather", + "flatpak-id" : "org.gnome.Weather", + "snap-id" : "gnome-weather" } ] }, { "id": "utilities", "title": "Common Utilities", - "subtitle": "Useful utilities like Disks or Fonts.", + "subtitle": "Useful utilities like Bottles.", "default": true, "applications" : [ { - "name" : "Disks", - "icon" : "org.gnome.DiskUtility-symbolic" - }, - { - "name" : "Fonts", - "icon" : "org.gnome.font-viewer-symbolic" + "name" : "Bottles", + "icon" : "com.usebottles.bottles", + "flatpak-id" : "com.usebottles.bottles" } ] } diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py index 7fb8b4b..69498f4 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/layouts/applications.py @@ -72,6 +72,7 @@ class VanillaLayoutApplications(Adw.Bin): _header_bar.set_show_start_title_buttons(False) _apps_list = Adw.PreferencesGroup() + _apps_list.set_description("The following list includes only applications available in your preferred package manager.") _apps_page = Adw.PreferencesPage() _apps_page.add(_apps_list) @@ -80,6 +81,7 @@ class VanillaLayoutApplications(Adw.Bin): _box.append(_apps_page) _selection_dialog.set_content(_box) + _selection_dialog.set_default_size(500, 600) selection_dialogs.append(_selection_dialog) _action_row = Adw.ActionRow( From bdc66db3f4103206e8ff9b803109e0da37634877 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Tue, 20 Dec 2022 08:04:04 +0100 Subject: [PATCH 04/19] update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 053b721..492b1ef 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ debian/vanilla-first-setup.debhelper.log debian/vanilla-first-setup debian/.debhelper */__pycache__ -*.pyc \ No newline at end of file +*.pyc +/localbuild \ No newline at end of file From b19672313827e5947c53e592111a8eaaea6a3010 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Tue, 20 Dec 2022 08:24:20 +0100 Subject: [PATCH 05/19] recipe: Update order --- recipe.json | 130 ++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/recipe.json b/recipe.json index cca8a05..5d6d6fb 100644 --- a/recipe.json +++ b/recipe.json @@ -25,6 +25,70 @@ } }, "steps": { + "welcome": { + "template": "welcome" + }, + "theme": { + "template": "theme" + }, + "packages": { + "template": "preferences", + "icon": "vanilla-package-symbolic", + "title": "Package Manager", + "description": "Choose one or more package managers to install", + "without_selection": { + "allowed": true, + "message": "You have chosen not to install any package manager, you will only be able to install packages using the package manager (apx).\n\nGNOME Software will be disabled.", + "title": "No package manager selected", + "final": [ + { + "type": "command", + "commands": [ + "apt remove -y gnome-software" + ] + } + ] + }, + "preferences": [ + { + "id": "flatpak", + "title": "Flatpak", + "subtitle": "Manage and configure Flatpaks and the Flathub repository.", + "default": true + }, + { + "id": "snap", + "title": "Snap", + "subtitle": "Manage and configure Snaps and the Snapcraft repository." + }, + { + "id": "appimage", + "title": "AppImage", + "subtitle": "Install necessary dependencies to run AppImages.", + "default": true + } + ], + "final": [ + { + "if": "flatpak", + "type": "command", + "commands": [ + "apt install -y flatpak gnome-software-plugin-flatpak", + "!outRun echo '[Desktop Entry]\nType=Application\nExec=kgx -e bash -c \"echo 'Configuring Flathub..' && flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo && rm -f ~/.config/autostart/flathub.desktop && echo 'Flathub installed successfully' || echo 'Failed installing Flathub. Are you connected to the internet?'\"\nName=Flatpak Flathub\nComment=Add Flathub repository to Flatpak\n' > ~/.config/autostart/flathub.desktop" + ] + }, + { + "if": "snap", + "type": "command", + "commands": ["apt install -y snapd"] + }, + { + "if": "appimage", + "type": "command", + "commands": ["apt install -y fuse3 libfuse2"] + } + ] + }, "apps": { "template": "applications", "icon": "org.gnome.Software-symbolic", @@ -165,72 +229,6 @@ } ] }, - - "welcome": { - "template": "welcome" - }, - "theme": { - "template": "theme" - }, - "packages": { - "template": "preferences", - "icon": "vanilla-package-symbolic", - "title": "Package Manager", - "description": "Choose one or more package managers to install", - "without_selection": { - "allowed": true, - "message": "You have chosen not to install any package manager, you will only be able to install packages using the package manager (apx).\n\nGNOME Software will be disabled since it is not compatible with the On-Demand Immutability.", - "title": "No package manager selected", - "final": [ - { - "if": "warp::immutability", - "type": "command", - "commands": [ - "apt remove -y gnome-software" - ] - } - ] - }, - "preferences": [ - { - "id": "flatpak", - "title": "Flatpak", - "subtitle": "Manage and configure Flatpaks and the Flathub repository.", - "default": true - }, - { - "id": "snap", - "title": "Snap", - "subtitle": "Manage and configure Snaps and the Snapcraft repository." - }, - { - "id": "appimage", - "title": "AppImage", - "subtitle": "Install necessary dependencies to run AppImages.", - "default": true - } - ], - "final": [ - { - "if": "flatpak", - "type": "command", - "commands": [ - "apt install -y flatpak gnome-software-plugin-flatpak", - "!outRun echo '[Desktop Entry]\nType=Application\nExec=kgx -e bash -c \"echo 'Configuring Flathub..' && flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo && rm -f ~/.config/autostart/flathub.desktop && echo 'Flathub installed successfully' || echo 'Failed installing Flathub. Are you connected to the internet?'\"\nName=Flatpak Flathub\nComment=Add Flathub repository to Flatpak\n' > ~/.config/autostart/flathub.desktop" - ] - }, - { - "if": "snap", - "type": "command", - "commands": ["apt install -y snapd"] - }, - { - "if": "appimage", - "type": "command", - "commands": ["apt install -y fuse3 libfuse2"] - } - ] - }, "nvidia": { "template": "yes-no", "display-conditions": [ From acca495fe61c9a3cd29631e574588815e475e665 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Tue, 20 Dec 2022 08:24:32 +0100 Subject: [PATCH 06/19] frontend: Make builder property public --- vanilla_first_setup/window.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vanilla_first_setup/window.py b/vanilla_first_setup/window.py index 01c1498..8c20809 100644 --- a/vanilla_first_setup/window.py +++ b/vanilla_first_setup/window.py @@ -52,6 +52,10 @@ class VanillaWindow(Adw.ApplicationWindow): # connect system signals self.__connect_signals() + + @property + def builder(self): + return self.__builder def __connect_signals(self): self.btn_back.connect("clicked", self.back) From 70b5c4192273be3eb3267a787ae620f5ee9a7ff1 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Tue, 20 Dec 2022 08:24:44 +0100 Subject: [PATCH 07/19] core: Allow access to temp finals --- vanilla_first_setup/utils/builder.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vanilla_first_setup/utils/builder.py b/vanilla_first_setup/utils/builder.py index 8a9b4b5..bb1391c 100644 --- a/vanilla_first_setup/utils/builder.py +++ b/vanilla_first_setup/utils/builder.py @@ -88,6 +88,13 @@ class Builder: if step["template"] in templates: _widget = templates[step["template"]](self.__window, self.distro_info, key, step) self.__register_widgets.append(_widget) + + def get_temp_finals(self, step_id: str): + for widget in self.__register_widgets: + if widget.step_id == step_id: + return widget.get_finals() + + return None def get_finals(self): self.__register_finals = [] From bc293a12b77a2f6f680678ed7078a0bc3576ed9d Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Tue, 20 Dec 2022 08:25:08 +0100 Subject: [PATCH 08/19] frontend: Make property step_id public --- vanilla_first_setup/defaults/theme.py | 4 ++++ vanilla_first_setup/defaults/welcome.py | 4 ++++ vanilla_first_setup/layouts/applications.py | 12 ++++++++---- vanilla_first_setup/layouts/preferences.py | 4 ++++ vanilla_first_setup/layouts/yes_no.py | 4 ++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/vanilla_first_setup/defaults/theme.py b/vanilla_first_setup/defaults/theme.py index a2310e1..38f9160 100644 --- a/vanilla_first_setup/defaults/theme.py +++ b/vanilla_first_setup/defaults/theme.py @@ -37,6 +37,10 @@ class VanillaDefaultTheme(Gtk.Box): self.btn_next.connect("clicked", self.__window.next) self.btn_default.connect('toggled', self.__set_theme, "light") self.btn_dark.connect('toggled', self.__set_theme, "dark") + + @property + def step_id(self): + return self.__key def __build_ui(self): self.btn_dark.set_group(self.btn_default) diff --git a/vanilla_first_setup/defaults/welcome.py b/vanilla_first_setup/defaults/welcome.py index 14cbd2a..881f156 100644 --- a/vanilla_first_setup/defaults/welcome.py +++ b/vanilla_first_setup/defaults/welcome.py @@ -79,6 +79,10 @@ class VanillaDefaultWelcome(Adw.Bin): # set distro logo self.status_page.set_icon_name(self.__distro_info["logo"]) + + @property + def step_id(self): + return self.__key def __start_welcome_animation(self): def change_langs(): diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py index 69498f4..e408b88 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/layouts/applications.py @@ -38,6 +38,10 @@ class VanillaLayoutApplications(Adw.Bin): # signals self.btn_next.connect("clicked", self.__next_step) + + @property + def step_id(self): + return self.__key def __build_ui(self): self.status_page.set_icon_name(self.__step["icon"]) @@ -46,13 +50,13 @@ class VanillaLayoutApplications(Adw.Bin): selection_dialogs = [] def present_customize(widget, dialog): - dialog.show() + dialog.show() + print(self.__window.builder.get_temp_finals("packages")) def close_customize(widget, dialog): dialog.hide() for item in self.__step["bundles"]: - _selection_dialog = VanillaDialog( self.__window, "Select Applications", @@ -104,8 +108,8 @@ class VanillaLayoutApplications(Adw.Bin): for app in item["applications"]: _apps_action_row = Adw.ActionRow( - title=app["name"], - icon_name=app["icon"] + title=app["name"], + icon_name=app["icon"] ) _app_switcher = Gtk.Switch() _app_switcher.set_active(True) diff --git a/vanilla_first_setup/layouts/preferences.py b/vanilla_first_setup/layouts/preferences.py index 57296c6..dc38a0a 100644 --- a/vanilla_first_setup/layouts/preferences.py +++ b/vanilla_first_setup/layouts/preferences.py @@ -38,6 +38,10 @@ class VanillaLayoutPreferences(Adw.Bin): # signals self.btn_next.connect("clicked", self.__next_step) + + @property + def step_id(self): + return self.__key def __build_ui(self): self.status_page.set_icon_name(self.__step["icon"]) diff --git a/vanilla_first_setup/layouts/yes_no.py b/vanilla_first_setup/layouts/yes_no.py index 68aa7fe..11d7526 100644 --- a/vanilla_first_setup/layouts/yes_no.py +++ b/vanilla_first_setup/layouts/yes_no.py @@ -43,6 +43,10 @@ class VanillaLayoutYesNo(Adw.Bin): self.btn_yes.connect("clicked", self.__on_response, True) self.btn_no.connect("clicked", self.__on_response, False) self.btn_info.connect("clicked", self.__on_info) + + @property + def step_id(self): + return self.__key def __build_ui(self): self.status_page.set_icon_name(self.__step["icon"]) From df6824412029a5907314dc692afa7d5b5c0335b9 Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:11:58 +0100 Subject: [PATCH 09/19] Test code --- recipe.json | 148 +++++++++++++++----- vanilla_first_setup/layouts/applications.py | 66 ++++++--- 2 files changed, 163 insertions(+), 51 deletions(-) diff --git a/recipe.json b/recipe.json index 5d6d6fb..041cc63 100644 --- a/recipe.json +++ b/recipe.json @@ -104,101 +104,101 @@ { "name" : "Calculator", "icon" : "org.gnome.Calculator", - "flatpak-id" : "org.gnome.Calculator", - "snap-id" : "gnome-calculator" + "flatpak" : true, + "snap" : true }, { "name" : "Calendar", "icon" : "org.gnome.Calendar", - "flatpak-id" : "org.gnome.Calendar" + "flatpak" : true }, { "name" : "Characters", "icon" : "org.gnome.Characters", - "flatpak-id" : "org.gnome.Characters", - "snap-id" : "gnome-characters" + "flatpak" : true, + "snap" : true }, { "name" : "Cheese", "icon" : "org.gnome.Cheese", - "flatpak-id" : "org.gnome.Cheese", - "snap-id" : "cheese" + "flatpak" : true, + "snap" : true }, { "name" : "Clocks", "icon" : "org.gnome.clocks", - "flatpak-id" : "org.gnome.clocks", - "snap-id" : "gnome-clocks" + "flatpak" : true, + "snap" : true }, { "name" : "Contacts", "icon" : "org.gnome.Contacts", - "flatpak-id" : "org.gnome.Contacts", - "snap-id" : "gnome-contacts" + "flatpak" : true, + "snap" : true }, { "name" : "Disk Usage Analyzer", "icon" : "org.gnome.baobab", - "flatpak-id" : "org.gnome.baobab" + "flatpak" : true }, { "name" : "Document Viewer", "icon" : "org.gnome.Evince", - "flatpak-id" : "org.gnome.Evince", - "snap-id" : "evince" + "flatpak" : true, + "snap" : true }, { "name" : "Extensions", "icon" : "org.gnome.Extensions", - "flatpak-id" : "org.gnome.Extensions" + "flatpak" : true }, { "name" : "Fonts", "icon" : "org.gnome.font-viewer", - "flatpak-id" : "org.gnome.font-viewer" + "flatpak" : true }, { "name" : "Image Viewer", "icon" : "org.gnome.eog", - "flatpak-id" : "org.gnome.eog", - "snap-id" : "eog" + "flatpak" : true, + "snap" : true }, { "name" : "Logs", "icon" : "org.gnome.Logs", - "flatpak-id" : "org.gnome.Logs", - "snap-id" : "gnome-logs" + "flatpak" : "org.gnome.Logs", + "snap" : true }, { "name" : "Maps", "icon" : "org.gnome.Maps", - "flatpak-id" : "org.gnome.Maps" + "flatpak" : true }, { "name" : "Music", "icon" : "org.gnome.Music", - "flatpak-id" : "org.gnome.Music" + "flatpak" : true }, { "name" : "Photos", "icon" : "org.gnome.Photos", - "flatpak-id" : "org.gnome.Photos" + "flatpak" : true }, { "name" : "Text Editor", "icon" : "org.gnome.TextEditor", - "flatpak-id" : "org.gnome.TextEditor" + "flatpak" : true }, { "name" : "Videos", "icon" : "org.gnome.Totem", - "flatpak-id" : "org.gnome.Totem" + "flatpak" : true }, { "name" : "Weather", "icon" : "org.gnome.Weather", - "flatpak-id" : "org.gnome.Weather", - "snap-id" : "gnome-weather" + "flatpak" : true, + "snap" : true } ] }, @@ -211,21 +211,101 @@ { "name" : "Bottles", "icon" : "com.usebottles.bottles", - "flatpak-id" : "com.usebottles.bottles" + "flatpak" : "com.usebottles.bottles" } ] } ], "final": [ { - "if": "essential-apps", - "type": "command", - "commands": ["flatpak install org.gnome.Geary || snap install snapd"] + "if" : "Calculator", + "type" : "command", + "commands" : "flatpak install org.gnome.Calculator || snap install gnome-calculator" }, { - "if": "utilities", - "type": "command", - "commands": ["flatpak install org.gnome.Geary || snap install snapd"] + "if" : "Calendar", + "type" : "command", + "commands" : "flatpak install org.gnome.Calendar" + }, + { + "if" : "Characters", + "type" : "command", + "commands" : "flatpak install org.gnome.Characters || snap install gnome-characters" + }, + { + "if" : "Cheese", + "type" : "command", + "commands" : "flatpak install org.gnome.Cheese || snap install cheese" + }, + { + "if" : "Clocks", + "type" : "command", + "commands" : "flatpak install org.gnome.clocks || snap install gnome-clocks" + }, + { + "if" : "Contacts", + "type" : "command", + "commands" : "flatpak install org.gnome.Contacts || snap install gnome-contacts" + }, + { + "if" : "Disk Usage Alanyzer", + "type" : "command", + "commands" : "flatpak install org.gnome.baobab" + }, + { + "if" : "Evince", + "type" : "command", + "commands" : "flatpak install org.gnome.Evince || snap install evince" + }, + { + "if" : "Extensions", + "type" : "command", + "commands" : "flatpak install org.gnome.Extensions" + }, + { + "if" : "Fonts", + "type" : "command", + "commands" : "flatpak install org.gnome.Fonts" + }, + { + "if" : "Image Viewer", + "type" : "command", + "commands" : "flatpak install org.gnome.eog || snap install eog" + }, + { + "if" : "Logs", + "type" : "command", + "commands" : "flatpak install org.gnome.Logs || snap install gnome-logs" + }, + { + "if" : "Maps", + "type" : "command", + "commands" : "flatpak install org.gnome.Maps" + }, + { + "if" : "Music", + "type" : "command", + "commands" : "flatpak install org.gnome.Music" + }, + { + "name" : "Photos", + "icon" : "org.gnome.Photos", + "flatpak" : "org.gnome.Photos" + }, + { + "if" : "Text Editor", + "type" : "command", + "commands" : "flatpak install org.gnome.TextEditor" + }, + { + "if" : "Videos", + "type" : "command", + "commands" : "flatpak install org.gnome.Totem" + }, + { + "if" : "Weather", + "type" : "command", + "commands" : "flatpak install org.gnome.Weather || snap install gnome-weather" } ] }, diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py index e408b88..1e2c70b 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/layouts/applications.py @@ -49,11 +49,48 @@ class VanillaLayoutApplications(Adw.Bin): self.status_page.set_description(self.__step["description"]) selection_dialogs = [] - def present_customize(widget, dialog): + def present_customize(widget, dialog, apps_list, item): + for app in item["applications"]: + try: + apps_list.remove(app["apps_action_row"]) + except KeyError: + pass + if self.__window.builder.get_temp_finals("packages")["vars"]["flatpak"] == True: + package_manager = "flatpak" + elif self.__window.builder.get_temp_finals("packages")["vars"]["snap"] == True: + try: + package_manager = "snap" + except KeyError: + continue + else: + continue + try: + if app[package_manager]: + _apps_action_row = Adw.ActionRow( + title=app["name"], + icon_name=app["icon"] + ) + _app_switcher = Gtk.Switch() + _app_switcher.set_active(True) + _app_switcher.set_valign(Gtk.Align.CENTER) + _apps_action_row.add_suffix(_app_switcher) + apps_list.add(_apps_action_row) + app["apps_action_row"] = _apps_action_row + app["switch"] = _app_switcher + try: + app["switch"].set_active(app["active"]) + except KeyError: + pass + except KeyError: + continue dialog.show() - print(self.__window.builder.get_temp_finals("packages")) - def close_customize(widget, dialog): + def close_customize(widget, dialog, apps_list, item): + dialog.hide() + + def apply_preferences(widget, dialog, apps_list, item): + for app in item["applications"]: + app["active"] = app["switch"].get_active() dialog.hide() for item in self.__step["bundles"]: @@ -103,19 +140,9 @@ class VanillaLayoutApplications(Adw.Bin): _customize.add_css_class("flat") _action_row.add_suffix(_customize) - _customize.connect("clicked", present_customize, selection_dialogs[-1]) - _cancel_button.connect("clicked", close_customize, selection_dialogs[-1]) - - for app in item["applications"]: - _apps_action_row = Adw.ActionRow( - title=app["name"], - icon_name=app["icon"] - ) - _app_switcher = Gtk.Switch() - _app_switcher.set_active(True) - _app_switcher.set_valign(Gtk.Align.CENTER) - _apps_action_row.add_suffix(_app_switcher) - _apps_list.add(_apps_action_row) + _customize.connect("clicked", present_customize, selection_dialogs[-1], _apps_list, item) + _cancel_button.connect("clicked", close_customize, selection_dialogs[-1], _apps_list, item) + _apply_button.connect("clicked", apply_preferences, selection_dialogs[-1], _apps_list, item) self.bundles_list.add(_action_row) @@ -129,6 +156,11 @@ class VanillaLayoutApplications(Adw.Bin): finals = {"vars": {}, "funcs": [x for x in self.__step["final"]]} for _id, switcher in self.__register_widgets: - finals["vars"][_id] = switcher.get_active() + if switcher.get_active() == True: + for app in _id["applications"]: + finals["vars"][app] = app["active"] + else: + for app in _id["applications"]: + finals["vars"][app] = False return finals \ No newline at end of file From 6abf63692dabda7005c20ee9d0c6a925d6f5d29f Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:31:28 +0100 Subject: [PATCH 10/19] Test code --- recipe.json | 49 ++++++++++++--------- vanilla_first_setup/layouts/applications.py | 15 ++++--- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/recipe.json b/recipe.json index 041cc63..d559577 100644 --- a/recipe.json +++ b/recipe.json @@ -220,92 +220,97 @@ { "if" : "Calculator", "type" : "command", - "commands" : "flatpak install org.gnome.Calculator || snap install gnome-calculator" + "commands" : ["flatpak --user install org.gnome.Calculator || snap install gnome-calculator"] }, { "if" : "Calendar", "type" : "command", - "commands" : "flatpak install org.gnome.Calendar" + "commands" : ["flatpak --user install org.gnome.Calendar"] }, { "if" : "Characters", "type" : "command", - "commands" : "flatpak install org.gnome.Characters || snap install gnome-characters" + "commands" : ["flatpak --user install org.gnome.Characters || snap install gnome-characters"] }, { "if" : "Cheese", "type" : "command", - "commands" : "flatpak install org.gnome.Cheese || snap install cheese" + "commands" : ["flatpak --user install org.gnome.Cheese || snap install cheese"] }, { "if" : "Clocks", "type" : "command", - "commands" : "flatpak install org.gnome.clocks || snap install gnome-clocks" + "commands" : ["flatpak --user install org.gnome.clocks || snap install gnome-clocks"] }, { "if" : "Contacts", "type" : "command", - "commands" : "flatpak install org.gnome.Contacts || snap install gnome-contacts" + "commands" : ["flatpak --user install org.gnome.Contacts || snap install gnome-contacts"] }, { - "if" : "Disk Usage Alanyzer", + "if" : "Disk Usage Analyzer", "type" : "command", - "commands" : "flatpak install org.gnome.baobab" + "commands" : ["flatpak --user install org.gnome.baobab"] }, { - "if" : "Evince", + "if" : "Document Viewer", "type" : "command", - "commands" : "flatpak install org.gnome.Evince || snap install evince" + "commands" : ["flatpak --user install org.gnome.Evince || snap install evince"] }, { "if" : "Extensions", "type" : "command", - "commands" : "flatpak install org.gnome.Extensions" + "commands" : ["flatpak --user install org.gnome.Extensions"] }, { "if" : "Fonts", "type" : "command", - "commands" : "flatpak install org.gnome.Fonts" + "commands" : ["flatpak --user install org.gnome.Fonts"] }, { "if" : "Image Viewer", "type" : "command", - "commands" : "flatpak install org.gnome.eog || snap install eog" + "commands" : ["flatpak --user install org.gnome.eog || snap install eog"] }, { "if" : "Logs", "type" : "command", - "commands" : "flatpak install org.gnome.Logs || snap install gnome-logs" + "commands" : ["flatpak --user install org.gnome.Logs || snap install gnome-logs"] }, { "if" : "Maps", "type" : "command", - "commands" : "flatpak install org.gnome.Maps" + "commands" : ["flatpak --user install org.gnome.Maps"] }, { "if" : "Music", "type" : "command", - "commands" : "flatpak install org.gnome.Music" + "commands" : ["flatpak --user install org.gnome.Music"] }, { - "name" : "Photos", - "icon" : "org.gnome.Photos", - "flatpak" : "org.gnome.Photos" + "if" : "Photos", + "type" : "command", + "commands" : ["flatpak --user install org.gnome.Photos"] }, { "if" : "Text Editor", "type" : "command", - "commands" : "flatpak install org.gnome.TextEditor" + "commands" : ["flatpak --user install org.gnome.TextEditor"] }, { "if" : "Videos", "type" : "command", - "commands" : "flatpak install org.gnome.Totem" + "commands" : ["flatpak --user install org.gnome.Totem"] }, { "if" : "Weather", "type" : "command", - "commands" : "flatpak install org.gnome.Weather || snap install gnome-weather" + "commands" : ["flatpak --user install org.gnome.Weather || snap install gnome-weather"] + }, + { + "if" : "Bottles", + "type" : "command", + "commands" : ["flatpak --user install com.usebottles.bottles"] } ] }, diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py index 1e2c70b..443882c 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/layouts/applications.py @@ -48,6 +48,7 @@ class VanillaLayoutApplications(Adw.Bin): self.status_page.set_title(self.__step["title"]) self.status_page.set_description(self.__step["description"]) selection_dialogs = [] + _index = 0 def present_customize(widget, dialog, apps_list, item): for app in item["applications"]: @@ -146,8 +147,8 @@ class VanillaLayoutApplications(Adw.Bin): self.bundles_list.add(_action_row) - self.__register_widgets.append((item["id"], _switcher)) - + self.__register_widgets.append((item["id"], _switcher, _index)) + _index += 1 def __next_step(self, widget): self.__window.next() @@ -155,12 +156,12 @@ class VanillaLayoutApplications(Adw.Bin): def get_finals(self): finals = {"vars": {}, "funcs": [x for x in self.__step["final"]]} - for _id, switcher in self.__register_widgets: + for _id, switcher, index in self.__register_widgets: if switcher.get_active() == True: - for app in _id["applications"]: - finals["vars"][app] = app["active"] + for app in self.__step["bundles"][index]["applications"]: + finals["vars"][app["name"]] = app["active"] else: - for app in _id["applications"]: - finals["vars"][app] = False + for app in self.__step["bundles"][index]["applications"]: + finals["vars"][app["name"]] = False return finals \ No newline at end of file From 7a6981c512ece6c7ad42fc8d60e82cdb1a44364d Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:45:33 +0100 Subject: [PATCH 11/19] Test code --- vanilla_first_setup/layouts/applications.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/layouts/applications.py index 443882c..99634a8 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/layouts/applications.py @@ -159,6 +159,8 @@ class VanillaLayoutApplications(Adw.Bin): for _id, switcher, index in self.__register_widgets: if switcher.get_active() == True: for app in self.__step["bundles"][index]["applications"]: + if "active" not in app.keys(): + app["active"] = True finals["vars"][app["name"]] = app["active"] else: for app in self.__step["bundles"][index]["applications"]: From d4c82cafe1e315b3474faaa3bffd032c4930ebe4 Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:59:26 +0100 Subject: [PATCH 12/19] Change configuration --- recipe.json | 38 +++++++++---------- .../{layouts => defaults}/applications.py | 4 +- vanilla_first_setup/defaults/meson.build | 3 +- vanilla_first_setup/layouts/meson.build | 5 +-- vanilla_first_setup/utils/builder.py | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) rename vanilla_first_setup/{layouts => defaults}/applications.py (98%) diff --git a/recipe.json b/recipe.json index d559577..1872f4b 100644 --- a/recipe.json +++ b/recipe.json @@ -220,97 +220,97 @@ { "if" : "Calculator", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Calculator || snap install gnome-calculator"] + "commands" : ["flatpak install org.gnome.Calculator || snap install gnome-calculator"] }, { "if" : "Calendar", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Calendar"] + "commands" : ["flatpak install org.gnome.Calendar"] }, { "if" : "Characters", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Characters || snap install gnome-characters"] + "commands" : ["flatpak install org.gnome.Characters || snap install gnome-characters"] }, { "if" : "Cheese", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Cheese || snap install cheese"] + "commands" : ["flatpak install org.gnome.Cheese || snap install cheese"] }, { "if" : "Clocks", "type" : "command", - "commands" : ["flatpak --user install org.gnome.clocks || snap install gnome-clocks"] + "commands" : ["flatpak install org.gnome.clocks || snap install gnome-clocks"] }, { "if" : "Contacts", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Contacts || snap install gnome-contacts"] + "commands" : ["flatpak install org.gnome.Contacts || snap install gnome-contacts"] }, { "if" : "Disk Usage Analyzer", "type" : "command", - "commands" : ["flatpak --user install org.gnome.baobab"] + "commands" : ["flatpak install org.gnome.baobab"] }, { "if" : "Document Viewer", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Evince || snap install evince"] + "commands" : ["flatpak install org.gnome.Evince || snap install evince"] }, { "if" : "Extensions", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Extensions"] + "commands" : ["flatpak install org.gnome.Extensions"] }, { "if" : "Fonts", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Fonts"] + "commands" : ["flatpak install org.gnome.Fonts"] }, { "if" : "Image Viewer", "type" : "command", - "commands" : ["flatpak --user install org.gnome.eog || snap install eog"] + "commands" : ["flatpak install org.gnome.eog || snap install eog"] }, { "if" : "Logs", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Logs || snap install gnome-logs"] + "commands" : ["flatpak install org.gnome.Logs || snap install gnome-logs"] }, { "if" : "Maps", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Maps"] + "commands" : ["flatpak install org.gnome.Maps"] }, { "if" : "Music", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Music"] + "commands" : ["flatpak install org.gnome.Music"] }, { "if" : "Photos", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Photos"] + "commands" : ["flatpak install org.gnome.Photos"] }, { "if" : "Text Editor", "type" : "command", - "commands" : ["flatpak --user install org.gnome.TextEditor"] + "commands" : ["flatpak install org.gnome.TextEditor"] }, { "if" : "Videos", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Totem"] + "commands" : ["flatpak install org.gnome.Totem"] }, { "if" : "Weather", "type" : "command", - "commands" : ["flatpak --user install org.gnome.Weather || snap install gnome-weather"] + "commands" : ["flatpak install org.gnome.Weather || snap install gnome-weather"] }, { "if" : "Bottles", "type" : "command", - "commands" : ["flatpak --user install com.usebottles.bottles"] + "commands" : ["flatpak install com.usebottles.bottles"] } ] }, diff --git a/vanilla_first_setup/layouts/applications.py b/vanilla_first_setup/defaults/applications.py similarity index 98% rename from vanilla_first_setup/layouts/applications.py rename to vanilla_first_setup/defaults/applications.py index 99634a8..55741bf 100644 --- a/vanilla_first_setup/layouts/applications.py +++ b/vanilla_first_setup/defaults/applications.py @@ -86,7 +86,7 @@ class VanillaLayoutApplications(Adw.Bin): continue dialog.show() - def close_customize(widget, dialog, apps_list, item): + def close_customize(widget, dialog): dialog.hide() def apply_preferences(widget, dialog, apps_list, item): @@ -142,7 +142,7 @@ class VanillaLayoutApplications(Adw.Bin): _action_row.add_suffix(_customize) _customize.connect("clicked", present_customize, selection_dialogs[-1], _apps_list, item) - _cancel_button.connect("clicked", close_customize, selection_dialogs[-1], _apps_list, item) + _cancel_button.connect("clicked", close_customize, selection_dialogs[-1]) _apply_button.connect("clicked", apply_preferences, selection_dialogs[-1], _apps_list, item) self.bundles_list.add(_action_row) diff --git a/vanilla_first_setup/defaults/meson.build b/vanilla_first_setup/defaults/meson.build index 569a130..3552e4e 100644 --- a/vanilla_first_setup/defaults/meson.build +++ b/vanilla_first_setup/defaults/meson.build @@ -5,6 +5,7 @@ sources = [ '__init__.py', 'welcome.py', 'theme.py', + 'applications.py' ] -install_data(sources, install_dir: defaultsdir) \ No newline at end of file +install_data(sources, install_dir: defaultsdir) diff --git a/vanilla_first_setup/layouts/meson.build b/vanilla_first_setup/layouts/meson.build index c70981c..634e2ff 100644 --- a/vanilla_first_setup/layouts/meson.build +++ b/vanilla_first_setup/layouts/meson.build @@ -4,8 +4,7 @@ layoutsdir = join_paths(pkgdatadir, 'vanilla_first_setup/layouts') sources = [ '__init__.py', 'preferences.py', - 'yes_no.py', - 'applications.py' + 'yes_no.py' ] -install_data(sources, install_dir: layoutsdir) \ No newline at end of file +install_data(sources, install_dir: layoutsdir) diff --git a/vanilla_first_setup/utils/builder.py b/vanilla_first_setup/utils/builder.py index bb1391c..2c36fa5 100644 --- a/vanilla_first_setup/utils/builder.py +++ b/vanilla_first_setup/utils/builder.py @@ -26,7 +26,7 @@ from vanilla_first_setup.defaults.theme import VanillaDefaultTheme from vanilla_first_setup.layouts.preferences import VanillaLayoutPreferences from vanilla_first_setup.layouts.yes_no import VanillaLayoutYesNo -from vanilla_first_setup.layouts.applications import VanillaLayoutApplications +from vanilla_first_setup.defaults.applications import VanillaLayoutApplications logger = logging.getLogger("FirstSetup::Builder") From 202f6d2e656aee85f957f83878f6d7bf6b33e744 Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 21:45:16 +0100 Subject: [PATCH 13/19] Fix package manager conditions --- vanilla_first_setup/defaults/applications.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vanilla_first_setup/defaults/applications.py b/vanilla_first_setup/defaults/applications.py index 55741bf..1b1364b 100644 --- a/vanilla_first_setup/defaults/applications.py +++ b/vanilla_first_setup/defaults/applications.py @@ -156,9 +156,21 @@ class VanillaLayoutApplications(Adw.Bin): def get_finals(self): finals = {"vars": {}, "funcs": [x for x in self.__step["final"]]} + if self.__window.builder.get_temp_finals("packages")["vars"]["flatpak"] == True: + package_manager = "flatpak" + elif self.__window.builder.get_temp_finals("packages")["vars"]["snap"] == True: + try: + package_manager = "snap" + except KeyError: + pass + else: + package_manager = None + for _id, switcher, index in self.__register_widgets: if switcher.get_active() == True: for app in self.__step["bundles"][index]["applications"]: + if package_manager not in app.keys(): + app["active"] = False if "active" not in app.keys(): app["active"] = True finals["vars"][app["name"]] = app["active"] From 7d6cade401d384748aa591cf48206887d8bc4030 Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 21:47:17 +0100 Subject: [PATCH 14/19] Fix snap variable --- vanilla_first_setup/defaults/applications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vanilla_first_setup/defaults/applications.py b/vanilla_first_setup/defaults/applications.py index 1b1364b..1b2a73e 100644 --- a/vanilla_first_setup/defaults/applications.py +++ b/vanilla_first_setup/defaults/applications.py @@ -162,7 +162,7 @@ class VanillaLayoutApplications(Adw.Bin): try: package_manager = "snap" except KeyError: - pass + package_manager = None else: package_manager = None From 877f8291b0f2fb86be82e01596656f0f4761d3e9 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Wed, 21 Dec 2022 21:49:33 +0100 Subject: [PATCH 15/19] core: Add support for !nextBoot commands --- vanilla_first_setup/utils/processor.py | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/vanilla_first_setup/utils/processor.py b/vanilla_first_setup/utils/processor.py index a0956a3..33a089a 100644 --- a/vanilla_first_setup/utils/processor.py +++ b/vanilla_first_setup/utils/processor.py @@ -30,11 +30,48 @@ class Processor: def run(log_path, pre_run, post_run, commands): commands = pre_run + commands + post_run out_run = "" + next_boot = [] + next_boot_script_path = os.path.expanduser("~/.local/org.vanillaos.FirstSetup.nextBoot") + next_boot_autostart_path = os.path.expanduser("~/.config/autostart/org.vanillaos.FirstSetup.nextBoot.desktop") abroot_bin = shutil.which("abroot") logger.info("processing the following commands: \n%s" % '\n'.join(commands)) + # nextBoot commands are collected in ~/.local/org.vanillaos.FirstSetup.nextBoot + # and executed at the next boot by a desktop entry + for command in commands: + if command.startswith("!nextBoot"): + next_boot.append(command.replace("!nextBoot", "")) + continue + + if len(next_boot) > 0: + with open(next_boot_script_path, "w") as f: + f.write("#!/bin/sh\n") + f.write("# This file was created by FirstSetup\n") + f.write("# Do not edit this file manually\n\n") + + for command in next_boot: + f.write(f"{command}\n") + + f.flush() + f.close() + + # setting the file executable + os.chmod(next_boot_script_path, 0o755) + + # creating the desktop entry + with open(next_boot_autostart_path, "w") as f: + f.write("[Desktop Entry]\n") + f.write("Name=FirstSetup Next Boot\n") + f.write("Comment=Run FirstSetup commands at the next boot\n") + f.write("Exec=kgx -e bash -c 'sh %s'\n" % next_boot_script_path) + f.write("Terminal=false\n") + f.write("Type=Application\n") + f.write("X-GNOME-Autostart-enabled=true\n") + f.flush() + f.close() + # generating a temporary file to store all the commands so we can # run them all at once with tempfile.NamedTemporaryFile(mode='w', delete=False) as f: @@ -43,6 +80,9 @@ class Processor: f.write("# Do not edit this file manually\n\n") for command in commands: + if command.startswith("!nextBoot"): + continue + if command.startswith("!noSudo"): command = command.replace("!noSudo", "sudo -u $USER") From 609ac5a6208be9725beb6a4e8965020d6d4977c4 Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Wed, 21 Dec 2022 21:49:48 +0100 Subject: [PATCH 16/19] recipe: Use !nextBoot for flathub --- recipe.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe.json b/recipe.json index 1872f4b..23ac6d3 100644 --- a/recipe.json +++ b/recipe.json @@ -74,7 +74,7 @@ "type": "command", "commands": [ "apt install -y flatpak gnome-software-plugin-flatpak", - "!outRun echo '[Desktop Entry]\nType=Application\nExec=kgx -e bash -c \"echo 'Configuring Flathub..' && flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo && rm -f ~/.config/autostart/flathub.desktop && echo 'Flathub installed successfully' || echo 'Failed installing Flathub. Are you connected to the internet?'\"\nName=Flatpak Flathub\nComment=Add Flathub repository to Flatpak\n' > ~/.config/autostart/flathub.desktop" + "!nextBoot flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo" ] }, { From a22a007b623044e0dff85efc2df99182bcff5d9d Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Wed, 21 Dec 2022 21:57:10 +0100 Subject: [PATCH 17/19] recipe: Use !nextBoot for applications --- recipe.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/recipe.json b/recipe.json index 23ac6d3..1e8d1a2 100644 --- a/recipe.json +++ b/recipe.json @@ -220,97 +220,97 @@ { "if" : "Calculator", "type" : "command", - "commands" : ["flatpak install org.gnome.Calculator || snap install gnome-calculator"] + "commands" : ["!nextBoot flatpak install org.gnome.Calculator || snap install gnome-calculator"] }, { "if" : "Calendar", "type" : "command", - "commands" : ["flatpak install org.gnome.Calendar"] + "commands" : ["!nextBoot flatpak install org.gnome.Calendar"] }, { "if" : "Characters", "type" : "command", - "commands" : ["flatpak install org.gnome.Characters || snap install gnome-characters"] + "commands" : ["!nextBoot flatpak install org.gnome.Characters || snap install gnome-characters"] }, { "if" : "Cheese", "type" : "command", - "commands" : ["flatpak install org.gnome.Cheese || snap install cheese"] + "commands" : ["!nextBoot flatpak install org.gnome.Cheese || snap install cheese"] }, { "if" : "Clocks", "type" : "command", - "commands" : ["flatpak install org.gnome.clocks || snap install gnome-clocks"] + "commands" : ["!nextBoot flatpak install org.gnome.clocks || snap install gnome-clocks"] }, { "if" : "Contacts", "type" : "command", - "commands" : ["flatpak install org.gnome.Contacts || snap install gnome-contacts"] + "commands" : ["!nextBoot flatpak install org.gnome.Contacts || snap install gnome-contacts"] }, { "if" : "Disk Usage Analyzer", "type" : "command", - "commands" : ["flatpak install org.gnome.baobab"] + "commands" : ["!nextBoot flatpak install org.gnome.baobab"] }, { "if" : "Document Viewer", "type" : "command", - "commands" : ["flatpak install org.gnome.Evince || snap install evince"] + "commands" : ["!nextBoot flatpak install org.gnome.Evince || snap install evince"] }, { "if" : "Extensions", "type" : "command", - "commands" : ["flatpak install org.gnome.Extensions"] + "commands" : ["!nextBoot flatpak install org.gnome.Extensions"] }, { "if" : "Fonts", "type" : "command", - "commands" : ["flatpak install org.gnome.Fonts"] + "commands" : ["!nextBoot flatpak install org.gnome.Fonts"] }, { "if" : "Image Viewer", "type" : "command", - "commands" : ["flatpak install org.gnome.eog || snap install eog"] + "commands" : ["!nextBoot flatpak install org.gnome.eog || snap install eog"] }, { "if" : "Logs", "type" : "command", - "commands" : ["flatpak install org.gnome.Logs || snap install gnome-logs"] + "commands" : ["!nextBoot flatpak install org.gnome.Logs || snap install gnome-logs"] }, { "if" : "Maps", "type" : "command", - "commands" : ["flatpak install org.gnome.Maps"] + "commands" : ["!nextBoot flatpak install org.gnome.Maps"] }, { "if" : "Music", "type" : "command", - "commands" : ["flatpak install org.gnome.Music"] + "commands" : ["!nextBoot flatpak install org.gnome.Music"] }, { "if" : "Photos", "type" : "command", - "commands" : ["flatpak install org.gnome.Photos"] + "commands" : ["!nextBoot flatpak install org.gnome.Photos"] }, { "if" : "Text Editor", "type" : "command", - "commands" : ["flatpak install org.gnome.TextEditor"] + "commands" : ["!nextBoot flatpak install org.gnome.TextEditor"] }, { "if" : "Videos", "type" : "command", - "commands" : ["flatpak install org.gnome.Totem"] + "commands" : ["!nextBoot flatpak install org.gnome.Totem"] }, { "if" : "Weather", "type" : "command", - "commands" : ["flatpak install org.gnome.Weather || snap install gnome-weather"] + "commands" : ["!nextBoot flatpak install org.gnome.Weather || snap install gnome-weather"] }, { "if" : "Bottles", "type" : "command", - "commands" : ["flatpak install com.usebottles.bottles"] + "commands" : ["!nextBoot flatpak install com.usebottles.bottles"] } ] }, From 646e0c99e8f91eca63295a45ae94c929ec397644 Mon Sep 17 00:00:00 2001 From: kra-mo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 21 Dec 2022 22:00:51 +0100 Subject: [PATCH 18/19] Add -y flag to flatpak install --- recipe.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/recipe.json b/recipe.json index 1e8d1a2..b3961cb 100644 --- a/recipe.json +++ b/recipe.json @@ -220,97 +220,97 @@ { "if" : "Calculator", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Calculator || snap install gnome-calculator"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Calculator || snap install gnome-calculator"] }, { "if" : "Calendar", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Calendar"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Calendar"] }, { "if" : "Characters", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Characters || snap install gnome-characters"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Characters || snap install gnome-characters"] }, { "if" : "Cheese", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Cheese || snap install cheese"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Cheese || snap install cheese"] }, { "if" : "Clocks", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.clocks || snap install gnome-clocks"] + "commands" : ["!nextBoot flatpak install -y org.gnome.clocks || snap install gnome-clocks"] }, { "if" : "Contacts", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Contacts || snap install gnome-contacts"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Contacts || snap install gnome-contacts"] }, { "if" : "Disk Usage Analyzer", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.baobab"] + "commands" : ["!nextBoot flatpak install -y org.gnome.baobab"] }, { "if" : "Document Viewer", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Evince || snap install evince"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Evince || snap install evince"] }, { "if" : "Extensions", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Extensions"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Extensions"] }, { "if" : "Fonts", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Fonts"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Fonts"] }, { "if" : "Image Viewer", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.eog || snap install eog"] + "commands" : ["!nextBoot flatpak install -y org.gnome.eog || snap install eog"] }, { "if" : "Logs", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Logs || snap install gnome-logs"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Logs || snap install gnome-logs"] }, { "if" : "Maps", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Maps"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Maps"] }, { "if" : "Music", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Music"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Music"] }, { "if" : "Photos", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Photos"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Photos"] }, { "if" : "Text Editor", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.TextEditor"] + "commands" : ["!nextBoot flatpak install -y org.gnome.TextEditor"] }, { "if" : "Videos", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Totem"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Totem"] }, { "if" : "Weather", "type" : "command", - "commands" : ["!nextBoot flatpak install org.gnome.Weather || snap install gnome-weather"] + "commands" : ["!nextBoot flatpak install -y org.gnome.Weather || snap install gnome-weather"] }, { "if" : "Bottles", "type" : "command", - "commands" : ["!nextBoot flatpak install com.usebottles.bottles"] + "commands" : ["!nextBoot flatpak install -y com.usebottles.bottles"] } ] }, From 5cd793e60b8452ff58d56d2ff88615fd84772fea Mon Sep 17 00:00:00 2001 From: Mirko Brombin Date: Thu, 22 Dec 2022 13:50:36 +0100 Subject: [PATCH 19/19] remove nextBoot script at the end --- vanilla_first_setup/utils/processor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vanilla_first_setup/utils/processor.py b/vanilla_first_setup/utils/processor.py index 33a089a..268515b 100644 --- a/vanilla_first_setup/utils/processor.py +++ b/vanilla_first_setup/utils/processor.py @@ -54,6 +54,8 @@ class Processor: for command in next_boot: f.write(f"{command}\n") + f.write(f"rm -f {next_boot_script_path}\n") + f.write(f"rm -f {next_boot_autostart_path}\n") f.flush() f.close()