Browse files

simplify enabling the sleep timer by defaulting the action of the sleep

timer editor to "enable" and restoring the last setting for the sleep
time
  • Loading branch information...
1 parent 34a0cb1 commit 830d79376a0bc82a7c50930c5dc7d48b35bb8a21 Stefan Pluecken committed Jun 23, 2008
Showing with 42 additions and 22 deletions.
  1. +4 −3 SleepTimer.py
  2. +12 −11 data/skin_default.xml
  3. +26 −8 lib/python/Screens/SleepTimerEdit.py
View
7 SleepTimer.py
@@ -9,6 +9,10 @@
from Screens.MessageBox import MessageBox
import Screens.Standby
+config.SleepTimer = ConfigSubsection()
+config.SleepTimer.ask = ConfigYesNo(default = True)
+config.SleepTimer.action = ConfigSelection(default = "shutdown", choices = [("shutdown", _("shutdown")), ("standby", _("standby"))])
+
class SleepTimerEntry(timer.TimerEntry):
def __init__(self, begin):
timer.TimerEntry.__init__(self, int(begin), int(begin))
@@ -48,9 +52,6 @@ def standby(self, answer):
class SleepTimer(timer.Timer):
def __init__(self):
- config.SleepTimer = ConfigSubsection()
- config.SleepTimer.ask = ConfigYesNo(default = True)
- config.SleepTimer.action = ConfigSelection(default = "shutdown", choices = [("shutdown", _("shutdown")), ("standby", _("standby"))])
timer.Timer.__init__(self)
self.defaultTime = 30
View
23 data/skin_default.xml
@@ -848,15 +848,16 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
<widget name="Preview" position="305,45" size="280,210" alphatest="on" />
</screen>
<!-- Sleeptimer edit -->
- <screen name="SleepTimerEdit" position="110,215" size="500,160" title="Sleep Timer">
- <widget name="red" pixmap="skin_default/buttons/button_red.png" position="10,48" size="12,12" alphatest="on" />
- <widget name="green" pixmap="skin_default/buttons/button_green.png" position="10,88" size="12,12" alphatest="on" />
- <widget name="yellow" pixmap="skin_default/buttons/button_yellow.png" position="10,128" size="12,12" alphatest="on" />
+ <screen name="SleepTimerEdit" position="110,215" size="500,200" title="Sleep Timer">
+ <widget name="current_status" position="40,40" size="400,30" valign="center" font="Regular;20" />
+ <widget name="red" pixmap="skin_default/buttons/button_red.png" position="10,88" size="12,12" alphatest="on" />
+ <widget name="green" pixmap="skin_default/buttons/button_green.png" position="10,128" size="12,12" alphatest="on" />
+ <widget name="yellow" pixmap="skin_default/buttons/button_yellow.png" position="10,168" size="12,12" alphatest="on" />
<widget name="blue" pixmap="skin_default/buttons/button_blue.png" position="10,168" size="12,12" alphatest="on" />
- <widget name="red_text" position="40,40" size="400,30" valign="center" font="Regular;20" />
- <widget name="green_text" position="40,80" size="400,30" valign="center" font="Regular;20" />
- <widget name="yellow_text" position="40,120" size="400,30" valign="center" font="Regular;20" />
- <widget name="blue_text" position="40,160" size="400,30" valign="center" font="Regular;20" />
+ <widget name="red_text" position="40,80" size="400,30" valign="center" font="Regular;20" />
+ <widget name="green_text" position="40,120" size="400,30" valign="center" font="Regular;20" />
+ <widget name="yellow_text" position="40,160" size="400,30" valign="center" font="Regular;20" />
+ <widget name="blue_text" position="40,200" size="400,30" valign="center" font="Regular;20" />
<widget name="pretext" position="15,10" size="235,25" font="Regular;19" />
<widget name="input" position="260,10" size="40,25" font="Regular;19" />
<widget name="aftertext" position="305,10" size="100,25" font="Regular;19" />
@@ -963,9 +964,9 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
- <widget name="timer1" position="10,45" size="280,80" scrollbarMode="showOnDemand" />
- <widget name="timer2" position="310,45" size="280,80" scrollbarMode="showOnDemand" />
- <widget name="list" position="0,140" size="250,290" scrollbarMode="showOnDemand" />
+ <widget name="timer1" position="10,45" size="280,220" scrollbarMode="showOnDemand" />
+ <widget name="timer2" position="310,45" size="280,220" scrollbarMode="showOnDemand" />
+ <widget name="list" position="0,280" size="500,290" scrollbarMode="showOnDemand" />
</screen>
<!-- Timer Selection -->
<screen name="TimerSelection" position="90,95" size="560,430" title="Timer selection">
View
34 lib/python/Screens/SleepTimerEdit.py
@@ -4,7 +4,10 @@
from Components.Input import Input
from Components.Label import Label
from Components.Pixmap import Pixmap
-from Components.config import config
+from Components.config import config, ConfigInteger
+from SleepTimer import SleepTimer
+
+config.SleepTimer.defaulttime = ConfigInteger(default = 30)
class SleepTimerEdit(Screen):
def __init__(self, session):
@@ -18,11 +21,24 @@ def __init__(self, session):
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", "TextEntryActions", "KeyboardInputActions"],
@@ -53,10 +69,10 @@ def __init__(self, session):
}, -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"))
@@ -75,8 +91,10 @@ def cancel(self):
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()
@@ -104,7 +122,7 @@ 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):

0 comments on commit 830d793

Please sign in to comment.