[gnome-music/freeze-break: 26/107] player: Select first track if current track was hidden/removed



commit fe911e00cadd4442857eadbaad1ae154dfb3de6a
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Wed Sep 4 19:32:01 2013 +0800

    player: Select first track if current track was hidden/removed
    
    This would handle next and previous track when the track changes while
    searching if there is no match.

 gnomemusic/player.py |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 917f024..4a68c27 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -200,13 +200,18 @@ class Player(GObject.GObject):
         nextTrack = None
 
         if self.repeat == RepeatType.SONG:
-            nextTrack = currentTrack
+            if currentTrack:
+                nextTrack = currentTrack
+            else:
+                nextTrack = self.playlist.get_iter_first()
         elif self.repeat == RepeatType.ALL:
-            nextTrack = self.playlist.iter_next(currentTrack)
-            if nextTrack is None:
+            if currentTrack:
+                nextTrack = self.playlist.iter_next(currentTrack)
+            if not nextTrack:
                 nextTrack = self.playlist.get_iter_first()
         elif self.repeat == RepeatType.NONE:
-            nextTrack = self.playlist.iter_next(currentTrack)
+            if currentTrack:
+                nextTrack = self.playlist.iter_next(currentTrack)
         elif self.repeat == RepeatType.SHUFFLE:
             nextTrack = self.playlist.get_iter_first()
             rows = self.playlist.iter_n_children(None)
@@ -237,13 +242,18 @@ class Player(GObject.GObject):
         previousTrack = None
 
         if self.repeat == RepeatType.SONG:
-            previousTrack = currentTrack
+            if currentTrack:
+                previousTrack = currentTrack
+            else:
+                previousTrack = self.playlist.get_iter_first()
         elif self.repeat == RepeatType.ALL:
-            previousTrack = self.playlist.iter_previous(currentTrack)
-            if previousTrack is None:
+            if currentTrack:
+                previousTrack = self.playlist.iter_previous(currentTrack)
+            if not previousTrack:
                 previousTrack = self._get_iter_last()
         elif self.repeat == RepeatType.NONE:
-            previousTrack = self.playlist.iter_previous(currentTrack)
+            if currentTrack:
+                previousTrack = self.playlist.iter_previous(currentTrack)
         elif self.repeat == RepeatType.SHUFFLE:
             previousTrack = self.playlist.get_iter_first()
             rows = self.playlist.iter_n_children(None)


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