curds: Send the playlist-changed notification when changin current
This tells the UI that it needs to update how playlists are displayed. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
8a04d63c52
commit
6255e22cf0
|
@ -98,8 +98,10 @@ class PlaylistManager(PlaylistManagerBase):
|
|||
def next(self):
|
||||
self.track = self.current[0].next()
|
||||
while self.track == None and len(self.current) > 1:
|
||||
self.current = self.current[1:]
|
||||
self.track = self.current[0].next()
|
||||
old = self.current.pop(0)
|
||||
old.changed()
|
||||
self.current[0].changed()
|
||||
self.track = self.current[0].next()
|
||||
self.lookup("Previous").add(self.track)
|
||||
return self.track
|
||||
|
||||
|
@ -149,8 +151,13 @@ class PlaylistManager(PlaylistManagerBase):
|
|||
self.track = None
|
||||
|
||||
def select(self, plist):
|
||||
old = self.current[0]
|
||||
|
||||
if plist == self.lookup("Collection"):
|
||||
self.current = [ ]
|
||||
elif plist in self.current:
|
||||
self.current.remove(plist)
|
||||
self.current.insert(0, plist)
|
||||
|
||||
old.changed()
|
||||
plist.changed()
|
||||
|
|
|
@ -19,20 +19,23 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
def setUp(self):
|
||||
tags.clear()
|
||||
library.reset()
|
||||
notify.register("new-playlist", self.on_new_playlist)
|
||||
notify.register("new-playlist", self.on_new_playlist)
|
||||
notify.register("playlist-changed", self.on_playlist_changed)
|
||||
|
||||
try:
|
||||
self.playman.reset()
|
||||
except:
|
||||
self.playman = manager.PlaylistManager()
|
||||
self.cb_plist = None
|
||||
self.cb_index = None
|
||||
self.cb_first = None
|
||||
self.cb_plist = None
|
||||
self.cb_index = None
|
||||
self.cb_first = None
|
||||
self.cb_change = [ ]
|
||||
|
||||
def tearDown(self):
|
||||
notify.cancel("new-track", self.playman.lookup("Collection").add)
|
||||
notify.cancel("new-track", self.playman.lookup("Genre").add_track)
|
||||
notify.cancel("new-playlist", self.on_new_playlist)
|
||||
notify.register("playlist-changed", self.on_playlist_changed)
|
||||
library.stop()
|
||||
|
||||
def on_new_playlist(self, plist, index, first):
|
||||
|
@ -40,6 +43,9 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
self.cb_index = index
|
||||
self.cb_first = first
|
||||
|
||||
def on_playlist_changed(self, plist):
|
||||
self.cb_change.append(plist)
|
||||
|
||||
def test_manager_init(self):
|
||||
self.assertIsInstance(self.playman, manager.PlaylistManager)
|
||||
self.assertIsInstance(self.playman, manager.PlaylistManagerBase)
|
||||
|
@ -235,12 +241,15 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
|
||||
self.playman.select(plist)
|
||||
self.assertEqual(self.playman.current, [ plist, clist ])
|
||||
self.assertEqual(self.cb_change[-2:], [ clist, plist ])
|
||||
|
||||
self.playman.select(glist)
|
||||
self.assertEqual(self.playman.current, [ glist, plist, clist ])
|
||||
self.assertEqual(self.cb_change[-2:], [ plist, glist ])
|
||||
|
||||
self.playman.select(plist)
|
||||
self.assertEqual(self.playman.current, [ plist, glist, clist ])
|
||||
self.assertEqual(self.cb_change[-2:], [ glist, plist ])
|
||||
|
||||
plist.current = 1247
|
||||
peek = self.playman.peek(4)
|
||||
|
@ -255,6 +264,7 @@ class TestPlaylistManager(unittest.TestCase):
|
|||
self.assertEqual(self.playman.current, [ plist, glist, clist ])
|
||||
self.assertEqual(self.playman.next(), glist[0])
|
||||
self.assertEqual(self.playman.current, [ glist, clist ])
|
||||
self.assertEqual(self.cb_change[-2:], [ plist, glist ])
|
||||
|
||||
self.playman.select(plist)
|
||||
self.assertEqual(self.playman.current, [ plist, glist, clist ])
|
||||
|
|
Loading…
Reference in New Issue