Moved invalid location message to location
This commit is contained in:
@@ -101,5 +101,6 @@ class BottlesSource(URLExecutableSource):
|
||||
"library.yml": LocationSubPath("library.yml"),
|
||||
"data.yml": LocationSubPath("data.yml"),
|
||||
},
|
||||
invalid_subtitle=Location.DATA_INVALID_SUBTITLE,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -97,5 +97,6 @@ class ItchSource(URLExecutableSource):
|
||||
paths={
|
||||
"butler.db": LocationSubPath("db/butler.db"),
|
||||
},
|
||||
invalid_subtitle=Location.CONFIG_INVALID_SUBTITLE,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -110,5 +110,6 @@ class LegendarySource(Source):
|
||||
"installed.json": LocationSubPath("installed.json"),
|
||||
"metadata": LocationSubPath("metadata", True),
|
||||
},
|
||||
invalid_subtitle=Location.CONFIG_INVALID_SUBTITLE,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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"""
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -132,5 +132,6 @@ class SteamSource(URLExecutableSource):
|
||||
"libraryfolders.vdf": LocationSubPath("steamapps/libraryfolders.vdf"),
|
||||
"librarycache": LocationSubPath("appcache/librarycache", True),
|
||||
},
|
||||
invalid_subtitle=Location.DATA_INVALID_SUBTITLE,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user