[gnome-music/freeze-break: 72/107] view: Update model when current track changes



commit dc98ff1c3bb816cd080f2cf2f0f1b15ae7e97e9d
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Thu Sep 5 00:27:28 2013 +0800

    view: Update model when current track changes

 gnomemusic/view.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index d91df4d..35435bc 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -644,7 +644,10 @@ class Playlist(ViewContainer):
                 add_class("artist-panel-white")
 
         self.monitors = []
+        self.iter_to_clean = None
+        self.iter_to_clean_model = None
         self.player = player
+        self.player.connect('playlist-item-changed', self.update_model)
         self.show_all()
 
     def _add_list_renderers(self):
@@ -751,6 +754,18 @@ class Playlist(ViewContainer):
         self._init = True
         self.populate()
 
+    def update_model(self, player, playlist, currentIter):
+        if self.iter_to_clean:
+            self.iter_to_clean_model.set_value(self.iter_to_clean, 10, False)
+        if playlist != self._model:
+            return False
+
+        self._model.set_value(currentIter, 10, True)
+        if self._model.get_value(currentIter, 8) != self.errorIconName:
+            self.iter_to_clean = currentIter.copy()
+            self.iter_to_clean_model = self._model
+        return False
+
     def _add_item(self, item):
         _iter = self.playlists_model.append()
         self._playlist_list[item] = {"iter": _iter, "albums": []}


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