diff --git a/src/game.py b/src/game.py index 10999a4..29df76b 100644 --- a/src/game.py +++ b/src/game.py @@ -117,10 +117,6 @@ class game(Gtk.Box): # pylint: disable=invalid-name save_game(self.parent_widget, data) 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 cover_path = ( self.parent_widget.data_dir diff --git a/src/utils/create_details_window.py b/src/utils/create_details_window.py index 64d03cd..eabb348 100644 --- a/src/utils/create_details_window.py +++ b/src/utils/create_details_window.py @@ -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) diff --git a/src/utils/save_cover.py b/src/utils/save_cover.py index f21a77f..2ad5aa8 100644 --- a/src/utils/save_cover.py +++ b/src/utils/save_cover.py @@ -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, ) diff --git a/src/window.py b/src/window.py index 65ba66d..2ce9b57 100644 --- a/src/window.py +++ b/src/window.py @@ -94,7 +94,6 @@ class CartridgesWindow(Adw.ApplicationWindow): self.hidden_filtered = {} self.previous_page = self.library_view self.toasts = {} - self.pixbufs = {} self.active_game_id = None self.loading = None self.scaled_pixbuf = None