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