- fixed left/right in language selection (updates language on the fly)
[enigma2.git] / lib / python / Screens / TimerEntry.py
index 374ea11a498200d7e5ed9bfa8bd46bb5ff2d5811..752ace42c1bca74fc05ac537874fc1c88eb9b126 100644 (file)
@@ -4,10 +4,13 @@ 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
@@ -15,7 +18,7 @@ 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"))
@@ -81,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))
@@ -163,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))
 
@@ -211,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
@@ -266,7 +273,7 @@ class TimerEntry(Screen):
                                if event.getNumOfLinkageServices() > 0:
                                        self.session.openWithCallback(self.subserviceSelected, SubserviceSelection, event, self.timer.service_ref.ref)
                                        return
-                       self.close((True, self.timer))
+               self.close((True, self.timer))
 
        def subserviceSelected(self, service):
                if not service is None:
@@ -275,3 +282,79 @@ class TimerEntry(Screen):
 
        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("")