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