diff --git a/src/game.py b/src/game.py index df9b47e..5b0e0c2 100644 --- a/src/game.py +++ b/src/game.py @@ -65,7 +65,7 @@ class Game(Gtk.Box): if self.game_id in self.win.game_covers: self.win.game_covers[self.game_id].add_picture(self.cover) else: - game_cover = GameCover({self.cover}, path=self.get_cover_path()) + game_cover = GameCover({self.cover}, self.get_cover_path()) self.win.game_covers[self.game_id] = game_cover self.event_contoller_motion = Gtk.EventControllerMotion.new() diff --git a/src/game_cover.py b/src/game_cover.py index 2b886cf..c16c5ad 100644 --- a/src/game_cover.py +++ b/src/game_cover.py @@ -30,9 +30,9 @@ class GameCover: "/hu/kramo/Cartridges/library_placeholder.svg", 400, 600, False ) - def __init__(self, pictures, pixbuf=None, path=None): + def __init__(self, pictures, path=None): self.pictures = pictures - self.new_pixbuf(pixbuf, path) + self.new_pixbuf(path) # Wrap the function in another one as Gio.Task.run_in_thread does not allow for passing args def create_func(self, path): @@ -44,17 +44,12 @@ class GameCover: return wrapper - def new_pixbuf(self, pixbuf=None, path=None): + def new_pixbuf(self, path=None): self.animation = None self.pixbuf = None - self.path = None - - if pixbuf: - self.pixbuf = pixbuf + self.path = path if path: - self.path = path - if str(path).rsplit(".", maxsplit=1)[-1] == "gif": task = Gio.Task.new() task.run_in_thread(self.create_func(self.path)) diff --git a/src/utils/create_details_window.py b/src/utils/create_details_window.py index e420a56..57a1ff7 100644 --- a/src/utils/create_details_window.py +++ b/src/utils/create_details_window.py @@ -88,7 +88,7 @@ def create_details_window(win, game_id=None): ) apply_button = Gtk.Button.new_with_label(_("Apply")) - game_cover.new_pixbuf(path=win.games[game_id].get_cover_path()) + game_cover.new_pixbuf(win.games[game_id].get_cover_path()) if game_cover.get_pixbuf(): cover_button_delete_revealer.set_reveal_child(True) else: @@ -230,7 +230,7 @@ def create_details_window(win, game_id=None): cover_button_delete_revealer.set_reveal_child(True) cover_changed = True game_cover.new_pixbuf( - path=resize_animation(path) + resize_animation(path) if str(path).rsplit(".", maxsplit=1)[-1] == "gif" else path ) diff --git a/src/utils/save_cover.py b/src/utils/save_cover.py index 30eaca5..468a5e3 100644 --- a/src/utils/save_cover.py +++ b/src/utils/save_cover.py @@ -57,7 +57,7 @@ def save_cover( if animation_path: copyfile(animation_path, win.covers_dir / f"{game_id}.gif") - win.game_covers[game_id].new_pixbuf(path=animation_path) + win.game_covers[game_id].new_pixbuf(animation_path) return if not pixbuf: @@ -74,4 +74,4 @@ def save_cover( ["8"] if win.schema.get_boolean("high-quality-images") else ["7"], ) - win.game_covers[game_id].new_pixbuf(pixbuf=pixbuf) + win.game_covers[game_id].new_pixbuf(win.covers_dir / f"{game_id}.tiff") diff --git a/src/window.py b/src/window.py index 8662cb2..b147f43 100644 --- a/src/window.py +++ b/src/window.py @@ -279,10 +279,6 @@ class CartridgesWindow(Adw.ApplicationWindow): self.details_view_hide_button.set_icon_name("view-conceal-symbolic") self.details_view_hide_button.set_tooltip_text(_("Hide")) - if self.stack.get_visible_child() != self.details_view: - self.stack.set_transition_type(Gtk.StackTransitionType.OVER_LEFT) - self.stack.set_visible_child(self.details_view) - self.active_game_id = game_id if self.details_view_game_cover: @@ -295,7 +291,6 @@ class CartridgesWindow(Adw.ApplicationWindow): or self.details_view_game_cover.placeholder_pixbuf ).scale_simple(2, 3, GdkPixbuf.InterpType.BILINEAR) self.details_view_blurred_cover.set_pixbuf(self.scaled_pixbuf) - self.set_details_view_opacity() self.details_view_title.set_label(current_game.name) self.details_view_header_bar_title.set_title(current_game.name) @@ -314,6 +309,12 @@ class CartridgesWindow(Adw.ApplicationWindow): _("Last played: {}").format(last_played_date) ) + if self.stack.get_visible_child() != self.details_view: + self.stack.set_transition_type(Gtk.StackTransitionType.OVER_LEFT) + self.stack.set_visible_child(self.details_view) + + self.set_details_view_opacity() + def set_details_view_opacity(self, _widget=None, _unused=None): if self.stack.get_visible_child() == self.details_view: style_manager = Adw.StyleManager.get_default()