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 8e3bf7d..2fa539b 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 dfafc11..5aa1cd7 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 58321ac..e96a034 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 217f334..7c06d79 100644 (file)
@@ -41,7 +41,7 @@ class Standby(Screen):
                self["actions"] = ActionMap( [ "StandbyActions" ],
                {
                        "power": self.Power
-               })
+               }, -1)
 
                #mute adc
                self.setMute()
index 41ce9c8..caad520 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()