diff options
| -rw-r--r-- | data/keymap.xml | 5 | ||||
| -rw-r--r-- | data/setup.xml | 1 | ||||
| -rw-r--r-- | lib/python/Components/UsageConfig.py | 4 | ||||
| -rw-r--r-- | mytest.py | 51 |
4 files changed, 41 insertions, 20 deletions
diff --git a/data/keymap.xml b/data/keymap.xml index 3b2185da..94e19e15 100644 --- a/data/keymap.xml +++ b/data/keymap.xml @@ -187,8 +187,9 @@ <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" /> + <key id="KEY_POWER" mapto="power_down" flags="m" /> + <key id="KEY_POWER" mapto="power_up" flags="b" /> + <key id="KEY_POWER" mapto="power_long" flags="l" /> </map> <map context="PowerKeyActions"> diff --git a/data/setup.xml b/data/setup.xml index 3648420a..894a2b86 100644 --- a/data/setup.xml +++ b/data/setup.xml @@ -24,6 +24,7 @@ <item level="1" text="Enable multiple bouquets">config.usage.multibouquet</item> <item level="1" text="Change bouquets in quickzap">config.usage.quickzap_bouquet_change</item> <item level="1" text="Alternative radio mode">config.usage.e1like_radio_mode</item> + <item level="1" text="Action on long powerbutton press">config.usage.on_long_powerpress</item> <item level="0" text="Infobar timeout">config.usage.infobar_timeout</item> <item level="1" text="12V output">config.usage.output_12V</item> <item level="2" text="Show infobar on channel change">config.usage.show_infobar_on_zap</item> diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index 581e7cea..b3658018 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -34,6 +34,10 @@ def InitUsageConfig(): ("intermediate", _("Intermediate")), ("expert", _("Expert")) ]) + config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [ + ("show_menu", _("show shutdown menu")), + ("shutdown", _("immediate shutdown")) ] ) + def setHDDStandby(configElement): os.system("hdparm -S" + configElement.value + " /dev/ide/host0/bus0/target0/lun0/disc") config.usage.hdd_standby.addNotifier(setHDDStandby) @@ -393,36 +393,51 @@ class VolumeControl: self.volumeDialog.setValue(vol) import Screens.Standby +from Screens.Menu import MainMenu, mdom +import xml.dom.minidom 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 + globalActionMap.actions["power_down"]=self.powerdown + globalActionMap.actions["power_up"]=self.powerup + globalActionMap.actions["power_long"]=self.powerlong self.standbyblocked = 1 -# 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!" - if not Screens.Standby.inTryQuitMainloop: - self.session.open(Screens.Standby.TryQuitMainloop, 1) + + def MenuClosed(self, *val): + self.session.infobar = None + + def powerlong(self): + self.standbyblocked = 1 + action = config.usage.on_long_powerpress.value + if action == "shutdown": + print "PowerOff - Now!" + if not Screens.Standby.inTryQuitMainloop: + self.session.open(Screens.Standby.TryQuitMainloop, 1) + elif action == "show_menu": + print "Show shutdown Menu" + menu = mdom.childNodes[0] + for x in menu.childNodes: + if x.nodeType != xml.dom.minidom.Element.nodeType: + continue + elif x.tagName == 'menu': + for y in x.childNodes: + if y.nodeType != xml.dom.minidom.Element.nodeType: + continue + elif y.tagName == 'id': + id = y.getAttribute("val") + if id and id == "shutdown": + self.session.infobar = self + menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, menu, x.childNodes) + menu_screen.setTitle(_("Standby Menu")) + return 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() |
