Fix Flatpak source for .svgs
This commit is contained in:
@@ -17,11 +17,10 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from time import time
|
from time import time
|
||||||
|
import subprocess
|
||||||
from xdg import IconTheme
|
from xdg import IconTheme
|
||||||
|
|
||||||
from src import shared
|
from src import shared
|
||||||
@@ -38,11 +37,26 @@ class FlatpakSourceIterator(SourceIterator):
|
|||||||
|
|
||||||
added_time = int(time())
|
added_time = int(time())
|
||||||
|
|
||||||
IconTheme.icondirs.append("/var/lib/flatpak/exports/share/icons")
|
IconTheme.icondirs.append(self.source.data_location["icons"])
|
||||||
|
|
||||||
|
try:
|
||||||
|
process = subprocess.run(
|
||||||
|
("flatpak-spawn", "--host", "flatpak", "list", "--columns=application"),
|
||||||
|
capture_output=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
flatpak_ids = process.stdout.split("\n")
|
||||||
|
flatpak_ids.remove("hu.kramo.Cartridges")
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return
|
||||||
|
|
||||||
for entry in (self.source.data_location["applications"]).iterdir():
|
for entry in (self.source.data_location["applications"]).iterdir():
|
||||||
flatpak_id = entry.stem
|
flatpak_id = entry.stem
|
||||||
|
|
||||||
|
if flatpak_id not in flatpak_ids:
|
||||||
|
continue
|
||||||
|
|
||||||
with entry.open("r", encoding="utf-8") as open_file:
|
with entry.open("r", encoding="utf-8") as open_file:
|
||||||
string = open_file.read()
|
string = open_file.read()
|
||||||
|
|
||||||
@@ -76,7 +90,7 @@ class FlatpakSourceIterator(SourceIterator):
|
|||||||
if icon_path := IconTheme.getIconPath(icon_name, 512):
|
if icon_path := IconTheme.getIconPath(icon_name, 512):
|
||||||
additional_data = {"local_image_path": Path(icon_path)}
|
additional_data = {"local_image_path": Path(icon_path)}
|
||||||
else:
|
else:
|
||||||
print(":(")
|
pass
|
||||||
|
|
||||||
# Produce game
|
# Produce game
|
||||||
yield (game, additional_data)
|
yield (game, additional_data)
|
||||||
@@ -98,5 +112,6 @@ class FlatpakSource(Source):
|
|||||||
),
|
),
|
||||||
paths={
|
paths={
|
||||||
"applications": (True, "share/applications"),
|
"applications": (True, "share/applications"),
|
||||||
|
"icons": (True, "share/icons"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
from gi.repository import Gio
|
from gi.repository import Gdk, Gio, GLib
|
||||||
from PIL import Image, ImageSequence, UnidentifiedImageError
|
from PIL import Image, ImageSequence, UnidentifiedImageError
|
||||||
|
|
||||||
from src import shared
|
from src import shared
|
||||||
@@ -63,7 +63,13 @@ def resize_cover(cover_path=None, pixbuf=None):
|
|||||||
else "webp",
|
else "webp",
|
||||||
)
|
)
|
||||||
except UnidentifiedImageError:
|
except UnidentifiedImageError:
|
||||||
return None
|
try:
|
||||||
|
Gdk.Texture.new_from_filename(str(cover_path)).save_to_tiff(
|
||||||
|
tmp_path := Gio.File.new_tmp("XXXXXX.tiff")[0].get_path()
|
||||||
|
)
|
||||||
|
return resize_cover(tmp_path)
|
||||||
|
except GLib.GError:
|
||||||
|
return None
|
||||||
|
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user