add some new (currently unused) source/renderer based elements
[enigma2.git] / lib / python / Components / Converter / StringList.py
1 from Converter import Converter
2 from enigma import eListboxPythonStringContent
3
4
5 class StringList(Converter):
6         """Turns a simple python list into a list which can be used in a listbox."""
7         def __init__(self, *args, **kwargs):
8                 Converter.__init__(self)
9
10         def changed(self):
11                 self.content = eListboxPythonStringContent()
12                 if self.source:
13                         self.content.setList(self.source.list)
14                 self.downstream_elements.changed()
15
16         def selectionChanged(self, index):
17                 self.upstream_elements.selectionChanged(index)
18                 # update all non-master targets
19                 for x in self.downstream_elements:
20                         if x is not self.master:
21                                 x.index = index
22
23         def getCurrent(self):
24                 if self.source is None:
25                         return None
26                 return self.source.list[self.index]
27
28         current = property(getCurrent)
29
30         # pass through: getIndex / setIndex to master
31         def getIndex(self):
32                 if self.master is None:
33                         return None
34                 return self.master.index
35
36         def setIndex(self, index):
37                 if self.master is not None:
38                         self.master.index = index
39         
40         index = property(getIndex, setIndex)