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 if self.eventmap.has_key(ev):
32 def enablePolling(self, interval=60000):
34 self.poll_timer.start(interval)
36 self.poll_timer.stop()
38 def disablePolling(self):
39 self.enablePolling(interval=0)
44 class PerServiceDisplay(PerServiceBase, VariableText, GUIComponent):
45 """Mixin for building components which display something which changes on navigation events, for example "service name" """
46 def __init__(self, navcore, eventmap):
47 GUIComponent.__init__(self)
48 VariableText.__init__(self)
49 PerServiceBase.__init__(self, navcore, eventmap)
53 class PerServiceDisplayProgress(PerServiceBase, VariableValue, GUIComponent):
54 def __init__(self, navcore, eventmap):
55 GUIComponent.__init__(self)
56 VariableValue.__init__(self)
57 PerServiceBase.__init__(self, navcore, eventmap)
58 self.eventmap = eventmap
59 self.navcore = navcore
60 self.navcore.event.append(self.event)
62 # start with stopped state, so simulate that
63 self.event(iPlayableService.evEnd)