Resolves #85: removed flicker from Albums panel
This commit is contained in:
@@ -530,7 +530,8 @@ class CacheManager(metaclass=Singleton):
|
||||
|
||||
# If it is the placeholder LastFM image, try and use the cover
|
||||
# art filename given by the server.
|
||||
if lastfm_url.endswith('2a96cbd8b46e442fc41c2b86b821562f.png'):
|
||||
if (lastfm_url == '' or lastfm_url.endswith(
|
||||
'2a96cbd8b46e442fc41c2b86b821562f.png')):
|
||||
if isinstance(artist, ArtistWithAlbumsID3):
|
||||
return CacheManager.get_cover_art_filename(
|
||||
artist.coverArt, size=300)
|
||||
|
@@ -458,14 +458,26 @@ class AlbumsListWithSongs(Gtk.Overlay):
|
||||
self.albums = []
|
||||
|
||||
def update(self, artist):
|
||||
# TODO this introduces a flicker. Fix this. Need to do some diffing.
|
||||
for c in self.box.get_children():
|
||||
self.box.remove(c)
|
||||
def remove_all():
|
||||
for c in self.box.get_children():
|
||||
self.box.remove(c)
|
||||
|
||||
if artist is None:
|
||||
remove_all()
|
||||
self.spinner.hide()
|
||||
return
|
||||
|
||||
for album in artist.get('album', artist.get('child', [])):
|
||||
new_albums = artist.get('album', artist.get('child', []))
|
||||
|
||||
if self.albums == new_albums:
|
||||
# No need to do anything.
|
||||
return
|
||||
|
||||
self.albums = new_albums
|
||||
|
||||
remove_all()
|
||||
|
||||
for album in self.albums:
|
||||
album_with_songs = AlbumWithSongs(album, show_artist_name=False)
|
||||
album_with_songs.connect(
|
||||
'song-clicked',
|
||||
|
@@ -141,9 +141,7 @@ class AlbumWithSongs(Gtk.Box):
|
||||
return column
|
||||
|
||||
self.loading_indicator = Gtk.Spinner(
|
||||
name='album-list-song-list-spinner',
|
||||
active=True,
|
||||
)
|
||||
name='album-list-song-list-spinner')
|
||||
album_details.add(self.loading_indicator)
|
||||
|
||||
self.album_songs = Gtk.TreeView(
|
||||
@@ -266,10 +264,18 @@ class AlbumWithSongs(Gtk.Box):
|
||||
def update(self, force=False):
|
||||
self.update_album_songs(self.album.id)
|
||||
|
||||
def set_loading(self, loading):
|
||||
if loading:
|
||||
self.loading_indicator.start()
|
||||
self.loading_indicator.show()
|
||||
else:
|
||||
self.loading_indicator.stop()
|
||||
self.loading_indicator.hide()
|
||||
|
||||
@util.async_callback(
|
||||
lambda *a, **k: CacheManager.get_album(*a, **k),
|
||||
before_download=lambda self: self.loading_indicator.show(),
|
||||
on_failure=lambda self, e: self.loading_indicator.hide(),
|
||||
before_download=lambda self: self.set_loading(True),
|
||||
on_failure=lambda self, e: self.set_loading(False),
|
||||
)
|
||||
def update_album_songs(
|
||||
self,
|
||||
|
Reference in New Issue
Block a user