From fe3e42f417c8c735bdfd6f57799a2247477a0fda Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 27 Mar 2006 20:03:33 +0000 Subject: [PATCH] make power key handling global (so that standby/deep standby should work everywhere now) --- data/keymap.xml | 2 ++ lib/python/Screens/InfoBar.py | 10 +++---- lib/python/Screens/InfoBarGenerics.py | 36 ----------------------- lib/python/Screens/Standby.py | 2 +- mytest.py | 42 +++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 42 deletions(-) diff --git a/data/keymap.xml b/data/keymap.xml index 8e3bf7da..2fa539b8 100644 --- a/data/keymap.xml +++ b/data/keymap.xml @@ -146,6 +146,8 @@ + + diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index dfafc116..5aa1cd70 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -12,7 +12,7 @@ from Components.ServicePosition import ServicePosition, ServicePositionGauge from Tools.Notifications import AddNotificationWithCallback from Screens.InfoBarGenerics import InfoBarShowHide, \ - InfoBarPowerKey, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \ + InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \ InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \ InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \ InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift, \ @@ -25,7 +25,7 @@ from enigma import * import time -class InfoBar(InfoBarShowHide, InfoBarPowerKey, +class InfoBar(InfoBarShowHide, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, @@ -42,7 +42,7 @@ class InfoBar(InfoBarShowHide, InfoBarPowerKey, }) for x in HelpableScreen, \ - InfoBarShowHide, InfoBarPowerKey, \ + InfoBarShowHide, \ InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \ InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \ InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \ @@ -66,7 +66,7 @@ class InfoBar(InfoBarShowHide, InfoBarPowerKey, if service is not None: self.session.open(MoviePlayer, service) -class MoviePlayer(InfoBarShowHide, InfoBarPowerKey, \ +class MoviePlayer(InfoBarShowHide, \ InfoBarMenu, \ InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications, InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, @@ -80,7 +80,7 @@ class MoviePlayer(InfoBarShowHide, InfoBarPowerKey, \ "leavePlayer": (self.leavePlayer, _("leave movie player...")) }) - for x in HelpableScreen, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, \ + for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \ InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \ InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \ InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \ diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 58321ac6..e96a034d 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -26,7 +26,6 @@ from Screens.EventView import EventViewEPGSelect, EventViewSimple from Screens.InputBox import InputBox from Screens.MessageBox import MessageBox from Screens.MinuteInput import MinuteInput -from Screens.Standby import Standby from ServiceReference import ServiceReference from Tools import Notifications @@ -166,41 +165,6 @@ class NumberZap(Screen): self.Timer.timeout.get().append(self.keyOK) self.Timer.start(3000, True) -class InfoBarPowerKey: - """ PowerKey stuff - handles the powerkey press and powerkey release actions""" - - def __init__(self): - self.powerKeyTimer = eTimer() - self.powerKeyTimer.timeout.get().append(self.powertimer) - self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions", - { - "powerdown": self.powerdown, - "powerup": self.powerup, - "discreteStandby": (self.standby, "Go standby"), - "discretePowerOff": (self.quit, "Go to deep standby"), - }) - - def powertimer(self): - print "PowerOff - Now!" - self.quit() - - def powerdown(self): - self.standbyblocked = 0 - self.powerKeyTimer.start(3000, True) - - def powerup(self): - self.powerKeyTimer.stop() - if self.standbyblocked == 0: - self.standbyblocked = 1 - self.standby() - - def standby(self): - self.session.open(Standby, self) - - def quit(self): - # halt - quitMainloop(1) - class InfoBarNumberZap: """ Handles an initial number for NumberZapping """ def __init__(self): diff --git a/lib/python/Screens/Standby.py b/lib/python/Screens/Standby.py index 217f334c..7c06d79e 100644 --- a/lib/python/Screens/Standby.py +++ b/lib/python/Screens/Standby.py @@ -41,7 +41,7 @@ class Standby(Screen): self["actions"] = ActionMap( [ "StandbyActions" ], { "power": self.Power - }) + }, -1) #mute adc self.setMute() diff --git a/mytest.py b/mytest.py index 41ce9c84..caad5206 100644 --- a/mytest.py +++ b/mytest.py @@ -311,6 +311,47 @@ class VolumeControl: else: self.muteDialog.hide() +from Screens.Standby import Standby + +class PowerKey: + """ PowerKey stuff - handles the powerkey press and powerkey release actions""" + + def __init__(self, session): + self.session = session + self.powerKeyTimer = eTimer() + self.powerKeyTimer.timeout.get().append(self.powertimer) + globalActionMap.actions["powerdown"]=self.powerdown + globalActionMap.actions["powerup"]=self.powerup + +# self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions", + #{ + #"powerdown": self.powerdown, + #"powerup": self.powerup, + #"discreteStandby": (self.standby, "Go standby"), + #"discretePowerOff": (self.quit, "Go to deep standby"), + #}) + + def powertimer(self): + print "PowerOff - Now!" + self.quit() + + def powerdown(self): + self.standbyblocked = 0 + self.powerKeyTimer.start(3000, True) + + def powerup(self): + self.powerKeyTimer.stop() + if self.standbyblocked == 0: + self.standbyblocked = 1 + self.standby() + + def standby(self): + self.session.open(Standby, self) + + def quit(self): + # halt + quitMainloop(1) + def runScreenTest(): plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) @@ -342,6 +383,7 @@ def runScreenTest(): CONNECT(keyPressedSignal(), session.keyEvent) vol = VolumeControl(session) + power = PowerKey(session) runReactor() -- 2.30.2