make power key handling global (so that standby/deep standby should work everywhere...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 27 Mar 2006 20:03:33 +0000 (20:03 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 27 Mar 2006 20:03:33 +0000 (20:03 +0000)
data/keymap.xml
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Standby.py
mytest.py

index 8e3bf7da0c906f6076aa9fb6b2f96e00285b4827..2fa539b826042e5726aef1d8ec8e268398e83371 100644 (file)
                <key id="KEY_VOLUMEUP" mapto="volumeUp" flags="mr" />
                <key id="KEY_VOLUMEDOWN" mapto="volumeDown" flags="mr" />
                <key id="KEY_MUTE" mapto="volumeMute" flags="mr" />
+               <key id="KEY_POWER" mapto="powerdown" flags="m" />
+               <key id="KEY_POWER" mapto="powerup" flags="b" />
        </map>
        
        <map context="PowerKeyActions">
index dfafc1161d2d105aed5b37b5cf21012815521635..5aa1cd70a40e467776aa1feb0a12c7699eed10c9 100644 (file)
@@ -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, \
index 58321ac60e4c2b931d823c53a276532b0050b485..e96a034d2dbc576fe4c694ae5627ea956e1aafb9 100644 (file)
@@ -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):
index 217f334c689e33c6cd0951c0b2d9c353c55a2567..7c06d79e4f0a1cde2d2db16ce9bf45137eccab09 100644 (file)
@@ -41,7 +41,7 @@ class Standby(Screen):
                self["actions"] = ActionMap( [ "StandbyActions" ],
                {
                        "power": self.Power
-               })
+               }, -1)
 
                #mute adc
                self.setMute()
index 41ce9c84c9038fe1329b683781063997b69b1a5b..caad52068d55f7dd3d9b2ea3e7a7e070b64b1e6a 100644 (file)
--- 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()