From 823641d909e8abba7e0c86ee1ad04e2213abe056 Mon Sep 17 00:00:00 2001 From: kramo Date: Wed, 10 Jul 2024 15:12:27 +0200 Subject: [PATCH] Make Heroic and itch sources available on macOS --- cartridges/details_dialog.py | 6 +++--- cartridges/importer/heroic_source.py | 3 ++- cartridges/importer/itch_source.py | 3 ++- cartridges/preferences.py | 5 +++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cartridges/details_dialog.py b/cartridges/details_dialog.py index 76ca4d1..c3f6d3f 100644 --- a/cartridges/details_dialog.py +++ b/cartridges/details_dialog.py @@ -17,9 +17,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -import os import shlex from pathlib import Path +from sys import platform from time import time from typing import Any, Optional @@ -106,7 +106,7 @@ class DetailsDialog(Adw.Dialog): # As in software exe_name = _("program") - if os.name == "nt": + if platform == "win32": exe_name += ".exe" # Translate this string as you would translate "path to {}" exe_path = _("C:\\path\\to\\{}").format(exe_name) @@ -118,7 +118,7 @@ class DetailsDialog(Adw.Dialog): exe_path = _("/path/to/{}").format(exe_name) # Translate this string as you would translate "path to {}" file_path = _("/path/to/{}").format(file_name) - command = "xdg-open" + command = "open" if platform == "darwin" else "xdg-open" # pylint: disable=line-too-long exec_info_text = _( diff --git a/cartridges/importer/heroic_source.py b/cartridges/importer/heroic_source.py index 306c91e..46e8627 100644 --- a/cartridges/importer/heroic_source.py +++ b/cartridges/importer/heroic_source.py @@ -355,7 +355,7 @@ class HeroicSource(URLExecutableSource): name = _("Heroic") iterable_class = HeroicSourceIterable url_format = "heroic://launch/{runner}/{app_name}" - available_on = {"linux", "win32"} + available_on = {"linux", "win32", "darwin"} locations: HeroicLocations @@ -377,6 +377,7 @@ class HeroicSource(URLExecutableSource): / "config" / "heroic", shared.appdata_dir / "heroic", + shared.app_support_dir / "heroic", ), paths={ "config.json": LocationSubPath("config.json"), diff --git a/cartridges/importer/itch_source.py b/cartridges/importer/itch_source.py index 2a73594..6f198f9 100644 --- a/cartridges/importer/itch_source.py +++ b/cartridges/importer/itch_source.py @@ -81,7 +81,7 @@ class ItchSource(URLExecutableSource): name = _("itch") iterable_class = ItchSourceIterable url_format = "itch://caves/{cave_id}/launch" - available_on = {"linux", "win32"} + available_on = {"linux", "win32", "darwin"} locations: ItchLocations @@ -95,6 +95,7 @@ class ItchSource(URLExecutableSource): shared.config_dir / "itch", shared.host_config_dir / "itch", shared.appdata_dir / "itch", + shared.app_support_dir / "itch", ), paths={ "butler.db": LocationSubPath("db/butler.db"), diff --git a/cartridges/preferences.py b/cartridges/preferences.py index fc79b07..47b3c3f 100644 --- a/cartridges/preferences.py +++ b/cartridges/preferences.py @@ -30,6 +30,7 @@ from cartridges import shared from cartridges.errors.friendly_error import FriendlyError from cartridges.game import Game from cartridges.importer.bottles_source import BottlesSource +from cartridges.importer.desktop_source import DesktopSource from cartridges.importer.flatpak_source import FlatpakSource from cartridges.importer.heroic_source import HeroicSource from cartridges.importer.itch_source import ItchSource @@ -169,6 +170,10 @@ class CartridgesPreferences(Adw.PreferencesDialog): else: self.init_source_row(source) + # Special case for the desktop source + if not DesktopSource().is_available: + self.desktop_switch.set_visible(False) + # SteamGridDB def sgdb_key_changed(*_args: Any) -> None: shared.schema.set_string("sgdb-key", self.sgdb_key_entry_row.get_text())