Update build configuration

This commit is contained in:
kramo
2023-05-27 15:11:03 +02:00
parent d05a03dee7
commit 4c1af9245f
26 changed files with 195 additions and 61 deletions

View File

@@ -32,7 +32,7 @@ from .save_cover import resize_cover, save_cover
from .steamgriddb import SGDBSave
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/details_window.ui")
@Gtk.Template(resource_path=shared.PREFIX + "gtk/details_window.ui")
class DetailsWindow(Adw.Window):
__gtype_name__ = "DetailsWindow"

View File

@@ -24,13 +24,13 @@ import subprocess
from pathlib import Path
from time import time
from gi.repository import Adw, Gio, Gtk
from gi.repository import Adw, Gtk
from . import shared
from .game_cover import GameCover
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/game.ui")
@Gtk.Template(resource_path=shared.PREFIX + "gtk/game.ui")
class Game(Gtk.Box):
__gtype_name__ = "Game"
@@ -65,7 +65,7 @@ class Game(Gtk.Box):
self.win = shared.win
self.app = self.win.get_application()
self.version = shared.spec_version
self.version = shared.SPEC_VERSION
self.update_values(data)
@@ -189,7 +189,7 @@ class Game(Gtk.Box):
args = (
"flatpak-spawn --host /bin/sh -c " + shlex.quote(string) # Flatpak
if os.getenv("FLATPAK_ID") == "hu.kramo.Cartridges"
if os.getenv("FLATPAK_ID") == shared.APP_ID
else string # Others
)
@@ -201,7 +201,7 @@ class Game(Gtk.Box):
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if os.name == "nt" else 0,
)
if Gio.Settings.new("hu.kramo.Cartridges").get_boolean("exit-after-launch"):
if shared.state_schema.get_boolean("exit-after-launch"):
self.app.quit()
# The variable is the title of the game

View File

@@ -20,6 +20,8 @@
from gi.repository import GdkPixbuf, Gio, GLib
from PIL import Image, ImageFilter, ImageStat
from . import shared
class GameCover:
pixbuf = None
@@ -30,7 +32,7 @@ class GameCover:
anim_iter = None
placeholder_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale(
"/hu/kramo/Cartridges/library_placeholder.svg", 400, 600, False
shared.PREFIX + "library_placeholder.svg", 400, 600, False
)
def __init__(self, pictures, path=None):
@@ -91,7 +93,7 @@ class GameCover:
)
else:
self.blurred = GdkPixbuf.Pixbuf.new_from_resource_at_scale(
"/hu/kramo/Cartridges/library_placeholder.svg", 2, 2, False
shared.PREFIX + "library_placeholder.svg", 2, 2, False
)
self.luminance = (0.1, 0.8)

View File

@@ -44,12 +44,12 @@ class CartridgesApplication(Adw.Application):
def __init__(self):
super().__init__(
application_id="hu.kramo.Cartridges", flags=Gio.ApplicationFlags.FLAGS_NONE
application_id=shared.APP_ID, flags=Gio.ApplicationFlags.FLAGS_NONE
)
def do_activate(self): # pylint: disable=arguments-differ
# Set fallback icon-name
Gtk.Window.set_default_icon_name("hu.kramo.Cartridges")
Gtk.Window.set_default_icon_name(shared.APP_ID)
# Create the main window
self.win = self.props.active_window # pylint: disable=no-member
@@ -110,9 +110,9 @@ class CartridgesApplication(Adw.Application):
about = Adw.AboutWindow(
transient_for=self.win,
application_name=_("Cartridges"),
application_icon="hu.kramo.Cartridges",
application_icon=shared.APP_ID,
developer_name="kramo",
version="1.5.2",
version=shared.VERSION,
developers=[
"kramo https://kramo.hu",
"Arcitec https://github.com/Arcitec",

View File

@@ -1,13 +1,5 @@
moduledir = join_paths(pkgdatadir, 'cartridges')
python = import('python')
conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').path())
conf.set('VERSION', meson.project_version())
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
conf.set('pkgdatadir', pkgdatadir)
configure_file(
input: 'cartridges.in',
output: 'cartridges',
@@ -17,6 +9,11 @@ configure_file(
)
cartridges_sources = [
configure_file(
input: 'shared.py.in',
output: 'shared.py',
configuration: conf
),
'__init__.py',
'main.py',
'window.py',
@@ -24,7 +21,6 @@ cartridges_sources = [
'details_window.py',
'game.py',
'game_cover.py',
'shared.py',
'importers/steam_importer.py',
'importers/lutris_importer.py',
'importers/heroic_importer.py',

View File

@@ -33,7 +33,7 @@ from .lutris_importer import lutris_cache_exists, lutris_installed
from .steam_importer import steam_installed
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/preferences.ui")
@Gtk.Template(resource_path=shared.PREFIX + "gtk/preferences.ui")
class PreferencesWindow(Adw.PreferencesWindow):
__gtype_name__ = "PreferencesWindow"

View File

@@ -1,4 +1,4 @@
# shared.py
# shared.py.in
#
# Copyright 2022-2023 kramo
#
@@ -22,8 +22,13 @@ from pathlib import Path
from gi.repository import Gdk, Gio
schema = Gio.Settings.new("hu.kramo.Cartridges")
state_schema = Gio.Settings.new("hu.kramo.Cartridges.State")
APP_ID = "@APP_ID@"
VERSION = "@VERSION@"
PREFIX = "@PREFIX@"
SPEC_VERSION = 1.5 # The version of the game_id.json spec
schema = Gio.Settings.new(APP_ID)
state_schema = Gio.Settings.new(APP_ID + ".State")
data_dir = (
Path(os.getenv("XDG_DATA_HOME"))
@@ -52,4 +57,3 @@ image_size = (200 * scale_factor, 300 * scale_factor)
# pylint: disable=invalid-name
win = None
importer = None
spec_version = 1.5 # The version of the game_id.json spec

View File

@@ -20,13 +20,13 @@
import json
from datetime import datetime
from gi.repository import Adw, Gio, GLib, Gtk
from gi.repository import Adw, GLib, Gtk
from . import shared
from .game import Game
@Gtk.Template(resource_path="/hu/kramo/Cartridges/gtk/window.ui")
@Gtk.Template(resource_path=shared.PREFIX + "gtk/window.ui")
class CartridgesWindow(Adw.ApplicationWindow):
__gtype_name__ = "CartridgesWindow"
@@ -92,6 +92,11 @@ class CartridgesWindow(Adw.ApplicationWindow):
self.set_library_child()
self.notice_empty.set_icon_name(shared.APP_ID + "-symbolic")
if "Devel" in shared.APP_ID:
self.add_css_class("devel")
games = {}
if shared.games_dir.is_dir():
@@ -100,7 +105,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
games[data["game_id"]] = data
for game_id, game in games.items():
if (version := game.get("version")) and version > shared.spec_version:
if (version := game.get("version")) and version > shared.SPEC_VERSION:
continue
if game.get("removed"):
@@ -318,9 +323,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
self.sort_state = str(state).strip("'")
self.library.invalidate_sort()
Gio.Settings(schema_id="hu.kramo.Cartridges.State").set_string(
"sort-mode", self.sort_state
)
shared.state_schema.set_string("sort-mode", self.sort_state)
def on_toggle_search_action(self, *_args):
if self.stack.get_visible_child() == self.library_view: