push down initial 'changed' event
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 24 Sep 2007 00:06:18 +0000 (00:06 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 24 Sep 2007 00:06:18 +0000 (00:06 +0000)
lib/python/Components/Converter/StringListSelection.py [new file with mode: 0644]

diff --git a/lib/python/Components/Converter/StringListSelection.py b/lib/python/Components/Converter/StringListSelection.py
new file mode 100644 (file)
index 0000000..747a82a
--- /dev/null
@@ -0,0 +1,24 @@
+from Components.Converter.Converter import Converter
+from Components.Element import cached
+
+class StringListSelection(Converter, object):
+       "extracts the first element of a the current string list  element for displaying it on LCD"
+       def __init__(self, args):
+               Converter.__init__(self, args)
+
+       def selChanged(self):
+               self.downstream_elements.changed((self.CHANGED_ALL, 0))
+
+       @cached
+       def getText(self):
+               cur = self.source.current
+               if cur and len(cur):
+                       return cur[0]
+               return None
+
+       text = property(getText)
+
+       def changed(self, what):
+               if what[0] == self.CHANGED_DEFAULT:
+                       self.source.onSelectionChanged.append(self.selChanged)
+               Converter.changed(self, what)