From 8cc3e47f3870bd7e3cfa1f927c07a9321e5dd6c6 Mon Sep 17 00:00:00 2001 From: ArtyIF Date: Tue, 2 Aug 2022 15:08:12 +0300 Subject: [PATCH] Moving some window-specific code to window file --- src/main.py | 35 ----------------------------------- src/window.py | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/main.py b/src/main.py index 613f9150..b0d35d3c 100644 --- a/src/main.py +++ b/src/main.py @@ -86,41 +86,6 @@ class AdwcustomizerApplication(Adw.Application): if not win: win = AdwcustomizerMainWindow(application=self) - for group in settings_schema["groups"]: - pref_group = Adw.PreferencesGroup() - pref_group.set_name(group["name"]) - pref_group.set_title(group["title"]) - pref_group.set_description(group["description"]) - - for variable in group["variables"]: - pref_variable = AdwcustomizerOption(variable["name"], - variable["title"], - variable["adw_gtk3_support"], - variable.get("explanation")) - pref_group.add(pref_variable) - self.pref_variables[variable["name"]] = pref_variable - - win.content.add(pref_group) - - palette_pref_group = Adw.PreferencesGroup() - palette_pref_group.set_name("palette_colors") - palette_pref_group.set_title(_("Palette Colors")) - palette_pref_group.set_description(_("Named palette colors used by some applications. Default colors follow the GNOME Human Interface Guidelines.")) - for color in settings_schema["palette"]: - palette_shades = AdwcustomizerPaletteShades(color["prefix"], - color["title"], - color["n_shades"]) - palette_pref_group.add(palette_shades) - self.pref_palette_shades[color["prefix"]] = palette_shades - win.content.add(palette_pref_group) - - self.custom_css_group = AdwcustomizerCustomCSSGroup() - for app_type in settings_schema["custom_css_app_types"]: - self.custom_css[app_type] = "" - self.custom_css_group.load_custom_css(self.custom_css) - win.content.add(self.custom_css_group) - - self.create_action("open_preset_directory", self.open_preset_directory) self.create_stateful_action("load_preset", GLib.VariantType.new('s'), GLib.Variant('s', 'adwaita'), self.load_preset_action) self.create_action("apply_color_scheme", self.show_apply_color_scheme_dialog) diff --git a/src/window.py b/src/window.py index 66598948..3f60d307 100644 --- a/src/window.py +++ b/src/window.py @@ -26,8 +26,13 @@ # use or other dealings in this Software without prior written # authorization. -from gi.repository import Gtk +from gi.repository import Gtk, Adw from .error import AdwcustomizerError +from .settings_schema import settings_schema +from .palette_shades import AdwcustomizerPaletteShades +from .option import AdwcustomizerOption +from .app_type_dialog import AdwcustomizerAppTypeDialog +from .custom_css_group import AdwcustomizerCustomCSSGroup @Gtk.Template(resource_path='/com/github/ArtyIF/AdwCustomizer/ui/window.ui') class AdwcustomizerMainWindow(Gtk.ApplicationWindow): @@ -44,6 +49,41 @@ class AdwcustomizerMainWindow(Gtk.ApplicationWindow): super().__init__(**kwargs) self.presets_dropdown.get_popover().connect("show", self.on_presets_dropdown_activate) + for group in settings_schema["groups"]: + pref_group = Adw.PreferencesGroup() + pref_group.set_name(group["name"]) + pref_group.set_title(group["title"]) + pref_group.set_description(group["description"]) + + for variable in group["variables"]: + pref_variable = AdwcustomizerOption(variable["name"], + variable["title"], + variable["adw_gtk3_support"], + variable.get("explanation")) + pref_group.add(pref_variable) + self.get_application().pref_variables[variable["name"]] = pref_variable + + self.content.add(pref_group) + + palette_pref_group = Adw.PreferencesGroup() + palette_pref_group.set_name("palette_colors") + palette_pref_group.set_title(_("Palette Colors")) + palette_pref_group.set_description(_("Named palette colors used by some applications. Default colors follow the GNOME Human Interface Guidelines.")) + for color in settings_schema["palette"]: + palette_shades = AdwcustomizerPaletteShades(color["prefix"], + color["title"], + color["n_shades"]) + palette_pref_group.add(palette_shades) + self.get_application().pref_palette_shades[color["prefix"]] = palette_shades + self.content.add(palette_pref_group) + + custom_css_group = AdwcustomizerCustomCSSGroup() + for app_type in settings_schema["custom_css_app_types"]: + self.get_application().custom_css[app_type] = "" + custom_css_group.load_custom_css(self.get_application().custom_css) + self.content.add(custom_css_group) + self.get_application().custom_css_group = custom_css_group + def update_errors(self, errors): child = self.errors_list.get_row_at_index(0) while child is not None: