show single service epg on long info keypress
[enigma2.git] / lib / python / Components / Sources / ServiceEvent.py
1 from Components.VariableText import VariableText
2 from Components.Element import cached
3 from Components.GUIComponent import GUIComponent
4 from enigma import eEPGCache, eServiceReference as Ref, eLabel
5 from Source import Source
6
7 class ServiceEvent(VariableText, GUIComponent, Source, object):
8         def __init__(self):
9                 Source.__init__(self)
10                 GUIComponent.__init__(self)
11                 VariableText.__init__(self)
12                 self.cur_ref = None
13
14         GUI_WIDGET = eLabel
15
16 #TODO Add a timer to get every minute the actual event..
17 #but this just make sense when the Servicelist do the same thing..
18         @cached
19         def getCurrentEvent(self):
20                 epg = eEPGCache.getInstance()
21                 return epg and self.cur_ref and epg.startTimeQuery(self.cur_ref) != -1 and epg.getNextTimeEntry() or None
22
23         event = property(getCurrentEvent)
24
25         def newService(self, ref):
26                 self.cur_ref = ref
27                 if not ref or (ref.flags & Ref.flagDirectory) == Ref.flagDirectory or ref.flags & Ref.isMarker:
28                         self.changed((self.CHANGED_CLEAR,))
29                 else:
30                         self.changed((self.CHANGED_ALL,))