From 4c1af9245f585c0ba9f436b6defbe2a5e047f0d8 Mon Sep 17 00:00:00 2001
From: kramo <93832451+kra-mo@users.noreply.github.com>
Date: Sat, 27 May 2023 15:11:03 +0200
Subject: [PATCH] Update build configuration
---
.github/workflows/flatpak-builder.yml | 4 +-
.github/workflows/windows.yml | 4 +-
README.md | 9 +-
...source.xml => cartridges.gresource.xml.in} | 2 +-
data/gtk/window.blp | 1 -
data/hu.kramo.Cartridges.desktop.in | 2 +-
...xml => hu.kramo.Cartridges.gschema.xml.in} | 4 +-
data/hu.kramo.Cartridges.metainfo.xml.in | 4 +-
.../apps/hu.kramo.Cartridges.Devel.svg | 85 ++++++++++++++++++
.../hu.kramo.Cartridges.Devel-symbolic.svg | 3 +
data/icons/meson.build | 6 +-
data/meson.build | 29 ++++--
.../hu.kramo.Cartridges.Devel.json | 5 +-
meson.build | 18 ++++
meson_options.txt | 9 ++
po/POTFILES | 2 +-
src/details_window.py | 2 +-
src/game.py | 10 +--
src/game_cover.py | 6 +-
src/main.py | 8 +-
src/meson.build | 14 ++-
src/preferences.py | 2 +-
src/{shared.py => shared.py.in} | 12 ++-
src/window.py | 15 ++--
{.windows => windows}/Cartridges.iss | 0
{.windows => windows}/icon.ico | Bin
26 files changed, 195 insertions(+), 61 deletions(-)
rename data/{cartridges.gresource.xml => cartridges.gresource.xml.in} (91%)
rename data/{hu.kramo.Cartridges.gschema.xml => hu.kramo.Cartridges.gschema.xml.in} (94%)
create mode 100644 data/icons/hicolor/scalable/apps/hu.kramo.Cartridges.Devel.svg
create mode 100644 data/icons/hicolor/symbolic/apps/hu.kramo.Cartridges.Devel-symbolic.svg
rename hu.kramo.Cartridges.json => flatpak/hu.kramo.Cartridges.Devel.json (97%)
create mode 100644 meson_options.txt
rename src/{shared.py => shared.py.in} (87%)
rename {.windows => windows}/Cartridges.iss (100%)
rename {.windows => windows}/icon.ico (100%)
diff --git a/.github/workflows/flatpak-builder.yml b/.github/workflows/flatpak-builder.yml
index 0d13dc9..c868945 100644
--- a/.github/workflows/flatpak-builder.yml
+++ b/.github/workflows/flatpak-builder.yml
@@ -14,6 +14,6 @@ jobs:
- uses: actions/checkout@v3
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
- bundle: hu.kramo.Cartridges.flatpak
- manifest-path: hu.kramo.Cartridges.json
+ bundle: hu.kramo.Cartridges.Devel.flatpak
+ manifest-path: flatpak/hu.kramo.Cartridges.Devel.json
cache-key: flatpak-builder-${{ github.sha }}
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 636492c..7e9f264 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -24,9 +24,9 @@ jobs:
pacman --noconfirm -Rs mingw-w64-ucrt-x86_64-desktop-file-utils mingw-w64-ucrt-x86_64-meson git
find /ucrt64/share/locale/ -type f ! -name "*cartridges.mo" -delete
- name: "Inno Setup"
- run: iscc ".\.windows\Cartridges.iss"
+ run: iscc ".\windows\Cartridges.iss"
- name: "Upload Artifact"
uses: actions/upload-artifact@v3
with:
name: "Installer"
- path: ".windows/Output/Cartridges Setup.exe"
\ No newline at end of file
+ path: "windows/Output/Cartridges Setup.exe"
\ No newline at end of file
diff --git a/README.md b/README.md
index cc6b323..ffc0fab 100644
--- a/README.md
+++ b/README.md
@@ -53,15 +53,12 @@ For updates and questions, join our [Discord server][discord-url]!
## Linux
-### Flathub (Recommended)
+### Flathub
+
+The app is available on Flathub.
-### From Releases
-
-1. Download the latest release from [Releases](https://github.com/kra-mo/cartridges/releases).
-2. Install the downloaded file via GNOME Software or `flatpak install hu.kramo.Cartridges.flatpak`.
-
## Windows
### From Releases
diff --git a/data/cartridges.gresource.xml b/data/cartridges.gresource.xml.in
similarity index 91%
rename from data/cartridges.gresource.xml
rename to data/cartridges.gresource.xml.in
index afa550b..1205656 100644
--- a/data/cartridges.gresource.xml
+++ b/data/cartridges.gresource.xml.in
@@ -1,6 +1,6 @@
-
+
gtk/window.ui
gtk/help-overlay.ui
gtk/game.ui
diff --git a/data/gtk/window.blp b/data/gtk/window.blp
index 2ff8f0f..46c90f2 100644
--- a/data/gtk/window.blp
+++ b/data/gtk/window.blp
@@ -18,7 +18,6 @@ Adw.StatusPage hidden_notice_no_results {
}
Adw.StatusPage notice_empty {
- icon-name: "hu.kramo.Cartridges-symbolic";
title: _("No Games");
description: _("Use the + button to add games.");
vexpand: true;
diff --git a/data/hu.kramo.Cartridges.desktop.in b/data/hu.kramo.Cartridges.desktop.in
index 531f739..643d02f 100644
--- a/data/hu.kramo.Cartridges.desktop.in
+++ b/data/hu.kramo.Cartridges.desktop.in
@@ -3,7 +3,7 @@ Name=Cartridges
GenericName=Game Launcher
Comment=Launch all your games
Exec=cartridges
-Icon=hu.kramo.Cartridges
+Icon=@APP_ID@
Terminal=false
Type=Application
Categories=GNOME;GTK;Game;
diff --git a/data/hu.kramo.Cartridges.gschema.xml b/data/hu.kramo.Cartridges.gschema.xml.in
similarity index 94%
rename from data/hu.kramo.Cartridges.gschema.xml
rename to data/hu.kramo.Cartridges.gschema.xml.in
index 15a6ab6..25d1784 100644
--- a/data/hu.kramo.Cartridges.gschema.xml
+++ b/data/hu.kramo.Cartridges.gschema.xml.in
@@ -1,6 +1,6 @@
-
+
false
@@ -68,7 +68,7 @@
false
-
+
1110
diff --git a/data/hu.kramo.Cartridges.metainfo.xml.in b/data/hu.kramo.Cartridges.metainfo.xml.in
index 718c791..807d788 100644
--- a/data/hu.kramo.Cartridges.metainfo.xml.in
+++ b/data/hu.kramo.Cartridges.metainfo.xml.in
@@ -1,6 +1,6 @@
- hu.kramo.Cartridges.desktop
+ @APP_ID@.desktop
CC0-1.0
GPL-3.0-or-later
Cartridges
@@ -15,7 +15,7 @@
https://github.com/kra-mo/cartridges
https://github.com/kra-mo/cartridges/blob/main/CONTRIBUTING.md
kramo
- hu.kramo.Cartridges.desktop
+ @APP_ID@.desktop
pointing
keyboard
diff --git a/data/icons/hicolor/scalable/apps/hu.kramo.Cartridges.Devel.svg b/data/icons/hicolor/scalable/apps/hu.kramo.Cartridges.Devel.svg
new file mode 100644
index 0000000..0d54b23
--- /dev/null
+++ b/data/icons/hicolor/scalable/apps/hu.kramo.Cartridges.Devel.svg
@@ -0,0 +1,85 @@
+
+
diff --git a/data/icons/hicolor/symbolic/apps/hu.kramo.Cartridges.Devel-symbolic.svg b/data/icons/hicolor/symbolic/apps/hu.kramo.Cartridges.Devel-symbolic.svg
new file mode 100644
index 0000000..2f56644
--- /dev/null
+++ b/data/icons/hicolor/symbolic/apps/hu.kramo.Cartridges.Devel-symbolic.svg
@@ -0,0 +1,3 @@
+
diff --git a/data/icons/meson.build b/data/icons/meson.build
index 25f8a5c..3d42f8d 100644
--- a/data/icons/meson.build
+++ b/data/icons/meson.build
@@ -1,13 +1,11 @@
-application_id = 'hu.kramo.Cartridges'
-
scalable_dir = join_paths('hicolor', 'scalable', 'apps')
install_data(
- join_paths(scalable_dir, ('@0@.svg').format(application_id)),
+ join_paths(scalable_dir, ('@0@.svg').format(app_id)),
install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir)
)
symbolic_dir = join_paths('hicolor', 'symbolic', 'apps')
install_data(
- join_paths(symbolic_dir, ('@0@-symbolic.svg').format(application_id)),
+ join_paths(symbolic_dir, ('@0@-symbolic.svg').format(app_id)),
install_dir: join_paths(get_option('datadir'), 'icons', symbolic_dir)
)
diff --git a/data/meson.build b/data/meson.build
index df0f8b8..071fb69 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -11,7 +11,11 @@ blueprints = custom_target('blueprints',
)
gnome.compile_resources('cartridges',
- 'cartridges.gresource.xml',
+ configure_file(
+ input: 'cartridges.gresource.xml.in',
+ output: 'cartridges.gresource.xml',
+ configuration: conf
+ ),
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
@@ -19,8 +23,12 @@ gnome.compile_resources('cartridges',
)
desktop_file = i18n.merge_file(
- input: 'hu.kramo.Cartridges.desktop.in',
- output: 'hu.kramo.Cartridges.desktop',
+ input: configure_file(
+ input: 'hu.kramo.Cartridges.desktop.in',
+ output: app_id + '.desktop.in',
+ configuration: conf
+ ),
+ output: app_id + '.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
@@ -33,8 +41,12 @@ if desktop_utils.found()
endif
appstream_file = i18n.merge_file(
- input: 'hu.kramo.Cartridges.metainfo.xml.in',
- output: 'hu.kramo.Cartridges.metainfo.xml',
+ input: configure_file(
+ input: 'hu.kramo.Cartridges.metainfo.xml.in',
+ output: app_id + '.metainfo.xml.in',
+ configuration: conf
+ ),
+ output: app_id + '.metainfo.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'metainfo')
@@ -45,7 +57,12 @@ if appstream_util.found()
test('Validate appstream file', appstream_util, args: ['validate', appstream_file])
endif
-install_data('hu.kramo.Cartridges.gschema.xml',
+install_data(
+ configure_file(
+ input: 'hu.kramo.Cartridges.gschema.xml.in',
+ output: app_id + '.gschema.xml',
+ configuration: conf
+ ),
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)
diff --git a/hu.kramo.Cartridges.json b/flatpak/hu.kramo.Cartridges.Devel.json
similarity index 97%
rename from hu.kramo.Cartridges.json
rename to flatpak/hu.kramo.Cartridges.Devel.json
index fff931d..6ffc966 100644
--- a/hu.kramo.Cartridges.json
+++ b/flatpak/hu.kramo.Cartridges.Devel.json
@@ -1,5 +1,5 @@
{
- "id" : "hu.kramo.Cartridges",
+ "id" : "hu.kramo.Cartridges.Devel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "44",
"sdk" : "org.gnome.Sdk",
@@ -117,6 +117,9 @@
"name" : "cartridges",
"builddir" : true,
"buildsystem" : "meson",
+ "config-opts": [
+ "-Dprofile=development"
+ ],
"sources" : [
{
"type" : "dir",
diff --git a/meson.build b/meson.build
index 182d657..46915d6 100644
--- a/meson.build
+++ b/meson.build
@@ -6,9 +6,27 @@ project('cartridges',
i18n = import('i18n')
gnome = import('gnome')
+python = import('python')
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
+profile = get_option('profile')
+if profile == 'development'
+ app_id = 'hu.kramo.Cartridges.Devel'
+ prefix = '/hu/kramo/Cartridges/Devel/'
+elif profile == 'release'
+ app_id = 'hu.kramo.Cartridges'
+ prefix = '/hu/kramo/Cartridges/'
+endif
+
+conf = configuration_data()
+conf.set('PYTHON', python.find_installation('python3').full_path())
+conf.set('APP_ID', app_id)
+conf.set('PREFIX', prefix)
+conf.set('VERSION', meson.project_version())
+conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
+conf.set('pkgdatadir', pkgdatadir)
+
subdir('data')
subdir('src')
subdir('po')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..5026cd2
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,9 @@
+option(
+ 'profile',
+ type: 'combo',
+ choices: [
+ 'release',
+ 'development',
+ ],
+ value: 'release'
+)
diff --git a/po/POTFILES b/po/POTFILES
index dbc9dd7..271d33c 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -1,5 +1,5 @@
data/hu.kramo.Cartridges.desktop.in
-data/hu.kramo.Cartridges.gschema.xml
+data/hu.kramo.Cartridges.gschema.xml.in
data/hu.kramo.Cartridges.metainfo.xml.in
data/gtk/details_window.blp
diff --git a/src/details_window.py b/src/details_window.py
index 57ad67e..ef0e7b6 100644
--- a/src/details_window.py
+++ b/src/details_window.py
@@ -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"
diff --git a/src/game.py b/src/game.py
index 8067e95..b045935 100644
--- a/src/game.py
+++ b/src/game.py
@@ -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
diff --git a/src/game_cover.py b/src/game_cover.py
index b82ec8c..857659c 100644
--- a/src/game_cover.py
+++ b/src/game_cover.py
@@ -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)
diff --git a/src/main.py b/src/main.py
index ea5753a..064ef16 100644
--- a/src/main.py
+++ b/src/main.py
@@ -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",
diff --git a/src/meson.build b/src/meson.build
index 87099ba..5b94f5b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -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',
diff --git a/src/preferences.py b/src/preferences.py
index dd36aa2..e615683 100644
--- a/src/preferences.py
+++ b/src/preferences.py
@@ -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"
diff --git a/src/shared.py b/src/shared.py.in
similarity index 87%
rename from src/shared.py
rename to src/shared.py.in
index 9cf54d5..0060914 100644
--- a/src/shared.py
+++ b/src/shared.py.in
@@ -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
diff --git a/src/window.py b/src/window.py
index d21f48e..19b7ce2 100644
--- a/src/window.py
+++ b/src/window.py
@@ -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:
diff --git a/.windows/Cartridges.iss b/windows/Cartridges.iss
similarity index 100%
rename from .windows/Cartridges.iss
rename to windows/Cartridges.iss
diff --git a/.windows/icon.ico b/windows/icon.ico
similarity index 100%
rename from .windows/icon.ico
rename to windows/icon.ico