diff --git a/src/details_window.py b/src/details_window.py index df56f0f..57ad67e 100644 --- a/src/details_window.py +++ b/src/details_window.py @@ -18,6 +18,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import os +import shlex from time import time from gi.repository import Adw, Gio, GLib, Gtk @@ -66,7 +67,11 @@ class DetailsWindow(Adw.Window): self.name.set_text(self.game.name) if self.game.developer: self.developer.set_text(self.game.developer) - self.executable.set_text(" ".join(self.game.executable)) + self.executable.set_text( + self.game.executable + if isinstance(self.game.executable, str) + else shlex.join(self.game.executable) + ) self.apply_button.set_label(_("Apply")) self.game_cover.new_cover(self.game.get_cover_path()) @@ -131,7 +136,6 @@ class DetailsWindow(Adw.Window): final_name = self.name.get_text() final_developer = self.developer.get_text() final_executable = self.executable.get_text() - final_executable_split = final_executable.split() if not self.game: if final_name == "": @@ -183,7 +187,7 @@ class DetailsWindow(Adw.Window): self.game.name = final_name self.game.developer = final_developer or None - self.game.executable = final_executable_split + self.game.executable = final_executable if self.game.game_id in self.win.game_covers.keys(): self.win.game_covers[self.game.game_id].animation = None diff --git a/src/game.py b/src/game.py index 8f0a13e..8067e95 100644 --- a/src/game.py +++ b/src/game.py @@ -65,6 +65,7 @@ class Game(Gtk.Box): self.win = shared.win self.app = self.win.get_application() + self.version = shared.spec_version self.update_values(data) @@ -141,6 +142,7 @@ class Game(Gtk.Box): "developer", "removed", "blacklisted", + "version", ) # TODO: remove for 2.0 @@ -179,19 +181,17 @@ class Game(Gtk.Box): self.last_played = int(time()) self.save() - args = " ".join( - [ - "flatpak-spawn", - "--host", - "/bin/sh", - "-c", - shlex.quote(" ".join(self.executable)), - ] - if os.getenv("FLATPAK_ID") == "hu.kramo.Cartridges" - else self.executable + string = ( + self.executable + if isinstance(self.executable, str) + else shlex.join(self.executable) ) - print(args) + args = ( + "flatpak-spawn --host /bin/sh -c " + shlex.quote(string) # Flatpak + if os.getenv("FLATPAK_ID") == "hu.kramo.Cartridges" + else string # Others + ) subprocess.Popen( args, diff --git a/src/shared.py b/src/shared.py index a40bef6..9cf54d5 100644 --- a/src/shared.py +++ b/src/shared.py @@ -52,3 +52,4 @@ 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 2de6c5b..3c99464 100644 --- a/src/window.py +++ b/src/window.py @@ -100,6 +100,9 @@ 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: + continue + if game.get("removed"): for path in ( shared.games_dir / f"{game_id}.json",