1 from GUIComponent import GUIComponent
2 from VariableText import VariableText
3 from VariableValue import VariableValue
5 from enigma import iPlayableService
6 from enigma import eLabel, eSlider, eTimer
8 class PerServiceBase(object):
9 def __init__(self, navcore, eventmap, with_event=False):
10 self.eventmap = eventmap
11 self.navcore = navcore
12 self.navcore.event.append(self.event_callback)
13 self.poll_timer = eTimer()
14 self.poll_timer.callback.append(self.poll)
15 self.with_event = with_event
17 # start with stopped state, so simulate that
18 self.event_callback(iPlayableService.evEnd)
21 self.navcore.event.remove(self.event_callback)
23 def event_callback(self, ev):
24 # loop up if we need to handle this event
25 func = self.eventmap.get(ev)
33 def enablePolling(self, interval=60000):
35 self.poll_timer.start(interval)
37 self.poll_timer.stop()
39 def disablePolling(self):
40 self.enablePolling(interval=0)
45 class PerServiceDisplay(PerServiceBase, VariableText, GUIComponent):
46 """Mixin for building components which display something which changes on navigation events, for example "service name" """
47 def __init__(self, navcore, eventmap):
48 GUIComponent.__init__(self)
49 VariableText.__init__(self)
50 PerServiceBase.__init__(self, navcore, eventmap)
53 PerServiceBase.destroy(self)
54 GUIComponent.destroy(self)
58 class PerServiceDisplayProgress(PerServiceBase, VariableValue, GUIComponent):
59 def __init__(self, navcore, eventmap):
60 GUIComponent.__init__(self)
61 VariableValue.__init__(self)
62 PerServiceBase.__init__(self, navcore, eventmap)
63 self.eventmap = eventmap
64 self.navcore = navcore
65 self.navcore.event.append(self.event)
67 # start with stopped state, so simulate that
68 self.event(iPlayableService.evEnd)
73 PerServiceBase.destroy(self)
74 GUIComponent.destroy(self)