Load in background

The library and playlist can be loaded in the background to save time!
Also, I changed the library list to use the new populate function.!
This commit is contained in:
Bryan Schumaker 2010-11-08 22:47:31 -05:00
parent 511fb83b0e
commit 5cf8e8e639
3 changed files with 8 additions and 18 deletions

View File

@ -39,17 +39,16 @@ def load():
reset()
return
(fs_tree, tag_tree, index, tracks, next_id, size) = objects
load()
libsaria.event.start("POSTLIBLOAD")
def save():
libsaria.data.save(
(fs_tree, tag_tree, index, tracks, next_id, size),
"library", ".dl_tree")
def walk_tags():
def walk():
for tag in tag_tree.walk_forwards():
rec = tracks[tag[3]]
yield tag + [rec.year] + [rec.lenstr]
yield tag[3]
def file_to_id(file):
global fs_tree

View File

@ -30,7 +30,6 @@ def load():
reset()
return
song_set = set(song_list)
load()
def save():
libsaria.data.save(song_list, "playlist", ".list")

View File

@ -34,16 +34,6 @@ class Collection(gtk.ScrolledWindow):
self.list.clear()
def populate(self, func):
self.list.freeze()
insert = self.list.list.insert
ins_next = 0
for track in func():
insert(ins_next, [track[3], track[2],
track[5], track[0], track[1], track[4]])
ins_next += 1
self.list.thaw()
def populate2(self, func):
self.list.freeze()
insert = self.list.list.insert
get_attrs = library.get_attrs
@ -75,7 +65,8 @@ class Library(Collection):
def populate(self):
#import datetime
#before = datetime.datetime.now()
Collection.populate(self, library.walk_tags)
library.load()
Collection.populate(self, library.walk)
#after = datetime.datetime.now()
#print "Populating took: %s" % (after - before)
@ -108,7 +99,7 @@ class Playlist(Collection):
actions.show_rc_menu = menu.make_plist_menu
Collection.__init__(self, actions)
libsaria.event.invite("POSTSTART", self.populate, bg=True)
libsaria.event.invite("POSTLIBLOAD", self.populate, bg=True)
libsaria.event.invite("PREPLISTREFRESH", self.refresh)
def refresh(self, arg=None):
@ -124,7 +115,8 @@ class Playlist(Collection):
#import datetime
#before = datetime.datetime.now()
#Collection.populate(self, collection.walk_plist)
Collection.populate2(self, playlist.walk)
playlist.load()
Collection.populate(self, playlist.walk)
#after = datetime.datetime.now()
#print "Populating took: %s" % (after - before)