- add positioner plugin (just basic gui atm)
[enigma2.git] / lib / python / Components / FileList.py
index 31ffc98a191b383b8aa22672a3badd5a95a8be61..961eb09ddc28d2c8ab96645d0a5021378bd6f6cb 100644 (file)
@@ -35,9 +35,10 @@ def FileEntryComponent(name, absolute, isDir = False):
        if isDir:
                png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "/extensions/directory.png"))
        else:
-               # FIXME: detect file extensions correctly
-               if EXTENSIONS.has_key(name[-3:]):
-                       png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "/extensions/" + EXTENSIONS[name[-3:]] + ".png"))
+               extension = name.split('.')
+               extension = extension[-1]
+               if EXTENSIONS.has_key(extension):
+                       png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "/extensions/" + EXTENSIONS[extension] + ".png"))
        if png is not None:
                res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 10, 2, 20, 20, png))
        
@@ -62,15 +63,25 @@ class FileList(HTMLComponent, GUIComponent, MenuList):
        def changeDir(self, directory):
                self.list = []
                
-               directories = os.listdir(directory)
+               files = os.listdir(directory)
+               files.sort()
                
                if directory != "/" and self.showDirectories:
                        self.list.append(FileEntryComponent(name = "..", absolute = '/'.join(directory.split('/')[:-2]) + '/', isDir = True))
-               for x in directories:
+                       
+               directories = []
+               for x in files:
                        if os.path.isdir(directory + x):
-                               if self.showDirectories:
-                                       self.list.append(FileEntryComponent(name = x, absolute = directory + x + "/" , isDir = True))
-                       elif self.showFiles:
+                               directories.append(x)
+                               files.remove(x)
+
+               if self.showDirectories:
+                       for x in directories:
+                               self.list.append(FileEntryComponent(name = x, absolute = directory + x + "/" , isDir = True))
+
+                                       
+               if self.showFiles:
+                       for x in files:
                                if self.matchingPattern is not None:
                                        if re.compile(self.matchingPattern).search(x):
                                                self.list.append(FileEntryComponent(name = x, absolute = directory + x , isDir = False))