set hdd standby value for all hdds (not working on hotplug devices,
[enigma2.git] / lib / python / Screens / SleepTimerEdit.py
index f582ff2269935e499fc34ed3149487853a3939a9..2416dd03d9905a1f37c579e06596776516d99782 100644 (file)
@@ -4,9 +4,10 @@ from Components.ActionMap import NumberActionMap
 from Components.Input import Input
 from Components.Label import Label
 from Components.Pixmap import Pixmap
-from Components.config import config
-from SleepTimer import SleepTimerEntry
-import time
+from Components.config import config, ConfigInteger
+from SleepTimer import SleepTimer
+
+config.SleepTimer.defaulttime = ConfigInteger(default = 30)
 
 class SleepTimerEdit(Screen):
        def __init__(self, session):
@@ -20,14 +21,27 @@ class SleepTimerEdit(Screen):
                self["green_text"] = Label()
                self["yellow_text"] = Label()
                self["blue_text"] = Label()
+               self["current_status"] = Label()
                self.is_active = self.session.nav.SleepTimer.isActive()
+               if self.is_active:
+                       self["current_status"].setText(_("Timer status:") + " " + _("Enabled"))
+               else:
+                       self["current_status"].setText(_("Timer status:") + " " + _("Disabled"))
+               
+               if self.is_active:
+                       self.time = self.session.nav.SleepTimer.getCurrentSleepTime()
+               else:
+                       self.time = config.SleepTimer.defaulttime.value
+               self["input"] = Input(text = str(self.time), maxSize = False, type = Input.NUMBER)
+               
+               self.status = True
                self.updateColors()
                
+               
                self["pretext"] = Label(_("Shutdown Dreambox after"))
-               self["input"] = Input(text = str(self.session.nav.SleepTimer.getCurrentSleepTime()), maxSize = False, type = Input.NUMBER)
                self["aftertext"] = Label(_("minutes"))
                
-               self["actions"] = NumberActionMap(["SleepTimerEditorActions"], 
+               self["actions"] = NumberActionMap(["SleepTimerEditorActions", "TextEntryActions", "KeyboardInputActions"], 
                {
                        "exit": self.cancel,
                        "select": self.select,
@@ -43,16 +57,22 @@ class SleepTimerEdit(Screen):
                        "0": self.keyNumberGlobal,
                        "selectLeft": self.selectLeft,
                        "selectRight": self.selectRight,
+                       "left": self.selectLeft,
+                       "right": self.selectRight,
+                       "home": self.selectHome,
+                       "end": self.selectEnd,
+                       "deleteForward": self.deleteForward,
+                       "deleteBackward": self.deleteBackward,
                        "disableTimer": self.disableTimer,
                        "toggleAction": self.toggleAction,
                        "toggleAsk": self.toggleAsk
                }, -1)
 
        def updateColors(self):
-               if self.is_active:
-                       self["red_text"].setText(_("Timer status:") + " " + _("Enabled"))
+               if self.status:
+                       self["red_text"].setText(_("Action:") + " " + _("Enable timer"))
                else:
-                       self["red_text"].setText(_("Timer status:") + " " + _("Disabled"))
+                       self["red_text"].setText(_("Action:") + " " + _("Disable timer"))
                
                if config.SleepTimer.action.value == "shutdown":
                        self["green_text"].setText(_("Sleep timer action:") + " " + _("Deep Standby"))
@@ -71,8 +91,10 @@ class SleepTimerEdit(Screen):
                self.close()
 
        def select(self):
-               if self.is_active:
-                       self.session.nav.SleepTimer.setSleepTime(int(self["input"].getText()))
+               if self.status:
+                       time = int(self["input"].getText())
+                       config.SleepTimer.defaulttime.setValue(time)
+                       self.session.nav.SleepTimer.setSleepTime(time)
                        self.session.openWithCallback(self.close, MessageBox, _("The sleep timer has been activated."), MessageBox.TYPE_INFO)
                else:
                        self.session.nav.SleepTimer.clear()
@@ -87,8 +109,20 @@ class SleepTimerEdit(Screen):
        def selectRight(self):
                self["input"].right()
 
+       def selectHome(self):
+               self["input"].home()
+       
+       def selectEnd(self):
+               self["input"].end()
+       
+       def deleteForward(self):
+               self["input"].delete()
+       
+       def deleteBackward(self):
+               self["input"].deleteBackward()
+       
        def disableTimer(self):
-               self.is_active = not self.is_active
+               self.status = not self.status
                self.updateColors()
 
        def toggleAction(self):