This commit is contained in:
kramo
2023-05-07 17:59:23 +02:00
parent e1296444e5
commit 00fa770943
3 changed files with 40 additions and 82 deletions

View File

@@ -136,9 +136,9 @@ template PreferencesWindow : Adw.PreferencesWindow {
Adw.ActionRow { Adw.ActionRow {
title: _("Import Steam Games"); 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; valign: center;
} }
} }
@@ -160,27 +160,27 @@ template PreferencesWindow : Adw.PreferencesWindow {
Adw.ActionRow { Adw.ActionRow {
title: _("Import Epic Games"); 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; valign: center;
} }
} }
Adw.ActionRow { Adw.ActionRow {
title: _("Import GOG Games"); 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; valign: center;
} }
} }
Adw.ActionRow { Adw.ActionRow {
title: _("Import Sideloaded Games"); 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; valign: center;
} }
} }
@@ -237,9 +237,9 @@ template PreferencesWindow : Adw.PreferencesWindow {
Adw.ActionRow { Adw.ActionRow {
title: _("Use SteamGridDB"); title: _("Use SteamGridDB");
subtitle: _("Download images when adding or importing games"); 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; valign: center;
} }
} }

View File

@@ -182,9 +182,6 @@ class CartridgesApplication(Adw.Application):
if self.win.stack.get_visible_child() == self.win.details_view: if self.win.stack.get_visible_child() == self.win.details_view:
self.on_remove_game_action() self.on_remove_game_action()
def on_quit_action(self, *_args):
self.quit()
def search(self, uri): def search(self, uri):
Gio.AppInfo.launch_default_for_uri(f"{uri}{self.win.active_game.name}") 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): def on_hltb_search_action(self, *_args):
self.search("https://howlongtobeat.com/?q=") self.search("https://howlongtobeat.com/?q=")
def on_quit_action(self, *_args):
self.quit()
def create_actions(self, actions): def create_actions(self, actions):
for action in actions: for action in actions:
simple_action = Gio.SimpleAction.new(action[0], None) simple_action = Gio.SimpleAction.new(action[0], None)

View File

@@ -97,13 +97,13 @@ class PreferencesWindow(Adw.PreferencesWindow):
lutris_expander_row = Gtk.Template.Child() lutris_expander_row = Gtk.Template.Child()
lutris_file_chooser_button = Gtk.Template.Child() lutris_file_chooser_button = Gtk.Template.Child()
lutris_cache_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_expander_row = Gtk.Template.Child()
heroic_file_chooser_button = Gtk.Template.Child() heroic_file_chooser_button = Gtk.Template.Child()
heroic_epic_switch = Gtk.Template.Child() heroic_import_epic_switch = Gtk.Template.Child()
heroic_gog_switch = Gtk.Template.Child() heroic_import_gog_switch = Gtk.Template.Child()
heroic_sideloaded_switch = Gtk.Template.Child() heroic_import_sideload_switch = Gtk.Template.Child()
bottles_expander_row = Gtk.Template.Child() bottles_expander_row = Gtk.Template.Child()
bottles_file_chooser_button = 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_group = Gtk.Template.Child()
sgdb_key_entry_row = 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_prefer_switch = Gtk.Template.Child()
sgdb_animated_switch = Gtk.Template.Child() sgdb_animated_switch = Gtk.Template.Child()
@@ -139,25 +139,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
self.removed_games = set() self.removed_games = set()
# General # 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) self.remove_all_games_button.connect("clicked", self.remove_all_games)
# Steam # Steam
@@ -205,12 +186,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
self.lutris_expander_row, self.lutris_expander_row,
self.lutris_file_chooser_button, 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): def set_cache_dir(_source, result, *_args):
try: try:
@@ -249,25 +224,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
True, 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 # Bottles
ImportPreferences( ImportPreferences(
self, self,
@@ -292,26 +248,19 @@ class PreferencesWindow(Adw.PreferencesWindow):
True, True,
) )
# SteamGridDB self.bind_switches(
self.schema.bind( (
"sgdb", "exit-after-launch",
self.sgdb_download_switch, "cover-launches-game",
"active", "high-quality-images",
Gio.SettingsBindFlags.DEFAULT, "lutris-import-steam",
) "heroic-import-epic",
"heroic-import-gog",
self.schema.bind( "heroic-import-sideload",
"sgdb-prefer", "sgdb",
self.sgdb_prefer_switch, "sgdb-prefer",
"active", "sgdb-animated",
Gio.SettingsBindFlags.DEFAULT, )
)
self.schema.bind(
"sgdb-animated",
self.sgdb_animated_switch,
"active",
Gio.SettingsBindFlags.DEFAULT,
) )
def sgdb_key_changed(*_args): 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): def choose_folder(self, _widget, function):
self.file_chooser.select_folder(self.win, None, function, None) self.file_chooser.select_folder(self.win, None, function, None)