Fix cover saving issue
This commit is contained in:
@@ -117,10 +117,6 @@ class game(Gtk.Box): # pylint: disable=invalid-name
|
|||||||
save_game(self.parent_widget, data)
|
save_game(self.parent_widget, data)
|
||||||
|
|
||||||
def get_cover(self):
|
def get_cover(self):
|
||||||
# If the cover is already in memory, return
|
|
||||||
if self.game_id in self.parent_widget.pixbufs:
|
|
||||||
return self.parent_widget.pixbufs[self.game_id]
|
|
||||||
|
|
||||||
# Create a new pixbuf
|
# Create a new pixbuf
|
||||||
cover_path = (
|
cover_path = (
|
||||||
self.parent_widget.data_dir
|
self.parent_widget.data_dir
|
||||||
|
|||||||
@@ -219,14 +219,19 @@ def create_details_window(parent_widget, game_id=None):
|
|||||||
def set_cover(_source, result, _unused):
|
def set_cover(_source, result, _unused):
|
||||||
nonlocal pixbuf
|
nonlocal pixbuf
|
||||||
try:
|
try:
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
path = filechooser.open_finish(result).get_path()
|
||||||
filechooser.open_finish(result).get_path(), 200, 300, False
|
|
||||||
)
|
|
||||||
cover_button_delete_revealer.set_reveal_child(True)
|
|
||||||
cover.set_pixbuf(pixbuf)
|
|
||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
return
|
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):
|
def close_window(_widget, _callback=None):
|
||||||
window.close()
|
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"
|
parent_widget.data_dir / "cartridges" / "covers" / f"{game_id}.tiff"
|
||||||
).unlink(missing_ok=True)
|
).unlink(missing_ok=True)
|
||||||
if game_id in parent_widget.pixbufs:
|
|
||||||
parent_widget.pixbufs.pop(game_id)
|
|
||||||
|
|
||||||
if pixbuf:
|
if pixbuf:
|
||||||
save_cover(parent_widget, game_id, None, 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
|
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"))
|
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),
|
open_file.replace(None, False, Gio.FileCreateFlags.NONE),
|
||||||
"tiff",
|
"tiff",
|
||||||
["compression"],
|
["compression"],
|
||||||
["8"] if parent_widget.schema.get_boolean("high-quality-images") else ["7"],
|
["8"] if parent_widget.schema.get_boolean("high-quality-images") else ["7"],
|
||||||
callback=cover_callback,
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
self.hidden_filtered = {}
|
self.hidden_filtered = {}
|
||||||
self.previous_page = self.library_view
|
self.previous_page = self.library_view
|
||||||
self.toasts = {}
|
self.toasts = {}
|
||||||
self.pixbufs = {}
|
|
||||||
self.active_game_id = None
|
self.active_game_id = None
|
||||||
self.loading = None
|
self.loading = None
|
||||||
self.scaled_pixbuf = None
|
self.scaled_pixbuf = None
|
||||||
|
|||||||
Reference in New Issue
Block a user