diff --git a/src/importer/sources/bottles_source.py b/src/importer/sources/bottles_source.py index 5983c27..5b48078 100644 --- a/src/importer/sources/bottles_source.py +++ b/src/importer/sources/bottles_source.py @@ -101,5 +101,6 @@ class BottlesSource(URLExecutableSource): "library.yml": LocationSubPath("library.yml"), "data.yml": LocationSubPath("data.yml"), }, + invalid_subtitle=Location.DATA_INVALID_SUBTITLE, ) ) diff --git a/src/importer/sources/flatpak_source.py b/src/importer/sources/flatpak_source.py index ec8e2a5..b78815c 100644 --- a/src/importer/sources/flatpak_source.py +++ b/src/importer/sources/flatpak_source.py @@ -135,5 +135,6 @@ class FlatpakSource(Source): "applications": LocationSubPath("exports/share/applications", True), "icons": LocationSubPath("exports/share/icons", True), }, + invalid_subtitle=Location.DATA_INVALID_SUBTITLE, ) ) diff --git a/src/importer/sources/heroic_source.py b/src/importer/sources/heroic_source.py index 2986aad..605ba56 100644 --- a/src/importer/sources/heroic_source.py +++ b/src/importer/sources/heroic_source.py @@ -377,6 +377,7 @@ class HeroicSource(URLExecutableSource): "config.json": LocationSubPath("config.json"), "store_config.json": LocationSubPath("store/config.json"), }, + invalid_subtitle=Location.CONFIG_INVALID_SUBTITLE, ) ) diff --git a/src/importer/sources/itch_source.py b/src/importer/sources/itch_source.py index 19839cd..8302e91 100644 --- a/src/importer/sources/itch_source.py +++ b/src/importer/sources/itch_source.py @@ -97,5 +97,6 @@ class ItchSource(URLExecutableSource): paths={ "butler.db": LocationSubPath("db/butler.db"), }, + invalid_subtitle=Location.CONFIG_INVALID_SUBTITLE, ) ) diff --git a/src/importer/sources/legendary_source.py b/src/importer/sources/legendary_source.py index e802f51..48f0cac 100644 --- a/src/importer/sources/legendary_source.py +++ b/src/importer/sources/legendary_source.py @@ -110,5 +110,6 @@ class LegendarySource(Source): "installed.json": LocationSubPath("installed.json"), "metadata": LocationSubPath("metadata", True), }, + invalid_subtitle=Location.CONFIG_INVALID_SUBTITLE, ) ) diff --git a/src/importer/sources/location.py b/src/importer/sources/location.py index a884ba0..55684b4 100644 --- a/src/importer/sources/location.py +++ b/src/importer/sources/location.py @@ -29,9 +29,18 @@ class Location: * When resolved, the schema is updated with the picked chosen """ + # The variable is the name of the source + CACHE_INVALID_SUBTITLE = _("Select the {} cache directory.") + # The variable is the name of the source + CONFIG_INVALID_SUBTITLE = _("Select the {} configuration directory.") + # The variable is the name of the source + DATA_INVALID_SUBTITLE = _("Select the {} data directory.") + schema_key: str candidates: Iterable[Candidate] paths: Mapping[str, LocationSubPath] + invalid_subtitle: str + root: Path = None def __init__( @@ -39,11 +48,13 @@ class Location: schema_key: str, candidates: Iterable[Candidate], paths: Mapping[str, LocationSubPath], + invalid_subtitle: str, ) -> None: super().__init__() self.schema_key = schema_key self.candidates = candidates self.paths = paths + self.invalid_subtitle = invalid_subtitle def check_candidate(self, candidate: Path) -> bool: """Check if a candidate root has the necessary files and directories""" diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index 627f896..9afc977 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -110,6 +110,7 @@ class LutrisSource(URLExecutableSource): paths={ "pga.db": (False, "pga.db"), }, + invalid_subtitle=Location.DATA_INVALID_SUBTITLE, ), Location( schema_key="lutris-cache-location", @@ -121,6 +122,7 @@ class LutrisSource(URLExecutableSource): paths={ "coverart": LocationSubPath("coverart", True), }, + invalid_subtitle=Location.CACHE_INVALID_SUBTITLE, ), ) diff --git a/src/importer/sources/steam_source.py b/src/importer/sources/steam_source.py index 39e3c49..f1c34ba 100644 --- a/src/importer/sources/steam_source.py +++ b/src/importer/sources/steam_source.py @@ -132,5 +132,6 @@ class SteamSource(URLExecutableSource): "libraryfolders.vdf": LocationSubPath("steamapps/libraryfolders.vdf"), "librarycache": LocationSubPath("appcache/librarycache", True), }, + invalid_subtitle=Location.DATA_INVALID_SUBTITLE, ) ) diff --git a/src/preferences.py b/src/preferences.py index 7300523..53bc098 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -351,20 +351,10 @@ class PreferencesWindow(Adw.PreferencesWindow): # Bad picked location, inform user else: title = _("Invalid Directory") - match location_name: - case "cache": - # The variable is the name of the source - subtitle_format = _("Select the {} cache directory.") - case "config": - # The variable is the name of the source - subtitle_format = _("Select the {} configuration directory.") - case "data": - # The variable is the name of the source - subtitle_format = _("Select the {} data directory.") dialog = create_dialog( self, title, - subtitle_format.format(source.name), + location.invalid_subtitle.format(source.name), "choose_folder", _("Set Location"), )