curds: Move the UpNext playlist into special.py
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
e4709a80e2
commit
9fdf837046
|
@ -5,7 +5,6 @@ from . import genre
|
|||
from . import library
|
||||
from . import prev
|
||||
from . import special
|
||||
from . import up_next
|
||||
from . import user
|
||||
from .. import sort
|
||||
from .. import tree
|
||||
|
@ -17,7 +16,7 @@ class PlaylistRoot(tree.ETree):
|
|||
|
||||
with self.tree_lock:
|
||||
self.__insert__(0, special.CollectionPlaylist())
|
||||
self.__insert__(1, up_next.UpNextPlaylist())
|
||||
self.__insert__(1, special.UpNextPlaylist())
|
||||
self.__insert__(2, prev.PreviousPlaylist())
|
||||
self.__insert__(3, user.UserNode())
|
||||
self.__insert__(4, artist.ArtistNode())
|
||||
|
|
|
@ -5,6 +5,10 @@ from .. import notify
|
|||
COLL_ICON = "media-playback-start"
|
||||
COLL_SORT = [ "artist", "date", "album", "discnumber", "tracknumber" ]
|
||||
|
||||
NEXT_ICON = "edit-redo"
|
||||
NEXT_SORT = [ ]
|
||||
|
||||
|
||||
class CollectionPlaylist(playlist.Playlist):
|
||||
def __init__(self):
|
||||
playlist.Playlist.__init__(self, "Collection", COLL_ICON, COLL_SORT, can_loop=False)
|
||||
|
@ -16,3 +20,19 @@ class CollectionPlaylist(playlist.Playlist):
|
|||
def reset(self):
|
||||
playlist.Playlist.reset(self)
|
||||
self.loop = True
|
||||
|
||||
|
||||
class UpNextPlaylist(playlist.Playlist):
|
||||
def __init__(self):
|
||||
playlist.Playlist.__init__(self, "Up Next", NEXT_ICON, NEXT_SORT, can_loop=False)
|
||||
|
||||
def next(self):
|
||||
track = playlist.Playlist.next(self)
|
||||
self.remove(track)
|
||||
if len(self) == 0:
|
||||
self.reset()
|
||||
return track
|
||||
|
||||
def track_removed(self, track, index):
|
||||
notify.notify("remove-track", self, track, index)
|
||||
self.changed()
|
||||
|
|
|
@ -7,7 +7,6 @@ from . import playlist
|
|||
from . import prev
|
||||
from . import root
|
||||
from . import special
|
||||
from . import up_next
|
||||
from . import user
|
||||
from .. import notify
|
||||
from .. import threadqueue
|
||||
|
@ -55,7 +54,7 @@ class TestPlaylistRoot(unittest.TestCase):
|
|||
self.assertIsInstance(self.playman, tree.ETree)
|
||||
|
||||
self.assertIsInstance(self.playman.lookup("Collection"), special.CollectionPlaylist)
|
||||
self.assertIsInstance(self.playman.lookup("Up Next"), up_next.UpNextPlaylist)
|
||||
self.assertIsInstance(self.playman.lookup("Up Next"), special.UpNextPlaylist)
|
||||
self.assertIsInstance(self.playman.lookup("Previous"), prev.PreviousPlaylist)
|
||||
self.assertIsInstance(self.playman.lookup("Playlists"), user.UserNode)
|
||||
self.assertIsInstance(self.playman.lookup("Artists"), artist.ArtistNode)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
from .. import notify
|
||||
from .. import trak
|
||||
from . import up_next
|
||||
from . import special
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
@ -31,7 +31,7 @@ class TestUpNextPlaylist(unittest.TestCase):
|
|||
return tracks
|
||||
|
||||
def test_up_next_playlist(self):
|
||||
plist = up_next.UpNextPlaylist()
|
||||
plist = special.UpNextPlaylist()
|
||||
self.assertEqual(plist.name, "Up Next")
|
||||
self.assertEqual(plist.icon, "edit-redo")
|
||||
self.assertEqual(plist.sort_order, [ ])
|
||||
|
@ -39,7 +39,7 @@ class TestUpNextPlaylist(unittest.TestCase):
|
|||
self.assertTrue( plist.can_random)
|
||||
|
||||
def test_up_next_next(self):
|
||||
plist = up_next.UpNextPlaylist()
|
||||
plist = special.UpNextPlaylist()
|
||||
tracks = self.add_tracks(plist)
|
||||
self.assertEqual(len(plist), 3)
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
from .. import notify
|
||||
from . import playlist
|
||||
|
||||
class UpNextPlaylist(playlist.Playlist):
|
||||
def __init__(self):
|
||||
playlist.Playlist.__init__(self, "Up Next", "edit-redo", [ ], can_loop=False)
|
||||
|
||||
def next(self):
|
||||
track = playlist.Playlist.next(self)
|
||||
self.remove(track)
|
||||
if len(self) == 0:
|
||||
self.reset()
|
||||
return track
|
||||
|
||||
def track_removed(self, track, index):
|
||||
notify.notify("remove-track", self, track, index)
|
||||
self.changed()
|
Loading…
Reference in New Issue