From 00fbcef4bf8b85dc3f5ed0573648365fbb6f8283 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 9 Dec 2013 08:57:31 +0000 Subject: [PATCH] ensure we get a reference to the keyboard instance (when setting up the client reference) so that we can use the keyboard menu entries (swapkeys and numlock) git-svn-id: https://xpra.org/svn/Xpra/trunk@4897 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/platform/darwin/osx_menu.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/xpra/platform/darwin/osx_menu.py b/src/xpra/platform/darwin/osx_menu.py index f9fb32e76e..00385e3b3d 100644 --- a/src/xpra/platform/darwin/osx_menu.py +++ b/src/xpra/platform/darwin/osx_menu.py @@ -25,7 +25,7 @@ def getOSXMenuHelper(client=None): if _OSXMenuHelper is None: _OSXMenuHelper = OSXMenuHelper(client) elif client is not None: - _OSXMenuHelper.client = client + _OSXMenuHelper.set_client(client) return _OSXMenuHelper @@ -44,6 +44,12 @@ def __init__(self, client=None): self.hidden_window = None self.keyboard = None self.menus = {} + self.set_client(client) + + def set_client(self, client): + self.client = client + if client and client.keyboard_helper: + self.keyboard = client.keyboard_helper.keyboard def build(self): debug("OSXMenuHelper.build()") @@ -130,7 +136,11 @@ def numlock_toggled(*args): self.numlock_menuitem.set_active(True) def set_numlock_menuitem(*args): if self.keyboard: + debug("set_numlock_menuitem(%s) num_lock_state=%s", args, self.keyboard.num_lock_state) self.numlock_menuitem.set_active(self.keyboard.num_lock_state) + else: + debug("set_numlock_menuitem(%s) no keyboard!", args) + self.swapkeys_menuitem.set_sensitive(False) self.client.connect("handshake-complete", set_numlock_menuitem) return self.numlock_menuitem