Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -91,6 +91,8 @@ class Importer(ErrorProducer):
|
||||
def run(self):
|
||||
"""Use several Gio.Task to import games from added sources"""
|
||||
|
||||
shared.win.get_application().lookup_action("import").set_enabled(False)
|
||||
|
||||
self.create_dialog()
|
||||
|
||||
# Collect all errors and reset the cancellables for the managers
|
||||
@@ -221,6 +223,7 @@ class Importer(ErrorProducer):
|
||||
self.import_dialog.close()
|
||||
self.summary_toast = self.create_summary_toast()
|
||||
self.create_error_dialog()
|
||||
shared.win.get_application().lookup_action("import").set_enabled(True)
|
||||
|
||||
def create_error_dialog(self):
|
||||
"""Dialog containing all errors raised by importers"""
|
||||
@@ -263,7 +266,7 @@ class Importer(ErrorProducer):
|
||||
list_box = Gtk.ListBox()
|
||||
list_box.set_selection_mode(Gtk.SelectionMode.NONE)
|
||||
list_box.set_css_classes(["boxed-list"])
|
||||
list_box.set_margin_top(8)
|
||||
list_box.set_margin_top(9)
|
||||
for error in errors:
|
||||
row = Adw.ActionRow.new()
|
||||
row.set_title(error[0])
|
||||
|
||||
@@ -83,7 +83,7 @@ class BottlesSourceIterator(SourceIterator):
|
||||
class BottlesSource(URLExecutableSource):
|
||||
"""Generic Bottles source"""
|
||||
|
||||
name = "Bottles"
|
||||
name = _("Bottles")
|
||||
iterator_class = BottlesSourceIterator
|
||||
url_format = 'bottles:run/"{bottle_name}"/"{game_name}"'
|
||||
available_on = {"linux"}
|
||||
|
||||
@@ -40,10 +40,11 @@ class FlatpakSourceIterator(SourceIterator):
|
||||
icon_theme.add_search_path(str(self.source.data_location["icons"]))
|
||||
|
||||
blacklist = (
|
||||
{"hu.kramo.Cartridges"}
|
||||
{"hu.kramo.Cartridges", "hu.kramo.Cartridges.Devel"}
|
||||
if shared.schema.get_boolean("flatpak-import-launchers")
|
||||
else {
|
||||
"hu.kramo.Cartridges",
|
||||
"hu.kramo.Cartridges.Devel",
|
||||
"com.valvesoftware.Steam",
|
||||
"net.lutris.Lutris",
|
||||
"com.heroicgameslauncher.hgl",
|
||||
@@ -113,7 +114,7 @@ class FlatpakSourceIterator(SourceIterator):
|
||||
class FlatpakSource(Source):
|
||||
"""Generic Flatpak source"""
|
||||
|
||||
name = "Flatpak"
|
||||
name = _("Flatpak")
|
||||
iterator_class = FlatpakSourceIterator
|
||||
executable_format = "flatpak run {flatpak_id}"
|
||||
available_on = {"linux"}
|
||||
|
||||
@@ -81,10 +81,10 @@ class HeroicSourceIterator(SourceIterator):
|
||||
runner = entry["runner"]
|
||||
service = self.sub_sources[runner]["service"]
|
||||
values = {
|
||||
"source": self.source.id,
|
||||
"source": f"{self.source.id}_{service}",
|
||||
"added": added_time,
|
||||
"name": entry["title"],
|
||||
"developer": entry["developer"],
|
||||
"developer": entry.get("developer", None),
|
||||
"game_id": self.source.game_id_format.format(
|
||||
service=service, game_id=app_name
|
||||
),
|
||||
@@ -106,14 +106,16 @@ class HeroicSourceIterator(SourceIterator):
|
||||
def generator_builder(self) -> SourceIterationResult:
|
||||
"""Generator method producing games from all the Heroic sub-sources"""
|
||||
|
||||
for sub_source in self.sub_sources.values():
|
||||
for sub_source_name, sub_source in self.sub_sources.items():
|
||||
# Skip disabled sub-sources
|
||||
if not shared.schema.get_boolean("heroic-import-" + sub_source["service"]):
|
||||
continue
|
||||
# Load games from JSON
|
||||
file = self.source.config_location.root.joinpath(*sub_source["path"])
|
||||
try:
|
||||
library = json.load(file.open())["library"]
|
||||
contents = json.load(file.open())
|
||||
key = "library" if sub_source_name == "legendary" else "games"
|
||||
library = contents[key]
|
||||
except (JSONDecodeError, OSError, KeyError):
|
||||
# Invalid library.json file, skip it
|
||||
logging.warning("Couldn't open Heroic file: %s", str(file))
|
||||
@@ -124,9 +126,11 @@ class HeroicSourceIterator(SourceIterator):
|
||||
for entry in library:
|
||||
try:
|
||||
result = self.game_from_library_entry(entry, added_time)
|
||||
except KeyError:
|
||||
except KeyError as error:
|
||||
# Skip invalid games
|
||||
logging.warning("Invalid Heroic game skipped in %s", str(file))
|
||||
logging.warning(
|
||||
"Invalid Heroic game skipped in %s", str(file), exc_info=error
|
||||
)
|
||||
continue
|
||||
yield result
|
||||
|
||||
@@ -134,7 +138,7 @@ class HeroicSourceIterator(SourceIterator):
|
||||
class HeroicSource(URLExecutableSource):
|
||||
"""Generic Heroic Games Launcher source"""
|
||||
|
||||
name = "Heroic"
|
||||
name = _("Heroic")
|
||||
iterator_class = HeroicSourceIterator
|
||||
url_format = "heroic://launch/{app_name}"
|
||||
available_on = {"linux", "win32"}
|
||||
@@ -155,4 +159,4 @@ class HeroicSource(URLExecutableSource):
|
||||
@property
|
||||
def game_id_format(self) -> str:
|
||||
"""The string format used to construct game IDs"""
|
||||
return self.name.lower() + "_{service}_{game_id}"
|
||||
return self.id + "_{service}_{game_id}"
|
||||
|
||||
@@ -79,7 +79,7 @@ class ItchSourceIterator(SourceIterator):
|
||||
|
||||
|
||||
class ItchSource(URLExecutableSource):
|
||||
name = "Itch"
|
||||
name = _("itch")
|
||||
iterator_class = ItchSourceIterator
|
||||
url_format = "itch://caves/{cave_id}/launch"
|
||||
available_on = {"linux", "win32"}
|
||||
|
||||
@@ -51,7 +51,7 @@ class LegendarySourceIterator(SourceIterator):
|
||||
data = {}
|
||||
|
||||
# Get additional metadata from file (optional)
|
||||
metadata_file = self.source.data_location["metadata"] / f"{app_name}.json"
|
||||
metadata_file = self.source.config_location["metadata"] / f"{app_name}.json"
|
||||
try:
|
||||
metadata = json.load(metadata_file.open())
|
||||
values["developer"] = metadata["metadata"]["developer"]
|
||||
@@ -67,7 +67,7 @@ class LegendarySourceIterator(SourceIterator):
|
||||
|
||||
def generator_builder(self) -> Generator[SourceIterationResult, None, None]:
|
||||
# Open library
|
||||
file = self.source.data_location["installed.json"]
|
||||
file = self.source.config_location["installed.json"]
|
||||
try:
|
||||
library: dict = json.load(file.open())
|
||||
except (JSONDecodeError, OSError):
|
||||
@@ -90,9 +90,9 @@ class LegendarySourceIterator(SourceIterator):
|
||||
|
||||
|
||||
class LegendarySource(Source):
|
||||
name = "Legendary"
|
||||
name = _("Legendary")
|
||||
executable_format = "legendary launch {app_name}"
|
||||
available_on = {"linux", "win32"}
|
||||
available_on = {"linux"}
|
||||
|
||||
iterator_class = LegendarySourceIterator
|
||||
config_location: Location = Location(
|
||||
|
||||
@@ -70,9 +70,9 @@ class LutrisSourceIterator(SourceIterator):
|
||||
"name": row[1],
|
||||
"source": f"{self.source.id}_{row[3]}",
|
||||
"game_id": self.source.game_id_format.format(
|
||||
game_id=row[2], game_internal_id=row[0]
|
||||
runner=row[3], game_id=row[0]
|
||||
),
|
||||
"executable": self.source.executable_format.format(game_id=row[2]),
|
||||
"executable": self.source.executable_format.format(game_id=row[0]),
|
||||
}
|
||||
game = Game(values)
|
||||
|
||||
@@ -90,7 +90,7 @@ class LutrisSourceIterator(SourceIterator):
|
||||
class LutrisSource(URLExecutableSource):
|
||||
"""Generic Lutris source"""
|
||||
|
||||
name = "Lutris"
|
||||
name = _("Lutris")
|
||||
iterator_class = LutrisSourceIterator
|
||||
url_format = "lutris:rungameid/{game_id}"
|
||||
available_on = {"linux"}
|
||||
@@ -123,4 +123,4 @@ class LutrisSource(URLExecutableSource):
|
||||
|
||||
@property
|
||||
def game_id_format(self):
|
||||
return super().game_id_format + "_{game_internal_id}"
|
||||
return self.id + "_{runner}_{game_id}"
|
||||
|
||||
@@ -110,7 +110,7 @@ class SteamSourceIterator(SourceIterator):
|
||||
|
||||
|
||||
class SteamSource(URLExecutableSource):
|
||||
name = "Steam"
|
||||
name = _("Steam")
|
||||
available_on = {"linux", "win32"}
|
||||
iterator_class = SteamSourceIterator
|
||||
url_format = "steam://rungameid/{game_id}"
|
||||
@@ -118,9 +118,9 @@ class SteamSource(URLExecutableSource):
|
||||
data_location = Location(
|
||||
schema_key="steam-location",
|
||||
candidates=(
|
||||
shared.flatpak_dir / "com.valvesoftware.Steam" / "data" / "Steam",
|
||||
shared.home / ".steam" / "steam",
|
||||
shared.data_dir / "Steam",
|
||||
shared.home / ".steam",
|
||||
shared.flatpak_dir / "com.valvesoftware.Steam" / "data" / "Steam",
|
||||
shared.programfiles32_dir / "Steam",
|
||||
),
|
||||
paths={
|
||||
|
||||
Reference in New Issue
Block a user