Can filter playlist

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@43 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-07-02 23:08:20 +00:00
parent 1c1c99ed81
commit 4dcd210f3e
2 changed files with 23 additions and 15 deletions

View File

@ -42,7 +42,7 @@ class LibView(gtk.VBox):
tree.append(aliter,[self.data.library.files[track].title,self.data.library.files[track].id]) tree.append(aliter,[self.data.library.files[track].title,self.data.library.files[track].id])
tree.set_sort_column_id(0,gtk.SORT_ASCENDING) tree.set_sort_column_id(0,gtk.SORT_ASCENDING)
self.treeview = gtk.TreeView(tree) self.treeview = gtk.TreeView(tree)
self.treeview.set_hover_expand(True) #self.treeview.set_hover_expand(True)
self.treeview.set_enable_search(True) self.treeview.set_enable_search(True)
self.treeview.connect("button_release_event",self.clicked) self.treeview.connect("button_release_event",self.clicked)
self.col = gtk.TreeViewColumn('Library ('+str(self.data.library.count)+')') self.col = gtk.TreeViewColumn('Library ('+str(self.data.library.count)+')')

View File

@ -3,6 +3,7 @@ import gobject
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import thread
from menuItem import MenuItem from menuItem import MenuItem
from song import Song from song import Song
@ -75,15 +76,20 @@ class PlistView(gtk.Notebook):
self.pwin.remove(self.ptree) self.pwin.remove(self.ptree)
self.ptree,self.ptreesel = self.list2Tree(self.plist) self.ptree,self.ptreesel = self.list2Tree(self.plist)
self.pwin.add(self.ptree) self.pwin.add(self.ptree)
self.prcmenu = gtk.Menu() self.prcmenu = gtk.Menu()
queue = MenuItem("Queue Song",self.enqueue,None,None,None,) queue = MenuItem("Queue Song",self.enqueue,None,None,None,)
self.prcmenu.append(queue) self.prcmenu.append(queue)
self.plist.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING) self.plist.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING)
self.ptree.connect("button_release_event",self.clicked) self.ptree.connect("button_release_event",self.clicked)
self.ptime = self.popList(self.data.curList,self.plist) self.ptime = self.popList(self.data.curList,self.plist)
self.pfilter = self.plist.filter_new() self.pfilter = self.plist.filter_new()
self.pfilter.set_visible_func(self.hideRows) self.pfilter.set_visible_func(self.hideRows)
self.ptree.set_model(self.pfilter) self.psort = gtk.TreeModelSort(self.pfilter)
self.ptree.set_model(self.psort)
#self.pfilter.set_child(self.ptreesel)
# Populate a list # Populate a list
@ -129,7 +135,7 @@ class PlistView(gtk.Notebook):
col = gtk.TreeViewColumn(cols[i],cell) col = gtk.TreeViewColumn(cols[i],cell)
col.add_attribute(cell,'text',i) col.add_attribute(cell,'text',i)
col.set_resizable(True) col.set_resizable(True)
col.set_sort_column_id(i) #col.set_sort_column_id(i)
col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
col.set_min_width(2) col.set_min_width(2)
col.set_max_width(700) col.set_max_width(700)
@ -211,7 +217,7 @@ class PlistView(gtk.Notebook):
# User selected a song with mouse click # User selected a song with mouse click
def selectSong(self,widgit,iter,path,data,list): def selectSong(self,widgit,iter,path,data,list):
self.data.curSong = self.plist[iter][0] self.data.curSong = self.pfilter[iter][0]
self.loadSong(False) self.loadSong(False)
self.controls.plause(None,None) self.controls.plause(None,None)
@ -219,6 +225,8 @@ class PlistView(gtk.Notebook):
# Go to the next song in the list # Go to the next song in the list
def next(self,widgit,data): def next(self,widgit,data):
self.data.playingQ = False self.data.playingQ = False
#print self.pfilter[0][1]
#print self.pfilter[1][1]
#print float(self.data.song.position)/float(self.data.song.info.duration) #print float(self.data.song.position)/float(self.data.song.info.duration)
if (float(self.data.song.position)/float(self.data.song.info.duration)) >= 0.75: if (float(self.data.song.position)/float(self.data.song.info.duration)) >= 0.75:
for row in self.plist: for row in self.plist:
@ -237,16 +245,16 @@ class PlistView(gtk.Notebook):
self.data.playingQ = True self.data.playingQ = True
self.setTabText("queue") self.setTabText("queue")
elif self.data.random == True: elif self.data.random == True:
self.data.curSong = self.data.curList[random.randint(0,len(self.data.curList))] self.data.curSong = self.pfilter[random.randint(0,len(self.pfilter))][0]
else: else:
next = self.plist[0][0] next = self.pfilter[0][0]
for i in range(len(self.plist)-1): for i in range(len(self.pfilter)-1):
if self.plist[i][0]==self.data.curSong: if self.pfilter[i][0]==self.data.curSong:
next = self.plist[i+1][0] next = self.pfilter[i+1][0]
break break
self.data.curSong = next self.data.curSong = next
if self.data.curSong >= len(self.data.curList): #if self.data.curSong >= len(self.data.curList):
self.data.curSong = 0 # self.data.curSong = 0
self.loadSong(True) self.loadSong(True)
pause = (self.status == PAFTER) pause = (self.status == PAFTER)
@ -270,15 +278,15 @@ class PlistView(gtk.Notebook):
# Scroll window and select row with current song # Scroll window and select row with current song
def gotoCurSong(self): def gotoCurSong(self):
if len(self.data.curList) == 0: if len(self.pfilter) == 0:
return return
for i in range(len(self.data.curList)): for i in range(len(self.pfilter)):
if self.plist[i][0] == self.data.song.info.id: if self.pfilter[i][0] == self.data.song.info.id:
if i > 10: if i > 10:
self.ptree.scroll_to_cell(i-10,None,True,0,0) self.ptree.scroll_to_cell(i-10,None,True,0,0)
else: else:
self.ptree.scroll_to_cell(0,None,True,0,0) self.ptree.scroll_to_cell(0,None,True,0,0)
self.ptreesel.select_path(i) self.ptree.set_cursor_on_cell(i,None,None,False)
# A callback to show the right click menu # A callback to show the right click menu