dont ask for scanning second nim in automatic scan, when it is not meaningful
[enigma2.git] / lib / python / Screens / EventView.py
index 79d548af5e002e2087357b5e9a614228dba5941c..ef3786c5e5604d814eeb22d7f847eacc1905da1b 100644 (file)
@@ -1,21 +1,30 @@
 from Screen import Screen
 from Components.ActionMap import ActionMap
 from Screen import Screen
 from Components.ActionMap import ActionMap
+from Components.Button import Button
 from Components.Label import Label
 from Components.ScrollLabel import ScrollLabel
 from enigma import eServiceEventPtr
 from ServiceReference import ServiceReference
 from Components.Label import Label
 from Components.ScrollLabel import ScrollLabel
 from enigma import eServiceEventPtr
 from ServiceReference import ServiceReference
-from RecordTimer import RecordTimerEntry
+from RecordTimer import RecordTimerEntry, parseEvent
 from TimerEntry import TimerEntry
 
 from TimerEntry import TimerEntry
 
-class EventView(Screen):
-       def __init__(self, session, Event, Ref, callback=None):
-               Screen.__init__(self, session)
+class EventViewBase:
+       def __init__(self, Event, Ref, callback=None):
                self.cbFunc = callback
                self.cbFunc = callback
-               self.currentService=None
+               self.currentService=Ref
+               self.isRecording = len(Ref.ref.getPath())
+               self.event = Event
                self["epg_description"] = ScrollLabel()
                self["datetime"] = Label()
                self["channel"] = Label()
                self["duration"] = Label()
                self["epg_description"] = ScrollLabel()
                self["datetime"] = Label()
                self["channel"] = Label()
                self["duration"] = Label()
+               self["key_red"] = Button("")
+               if self.isRecording:
+                       self["key_green"] = Button("")
+               else:
+                       self["key_green"] = Button(_("Add timer"))
+               self["key_yellow"] = Button("")
+               self["key_blue"] = Button("")
                self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
                        {
                                "cancel": self.close,
                self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
                        {
                                "cancel": self.close,
@@ -26,51 +35,41 @@ class EventView(Screen):
                                "nextEvent": self.nextEvent,
                                "timerAdd": self.timerAdd
                        })
                                "nextEvent": self.nextEvent,
                                "timerAdd": self.timerAdd
                        })
-               self.setEvent(Event)
-               self.setService(Ref)
+               self.onShown.append(self.onCreate)
+
+       def onCreate(self):
+               self.setEvent(self.event)
+               self.setService(self.currentService)
 
        def prevEvent(self):
                if self.cbFunc is not None:
 
        def prevEvent(self):
                if self.cbFunc is not None:
-                       self.cbFunc(self.setEvent, -1)
+                       self.cbFunc(self.setEvent, self.setService, -1)
 
        def nextEvent(self):
                if self.cbFunc is not None:
 
        def nextEvent(self):
                if self.cbFunc is not None:
-                       self.cbFunc(self.setEvent, +1)
-                       
-       def timerAdd(self):
-               epg = self.event
-               
-               if (epg == None):
-                       description = "unknown event"
-               else:
-                       description = epg.getEventName()
-                       # FIXME we need a timestamp here:
-                       begin = epg.getBeginTime()
-                       
-                       print begin
-                       print epg.getDuration()
-                       end = begin + epg.getDuration()
+                       self.cbFunc(self.setEvent, self.setService, +1)
 
 
-
-               # FIXME only works if already playing a service
-               serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
-               
-               newEntry = RecordTimerEntry(begin, end, serviceref, epg, description)
-               self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
+       def timerAdd(self):
+               if not self.isRecording:
+                       newEntry = RecordTimerEntry(self.currentService, *parseEvent(self.event))
+                       self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
 
        def timerEditFinished(self, answer):
                if (answer[0]):
                        self.session.nav.RecordTimer.record(answer[1])
                else:
 
        def timerEditFinished(self, answer):
                if (answer[0]):
                        self.session.nav.RecordTimer.record(answer[1])
                else:
-                       print "Timeredit aborted"       
+                       print "Timeredit aborted"
 
        def setService(self, service):
                self.currentService=service
 
        def setService(self, service):
                self.currentService=service
-               name = self.currentService.getServiceName()
-               if name is not None:
-                       self["channel"].setText(name)
+               if self.isRecording:
+                       self["channel"].setText(_("Recording"))
                else:
                else:
-                       self["channel"].setText(_("unknown service"))
+                       name = self.currentService.getServiceName()
+                       if name is not None:
+                               self["channel"].setText(name)
+                       else:
+                               self["channel"].setText(_("unknown service"))
 
        def setEvent(self, event):
                self.event = event
 
        def setEvent(self, event):
                self.event = event
@@ -83,13 +82,32 @@ class EventView(Screen):
                        if len(text) > 0:
                                text = text + '\n\n'
                        text = text + ext
                        if len(text) > 0:
                                text = text + '\n\n'
                        text = text + ext
-               self.session.currentDialog.instance.setTitle(event.getEventName())
+               self.setTitle(event.getEventName())
                self["epg_description"].setText(text)
                self["datetime"].setText(event.getBeginTimeString())
                self["duration"].setText(_("%d min")%(event.getDuration()/60))
 
        def pageUp(self):
                self["epg_description"].pageUp()
                self["epg_description"].setText(text)
                self["datetime"].setText(event.getBeginTimeString())
                self["duration"].setText(_("%d min")%(event.getDuration()/60))
 
        def pageUp(self):
                self["epg_description"].pageUp()
-       
+
        def pageDown(self):
                self["epg_description"].pageDown()
        def pageDown(self):
                self["epg_description"].pageDown()
+
+class EventViewSimple(Screen, EventViewBase):
+       def __init__(self, session, Event, Ref, callback=None):
+               Screen.__init__(self, session)
+               self.skinName = "EventView"
+               EventViewBase.__init__(self, Event, Ref, callback)
+
+class EventViewEPGSelect(Screen, EventViewBase):
+       def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
+               Screen.__init__(self, session)
+               self.skinName = "EventView"
+               EventViewBase.__init__(self, Event, Ref, callback)
+               self["key_yellow"].setText(_("Single EPG"))
+               self["key_blue"].setText(_("Multi EPG"))
+               self["epgactions"] = ActionMap(["EventViewEPGActions"],
+                       {
+                               "openSingleServiceEPG": singleEPGCB,
+                               "openMultiServiceEPG": multiEPGCB
+                       })