2009-07-13 23:17:53 -04:00
|
|
|
from list import List
|
|
|
|
|
|
|
|
class Queue(List):
|
2009-08-02 16:04:33 -04:00
|
|
|
def __init__(self,data,funcs):
|
|
|
|
List.__init__(self,data,"Queue",funcs)
|
2009-07-29 18:12:04 -04:00
|
|
|
self.data = data
|
|
|
|
self.count = len(self.data.curQ)
|
|
|
|
self.makeLabel()
|
|
|
|
|
|
|
|
|
2009-07-31 00:14:34 -04:00
|
|
|
# Returns true if we had a song to load, false otherwise
|
2009-07-29 18:12:04 -04:00
|
|
|
def getNext(self):
|
2009-07-31 00:14:34 -04:00
|
|
|
# Populate the queue
|
|
|
|
if self.populated == False:
|
2009-08-02 20:09:04 -04:00
|
|
|
self.populate()
|
2009-07-31 00:14:34 -04:00
|
|
|
# No songs in queue, return false
|
2009-07-29 18:12:04 -04:00
|
|
|
if len(self.list) == 0:
|
|
|
|
return False
|
2009-07-31 00:14:34 -04:00
|
|
|
# Queue ignores random settings and filtering, just takes next song
|
2009-07-29 18:12:04 -04:00
|
|
|
self.data.curSong = self.list[0][0]
|
2009-07-31 00:14:34 -04:00
|
|
|
|
|
|
|
# Remove file from queue and tree
|
|
|
|
for i in range(len(self.data.curQ)):
|
|
|
|
if self.data.curQ[i].id == self.data.curSong:
|
|
|
|
self.data.curQ.pop(i)
|
|
|
|
break
|
2009-07-29 18:12:04 -04:00
|
|
|
self.remove(self.list.get_iter_root())
|
2009-07-31 00:14:34 -04:00
|
|
|
|
2009-08-02 20:09:04 -04:00
|
|
|
# Load song and update the label
|
|
|
|
self.filterQuick(self.string)
|
2009-07-29 18:12:04 -04:00
|
|
|
self.loadSong(self.data.library.files[self.data.curSong])
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2009-07-31 00:14:34 -04:00
|
|
|
# Inselt a song into the queue
|
|
|
|
# Updates the visible treeview and the self.data.curQ array
|
2009-07-29 18:12:04 -04:00
|
|
|
def insert(self,file):
|
2009-07-31 00:14:34 -04:00
|
|
|
if self.populated == False:
|
2009-08-02 20:09:04 -04:00
|
|
|
self.populate()
|
2009-07-29 18:12:04 -04:00
|
|
|
List.insert(self,file)
|
2009-07-29 19:16:21 -04:00
|
|
|
self.data.curQ += [file]
|
2009-07-29 18:12:04 -04:00
|
|
|
|
|
|
|
|
2009-07-31 00:14:34 -04:00
|
|
|
# Shows and hides the treeview, populates if empty
|
2009-07-29 18:12:04 -04:00
|
|
|
def visible(self,func):
|
|
|
|
List.visible(self,func)
|
|
|
|
if (func == "show") and (self.populated == False):
|
2009-08-02 20:09:04 -04:00
|
|
|
self.populate()
|
|
|
|
|
|
|
|
|
|
|
|
# Populate the list
|
|
|
|
def populate(self):
|
|
|
|
for file in self.data.curQ:
|
|
|
|
List.insert(self,file)
|
|
|
|
List.populate(self)
|
2009-07-29 19:16:21 -04:00
|
|
|
|
|
|
|
|
2009-07-31 00:14:34 -04:00
|
|
|
# Filters things quicker because it does not have to show/hide rows
|
|
|
|
# This is only called for offscreen tabs
|
2009-07-29 19:30:06 -04:00
|
|
|
def filterQuick(self,string):
|
|
|
|
List.filterQuick(self,self.data.curQ,string)
|