From: Felix Domke Date: Mon, 24 Sep 2007 00:06:18 +0000 (+0000) Subject: push down initial 'changed' event X-Git-Tag: 2.6.0~1878 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/67ea9ad86c87e61ff57ec78403f43fde0ceb7632 push down initial 'changed' event --- diff --git a/lib/python/Components/Converter/StringListSelection.py b/lib/python/Components/Converter/StringListSelection.py new file mode 100644 index 00000000..747a82a6 --- /dev/null +++ b/lib/python/Components/Converter/StringListSelection.py @@ -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)