1 from Screens.Screen import Screen
2 from Screens.MessageBox import MessageBox
3 from Components.ActionMap import NumberActionMap
4 from Components.Input import Input
5 from Components.Label import Label
6 from Components.Pixmap import Pixmap
7 from Components.config import config
9 class SleepTimerEdit(Screen):
10 def __init__(self, session):
11 Screen.__init__(self, session)
13 self["red"] = Pixmap()
14 self["green"] = Pixmap()
15 self["yellow"] = Pixmap()
16 self["blue"] = Pixmap()
17 self["red_text"] = Label()
18 self["green_text"] = Label()
19 self["yellow_text"] = Label()
20 self["blue_text"] = Label()
21 self.is_active = self.session.nav.SleepTimer.isActive()
24 self["pretext"] = Label(_("Shutdown Dreambox after"))
25 self["input"] = Input(text = str(self.session.nav.SleepTimer.getCurrentSleepTime()), maxSize = False, type = Input.NUMBER)
26 self["aftertext"] = Label(_("minutes"))
28 self["actions"] = NumberActionMap(["SleepTimerEditorActions", "TextEntryActions", "KeyboardInputActions"],
31 "select": self.select,
32 "1": self.keyNumberGlobal,
33 "2": self.keyNumberGlobal,
34 "3": self.keyNumberGlobal,
35 "4": self.keyNumberGlobal,
36 "5": self.keyNumberGlobal,
37 "6": self.keyNumberGlobal,
38 "7": self.keyNumberGlobal,
39 "8": self.keyNumberGlobal,
40 "9": self.keyNumberGlobal,
41 "0": self.keyNumberGlobal,
42 "selectLeft": self.selectLeft,
43 "selectRight": self.selectRight,
44 "left": self.selectLeft,
45 "right": self.selectRight,
46 "home": self.selectHome,
47 "end": self.selectEnd,
48 "deleteForward": self.deleteForward,
49 "deleteBackward": self.deleteBackward,
50 "disableTimer": self.disableTimer,
51 "toggleAction": self.toggleAction,
52 "toggleAsk": self.toggleAsk
55 def updateColors(self):
57 self["red_text"].setText(_("Timer status:") + " " + _("Enabled"))
59 self["red_text"].setText(_("Timer status:") + " " + _("Disabled"))
61 if config.SleepTimer.action.value == "shutdown":
62 self["green_text"].setText(_("Sleep timer action:") + " " + _("Deep Standby"))
63 elif config.SleepTimer.action.value == "standby":
64 self["green_text"].setText(_("Sleep timer action:") + " " + _("Standby"))
66 if config.SleepTimer.ask.value:
67 self["yellow_text"].setText(_("Ask before shutdown:") + " " + _("yes"))
69 self["yellow_text"].setText(_("Ask before shutdown:") + " " + _("no"))
70 self["blue_text"].setText(_("Settings"))
73 config.SleepTimer.ask.cancel()
74 config.SleepTimer.action.cancel()
79 self.session.nav.SleepTimer.setSleepTime(int(self["input"].getText()))
80 self.session.openWithCallback(self.close, MessageBox, _("The sleep timer has been activated."), MessageBox.TYPE_INFO)
82 self.session.nav.SleepTimer.clear()
83 self.session.openWithCallback(self.close, MessageBox, _("The sleep timer has been disabled."), MessageBox.TYPE_INFO)
85 def keyNumberGlobal(self, number):
86 self["input"].number(number)
91 def selectRight(self):
100 def deleteForward(self):
101 self["input"].delete()
103 def deleteBackward(self):
104 self["input"].deleteBackward()
106 def disableTimer(self):
107 self.is_active = not self.is_active
110 def toggleAction(self):
111 if config.SleepTimer.action.value == "shutdown":
112 config.SleepTimer.action.value = "standby"
113 elif config.SleepTimer.action.value == "standby":
114 config.SleepTimer.action.value = "shutdown"
118 config.SleepTimer.ask.value = not config.SleepTimer.ask.value