From 072f5e38a9b365cd6a17d54fb1466ff5fba193fc Mon Sep 17 00:00:00 2001 From: bjschuma Date: Sat, 15 Aug 2009 02:20:20 +0000 Subject: [PATCH] New filtering system, recognizing a ',' as an or git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@61 1daee41c-8060-4895-b1f0-2197c00d777a --- trunk/Makefile | 3 +++ trunk/bugs | 5 +++++ trunk/dependencies | 4 ++++ trunk/src/contentPane.py | 5 ++++- trunk/src/cythonize | 8 ++++++++ trunk/src/library.py | 2 +- trunk/src/list.py | 29 ++++++++++++++++++++++------- 7 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 trunk/bugs create mode 100644 trunk/dependencies create mode 100755 trunk/src/cythonize diff --git a/trunk/Makefile b/trunk/Makefile index 9d31479e..e42c603c 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -17,6 +17,9 @@ compile: count: cat src/*.py | grep -v '[[:space:]]*\#' | cat -b +tar: + cd ../../ && tar -czf ocarina.tar.gz ocarina/ + install: # mkdir ~/bin/ocarina-bin rsync -avz src/ ~/bin/ocarina-bin/src diff --git a/trunk/bugs b/trunk/bugs new file mode 100644 index 00000000..31239240 --- /dev/null +++ b/trunk/bugs @@ -0,0 +1,5 @@ +- Cannot scan library twice in same session +- One song doesn't get added to list when scanning (probably last song) +- What happens when songs are selected to be added to library? +- Error updating liblist while scanning if library tab is visible +- diff --git a/trunk/dependencies b/trunk/dependencies new file mode 100644 index 00000000..cd9eb0a9 --- /dev/null +++ b/trunk/dependencies @@ -0,0 +1,4 @@ +- tagpy +- gstreamer-plugins-* +- pygst + diff --git a/trunk/src/contentPane.py b/trunk/src/contentPane.py index 53f448b9..6dc2d62c 100644 --- a/trunk/src/contentPane.py +++ b/trunk/src/contentPane.py @@ -31,7 +31,10 @@ class ContentPane(gtk.HBox): self.show() # Load up the last saved song - self.library.loadSong(self.data.library.files[self.data.curSong]) + try: + self.library.loadSong(self.data.library.files[self.data.curSong]) + except: + True == True self.gotoCurSong() diff --git a/trunk/src/cythonize b/trunk/src/cythonize new file mode 100755 index 00000000..7004dcb9 --- /dev/null +++ b/trunk/src/cythonize @@ -0,0 +1,8 @@ +#!/bin/bash +for file in `ls *.py | cut -d '.' -f 1` +do + echo $file + cython $file.py + gcc -c -fPIC -O3 -I/usr/include/python2.6 $file.c + gcc -shared $file.o -o $file.so +done diff --git a/trunk/src/library.py b/trunk/src/library.py index 0bd893a9..53fba407 100644 --- a/trunk/src/library.py +++ b/trunk/src/library.py @@ -3,7 +3,7 @@ import re import tagpy #import cPickle as pickle from songInfo import SongInfo -import thread +#import thread class Library: diff --git a/trunk/src/list.py b/trunk/src/list.py index 531f980f..416fc434 100644 --- a/trunk/src/list.py +++ b/trunk/src/list.py @@ -38,6 +38,7 @@ class List(gtk.ScrolledWindow): self.timeText() self.string = "" + self.search = [] self.filter = self.list.filter_new() self.filter.set_visible_func(self.hideRows,"") self.sort = gtk.TreeModelSort(self.filter) @@ -152,6 +153,7 @@ class List(gtk.ScrolledWindow): def filterRows(self,string): self.string = string + self.formatSearch(self.string) self.seconds = 0 self.count = 0 self.filter.refilter() @@ -167,6 +169,7 @@ class List(gtk.ScrolledWindow): self.count = 0 self.seconds = 0 self.string = string + self.formatSearch(self.string) for file in list: if self.hideRows(None,file,string) == True: self.count+=1 @@ -174,19 +177,31 @@ class List(gtk.ScrolledWindow): self.makeLabel() + def formatSearch(self,string): + self.search = [] + split = string.split(",") + for line in split: + line = line.strip() + if len(line) > 0: + self.search+=[line] + + def hideRows(self,list,iter,string): if list: file = self.data.library.files[list[iter][0]] else: file = iter - if self.string == "": - return True - if re.search(self.string,file.titlel): - return True - elif re.search(self.string,file.artistl): - return True - elif re.search(self.string,file.albuml): + #if self.string == "": + # return True + if len(self.search) == 0: return True + for term in self.search: + if re.search(term,file.titlel): + return True + elif re.search(term,file.artistl): + return True + elif re.search(term,file.albuml): + return True return False