aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-02-21 18:50:23 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-02-21 18:50:23 +0000
commitf458abcfbe30c3e3062a41b88d3244147bdc0607 (patch)
tree43b878a27855eccecc1cf3f35820a234afcc375a /lib/python/Components
parent7319cb85c7a9a6304ac92a7854a5d79c9d9f115b (diff)
downloadenigma2-f458abcfbe30c3e3062a41b88d3244147bdc0607.tar.gz
enigma2-f458abcfbe30c3e3062a41b88d3244147bdc0607.zip
add FileList component for browsing files and directories
Diffstat (limited to 'lib/python/Components')
-rw-r--r--lib/python/Components/FileList.py64
-rw-r--r--lib/python/Components/Makefile.am2
-rw-r--r--lib/python/Components/__init__.py3
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" ]