Port to Adw.SwitchRow

This commit is contained in:
kramo
2023-07-04 19:04:39 +02:00
parent 5fd6ea20f4
commit 536e6792e7
2 changed files with 20 additions and 76 deletions

View File

@@ -12,37 +12,22 @@ template $PreferencesWindow : Adw.PreferencesWindow {
Adw.PreferencesGroup behavior_group {
title: _("Behavior");
Adw.ActionRow {
Adw.SwitchRow exit_after_launch_switch {
title: _("Exit After Launching Games");
activatable-widget: exit_after_launch_switch;
Switch exit_after_launch_switch {
valign: center;
}
}
Adw.ActionRow {
Adw.SwitchRow cover_launches_game_switch {
title: _("Cover Image Launches Game");
subtitle: _("Swaps the behavior of the cover image and the play button");
activatable-widget: cover_launches_game_switch;
Switch cover_launches_game_switch {
valign: center;
}
}
}
Adw.PreferencesGroup images_group {
title: _("Images");
Adw.ActionRow {
Adw.SwitchRow high_quality_images_switch {
title: _("High Quality Images");
subtitle: _("Save game covers losslessly at the cost of storage");
activatable-widget: high_quality_images_switch;
Switch high_quality_images_switch {
valign: center;
}
}
}
@@ -124,22 +109,12 @@ template $PreferencesWindow : Adw.PreferencesWindow {
}
}
Adw.ActionRow {
Adw.SwitchRow lutris_import_steam_switch {
title: _("Import Steam Games");
activatable-widget: lutris_import_steam_switch;
Switch lutris_import_steam_switch {
valign: center;
}
}
Adw.ActionRow {
Adw.SwitchRow lutris_import_flatpak_switch {
title: _("Import Flatpak Games");
activatable-widget: lutris_import_flatpak_switch;
Switch lutris_import_flatpak_switch {
valign: center;
}
}
}
@@ -156,31 +131,16 @@ template $PreferencesWindow : Adw.PreferencesWindow {
}
}
Adw.ActionRow {
Adw.SwitchRow heroic_import_epic_switch {
title: _("Import Epic Games");
activatable-widget: heroic_import_epic_switch;
Switch heroic_import_epic_switch {
valign: center;
}
}
Adw.ActionRow {
Adw.SwitchRow heroic_import_gog_switch {
title: _("Import GOG Games");
activatable-widget: heroic_import_gog_switch;
Switch heroic_import_gog_switch {
valign: center;
}
}
Adw.ActionRow {
Adw.SwitchRow heroic_import_sideload_switch {
title: _("Import Sideloaded Games");
activatable-widget: heroic_import_sideload_switch;
Switch heroic_import_sideload_switch {
valign: center;
}
}
}
@@ -267,32 +227,17 @@ template $PreferencesWindow : Adw.PreferencesWindow {
Adw.PreferencesGroup sgdb_behavior_group {
title: _("Behavior");
Adw.ActionRow sgdb_switch_row {
Adw.SwitchRow sgdb_switch {
title: _("Use SteamGridDB");
subtitle: _("Download images when adding or importing games");
activatable-widget: sgdb_switch;
Switch sgdb_switch {
valign: center;
}
}
Adw.ActionRow {
Adw.SwitchRow sgdb_prefer_switch {
title: _("Prefer Over Official Images");
activatable-widget: sgdb_prefer_switch;
Switch sgdb_prefer_switch {
valign: center;
}
}
Adw.ActionRow {
Adw.SwitchRow sgdb_animated_switch {
title: _("Prefer Animated Images");
activatable-widget: sgdb_animated_switch;
Switch sgdb_animated_switch {
valign: center;
}
}
}
}

View File

@@ -90,7 +90,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
sgdb_key_group = Gtk.Template.Child()
sgdb_key_entry_row = Gtk.Template.Child()
sgdb_switch = Gtk.Template.Child()
sgdb_switch_row = Gtk.Template.Child()
sgdb_prefer_switch = Gtk.Template.Child()
sgdb_animated_switch = Gtk.Template.Child()
@@ -162,15 +161,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
)
)
def set_sgdb_sensitive(widget):
if not widget.get_text():
shared.schema.set_boolean("sgdb", False)
self.sgdb_switch_row.set_sensitive(widget.get_text())
self.sgdb_key_entry_row.connect("changed", set_sgdb_sensitive)
set_sgdb_sensitive(self.sgdb_key_entry_row)
# Switches
self.bind_switches(
(
@@ -189,6 +179,15 @@ class PreferencesWindow(Adw.PreferencesWindow):
)
)
def set_sgdb_sensitive(widget):
if not widget.get_text():
shared.schema.set_boolean("sgdb", False)
self.sgdb_switch.set_sensitive(widget.get_text())
self.sgdb_key_entry_row.connect("changed", set_sgdb_sensitive)
set_sgdb_sensitive(self.sgdb_key_entry_row)
def get_switch(self, setting):
return getattr(self, f'{setting.replace("-", "_")}_switch')