Add source and converter for streaming. Source/StreamService will start the streaming...
[enigma2.git] / lib / python / Components / Converter / StringList.py
1 from Converter import Converter
2 from enigma import eListboxPythonStringContent
3 from Components.Element import cached
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, type):
8                 Converter.__init__(self, type)
9
10         def changed(self, what):
11                 self.content = eListboxPythonStringContent()
12                 if self.source:
13                         self.content.setList(self.source.list)
14                 self.downstream_elements.changed(what)
15
16         def selectionChanged(self, index):
17                 self.source.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         @cached
24         def getCurrent(self):
25                 if self.source is None:
26                         return None
27                 return self.source.list[self.index]
28
29         current = property(getCurrent)
30
31         # pass through: getIndex / setIndex to master
32         @cached
33         def getIndex(self):
34                 if self.master is None:
35                         return None
36                 return self.master.index
37
38         def setIndex(self, index):
39                 if self.master is not None:
40                         self.master.index = index
41         
42         index = property(getIndex, setIndex)