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.
This commit is contained in:
coderkun 2020-03-15 15:19:04 +01:00
parent c8e24dc8c1
commit 6801dc9edd

View file

@ -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
)