X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/0dbb36049c5f14bbabc4596448dc148f108a2137..b5d77f1a7b719fccfa19561a5a07ea8de51f42a4:/SleepTimer.py diff --git a/SleepTimer.py b/SleepTimer.py index 891cd258..221e8f0b 100644 --- a/SleepTimer.py +++ b/SleepTimer.py @@ -9,6 +9,10 @@ from Components.config import config, ConfigYesNo, ConfigSelection, ConfigSubsec 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)) @@ -45,29 +49,26 @@ class SleepTimerEntry(timer.TimerEntry): if answer is not None: if answer and not Screens.Standby.inStandby: Notifications.AddNotification(Screens.Standby.Standby) - + 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 - + def setSleepTime(self, sleeptime): self.clear() self.addTimerEntry(SleepTimerEntry(time.time() + 60 * sleeptime)) def clear(self): self.timer_list = [] - + def getCurrentSleepTime(self): - if (self.getNextRecordingTime() == -1): - return self.defaultTime - return int(math.ceil((self.getNextRecordingTime() - time.time()) / 60)) + llen = len(self.timer_list) + idx = 0 + while idx < llen: + timer = self.timer_list[idx] + return int(math.ceil((timer.begin - time.time()) / 60)) + return self.defaultTime def isActive(self): return len(self.timer_list) > 0 - - \ No newline at end of file