diff options
Diffstat (limited to 'lib/python/Components')
| -rw-r--r-- | lib/python/Components/FileList.py | 64 | ||||
| -rw-r--r-- | lib/python/Components/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Components/__init__.py | 3 |
3 files changed, 67 insertions, 2 deletions
diff --git a/lib/python/Components/FileList.py b/lib/python/Components/FileList.py new file mode 100644 index 00000000..a6b5bf2f --- /dev/null +++ b/lib/python/Components/FileList.py @@ -0,0 +1,64 @@ +from HTMLComponent import * +from GUIComponent import * + +from MenuList import MenuList + +from Tools.Directories import * + +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 + +def FileEntryComponent(name, absolute, isDir = False): + res = [ (absolute, isDir) ] + res.append((eListboxPythonMultiContent.TYPE_TEXT, 35, 1, 200, 20, 0, RT_HALIGN_LEFT ,name)) + if isDir: + png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "/extensions/directory.png")) + else: + # FIXME: detect file extensions correctly + png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "/extensions/" + name[-3:] + ".png")) + if png is not None: + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 10, 2, 20, 20, png)) + + return res + +class FileList(HTMLComponent, GUIComponent, MenuList): + def __init__(self, directory, showDirectories = True, showFiles = True): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + + self.showDirectories = showDirectories + self.showFiles = showFiles + self.changeDir(directory) + + self.l.setFont(0, gFont("Regular", 18)) + + def getSelection(self): + return self.l.getCurrentSelection()[0] + + def changeDir(self, directory): + self.list = [] + + directories = os.listdir(directory) + + if directory != "/" and self.showDirectories: + self.list.append(FileEntryComponent(name = "..", absolute = '/'.join(directory.split('/')[:-2]) + '/', isDir = True)) + for x in directories: + if os.path.isdir(directory + x): + if self.showDirectories: + self.list.append(FileEntryComponent(name = x, absolute = directory + x + "/" , isDir = True)) + elif self.showFiles: + self.list.append(FileEntryComponent(name = x, absolute = directory + x , isDir = False)) + self.l.setList(self.list) + + def GUIcreate(self, parent): + self.instance = eListbox(parent) + self.instance.setContent(self.l) + self.instance.setItemHeight(23)
\ No newline at end of file diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index 7416ea35..14eb23c5 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -12,5 +12,5 @@ install_PYTHON = \ EpgList.py ScrollLabel.py Timezones.py Language.py HelpMenuList.py \ BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \ PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \ - FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py + FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index 38be156e..c006cba2 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -6,4 +6,5 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "components", "config", "TimerList", "TimeInput", "MovieList", "InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway", "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry", - "Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList", "TimerSanityCheck"] + "Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList", "TimerSanityCheck", + "FileList" ] |
