curds: Library node cleanups
- Use constants for the sort fields list - Have alloc_child() set the icon directly, rather than using the one passed in by lookup() Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
09ee71e616
commit
1291adb48b
|
@ -6,7 +6,8 @@ from .. import trak
|
|||
from .. import tree
|
||||
import os
|
||||
|
||||
LIBRARY_ICON = "folder-music"
|
||||
LIBRARY_ICON = "folder-music"
|
||||
LIBRARY_SORT = [ "artist", "date", "album", "discnumber", "tracknumber" ]
|
||||
library_thread = threadqueue.ThreadQueue()
|
||||
|
||||
class LibraryPlaylist(playlist.Playlist):
|
||||
|
@ -16,26 +17,22 @@ class LibraryPlaylist(playlist.Playlist):
|
|||
def thread_add(self, path):
|
||||
self.add(trak.lookup(path))
|
||||
|
||||
def thread_save(self):
|
||||
notify.notify("save-data")
|
||||
|
||||
def thread_scan(self):
|
||||
for dirname, subdirs, files in os.walk(self.name):
|
||||
for f in files:
|
||||
library_thread.push(self.thread_add, os.path.join(dirname, f))
|
||||
library_thread.push(self.thread_save)
|
||||
library_thread.push(notify.notify, "save-data")
|
||||
|
||||
|
||||
class LibraryNode(tree.ETree):
|
||||
def __init__(self):
|
||||
tree.ETree.__init__(self, "Libraries", "folder-music")
|
||||
tree.ETree.__init__(self, "Libraries", LIBRARY_ICON)
|
||||
|
||||
def alloc_child(self, path, icon):
|
||||
return LibraryPlaylist(path, icon,
|
||||
[ "artist", "date", "album", "discnumber", "tracknumber" ])
|
||||
return LibraryPlaylist(path, LIBRARY_ICON, LIBRARY_SORT)
|
||||
|
||||
def lookup(self, path):
|
||||
library = tree.ETree.lookup(self, os.path.abspath(path), LIBRARY_ICON)
|
||||
library = tree.ETree.lookup(self, os.path.abspath(path))
|
||||
library.scan()
|
||||
return library
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from . import library
|
||||
from . import playlist
|
||||
from .. import notify
|
||||
from .. import threadqueue
|
||||
from .. import trak
|
||||
from .. import tree
|
||||
import os
|
||||
|
|
Loading…
Reference in New Issue