Allow playback of VCD (Video CD) and SVCD
[enigma2.git] / lib / python / Components / Renderer / Listbox.py
1 from Renderer import Renderer
2 from enigma import eListbox
3
4 # the listbox renderer is the listbox, but no listbox content.
5 # the content will be provided by the source (or converter).
6
7 # the source should emit the 'changed' signal whenever
8 # it has a new listbox content.
9
10 # the source needs to have the 'content' property for the
11 # used listbox content
12
13 # it should expose exactly the non-content related functions
14 # of the eListbox class. more or less.
15
16 class Listbox(Renderer, object):
17         def __init__(self):
18                 Renderer.__init__(self)
19                 self.__content = None
20                 self.__wrap_around = False
21                 self.__selection_enabled = True
22
23         GUI_WIDGET = eListbox
24
25         def contentChanged(self):
26                 self.content = self.source.content
27
28         def setContent(self, content):
29                 self.__content = content
30                 if self.instance is not None:
31                         self.instance.setContent(self.__content)
32
33         content = property(lambda self: self.__content, setContent)
34
35         def postWidgetCreate(self, instance):
36                 if self.__content is not None:
37                         instance.setContent(self.__content)
38                 instance.selectionChanged.get().append(self.selectionChanged)
39                 self.wrap_around = self.wrap_around # trigger
40                 self.selection_enabled = self.selection_enabled # trigger
41
42         def preWidgetRemove(self, instance):
43                 instance.setContent(None)
44                 instance.selectionChanged.get().remove(self.selectionChanged)
45
46         def setWrapAround(self, wrap_around):
47                 self.__wrap_around = wrap_around
48                 if self.instance is not None:
49                         self.instance.setWrapAround(self.__wrap_around)
50
51         wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
52
53         def selectionChanged(self):
54                 self.source.selectionChanged(self.index)
55
56         def getIndex(self):
57                 if self.instance is None:
58                         return 0
59                 return self.instance.getCurrentIndex()
60
61         def moveToIndex(self, index):
62                 if self.instance is None:
63                         return
64                 self.instance.moveSelectionTo(index)
65
66         index = property(getIndex, moveToIndex)
67
68         def move(self, direction):
69                 if self.instance is not None:
70                         self.instance.moveSelection(direction)
71
72         def setSelectionEnabled(self, enabled):
73                 self.__selection_enabled = enabled
74                 if self.instance is not None:
75                         self.instance.setSelectionEnable(enabled)
76
77         selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
78
79         def changed(self, what):
80                 self.content = self.source.content