add converter to test config entrie values
[enigma2.git] / lib / python / Components / FileList.py
index 0c8a8814dcdfd62e98ede29cb0be5025227671b2..ae171c305153968edfcebf842984a0f083a84794 100644 (file)
@@ -1,22 +1,15 @@
-from HTMLComponent import *
-from GUIComponent import *
+from HTMLComponent import HTMLComponent
+from GUIComponent import GUIComponent
 import re
 
+from os import path as os_path, listdir
 from MenuList import MenuList
 from Components.Harddisk import harddiskmanager
 
-from Tools.Directories import *
+from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
 
-from enigma import *
-
-RT_HALIGN_LEFT = 0
-RT_HALIGN_RIGHT = 1
-RT_HALIGN_CENTER = 2
-RT_HALIGN_BLOCK = 4
-
-RT_VALIGN_TOP = 0
-RT_VALIGN_CENTER = 8
-RT_VALIGN_BOTTOM = 16
+from enigma import RT_HALIGN_LEFT, loadPNG, eListbox, eListboxPythonMultiContent, \
+       eServiceReference, eServiceCenter, gFont
 
 EXTENSIONS = {
                "mp3": "music",
@@ -25,6 +18,7 @@ EXTENSIONS = {
                "jpg": "picture",
                "jpeg": "picture",
                "png": "picture",
+               "bmp": "picture",
                "ts": "movie",
                "avi": "movie",
                "mpg": "movie",
@@ -64,12 +58,24 @@ class FileList(MenuList, HTMLComponent, GUIComponent):
                self.changeDir(directory)
 
                self.l.setFont(0, gFont("Regular", 18))
-               
+               self.l.setItemHeight(23)
+               self.serviceHandler = eServiceCenter.getInstance()
+
        def getSelection(self):
                if self.l.getCurrentSelection() is None:
                        return None
                return self.l.getCurrentSelection()[0]
        
+       def getSelectionIndex(self):
+               return self.l.getCurrentSelectionIndex()
+       
+       def getCurrentEvent(self):
+               l = self.l.getCurrentSelection()
+               if not l or l[0][1] == True:
+                       return None
+               else:
+                       return self.serviceHandler.info(l[0][0]).getEvent(l[0][0])
+       
        def getFileList(self):
                return self.list
        
@@ -86,7 +92,10 @@ class FileList(MenuList, HTMLComponent, GUIComponent):
                if directory is None: # present available mountpoints
                        print "listing partitions:"
                        for p in harddiskmanager.getMountedPartitions():
-                               self.list.append(FileEntryComponent(name = p.description, absolute = p.mountpoint, isDir = True))
+                               if p.mountpoint == "/":
+                                       self.list.append(FileEntryComponent(name = p.description, absolute = p.mountpoint, isDir = True))
+                               else:
+                                       self.list.append(FileEntryComponent(name = p.description, absolute = p.mountpoint + "/", isDir = True))
                        files = [ ]
                        directories = [ ]
                elif self.useServiceRef:
@@ -107,11 +116,11 @@ class FileList(MenuList, HTMLComponent, GUIComponent):
                        directories.sort()
                        files.sort()
                else:
-                       files = os.listdir(directory)
+                       files = listdir(directory)
                        files.sort()
                        tmpfiles = files[:]
                        for x in tmpfiles:
-                               if os.path.isdir(directory + x):
+                               if os_path.isdir(directory + x):
                                        directories.append(directory + x + "/")
                                        files.remove(x)
                
@@ -189,4 +198,16 @@ class FileList(MenuList, HTMLComponent, GUIComponent):
 
        def postWidgetCreate(self, instance):
                instance.setContent(self.l)
-               instance.setItemHeight(23)
+
+       def execBegin(self):
+               harddiskmanager.on_partition_list_change.append(self.partitionListChanged)
+               
+       def execEnd(self):
+               harddiskmanager.on_partition_list_change.remove(self.partitionListChanged)
+
+       def refresh(self):
+               self.changeDir(self.current_directory, self.getFilename())
+
+       def partitionListChanged(self, action, device):
+               if self.current_directory is None:
+                       self.refresh()