[gnome-music/wip/jfelder/player-playlist: 5/8] views: Fix now-playing icon display



commit c2970c411f5fe5c5764b811cc4186bf898704d89
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Aug 7 13:40:39 2018 +0200

    views: Fix now-playing icon display
    
    Correctly display the "now-playing" icon for PlaylistView and
    SongsView. Rely on the current_song id and not the url like the other
    views and widgets.
    
    Closes: #203

 gnomemusic/views/playlistview.py | 3 ++-
 gnomemusic/views/songsview.py    | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index b9d0d088..8f350465 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -234,10 +234,11 @@ class PlaylistView(BaseView):
         if not model.iter_is_valid(_iter):
             return
 
+        current_song = self.player.props.current_song
         if model[_iter][11] == ValidationStatus.FAILED:
             cell.set_property('icon-name', self._error_icon_name)
             cell.set_visible(True)
-        elif model[_iter][5].get_url() == self.player.url:
+        elif model[_iter][5].get_id() == current_song.get_id():
             cell.set_property('icon-name', self._now_playing_icon_name)
             cell.set_visible(True)
         else:
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index e33bae55..935e228f 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -150,15 +150,15 @@ class SongsView(BaseView):
             cell.props.text = utils.get_album_title(item)
 
     def _on_list_widget_icon_render(self, col, cell, model, itr, data):
-        track_uri = self.player.url
-        if not track_uri:
+        if not self.player.playing_playlist(PlayerPlaylist.Type.SONGS, None):
             cell.props.visible = False
-            return
+            return False
 
+        current_song = self.player.props.current_song
         if model[itr][11] == ValidationStatus.FAILED:
             cell.props.icon_name = self._error_icon_name
             cell.props.visible = True
-        elif model[itr][5].get_url() == track_uri:
+        elif model[itr][5].get_id() == current_song.get_id():
             cell.props.icon_name = self._now_playing_icon_name
             cell.props.visible = True
         else:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]