This commit is contained in:
kramo
2023-03-29 23:02:10 +02:00
parent e6ba083736
commit dad4905753
4 changed files with 44 additions and 40 deletions

View File

@@ -17,7 +17,6 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import os
import sys import sys
import time import time

View File

@@ -27,13 +27,13 @@ from .create_dialog import create_dialog
class ImportPreferences: class ImportPreferences:
def __init__( def __init__(
self, self,
window,
source_id, source_id,
name, name,
key, install_key,
paths, paths,
expander_row, expander_row,
file_chooser_button, file_chooser_button,
window,
config=False, config=False,
): ):
def set_dir(_source, result, _unused): def set_dir(_source, result, _unused):
@@ -60,7 +60,7 @@ class ImportPreferences:
).connect("response", response) ).connect("response", response)
else: else:
window.schema.set_string( window.schema.set_string(
key, install_key,
path, path,
) )
except GLib.GError: except GLib.GError:
@@ -109,8 +109,9 @@ class PreferencesWindow(Adw.PreferencesWindow):
self.schema = parent_widget.schema self.schema = parent_widget.schema
self.parent_widget = parent_widget self.parent_widget = parent_widget
self.file_chooser = Gtk.FileDialog() self.file_chooser = Gtk.FileDialog()
self.set_transient_for(parent_widget) self.set_transient_for(parent_widget)
# General
self.schema.bind( self.schema.bind(
"exit-after-launch", "exit-after-launch",
self.exit_after_launch_switch, self.exit_after_launch_switch,
@@ -129,23 +130,20 @@ class PreferencesWindow(Adw.PreferencesWindow):
"active", "active",
Gio.SettingsBindFlags.DEFAULT, Gio.SettingsBindFlags.DEFAULT,
) )
self.schema.bind(
"heroic-import-epic", # Steam
self.heroic_epic_switch, ImportPreferences(
"active", self,
Gio.SettingsBindFlags.DEFAULT, "steam",
) "Steam",
self.schema.bind( "steam-location",
"heroic-import-gog", [
self.heroic_gog_switch, "steamapps",
"active", os.path.join("steam", "steamapps"),
Gio.SettingsBindFlags.DEFAULT, os.path.join("Steam", "steamapps"),
) ],
self.schema.bind( self.steam_expander_row,
"heroic-import-sideload", self.steam_file_chooser_button,
self.heroic_sideloaded_switch,
"active",
Gio.SettingsBindFlags.DEFAULT,
) )
def update_revealer(): def update_revealer():
@@ -174,39 +172,46 @@ class PreferencesWindow(Adw.PreferencesWindow):
) )
self.steam_clear_button.connect("clicked", clear_steam_dirs) self.steam_clear_button.connect("clicked", clear_steam_dirs)
# Heroic
ImportPreferences( 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, self,
)
ImportPreferences(
"heroic", "heroic",
"Heroic", "Heroic",
"heroic-location", "heroic-location",
["config.json"], ["config.json"],
self.heroic_expander_row, self.heroic_expander_row,
self.heroic_file_chooser_button, self.heroic_file_chooser_button,
self,
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
ImportPreferences( ImportPreferences(
self,
"bottles", "bottles",
"Bottles", "Bottles",
"bottles-location", "bottles-location",
["library.yml"], ["library.yml"],
self.bottles_expander_row, self.bottles_expander_row,
self.bottles_file_chooser_button, self.bottles_file_chooser_button,
self,
) )
if os.name == "nt": if os.name == "nt":

View File

@@ -34,7 +34,7 @@ def save_cover(parent_widget, game_id, cover_path, pixbuf=None):
os.makedirs(covers_dir) os.makedirs(covers_dir)
if pixbuf is None: 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): def cover_callback(*_unused):
pass pass

View File

@@ -83,7 +83,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
self.schema = Gio.Settings.new("hu.kramo.Cartridges") self.schema = Gio.Settings.new("hu.kramo.Cartridges")
self.placeholder_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale( 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() current_games = get_games()
for current_game in current_games: for current_game in current_games:
@@ -104,7 +104,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
or os.path.expanduser(os.path.join("~", ".local", "share")), or os.path.expanduser(os.path.join("~", ".local", "share")),
"cartridges", "cartridges",
"covers", "covers",
f"{current_game}.dat", f"{current_game}.tiff",
) )
) )
except FileNotFoundError: except FileNotFoundError: