Added a gobject timeout for filtering. Only filter if no additional text has been typed in the last 250ms

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@53 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-07-31 21:29:11 +00:00
parent 860100f13a
commit e98ebb0bec
3 changed files with 11 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -150,6 +150,7 @@ class List(gtk.ScrolledWindow):
self.count = len(self.filter) self.count = len(self.filter)
for i in range(self.count): for i in range(self.count):
self.seconds+=self.data.library.files[self.filter[i][0]].duration self.seconds+=self.data.library.files[self.filter[i][0]].duration
self.gotoCurSong()
self.makeLabel() self.makeLabel()
self.timeText() self.timeText()

View File

@ -57,6 +57,7 @@ class RightPane(gtk.VBox):
#self.changedTab(None,None,0) #self.changedTab(None,None,0)
self.status = "" self.status = ""
self.filterCount = 0
def setLabels(self): def setLabels(self):
@ -221,15 +222,22 @@ class RightPane(gtk.VBox):
# text was typed, refilter rows # text was typed, refilter rows
# IDEA: refilter in half a second, if no additional text was typed # Arrange to filter rows in 250ms, as long as no additional text has been typed
def textTyped(self,entry): def textTyped(self,entry):
search = entry.get_text().lower() search = entry.get_text().lower()
self.filter(search) self.filterCount+=1
gobject.timeout_add(250,self.filter,search)
# Filter the rows of the current tab # Filter the rows of the current tab
# Do a quickFilter on nonvisible tabs # Do a quickFilter on nonvisible tabs
# Decrements self.filterCount
def filter(self,search): def filter(self,search):
# If filterCount is 0, no additional text has been typed
self.filterCount -= 1
if self.filterCount > 0:
return
# It is ok to filter rows
if self.curTab == 0: if self.curTab == 0:
self.playlist.filterRows(search) self.playlist.filterRows(search)
tabs = [1,2] tabs = [1,2]