+ return dlg
+
+ def close(self, screen, *retval):
+ if not self.in_exec:
+ print "close after exec!"
+ return
+
+ # be sure that the close is for the right dialog!
+ # if it's not, you probably closed after another dialog
+ # was opened. this can happen if you open a dialog
+ # onExecBegin, and forget to do this only once.
+ # after close of the top dialog, the underlying will
+ # gain focus again (for a short time), thus triggering
+ # the onExec, which opens the dialog again, closing the loop.
+ assert screen == self.current_dialog
+
+ self.current_dialog.returnValue = retval
+ self.delay_timer.start(0, 1)
+ self.execEnd()
+
+ def pushSummary(self):
+ if self.summary is not None:
+ self.summary.hide()
+ self.summary_stack.append(self.summary)
+ self.summary = None
+
+ def popSummary(self):
+ if self.summary is not None:
+ self.summary.doClose()
+ self.summary = self.summary_stack.pop()
+ if self.summary is not None:
+ self.summary.show()
+
+profile("Standby,PowerKey")
+import Screens.Standby
+from Screens.Menu import MainMenu, mdom
+import xml.dom.minidom
+from GlobalActions import globalActionMap
+
+class PowerKey:
+ """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
+
+ def __init__(self, session):
+ self.session = session
+ globalActionMap.actions["power_down"]=self.powerdown
+ globalActionMap.actions["power_up"]=self.powerup
+ globalActionMap.actions["power_long"]=self.powerlong
+ globalActionMap.actions["deepstandby"]=self.shutdown # frontpanel long power button press
+ self.standbyblocked = 1
+
+ def MenuClosed(self, *val):
+ self.session.infobar = None
+
+ def shutdown(self):
+ print "PowerOff - Now!"
+ if not Screens.Standby.inTryQuitMainloop and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
+ self.session.open(Screens.Standby.TryQuitMainloop, 1)
+
+ def powerlong(self):
+ self.standbyblocked = 1
+ action = config.usage.on_long_powerpress.value
+ if action == "shutdown":
+ self.shutdown()
+ 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, x, x.childNodes)
+ menu_screen.setTitle(_("Standby / Restart"))
+ return