Jim,
Thank you for the patch!
I've also considered trying to create a buffer of sorts so you only suffer
'the big pause', once on the initial read. I was thinking of a file in
'/tmp' that is just a directory listing.
Regards,
Greg
-----Original Message-----
From: James ''Wez'' Weatherall [mailto:jnw22_at_cam.ac.uk]
Sent: Saturday, May 26, 2001 1:47 PM
To: familiar_at_handhelds.org
Subject: [Familiar] Lazy Patch for pypaq
Replacing the createSubTree function in pypaq (the MP3 player UI) with the
bits below will change the MP3 playlist browse tree so that it only queries
the MP3 directory tree on-demand.
This makes browsing the tree very slightly slower, because whenever you
expand a tree it has to re-parse the directory structure, but it means that
you don't have the large initial pause before you can start selecting files.
(I've been accessing an 18Gb MP3 archive via WaveLAN and the initial
directory traversal was a pain).
I've also tried to make selecting a directory select the whole subtree but
if you if you try to do that with a closed subtree (i.e. one yet to be
iterated lazily) then creating it on the fly and marking it segfaults
Python.
The code below works for the current interface semantics, though!
Cheers,
James "Wez" Weatherall
--
"The path to enlightenment is /usr/bin/enlightenment"
Laboratory for Communications Engineering, Cambridge - Tel : 766513
AT&T Labs Cambridge, UK - Tel : 343000
---
def createSubTree(item,path):
item_subtree = None
mylist=os.listdir(path)
mylist.sort()
for each in mylist:
if os.path.isdir(path+each):
item_new = GtkTreeItem(each)
item_new.set_data('song','%s%s' % (path,each)) # greps
directories
item.append(item_new)
item_subtree = GtkTree()
item_subtree.connect('select-child',toggle_song_select)
item_new.set_subtree(item_subtree)
# *** FIX ME! There must be a better way to
get_subtree...
item_new.set_data('subtree', item_subtree)
item_new.signal_connect('expand',expand_song_tree)
item_new.signal_connect('collapse',collapse_song_tree)
item_new.show()
else:
item_subtree = GtkTree()
item_new = GtkTreeItem(each)
item_new.set_data('song','%s%s' % (path,each))
item.append(item_new)
item_new.show()
def expand_song_tree(item):
item_subtree = item.get_data('subtree')
createSubTree(item_subtree,item.get_data('song')+'/')
def collapse_song_tree(item):
# *** FIX ME! It should be possible to clear the GtkTree using
# clear_items but that destroys the +/- button...
item.remove_subtree()
item_subtree = GtkTree()
item_subtree.connect('select-child',toggle_song_select)
item.set_subtree(item_subtree)
item.set_data('subtree', item_subtree)
_______________________________________________
Familiar mailing list
Familiar_at_handhelds.org
http://handhelds.org/mailman/listinfo/familiar
Received on Sat May 26 2001 - 10:53:33 EDT
This archive was generated by hypermail 2.2.0 : Mon Jul 25 2005 - 17:12:25 EDT