From 13f110ab344606e0efb8a89af4a622f76227f577 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Thu, 5 Jun 2025 13:50:36 -0400 Subject: [PATCH] Updated bindings code. --- src/cthulhu/scripts/default.py | 40 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/cthulhu/scripts/default.py b/src/cthulhu/scripts/default.py index 4360443..b754d18 100644 --- a/src/cthulhu/scripts/default.py +++ b/src/cthulhu/scripts/default.py @@ -412,28 +412,32 @@ class Script(script.Script): # Add plugin keybindings from APIHelper storage try: import cthulhu.cthulhu as cthulhu - api_helper = cthulhu.getCthulhu() - with open('/tmp/extension_bindings_debug.log', 'a') as f: - f.write(f"=== Checking for plugin bindings ===\n") - f.write(f"api_helper exists: {api_helper is not None}\n") - if api_helper: - f.write(f"api_helper has _gestureBindings: {hasattr(api_helper, '_gestureBindings')}\n") - if hasattr(api_helper, '_gestureBindings'): - f.write(f"_gestureBindings content: {api_helper._gestureBindings}\n") - f.write(f"Available contexts: {list(api_helper._gestureBindings.keys())}\n") - - if api_helper and hasattr(api_helper, '_gestureBindings'): + if hasattr(cthulhu, 'cthulhuApp') and cthulhu.cthulhuApp: + api_helper = cthulhu.cthulhuApp.getAPIHelper() with open('/tmp/extension_bindings_debug.log', 'a') as f: - f.write(f"=== Adding plugin bindings in getExtensionBindings() ===\n") + f.write(f"=== Checking for plugin bindings ===\n") + f.write(f"api_helper exists: {api_helper is not None}\n") + if api_helper: + f.write(f"api_helper has _gestureBindings: {hasattr(api_helper, '_gestureBindings')}\n") + if hasattr(api_helper, '_gestureBindings'): + f.write(f"_gestureBindings content: {api_helper._gestureBindings}\n") + f.write(f"Available contexts: {list(api_helper._gestureBindings.keys())}\n") - for context_name, context_bindings in api_helper._gestureBindings.items(): - for binding in context_bindings: - keyBindings.add(binding) - with open('/tmp/extension_bindings_debug.log', 'a') as f: - f.write(f"Added plugin binding: {binding.keysymstring} modifiers={binding.modifiers} desc={binding.handler.description}\n") + if api_helper and hasattr(api_helper, '_gestureBindings'): + with open('/tmp/extension_bindings_debug.log', 'a') as f: + f.write(f"=== Adding plugin bindings in getExtensionBindings() ===\n") + + for context_name, context_bindings in api_helper._gestureBindings.items(): + for binding in context_bindings: + keyBindings.add(binding) + with open('/tmp/extension_bindings_debug.log', 'a') as f: + f.write(f"Added plugin binding: {binding.keysymstring} modifiers={binding.modifiers} desc={binding.handler.description}\n") + else: + with open('/tmp/extension_bindings_debug.log', 'a') as f: + f.write(f"=== No plugin bindings available ===\n") else: with open('/tmp/extension_bindings_debug.log', 'a') as f: - f.write(f"=== No plugin bindings available ===\n") + f.write(f"=== cthulhuApp not available ===\n") except Exception as e: import cthulhu.debug as debug debug.printMessage(debug.LEVEL_WARNING, f"Failed to add plugin bindings: {e}", True)