X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/blobdiff_plain/46f3ffd7fdde386f41020171b5733e55a8e64a85..e26832c9e7be68fc16059f7a2d3c2478afbcfa91:/src/minwii/widgets/songfilebrowser.py?ds=sidebyside diff --git a/src/minwii/widgets/songfilebrowser.py b/src/minwii/widgets/songfilebrowser.py index 973f9ab..99f81da 100755 --- a/src/minwii/widgets/songfilebrowser.py +++ b/src/minwii/widgets/songfilebrowser.py @@ -8,6 +8,7 @@ $URL$ from pgu.gui import FileDialog import os +from xml.etree import ElementTree class FileOpenDialog(FileDialog): @@ -28,24 +29,37 @@ class FileOpenDialog(FileDialog): files = [] try: for i in os.listdir(self.curdir): + if i.startswith('.') : continue if os.path.isdir(os.path.join(self.curdir, i)): dirs.append(i) else: files.append(i) except: - self.input_file.value = "Opps! no access" - #if '..' not in dirs: dirs.append('..') + self.input_file.value = "Dossier innacessible !" + dirs.sort() - dirs = ['..'] + dirs + dirs.insert(0, '..') files.sort() for i in dirs: - if i.startswith('.') and i != '..' : - continue self.list.add(i, image=self.dir_img, value=i) for i in files: - if i.startswith('.') or (not i.endswith('.xml')) : + if not i.endswith('.xml') : continue - self.list.add(i,value=i) - + filepath = os.path.join(self.curdir, i) + self.list.add(FileOpenDialog.getSongTitle(filepath), value=i) + self.list.set_vertical_scroll(0) - + + @staticmethod + def getSongTitle(file) : + it = ElementTree.iterparse(file, ['start', 'end']) + creditFound = False + + for evt, el in it : + if el.tag == 'credit' : + creditFound = True + if el.tag == 'credit-words' and creditFound: + return el.text.encode('iso-8859-1') + if el.tag == 'part-list' : + # plus de chance de trouver un titre + return os.path.basename(file) \ No newline at end of file