diff --git a/data/gtk/preferences.blp b/data/gtk/preferences.blp index ea2b8d1..85e551c 100644 --- a/data/gtk/preferences.blp +++ b/data/gtk/preferences.blp @@ -136,9 +136,9 @@ template PreferencesWindow : Adw.PreferencesWindow { Adw.ActionRow { title: _("Import Steam Games"); - activatable-widget: lutris_steam_switch; + activatable-widget: lutris_import_steam_switch; - Switch lutris_steam_switch { + Switch lutris_import_steam_switch { valign: center; } } @@ -160,27 +160,27 @@ template PreferencesWindow : Adw.PreferencesWindow { Adw.ActionRow { title: _("Import Epic Games"); - activatable-widget: heroic_epic_switch; + activatable-widget: heroic_import_epic_switch; - Switch heroic_epic_switch { + Switch heroic_import_epic_switch { valign: center; } } Adw.ActionRow { title: _("Import GOG Games"); - activatable-widget: heroic_gog_switch; + activatable-widget: heroic_import_gog_switch; - Switch heroic_gog_switch { + Switch heroic_import_gog_switch { valign: center; } } Adw.ActionRow { title: _("Import Sideloaded Games"); - activatable-widget: heroic_sideloaded_switch; + activatable-widget: heroic_import_sideload_switch; - Switch heroic_sideloaded_switch { + Switch heroic_import_sideload_switch { valign: center; } } @@ -237,9 +237,9 @@ template PreferencesWindow : Adw.PreferencesWindow { Adw.ActionRow { title: _("Use SteamGridDB"); subtitle: _("Download images when adding or importing games"); - activatable-widget: sgdb_download_switch; + activatable-widget: sgdb_switch; - Switch sgdb_download_switch { + Switch sgdb_switch { valign: center; } } diff --git a/src/main.py b/src/main.py index e173a20..8bbfff0 100644 --- a/src/main.py +++ b/src/main.py @@ -182,9 +182,6 @@ class CartridgesApplication(Adw.Application): if self.win.stack.get_visible_child() == self.win.details_view: self.on_remove_game_action() - def on_quit_action(self, *_args): - self.quit() - def search(self, uri): Gio.AppInfo.launch_default_for_uri(f"{uri}{self.win.active_game.name}") @@ -203,6 +200,9 @@ class CartridgesApplication(Adw.Application): def on_hltb_search_action(self, *_args): self.search("https://howlongtobeat.com/?q=") + def on_quit_action(self, *_args): + self.quit() + def create_actions(self, actions): for action in actions: simple_action = Gio.SimpleAction.new(action[0], None) diff --git a/src/preferences.py b/src/preferences.py index ff8c9fe..3119db7 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -97,13 +97,13 @@ class PreferencesWindow(Adw.PreferencesWindow): lutris_expander_row = Gtk.Template.Child() lutris_file_chooser_button = Gtk.Template.Child() lutris_cache_file_chooser_button = Gtk.Template.Child() - lutris_steam_switch = Gtk.Template.Child() + lutris_import_steam_switch = Gtk.Template.Child() heroic_expander_row = Gtk.Template.Child() heroic_file_chooser_button = Gtk.Template.Child() - heroic_epic_switch = Gtk.Template.Child() - heroic_gog_switch = Gtk.Template.Child() - heroic_sideloaded_switch = Gtk.Template.Child() + heroic_import_epic_switch = Gtk.Template.Child() + heroic_import_gog_switch = Gtk.Template.Child() + heroic_import_sideload_switch = Gtk.Template.Child() bottles_expander_row = Gtk.Template.Child() bottles_file_chooser_button = Gtk.Template.Child() @@ -113,7 +113,7 @@ class PreferencesWindow(Adw.PreferencesWindow): sgdb_key_group = Gtk.Template.Child() sgdb_key_entry_row = Gtk.Template.Child() - sgdb_download_switch = Gtk.Template.Child() + sgdb_switch = Gtk.Template.Child() sgdb_prefer_switch = Gtk.Template.Child() sgdb_animated_switch = Gtk.Template.Child() @@ -139,25 +139,6 @@ class PreferencesWindow(Adw.PreferencesWindow): self.removed_games = set() # General - self.schema.bind( - "exit-after-launch", - self.exit_after_launch_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - self.schema.bind( - "cover-launches-game", - self.cover_launches_game_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - self.schema.bind( - "high-quality-images", - self.high_quality_images_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - self.remove_all_games_button.connect("clicked", self.remove_all_games) # Steam @@ -205,12 +186,6 @@ class PreferencesWindow(Adw.PreferencesWindow): self.lutris_expander_row, self.lutris_file_chooser_button, ) - self.schema.bind( - "lutris-import-steam", - self.lutris_steam_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) def set_cache_dir(_source, result, *_args): try: @@ -249,25 +224,6 @@ class PreferencesWindow(Adw.PreferencesWindow): True, ) - self.schema.bind( - "heroic-import-epic", - self.heroic_epic_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - self.schema.bind( - "heroic-import-gog", - self.heroic_gog_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - self.schema.bind( - "heroic-import-sideload", - self.heroic_sideloaded_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - # Bottles ImportPreferences( self, @@ -292,26 +248,19 @@ class PreferencesWindow(Adw.PreferencesWindow): True, ) - # SteamGridDB - self.schema.bind( - "sgdb", - self.sgdb_download_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - - self.schema.bind( - "sgdb-prefer", - self.sgdb_prefer_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, - ) - - self.schema.bind( - "sgdb-animated", - self.sgdb_animated_switch, - "active", - Gio.SettingsBindFlags.DEFAULT, + self.bind_switches( + ( + "exit-after-launch", + "cover-launches-game", + "high-quality-images", + "lutris-import-steam", + "heroic-import-epic", + "heroic-import-gog", + "heroic-import-sideload", + "sgdb", + "sgdb-prefer", + "sgdb-animated", + ) ) def sgdb_key_changed(*_args): @@ -328,6 +277,15 @@ class PreferencesWindow(Adw.PreferencesWindow): ) ) + def bind_switches(self, settings): + for setting in settings: + self.schema.bind( + setting, + getattr(self, f'{setting.replace("-", "_")}_switch'), + "active", + Gio.SettingsBindFlags.DEFAULT, + ) + def choose_folder(self, _widget, function): self.file_chooser.select_folder(self.win, None, function, None)