curds: Check if the current playlist has changed from a single spot
This helps reduce code duplication, since we can just call a single function to handle sending the changed() signal. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
b0d124a0e5
commit
2ae7ac1aa1
|
@ -95,14 +95,19 @@ class PlaylistManager(PlaylistManagerBase):
|
|||
self.current = [ self.lookup("Collection") ]
|
||||
self.track = None
|
||||
|
||||
def next(self):
|
||||
self.track = self.current[0].next()
|
||||
while self.track == None and len(self.current) > 1:
|
||||
old = self.current.pop(0)
|
||||
def __current_changed(self, old):
|
||||
if old != self.current[0]:
|
||||
old.changed()
|
||||
self.current[0].changed()
|
||||
|
||||
def next(self):
|
||||
old = self.current[0]
|
||||
self.track = self.current[0].next()
|
||||
while self.track == None and len(self.current) > 1:
|
||||
self.current.pop(0)
|
||||
self.track = self.current[0].next()
|
||||
self.lookup("Previous").add(self.track)
|
||||
self.__current_changed(old)
|
||||
return self.track
|
||||
|
||||
def __peek_pl(self, plist, n):
|
||||
|
@ -159,7 +164,6 @@ class PlaylistManager(PlaylistManagerBase):
|
|||
return
|
||||
elif plist in self.current:
|
||||
self.current.remove(plist)
|
||||
self.current.insert(0, plist)
|
||||
|
||||
old.changed()
|
||||
plist.changed()
|
||||
self.current.insert(0, plist)
|
||||
self.__current_changed(old)
|
||||
|
|
|
@ -264,6 +264,7 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
self.assertEqual(peek[2], glist[ 0])
|
||||
self.assertEqual(peek[3], glist[ 1])
|
||||
|
||||
self.cb_change = [ ]
|
||||
self.assertEqual(self.playman.next(), plist[-2])
|
||||
self.assertEqual(self.playman.next(), plist[-1])
|
||||
self.assertEqual(self.playman.current, [ plist, glist, clist ])
|
||||
|
|
Loading…
Reference in New Issue