add TemplatedMultiContent converter
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 13 Apr 2008 22:32:36 +0000 (22:32 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 13 Apr 2008 22:32:36 +0000 (22:32 +0000)
lib/python/Components/Converter/Makefile.am
lib/python/Components/Converter/TemplatedMultiContent.py [new file with mode: 0644]

index f5188090d93d7e06025ddc476dab06c0bb72566f..0fff9c8d5eb36c9ee2f3bf126084475bbb0a9315 100644 (file)
@@ -5,5 +5,5 @@ install_PYTHON = \
        Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py ServiceInfo.py \
        ConditionalShowHide.py ServicePosition.py ValueRange.py RdsInfo.py Streaming.py \
        StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \
-       ValueBitTest.py TunerInfo.py ConfigEntryTest.py
+       ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py
 
diff --git a/lib/python/Components/Converter/TemplatedMultiContent.py b/lib/python/Components/Converter/TemplatedMultiContent.py
new file mode 100644 (file)
index 0000000..a1b601d
--- /dev/null
@@ -0,0 +1,34 @@
+from Components.Converter.StringList import StringList
+
+class TemplatedMultiContent(StringList):
+       """Turns a python tuple list into a multi-content list which can be used in a listbox renderer."""
+       def __init__(self, args):
+               StringList.__init__(self, args)
+               from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_HALIGN_RIGHT, RT_VALIGN_TOP, RT_VALIGN_CENTER, RT_VALIGN_BOTTOM
+               from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest
+               l = locals()
+               del l["self"] # cleanup locals a bit
+               del l["args"]
+
+               self.template = eval(args, {}, l)
+               assert "fonts" in self.template
+               assert "itemHeight" in self.template
+               assert "template" in self.template
+
+       def changed(self, what):
+               if not self.content:
+                       from enigma import eListboxPythonMultiContent
+                       self.content = eListboxPythonMultiContent()
+                       self.content.setItemHeight(self.template["itemHeight"])
+                       self.content.setTemplate(self.template["template"])
+
+                       # also setup fonts (also given by source)
+                       index = 0
+                       for f in self.template["fonts"]:
+                               self.content.setFont(index, f)
+                               index += 1
+
+               if self.source:
+                       self.content.setList(self.source.list)
+
+               self.downstream_elements.changed(what)