add perService position display with gauge
[openblackhole/openblackhole-enigma2.git] / lib / python / Components / PerServiceDisplay.py
1 from GUIComponent import *
2 from VariableText import *
3 from VariableValue import *
4
5 from enigma import iPlayableService
6 from enigma import eLabel, eSlider, eTimer
7
8 class PerServiceBase(GUIComponent):
9         def __init__(self, navcore, eventmap):
10                 GUIComponent.__init__(self)
11                 self.eventmap = eventmap
12                 self.navcore = navcore
13                 self.navcore.event.append(self.event)
14                 self.poll_timer = eTimer()
15                 self.poll_timer.timeout.get().append(self.poll)
16                 
17                 # start with stopped state, so simulate that
18                 self.event(iPlayableService.evEnd)
19
20         def event(self, ev):
21                 # loop up if we need to handle this event
22                 if self.eventmap.has_key(ev):
23                         # call handler
24                         self.eventmap[ev]()
25         
26         def enablePolling(self, interval=60000):
27                 if interval:
28                         self.poll_timer.start(interval)
29                 else:
30                         self.poll_timer.stop()
31         
32         def disablePolling(self):
33                 self.enablePolling(interval=0)
34
35         def poll(self):
36                 pass
37
38 class PerServiceDisplay(PerServiceBase, VariableText):
39         """Mixin for building components which display something which changes on navigation events, for example "service name" """
40         def __init__(self, navcore, eventmap):
41                 VariableText.__init__(self)
42                 PerServiceBase.__init__(self, navcore, eventmap)
43
44         def createWidget(self, parent):
45                 # by default, we use a label to display our data.
46                 g = eLabel(parent)
47                 return g
48
49 class PerServiceDisplayProgress(GUIComponent, VariableValue, PerServiceBase):
50         def __init__(self, navcore, eventmap):
51                 GUIComponent.__init__(self)
52                 VariableValue.__init__(self)
53                 self.eventmap = eventmap
54                 self.navcore = navcore
55                 self.navcore.event.append(self.event)
56
57                 # start with stopped state, so simulate that
58                 self.event(iPlayableService.evEnd)
59
60         def createWidget(self, parent):
61                 # by default, we use a label to display our data.
62                 self.g = eSlider(parent)
63                 return self.g