From 17a6a53fd291e098c79e120a5d01c1c79438de8d Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 29 Mar 2023 07:59:02 +0200 Subject: [PATCH] Use Adw.ExpanderRows for import sources --- data/gtk/preferences.blp | 159 +++++++++++++++++---------------------- src/preferences.py | 23 +++--- 2 files changed, 83 insertions(+), 99 deletions(-) diff --git a/data/gtk/preferences.blp b/data/gtk/preferences.blp index b606081..e6c9e78 100644 --- a/data/gtk/preferences.blp +++ b/data/gtk/preferences.blp @@ -48,116 +48,99 @@ template PreferencesWindow : Adw.PreferencesWindow { title: _("Import"); icon-name: "document-save-symbolic"; - Adw.PreferencesGroup steam_group { - title: _("Steam"); + Adw.PreferencesGroup sources_group { + title: _("Sources"); - Adw.ActionRow { - title: _("Import From Steam"); + Adw.ExpanderRow steam_expander_row { + title: _("Steam"); + show-enable-switch: true; - Switch steam_switch { + Adw.ActionRow { + title: _("Steam Install Location"); + subtitle: _("Directory to use when importing games"); + + Button steam_file_chooser_button { + icon-name: "folder-symbolic"; valign: center; + } + } + Adw.ActionRow { + title: _("Extra Steam Libraries"); + subtitle: _("Select other directories where you have Steam games installed"); + + + Revealer steam_clear_button_revealer { + reveal-child: false; + transition-type: slide_left; + Button steam_clear_button { + label: _("Clear"); + valign: center; + halign: end; + + styles [ + "destructive-action", + ] + } + } + + Button steam_extra_file_chooser_button { + icon-name: "folder-new-symbolic"; + valign: center; + } } } - Adw.ActionRow { - title: _("Steam Install Location"); - subtitle: _("Directory to use when importing games"); + Adw.ExpanderRow heroic_expander_row { + title: _("Heroic"); + show-enable-switch: true; - Button steam_file_chooser_button { - icon-name: "folder-symbolic"; - valign: center; - } - } - Adw.ActionRow { - title: _("Extra Steam Libraries"); - subtitle: _("Select other directories where you have Steam games installed"); + Adw.ActionRow { + title: _("Heroic Install Location"); + subtitle: _("Directory to use when importing games"); - - Revealer steam_clear_button_revealer { - reveal-child: false; - transition-type: slide_left; - Button steam_clear_button { - label: _("Clear"); + Button heroic_file_chooser_button { + icon-name: "folder-symbolic"; valign: center; - halign: end; - - styles [ - "destructive-action", - ] } } - Button steam_extra_file_chooser_button { - icon-name: "folder-new-symbolic"; - valign: center; - } - } - } + Adw.ActionRow { + title: _("Import Epic Games"); - Adw.PreferencesGroup heroic_group { - title: _("Heroic"); - - Adw.ActionRow { - title: _("Import From Heroic"); - - Switch heroic_switch { + Switch heroic_epic_switch { valign: center; + } } - } - Adw.ActionRow { - title: _("Heroic Install Location"); - subtitle: _("Directory to use when importing games"); + Adw.ActionRow { + title: _("Import GOG Games"); - Button heroic_file_chooser_button { - icon-name: "folder-symbolic"; - valign: center; - } - } - - Adw.ActionRow { - title: _("Import Epic Games"); - - Switch heroic_epic_switch { - valign: center; - } - } - - Adw.ActionRow { - title: _("Import GOG Games"); - - Switch heroic_gog_switch { - valign: center; - } - } - - Adw.ActionRow { - title: _("Import Sideloaded Games"); - - Switch heroic_sideloaded_switch { - valign: center; - } - } - } - - Adw.PreferencesGroup bottles_group { - title: _("Bottles"); - - Adw.ActionRow { - title: _("Import From Bottles"); - - Switch bottles_switch { + Switch heroic_gog_switch { valign: center; + } + } + + Adw.ActionRow { + title: _("Import Sideloaded Games"); + + Switch heroic_sideloaded_switch { + valign: center; + } } } - Adw.ActionRow { - title: _("Bottles Install Location"); - subtitle: _("Directory to use when importing games"); + Adw.ExpanderRow bottles_expander_row { + title: _("Bottles"); + show-enable-switch: true; - Button bottles_file_chooser_button { - icon-name: "folder-symbolic"; - valign: center; + Adw.ActionRow { + title: _("Bottles Install Location"); + subtitle: _("Directory to use when importing games"); + + Button bottles_file_chooser_button { + icon-name: "folder-symbolic"; + valign: center; + } } } } diff --git a/src/preferences.py b/src/preferences.py index 57c9309..9b280bd 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -29,24 +29,25 @@ class PreferencesWindow(Adw.PreferencesWindow): general_page = Gtk.Template.Child() import_page = Gtk.Template.Child() + sources_group = Gtk.Template.Child() + exit_after_launch_switch = Gtk.Template.Child() cover_launches_game_switch = Gtk.Template.Child() high_quality_images_switch = Gtk.Template.Child() - steam_switch = Gtk.Template.Child() + steam_expander_row = Gtk.Template.Child() steam_file_chooser_button = Gtk.Template.Child() steam_extra_file_chooser_button = Gtk.Template.Child() steam_clear_button_revealer = Gtk.Template.Child() steam_clear_button = Gtk.Template.Child() - heroic_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() - bottles_group = Gtk.Template.Child() - bottles_switch = Gtk.Template.Child() + bottles_expander_row = Gtk.Template.Child() bottles_file_chooser_button = Gtk.Template.Child() def __init__(self, parent_widget, **kwargs): @@ -74,14 +75,14 @@ class PreferencesWindow(Adw.PreferencesWindow): ) schema.bind( "steam", - self.steam_switch, - "active", + self.steam_expander_row, + "enable-expansion", Gio.SettingsBindFlags.DEFAULT, ) schema.bind( "heroic", - self.heroic_switch, - "active", + self.heroic_expander_row, + "enable-expansion", Gio.SettingsBindFlags.DEFAULT, ) schema.bind( @@ -104,8 +105,8 @@ class PreferencesWindow(Adw.PreferencesWindow): ) schema.bind( "bottles", - self.bottles_switch, - "active", + self.bottles_expander_row, + "enable-expansion", Gio.SettingsBindFlags.DEFAULT, ) @@ -175,4 +176,4 @@ class PreferencesWindow(Adw.PreferencesWindow): ) if os.name == "nt": - self.import_page.remove(self.bottles_group) + self.sources_group.remove(self.bottles_expander_row)