- fixed left/right in language selection (updates language on the fly)
[enigma2.git] / lib / python / Screens / TimerEntry.py
index 5c18c419470fea275fe65eab8895459eebee20d3..752ace42c1bca74fc05ac537874fc1c88eb9b126 100644 (file)
@@ -4,15 +4,21 @@ from ServiceReference import ServiceReference
 from Components.config import *
 from Components.ActionMap import NumberActionMap
 from Components.ConfigList import ConfigList
+from Components.MenuList import MenuList
+from Components.Button import Button
 from Components.NimManager import nimmanager
 from Components.Label import Label
+from Components.Pixmap import Pixmap
+from Screens.SubserviceSelection import SubserviceSelection
+from Screens.MessageBox import MessageBox
+from enigma import eEPGCache
 import time
 import datetime
 
 class TimerEntry(Screen):
        def __init__(self, session, timer):
                Screen.__init__(self, session)
-               self.timer = timer;
+               self.timer = timer
                
                self["oktext"] = Label(_("OK"))
                self["canceltext"] = Label(_("Cancel"))
@@ -78,6 +84,8 @@ class TimerEntry(Screen):
                        else: # once
                                type = 0
                                repeated = 0
+                               weekday = (int(strftime("%w", time.localtime(self.timer.begin))) - 1) % 7
+                               day[weekday] = 0
                        
                        config.timerentry.type = configElement_nonSave("config.timerentry.type", configSelection, type, (_("once"), _("repeated")))
                        config.timerentry.name = configElement_nonSave("config.timerentry.name", configText, self.timer.name, (configText.extendableSize, self.keyRightCallback))
@@ -135,7 +143,7 @@ class TimerEntry(Screen):
                self.list.append(self.timerTypeEntry)
 
                if (config.timerentry.type.value == 0): # once
-                       pass
+                       self.frequencyEntry = None
                else: # repeated
                        self.frequencyEntry = getConfigListEntry(_("Frequency"), config.timerentry.repeated)
                        self.list.append(self.frequencyEntry)
@@ -160,12 +168,12 @@ class TimerEntry(Screen):
 
                if (config.timerentry.type.value == 0): # once
                        self.list.append(getConfigListEntry(_("Start"), config.timerentry.startdate))
-                       self.list.append(getConfigListEntry("", config.timerentry.starttime))
+                       self.list.append(getConfigListEntry(" ", config.timerentry.starttime))
                else:
                        self.list.append(getConfigListEntry(_("StartTime"), config.timerentry.starttime))
                if (config.timerentry.type.value == 0): # once
                        self.list.append(getConfigListEntry(_("End"), config.timerentry.enddate))
-                       self.list.append(getConfigListEntry("", config.timerentry.endtime))
+                       self.list.append(getConfigListEntry(" ", config.timerentry.endtime))
                else:
                        self.list.append(getConfigListEntry(_("EndTime"), config.timerentry.endtime))
 
@@ -208,6 +216,8 @@ class TimerEntry(Screen):
        def keySelect(self):
                if self["config"].getCurrent() == self.channelEntry:
                        self.session.openWithCallback(self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"))
+               else:
+                       self.keyGo()
 
        def finishedChannelSelection(self, args):
                oldref = self.timer.service_ref
@@ -255,9 +265,96 @@ class TimerEntry(Screen):
                                        if (config.timerentry.day[x].value == 0): self.timer.setRepeated(x)
 
                        self.timer.begin = self.getTimestamp(time.time(), config.timerentry.starttime.value)
-                       self.timer.end = self.getTimestamp(time.time(), config.timerentry.endtime.value)                                
+                       self.timer.end = self.getTimestamp(time.time(), config.timerentry.endtime.value)
+
+               if self.timer.eit is not None:
+                       event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit)
+                       if event is not None:
+                               if event.getNumOfLinkageServices() > 0:
+                                       self.session.openWithCallback(self.subserviceSelected, SubserviceSelection, event, self.timer.service_ref.ref)
+                                       return
+               self.close((True, self.timer))
 
+       def subserviceSelected(self, service):
+               if not service is None:
+                       self.timer.service_ref = ServiceReference(service)
                self.close((True, self.timer))
 
        def keyCancel(self):
                self.close((False,))
+
+class TimerLog(Screen):
+       def __init__(self, session, timer):
+               Screen.__init__(self, session)
+               self.timer = timer;
+               self.log_entries = self.timer.log_entries[:]
+               
+               self.fillLogList()
+               
+               self["loglist"] = MenuList(self.list)
+               self["logentry"] = Label()
+               
+               self["key_red"] = Button(_("Delete entry"))
+               self["key_green"] = Button()
+               self["key_yellow"] = Button("")
+               self["key_blue"] = Button(_("Clear log"))
+               
+               self.onShown.append(self.updateText)
+
+               self["actions"] = NumberActionMap(["OkCancelActions", "DirectionActions", "ColorActions"],
+               {
+                       "ok": self.keyClose,
+                       "cancel": self.keyClose,
+                       "up": self.up,
+                       "down": self.down,
+                       "left": self.left,
+                       "right": self.right,
+                       "red": self.deleteEntry,
+                       "blue": self.clearLog
+               }, -1)
+
+       def deleteEntry(self):
+               self.log_entries.remove(self["loglist"].getCurrent()[1])
+               self.fillLogList()
+               self["loglist"].l.setList(self.list)
+               self.updateText()
+
+       def fillLogList(self):
+               self.list = [ ]
+               for x in self.log_entries:
+                       self.list.append((str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x))
+       
+       def clearLog(self):             
+               self.log_entries = []
+               self.fillLogList()
+               self["loglist"].l.setList(self.list)
+               self.updateText()
+               
+       def keyClose(self):
+               if self.timer.log_entries != self.log_entries:
+                       self.timer.log_entries = self.log_entries
+                       self.close((True, self.timer))
+               else:
+                       self.close((False,))
+               
+       def up(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.moveUp)
+               self.updateText()
+               
+       def down(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.moveDown)
+               self.updateText()
+
+       def left(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.pageUp)
+               self.updateText()
+               
+       def right(self):
+               self["loglist"].instance.moveSelection(self["loglist"].instance.pageDown)
+               self.updateText()
+
+       def updateText(self):
+               if len(self.list) > 0:
+                       self["logentry"].setText(str(self["loglist"].getCurrent()[1][2]))
+               else:
+                       self["logentry"].setText("")