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"],
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 "disableTimer": self.disableTimer,
45 "toggleAction": self.toggleAction,
46 "toggleAsk": self.toggleAsk
49 def updateColors(self):
51 self["red_text"].setText(_("Timer status:") + " " + _("Enabled"))
53 self["red_text"].setText(_("Timer status:") + " " + _("Disabled"))
55 if config.SleepTimer.action.value == "shutdown":
56 self["green_text"].setText(_("Sleep timer action:") + " " + _("Deep Standby"))
57 elif config.SleepTimer.action.value == "standby":
58 self["green_text"].setText(_("Sleep timer action:") + " " + _("Standby"))
60 if config.SleepTimer.ask.value:
61 self["yellow_text"].setText(_("Ask before shutdown:") + " " + _("yes"))
63 self["yellow_text"].setText(_("Ask before shutdown:") + " " + _("no"))
64 self["blue_text"].setText(_("Settings"))
67 config.SleepTimer.ask.cancel()
68 config.SleepTimer.action.cancel()
73 self.session.nav.SleepTimer.setSleepTime(int(self["input"].getText()))
74 self.session.openWithCallback(self.close, MessageBox, _("The sleep timer has been activated."), MessageBox.TYPE_INFO)
76 self.session.nav.SleepTimer.clear()
77 self.session.openWithCallback(self.close, MessageBox, _("The sleep timer has been disabled."), MessageBox.TYPE_INFO)
79 def keyNumberGlobal(self, number):
80 self["input"].number(number)
85 def selectRight(self):
88 def disableTimer(self):
89 self.is_active = not self.is_active
92 def toggleAction(self):
93 if config.SleepTimer.action.value == "shutdown":
94 config.SleepTimer.action.value = "standby"
95 elif config.SleepTimer.action.value == "standby":
96 config.SleepTimer.action.value = "shutdown"
100 config.SleepTimer.ask.value = not config.SleepTimer.ask.value