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
9 class PerServiceBase(object):
14 func_list = PerServiceBase.EventMap.setdefault(ev, [])
15 for func in func_list:
16 if func[0]: # with_event
21 def __init__(self, navcore, eventmap, with_event=False):
22 self.navcore = navcore
23 self.eventmap = eventmap
24 self.poll_timer = eTimer()
25 self.with_event = with_event
27 self.poll_timer.callback.append(self.poll)
29 EventMap = PerServiceBase.EventMap
31 self.navcore.event.append(PerServiceBase.event)
33 EventMap = EventMap.setdefault
34 for x in eventmap.iteritems():
35 EventMap(x[0], []).append((with_event, x[1]))
37 # start with stopped state, so simulate that
38 evEndEntry = eventmap.get(iPlayableService.evEnd)
41 evEndEntry(iPlayableService.evEnd)
46 EventMap = PerServiceBase.EventMap.setdefault
47 for x in self.eventmap.iteritems():
48 EventMap(x[0], []).remove((self.with_event, x[1]))
50 def enablePolling(self, interval=60000):
52 self.poll_timer.start(interval)
54 self.poll_timer.stop()
56 def disablePolling(self):
57 self.enablePolling(interval=0)
62 class PerServiceDisplay(PerServiceBase, VariableText, GUIComponent):
63 """Mixin for building components which display something which changes on navigation events, for example "service name" """
64 def __init__(self, navcore, eventmap):
65 GUIComponent.__init__(self)
66 VariableText.__init__(self)
67 PerServiceBase.__init__(self, navcore, eventmap)
70 PerServiceBase.destroy(self)
71 GUIComponent.destroy(self)
75 class PerServiceDisplayProgress(PerServiceBase, VariableValue, GUIComponent):
76 def __init__(self, navcore, eventmap):
77 GUIComponent.__init__(self)
78 VariableValue.__init__(self)
79 PerServiceBase.__init__(self, navcore, eventmap)
80 self.eventmap = eventmap
81 self.navcore = navcore
82 self.navcore.event.append(self.event)
84 # start with stopped state, so simulate that
85 self.event(iPlayableService.evEnd)
90 PerServiceBase.destroy(self)
91 GUIComponent.destroy(self)