- fix event info
[enigma2.git] / lib / python / Components / EventInfo.py
1 from PerServiceDisplay import *
2
3 from enigma import iServiceInformationPtr, eServiceEventPtr
4
5 class EventInfo(PerServiceDisplay):
6         Now = 0
7         Next = 1
8         Now_Duration = 2
9         Next_Duration = 3
10         
11         def __init__(self, navcore, now_or_next):
12                 # listen to evUpdatedEventInfo and evStopService
13                 # note that evStopService will be called once to establish a known state
14                 self.now_or_next = now_or_next
15                 PerServiceDisplay.__init__(self, navcore, 
16                         { 
17                                 pNavigation.evUpdatedEventInfo: self.ourEvent, 
18                                 pNavigation.evStopService: self.stopEvent 
19                         })
20
21         def ourEvent(self):
22                 info = iServiceInformationPtr()
23                 service = self.navcore.getCurrentService()
24                 
25                 if service != None:
26                         if not service.info(info):
27                                 ev = eServiceEventPtr()
28                                 if info.getEvent(ev, self.now_or_next & 1) == 0:
29                                         if self.now_or_next & 2:
30                                                 self.setText("%d min" % (ev.m_duration / 60))
31                                         else:
32                                                 self.setText(ev.m_event_name)
33                 print "new event info in EventInfo! yeah!"
34
35         def stopEvent(self):
36                 self.setText(
37                         ("waiting for event data...", "", "--:--",  "--:--")[self.now_or_next]);
38