fix inverted setting (meaning was inverted too)
[enigma2.git] / lib / python / Components / EventInfo.py
index ac7ed9b..36a5aa4 100644 (file)
@@ -1,4 +1,6 @@
 from PerServiceDisplay import *
+from time import strftime
+from time import localtime, time
 
 from enigma import iServiceInformationPtr, eServiceEventPtr
 
@@ -7,6 +9,8 @@ class EventInfo(PerServiceDisplay):
        Next = 1
        Now_Duration = 2
        Next_Duration = 3
+       Now_StartTime = 4
+       Next_StartTime = 5
        
        def __init__(self, navcore, now_or_next):
                # listen to evUpdatedEventInfo and evStopService
@@ -25,15 +29,39 @@ class EventInfo(PerServiceDisplay):
                if service != None:
                        info = service.info()
                        if info is not None: 
-                               ev = eServiceEventPtr()
-                               if info.getEvent(ev, self.now_or_next & 1) == 0:
-                                       if self.now_or_next & 2:
-                                               self.setText("%d min" % (ev.m_duration / 60))
-                                       else:
-                                               self.setText(ev.m_event_name)
-               print "new event info in EventInfo! yeah!"
+                               ev = info.getEvent(self.now_or_next & 1)
+                               if ev is not None:
+                                       self.update(ev)
+
+
+       def update(self, ev):
+               if (self.Now_Duration <= self.now_or_next <= self.Next_Duration):
+                       self.setText("%d min" % (ev.getDuration() / 60))
+               if (self.Now_StartTime <= self.now_or_next <= self.Next_StartTime):
+                       self.setText(strftime("%H:%M", localtime(ev.getBeginTime())))
+               if (self.Now <= self.now_or_next <= self.Next):
+                       self.setText(ev.getEventName())         
 
        def stopEvent(self):
                self.setText(
-                       ("waiting for event data...", "", "--:--",  "--:--")[self.now_or_next]);
+                       #(_("waiting for event data..."), "", "--:--",  "--:--", "--:--", "--:--")[self.now_or_next]);
+                       ("", "", "--:--",  "--:--", "--:--", "--:--")[self.now_or_next]);
 
+
+class EventInfoProgress(PerServiceDisplayProgress, EventInfo):
+       def __init__(self, navcore, now_or_next):
+               self.now_or_next = now_or_next
+               PerServiceDisplayProgress.__init__(self, navcore, 
+                       { 
+                               pNavigation.evUpdatedEventInfo: self.ourEvent, 
+                               pNavigation.evStopService: self.stopEvent 
+                       })
+
+       def update(self, ev):
+               self.g.setRange(0, ev.getDuration())
+               progress = int(time() - ev.getBeginTime())
+
+               self.setValue(progress)
+               
+       def stopEvent(self):
+               self.setValue(0)