From 6801dc9eddcdd08fd6c31824eb7167f08181f660 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 15 Mar 2020 15:19:04 +0100 Subject: [PATCH] Fix setting default image Fix setting the default image (if the selected/current album does not has a cover) for the Cover panel, the Playlist panel and the Library panel by using the default image instead of clearing the image widget. Additionally fix the check for the empty URL String. --- mcg/widgets.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mcg/widgets.py b/mcg/widgets.py index 03278c6..f074abc 100644 --- a/mcg/widgets.py +++ b/mcg/widgets.py @@ -1123,7 +1123,7 @@ class CoverPanel(GObject.GObject): self._cover_spinner.start() if not current_album or not new_album or current_album != new_album: url = new_album.get_cover() if new_album else None - if url and url is not "": + if url: # Load image and draw it self._cover_pixbuf = Utils.load_cover(url) else: @@ -1477,13 +1477,13 @@ class PlaylistPanel(GObject.GObject): self._standalone_stack.set_visible_child(self._standalone_spinner) self._standalone_spinner.start() url = album.get_cover() - if url is not None and url is not "": + if url: # Load image and draw it self._standalone_pixbuf = Utils.load_cover(url) - self._resize_standalone_image() else: # Reset image - self._standalone_image.clear() + self._standalone_pixbuf = self._get_default_image() + self._resize_standalone_image() self._standalone_stack.set_visible_child(self._standalone_scroll) self._standalone_spinner.stop() @@ -1515,6 +1515,14 @@ class PlaylistPanel(GObject.GObject): self._standalone_image.show() + def _get_default_image(self): + return self._icon_theme.load_icon( + Window.STOCK_ICON_DEFAULT, + 512, + Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE + ) + + class LibraryPanel(GObject.GObject): @@ -2009,13 +2017,13 @@ class LibraryPanel(GObject.GObject): self._standalone_stack.set_visible_child(self._standalone_spinner) self._standalone_spinner.start() url = album.get_cover() - if url is not None and url is not "": + if url: # Load image and draw it self._standalone_pixbuf = Utils.load_cover(url) - self._resize_standalone_image() else: # Reset image - self._standalone_image.clear() + self._standalone_pixbuf = self._get_default_image() + self._resize_standalone_image() self._standalone_stack.set_visible_child(self._standalone_scroll) self._standalone_spinner.stop() @@ -2050,7 +2058,7 @@ class LibraryPanel(GObject.GObject): def _get_default_image(self): return self._icon_theme.load_icon( Window.STOCK_ICON_DEFAULT, - 64, + 512, Gtk.IconLookupFlags.FORCE_SVG & Gtk.IconLookupFlags.FORCE_SIZE )