Beginnings of filtering
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@42 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
22c61164c1
commit
1c1c99ed81
|
@ -15,6 +15,7 @@ class LibView(gtk.VBox):
|
||||||
self.data = data
|
self.data = data
|
||||||
self.treeview = None
|
self.treeview = None
|
||||||
self.col = None
|
self.col = None
|
||||||
|
self.plist = None
|
||||||
self.pbar = gtk.ProgressBar()
|
self.pbar = gtk.ProgressBar()
|
||||||
self.pack_start(self.win)
|
self.pack_start(self.win)
|
||||||
self.pack_start(self.pbar,False,False,0)
|
self.pack_start(self.pbar,False,False,0)
|
||||||
|
@ -41,6 +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_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)+')')
|
||||||
|
@ -91,19 +93,23 @@ class LibView(gtk.VBox):
|
||||||
|
|
||||||
def populatePlaylist(self,widgit,func,data):
|
def populatePlaylist(self,widgit,func,data):
|
||||||
(model,pathlist) = self.selection.get_selected_rows()
|
(model,pathlist) = self.selection.get_selected_rows()
|
||||||
self.data.curList = []
|
list = []
|
||||||
|
#self.data.curList = []
|
||||||
for path in pathlist:
|
for path in pathlist:
|
||||||
iter = model.get_iter(path)
|
iter = model.get_iter(path)
|
||||||
self.popHelper(model,iter,model.iter_n_children(iter))
|
self.popHelper(model,iter,model.iter_n_children(iter),list)
|
||||||
self.data.updateList = True
|
#self.data.updateList = True
|
||||||
|
self.plist.addToList(list,self.plist.plist)
|
||||||
|
|
||||||
|
|
||||||
def popHelper(self,model,iter,count):
|
def popHelper(self,model,iter,count,list):
|
||||||
if count == 0:
|
if count == 0:
|
||||||
self.data.curList+=[model[iter][1]]
|
row = model[iter][1]
|
||||||
|
self.data.curList+=[row]
|
||||||
|
list += [row]
|
||||||
return
|
return
|
||||||
|
|
||||||
child = model.iter_children(iter)
|
child = model.iter_children(iter)
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
self.popHelper(model,child,model.iter_n_children(child))
|
self.popHelper(model,child,model.iter_n_children(child),list)
|
||||||
child = model.iter_next(child)
|
child = model.iter_next(child)
|
||||||
|
|
|
@ -23,6 +23,7 @@ class PlistView(gtk.Notebook):
|
||||||
|
|
||||||
self.ptime = 0
|
self.ptime = 0
|
||||||
self.qtime = 0
|
self.qtime = 0
|
||||||
|
self.search = ""
|
||||||
|
|
||||||
self.label = gtk.Label("")
|
self.label = gtk.Label("")
|
||||||
self.label.show()
|
self.label.show()
|
||||||
|
@ -35,9 +36,10 @@ class PlistView(gtk.Notebook):
|
||||||
self.qtree = None
|
self.qtree = None
|
||||||
self.makePList()
|
self.makePList()
|
||||||
self.makeQList()
|
self.makeQList()
|
||||||
|
self.makeSearch()
|
||||||
self.qwin.show()
|
self.qwin.show()
|
||||||
self.loadSong(True)
|
self.loadSong(True)
|
||||||
gobject.timeout_add(1000,self.checkUpdate)
|
#gobject.timeout_add(1000,self.checkUpdate)
|
||||||
self.append_page(self.pwin,gtk.Label(""))
|
self.append_page(self.pwin,gtk.Label(""))
|
||||||
self.append_page(self.qwin,gtk.Label(""))
|
self.append_page(self.qwin,gtk.Label(""))
|
||||||
self.setTabText("plist")
|
self.setTabText("plist")
|
||||||
|
@ -79,6 +81,9 @@ class PlistView(gtk.Notebook):
|
||||||
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.set_visible_func(self.hideRows)
|
||||||
|
self.ptree.set_model(self.pfilter)
|
||||||
|
|
||||||
|
|
||||||
# Populate a list
|
# Populate a list
|
||||||
|
@ -107,6 +112,13 @@ class PlistView(gtk.Notebook):
|
||||||
return time
|
return time
|
||||||
|
|
||||||
|
|
||||||
|
# Called by libview to add rows to list
|
||||||
|
def addToList(self,src,dest):
|
||||||
|
self.ptime+=self.generateList(src,dest)
|
||||||
|
self.updatePTime()
|
||||||
|
self.setTabText("plist")
|
||||||
|
|
||||||
|
|
||||||
# Make the playlist and show it
|
# Make the playlist and show it
|
||||||
def list2Tree(self,list):
|
def list2Tree(self,list):
|
||||||
tree = gtk.TreeView(list)
|
tree = gtk.TreeView(list)
|
||||||
|
@ -149,7 +161,7 @@ class PlistView(gtk.Notebook):
|
||||||
|
|
||||||
|
|
||||||
# Erase the entire list
|
# Erase the entire list
|
||||||
def clearList(self,list):
|
def clearList(self,list,time):
|
||||||
max = len(list)
|
max = len(list)
|
||||||
if max == 0:
|
if max == 0:
|
||||||
return
|
return
|
||||||
|
@ -157,6 +169,16 @@ class PlistView(gtk.Notebook):
|
||||||
iter = list.get_iter(0)
|
iter = list.get_iter(0)
|
||||||
for i in range(0,max):
|
for i in range(0,max):
|
||||||
list.remove(iter)
|
list.remove(iter)
|
||||||
|
self.ptime = 0
|
||||||
|
self.setTabText("plist")
|
||||||
|
self.updatePTime()
|
||||||
|
|
||||||
|
|
||||||
|
# Update the playlist time label
|
||||||
|
def updatePTime(self):
|
||||||
|
page = self.get_current_page()
|
||||||
|
if page==0:
|
||||||
|
self.label.set_text(self.makeTimeLabel(self.ptime))
|
||||||
|
|
||||||
|
|
||||||
# Shows total running time of the playlist
|
# Shows total running time of the playlist
|
||||||
|
@ -215,7 +237,7 @@ 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 = random.randint(0,len(self.data.curList))
|
self.data.curSong = self.data.curList[random.randint(0,len(self.data.curList))]
|
||||||
else:
|
else:
|
||||||
next = self.plist[0][0]
|
next = self.plist[0][0]
|
||||||
for i in range(len(self.plist)-1):
|
for i in range(len(self.plist)-1):
|
||||||
|
@ -282,3 +304,29 @@ class PlistView(gtk.Notebook):
|
||||||
self.label.set_text(self.makeTimeLabel(self.ptime))
|
self.label.set_text(self.makeTimeLabel(self.ptime))
|
||||||
else:
|
else:
|
||||||
self.label.set_text(self.makeTimeLabel(self.qtime))
|
self.label.set_text(self.makeTimeLabel(self.qtime))
|
||||||
|
|
||||||
|
|
||||||
|
def makeSearch(self):
|
||||||
|
self.searchBar = gtk.Entry()
|
||||||
|
self.searchBar.connect("changed",self.textTyped)
|
||||||
|
self.searchBar.show()
|
||||||
|
|
||||||
|
|
||||||
|
def textTyped(self,entry):
|
||||||
|
self.search = entry.get_text().lower()
|
||||||
|
self.pfilter.refilter()
|
||||||
|
|
||||||
|
|
||||||
|
def hideRows(self,list,iter):
|
||||||
|
if self.search != "":
|
||||||
|
title = list[iter][1].lower()
|
||||||
|
if title.find(self.search) > -1:
|
||||||
|
return True
|
||||||
|
artist = list[iter][3].lower()
|
||||||
|
if artist.find(self.search) > -1:
|
||||||
|
return True
|
||||||
|
album = list[iter][4].lower()
|
||||||
|
if album.find(self.search) > -1:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
|
@ -67,7 +67,8 @@ class Window(gtk.Window):
|
||||||
|
|
||||||
def clearPlist(self,widgit,data,other=None):
|
def clearPlist(self,widgit,data,other=None):
|
||||||
self.data.curList = []
|
self.data.curList = []
|
||||||
self.data.updateList = True
|
#self.data.updateList = True
|
||||||
|
self.plistview.clearList(self.plistview.plist,self.plistview.ptime)
|
||||||
|
|
||||||
|
|
||||||
def setPlayStatus(self,widgit,status,other):
|
def setPlayStatus(self,widgit,status,other):
|
||||||
|
@ -113,16 +114,22 @@ class Window(gtk.Window):
|
||||||
leftPane.append_page(scrobbler,scrobLabel)
|
leftPane.append_page(scrobbler,scrobLabel)
|
||||||
|
|
||||||
self.divider.add1(leftPane)
|
self.divider.add1(leftPane)
|
||||||
|
|
||||||
rightPane=gtk.VBox(False,0)
|
rightPane=gtk.VBox(False,0)
|
||||||
|
topRight = gtk.HBox(False,0)
|
||||||
|
topRight.show()
|
||||||
|
|
||||||
infoview = InfoView(self.data)
|
infoview = InfoView(self.data)
|
||||||
rightPane.pack_start(infoview,False,False,0)
|
topRight.pack_start(infoview,False,False,0)
|
||||||
|
rightPane.pack_start(topRight,False,False,0)
|
||||||
self.plistview = PlistView(self.data)
|
self.plistview = PlistView(self.data)
|
||||||
|
topRight.pack_end(self.plistview.searchBar,False,False,0)
|
||||||
rightPane.add(self.plistview)
|
rightPane.add(self.plistview)
|
||||||
self.makeBottomRow(rightPane)
|
self.makeBottomRow(rightPane)
|
||||||
rightPane.show()
|
rightPane.show()
|
||||||
|
|
||||||
|
self.libview.plist = self.plistview
|
||||||
|
|
||||||
self.divider.add2(rightPane)
|
self.divider.add2(rightPane)
|
||||||
|
|
||||||
self.contentPane.show()
|
self.contentPane.show()
|
||||||
|
|
Loading…
Reference in New Issue