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.set_sort_column_id(0,gtk.SORT_ASCENDING)
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.connect("button_release_event",self.clicked)
self.col = gtk.TreeViewColumn('Library ('+str(self.data.library.count)+')')

View File

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