From dad4905753384c8cdb440efcbf78100f3d83d4b5 Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Wed, 29 Mar 2023 23:02:10 +0200 Subject: [PATCH] Cleanups --- src/main.py | 1 - src/preferences.py | 77 ++++++++++++++++++++++------------------- src/utils/save_cover.py | 2 +- src/window.py | 4 +-- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/main.py b/src/main.py index 288605d..a9635ce 100644 --- a/src/main.py +++ b/src/main.py @@ -17,7 +17,6 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -import os import sys import time diff --git a/src/preferences.py b/src/preferences.py index b9a3b0e..b1f3e6f 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -27,13 +27,13 @@ from .create_dialog import create_dialog class ImportPreferences: def __init__( self, + window, source_id, name, - key, + install_key, paths, expander_row, file_chooser_button, - window, config=False, ): def set_dir(_source, result, _unused): @@ -60,7 +60,7 @@ class ImportPreferences: ).connect("response", response) else: window.schema.set_string( - key, + install_key, path, ) except GLib.GError: @@ -109,8 +109,9 @@ class PreferencesWindow(Adw.PreferencesWindow): self.schema = parent_widget.schema self.parent_widget = parent_widget self.file_chooser = Gtk.FileDialog() - self.set_transient_for(parent_widget) + + # General self.schema.bind( "exit-after-launch", self.exit_after_launch_switch, @@ -129,23 +130,20 @@ class PreferencesWindow(Adw.PreferencesWindow): "active", Gio.SettingsBindFlags.DEFAULT, ) - 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, + + # Steam + ImportPreferences( + self, + "steam", + "Steam", + "steam-location", + [ + "steamapps", + os.path.join("steam", "steamapps"), + os.path.join("Steam", "steamapps"), + ], + self.steam_expander_row, + self.steam_file_chooser_button, ) def update_revealer(): @@ -174,39 +172,46 @@ class PreferencesWindow(Adw.PreferencesWindow): ) self.steam_clear_button.connect("clicked", clear_steam_dirs) + # Heroic ImportPreferences( - "steam", - "Steam", - "steam-location", - [ - "steamapps", - os.path.join("steam", "steamapps"), - os.path.join("Steam", "steamapps"), - ], - self.steam_expander_row, - self.steam_file_chooser_button, self, - ) - - ImportPreferences( "heroic", "Heroic", "heroic-location", ["config.json"], self.heroic_expander_row, self.heroic_file_chooser_button, - self, 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, "bottles", "Bottles", "bottles-location", ["library.yml"], self.bottles_expander_row, self.bottles_file_chooser_button, - self, ) if os.name == "nt": diff --git a/src/utils/save_cover.py b/src/utils/save_cover.py index 9777aa5..9f868ad 100644 --- a/src/utils/save_cover.py +++ b/src/utils/save_cover.py @@ -34,7 +34,7 @@ def save_cover(parent_widget, game_id, cover_path, pixbuf=None): os.makedirs(covers_dir) if pixbuf is None: - pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(cover_path, 600, 900, False) + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(cover_path, 400, 600, False) def cover_callback(*_unused): pass diff --git a/src/window.py b/src/window.py index e69b168..6e7cb3c 100644 --- a/src/window.py +++ b/src/window.py @@ -83,7 +83,7 @@ class CartridgesWindow(Adw.ApplicationWindow): self.schema = Gio.Settings.new("hu.kramo.Cartridges") self.placeholder_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale( - "/hu/kramo/Cartridges/library_placeholder.svg", 200, 300, False + "/hu/kramo/Cartridges/library_placeholder.svg", 400, 600, False ) current_games = get_games() for current_game in current_games: @@ -104,7 +104,7 @@ class CartridgesWindow(Adw.ApplicationWindow): or os.path.expanduser(os.path.join("~", ".local", "share")), "cartridges", "covers", - f"{current_game}.dat", + f"{current_game}.tiff", ) ) except FileNotFoundError: