[node-patches] Change in ovirt-node[master]: ui: Allow hotkey control
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Thu Feb 28 18:12:51 UTC 2013
Fabian Deutsch has uploaded a new change for review.
Change subject: ui: Allow hotkey control
......................................................................
ui: Allow hotkey control
It can now be controlled how to handle hotkey callbacks.
Additionally this new functionality is now used to disable hotkeys when
the screen is locked.
rhbz#911680
Change-Id: I8e03dc250838a8737748a065f64cad5c5244bb24
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/setup/status_page.py
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/urwid_builder.py
3 files changed, 23 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/41/12541/1
diff --git a/scripts/tui/src/ovirt/node/setup/status_page.py b/scripts/tui/src/ovirt/node/setup/status_page.py
index 3be1f81..43139fc 100644
--- a/scripts/tui/src/ovirt/node/setup/status_page.py
+++ b/scripts/tui/src/ovirt/node/setup/status_page.py
@@ -124,12 +124,14 @@
if "action.lock" in changes:
self.logger.info("Locking screen")
self._lock_dialog = LockDialog()
+ self.application.ui.hotkeys_enabled(False)
return self._lock_dialog
elif "action.unlock" in changes and "password" in changes:
self.logger.info("UnLocking screen")
pam = security.PAM()
if pam.authenticate(os.getlogin(), changes["password"]):
self._lock_dialog.close()
+ self.application.ui.hotkeys_enabled(True)
elif "action.logoff" in changes:
self.logger.info("Logging off")
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index be8dda6..0832f04 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -456,6 +456,8 @@
application = None
+ __hotkeys_enabled = True
+
def __init__(self, path, application):
super(Window, self).__init__(path=path)
self.logger.info("Creating UI for application '%s'" % application)
@@ -476,8 +478,26 @@
"already registered: %s" % title)
self._plugins[title] = plugin
+ def hotkeys_enabled(self, new_value=None):
+ """Disable all attached hotkey callbacks
+
+ Args:
+ new_value: If hotkeys shall be enabled or disabled
+
+ Returns:
+ If the hotkeys are enabled or disabled
+ """
+ if new_value in [True, False]:
+ self.__hotkeys_enabled = new_value
+ return self.__hotkeys_enabled
+
def register_hotkey(self, hotkey, cb):
"""Register a hotkey
+
+ Args:
+ hotkeys: The key combination (very vague ...) triggering the
+ callback
+ cb: The callback to be called
"""
if type(hotkey) is str:
hotkey = [hotkey]
diff --git a/scripts/tui/src/ovirt/node/ui/urwid_builder.py b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
index 7645409..31671f8 100644
--- a/scripts/tui/src/ovirt/node/ui/urwid_builder.py
+++ b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
@@ -500,7 +500,7 @@
self.close_topmost_dialog()
return
- if key in self._hotkeys.keys():
+ if self.hotkeys_enabled() and key in self._hotkeys.keys():
self.logger.debug("Running hotkeys: %s" % key)
self._hotkeys[key]()
--
To view, visit http://gerrit.ovirt.org/12541
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e03dc250838a8737748a065f64cad5c5244bb24
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list