Fix cover saving issue
This commit is contained in:
@@ -219,14 +219,19 @@ def create_details_window(parent_widget, game_id=None):
|
||||
def set_cover(_source, result, _unused):
|
||||
nonlocal pixbuf
|
||||
try:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filechooser.open_finish(result).get_path(), 200, 300, False
|
||||
)
|
||||
cover_button_delete_revealer.set_reveal_child(True)
|
||||
cover.set_pixbuf(pixbuf)
|
||||
path = filechooser.open_finish(result).get_path()
|
||||
except GLib.GError:
|
||||
return
|
||||
|
||||
try:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, 200, 300, False)
|
||||
except GLib.GError:
|
||||
animated_pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(path)
|
||||
pixbuf = animated_pixbuf.get_static_image()
|
||||
|
||||
cover_button_delete_revealer.set_reveal_child(True)
|
||||
cover.set_pixbuf(pixbuf)
|
||||
|
||||
def close_window(_widget, _callback=None):
|
||||
window.close()
|
||||
|
||||
@@ -310,8 +315,6 @@ def create_details_window(parent_widget, game_id=None):
|
||||
(
|
||||
parent_widget.data_dir / "cartridges" / "covers" / f"{game_id}.tiff"
|
||||
).unlink(missing_ok=True)
|
||||
if game_id in parent_widget.pixbufs:
|
||||
parent_widget.pixbufs.pop(game_id)
|
||||
|
||||
if pixbuf:
|
||||
save_cover(parent_widget, game_id, None, pixbuf)
|
||||
|
||||
@@ -31,14 +31,10 @@ def save_cover(parent_widget, game_id, cover_path=None, pixbuf=None):
|
||||
str(cover_path), 400, 600, False
|
||||
)
|
||||
|
||||
def cover_callback(*_unused):
|
||||
pass
|
||||
|
||||
open_file = Gio.File.new_for_path(str(covers_dir / f"{game_id}.tiff"))
|
||||
pixbuf.save_to_streamv_async(
|
||||
pixbuf.save_to_streamv(
|
||||
open_file.replace(None, False, Gio.FileCreateFlags.NONE),
|
||||
"tiff",
|
||||
["compression"],
|
||||
["8"] if parent_widget.schema.get_boolean("high-quality-images") else ["7"],
|
||||
callback=cover_callback,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user