Another attempt to fix keybindings.
This commit is contained in:
parent
9e66f0ac98
commit
c03812eb05
@ -211,6 +211,7 @@ class APIHelper:
|
||||
self.description = description
|
||||
|
||||
def __call__(self, script, inputEvent):
|
||||
debug.printMessage(debug.LEVEL_INFO, f"Calling handler for {description}", True)
|
||||
return self.function(script, inputEvent)
|
||||
|
||||
handler = GestureHandler(function, name)
|
||||
@ -239,16 +240,17 @@ class APIHelper:
|
||||
if bindings:
|
||||
bindings.add(binding)
|
||||
debug.printMessage(debug.LEVEL_INFO,
|
||||
f"Added binding {binding} to active script {cthulhu_state.activeScript}", True)
|
||||
f"Added binding {binding.keysymstring} to active script {cthulhu_state.activeScript}", True)
|
||||
except Exception as e:
|
||||
debug.printMessage(debug.LEVEL_WARNING,
|
||||
f"Failed to add binding to active script: {e}", True)
|
||||
|
||||
return binding
|
||||
|
||||
else:
|
||||
debug.printMessage(debug.LEVEL_WARNING, f"Gesture doesn't use Cthulhu modifier: {gestureString}", True)
|
||||
return None
|
||||
|
||||
|
||||
def unregisterShortcut(self, binding, contextName=None):
|
||||
"""Unregister a previously registered shortcut.
|
||||
|
||||
|
@ -23,5 +23,5 @@
|
||||
# Fork of Orca Screen Reader (GNOME)
|
||||
# Original source: https://gitlab.gnome.org/GNOME/orca
|
||||
|
||||
version = "2025.04.04"
|
||||
version = "2025.04.05"
|
||||
codeName = "testing"
|
||||
|
@ -318,6 +318,24 @@ class PluginSystemManager:
|
||||
inactive_plugins = [p.get_module_name() for p in self.plugins if not p.loaded]
|
||||
logger.info(f"Inactive plugins after sync: {inactive_plugins}")
|
||||
|
||||
def syncPluginBindings(self, plugin_instance):
|
||||
"""Ensure any bindings registered by this plugin are synced to scripts."""
|
||||
logger.info(f"Syncing bindings for plugin: {plugin_instance.name}")
|
||||
|
||||
# Get the API helper to resync bindings
|
||||
try:
|
||||
api_helper = self.getApp().getAPIHelper()
|
||||
if api_helper:
|
||||
# Force a resync of all bindings
|
||||
from . import cthulhu_state
|
||||
if cthulhu_state.activeScript:
|
||||
logger.info(f"Forcing binding sync to active script: {cthulhu_state.activeScript}")
|
||||
api_helper._syncBindingsWithScript(cthulhu_state.activeScript)
|
||||
except Exception as e:
|
||||
logger.error(f"Error syncing plugin bindings: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
def loadPlugin(self, pluginInfo):
|
||||
"""Load a plugin."""
|
||||
# Skip if pluggy is not available
|
||||
@ -405,6 +423,7 @@ class PluginSystemManager:
|
||||
try:
|
||||
logger.info(f"Activating plugin: {module_name}")
|
||||
self.plugin_manager.hook.activate(plugin=plugin_instance)
|
||||
self.syncPluginBindings(plugin_instance)
|
||||
except Exception as e:
|
||||
logger.error(f"Error activating plugin {module_name}: {e}")
|
||||
import traceback
|
||||
|
@ -58,41 +58,17 @@ class Clipboard(Plugin):
|
||||
|
||||
logger.info("Activating Clipboard plugin")
|
||||
try:
|
||||
# Register keyboard shortcut
|
||||
self.registerGestureByString(self.speakClipboard, _('clipboard'), 'kb:cthulhu+shift+c')
|
||||
logger.debug("Registered shortcut for clipboard")
|
||||
except Exception as e:
|
||||
logger.error(f"Error activating Clipboard plugin: {e}")
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def deactivate(self, plugin=None):
|
||||
"""Deactivate the plugin."""
|
||||
# Skip if this deactivation call isn't for us
|
||||
if plugin is not None and plugin is not self:
|
||||
return
|
||||
|
||||
logger.info("Deactivating Clipboard plugin")
|
||||
try:
|
||||
# Unregister keyboard shortcut
|
||||
if self.app:
|
||||
api_helper = self.app.getAPIHelper()
|
||||
if api_helper and hasattr(api_helper, 'unregisterShortcut'):
|
||||
api_helper.unregisterShortcut('kb:cthulhu+shift+c')
|
||||
logger.debug("Unregistered clipboard shortcut")
|
||||
except Exception as e:
|
||||
logger.error(f"Error deactivating Clipboard plugin: {e}")
|
||||
"""Activate the plugin."""
|
||||
# Skip if this activation call isn't for us
|
||||
if plugin is not None and plugin is not self:
|
||||
return
|
||||
|
||||
logger.info("Activating Clipboard plugin")
|
||||
try:
|
||||
# Register keyboard shortcut
|
||||
self.registerGestureByString(self.speakClipboard, _('clipboard'), 'kb:cthulhu+shift+c')
|
||||
logger.debug("Registered shortcut for clipboard")
|
||||
# Register keyboard shortcut with more debugging
|
||||
logger.info("About to register the clipboard shortcut")
|
||||
binding = self.registerGestureByString(self.speakClipboard, _('clipboard'), 'kb:cthulhu+shift+c')
|
||||
if binding:
|
||||
logger.info(f"Successfully registered clipboard shortcut, binding: {binding}")
|
||||
else:
|
||||
logger.error("Failed to register clipboard shortcut")
|
||||
except Exception as e:
|
||||
logger.error(f"Error activating Clipboard plugin: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def deactivate(self, plugin=None):
|
||||
@ -112,6 +88,7 @@ class Clipboard(Plugin):
|
||||
def speakClipboard(self, script=None, inputEvent=None):
|
||||
"""Present the contents of the clipboard."""
|
||||
try:
|
||||
logger.info("speakClipboard called! InputEvent: %s", inputEvent)
|
||||
message = self.getClipboard()
|
||||
|
||||
state = self.app.getDynamicApiManager().getAPI('CthulhuState')
|
||||
@ -124,6 +101,8 @@ class Clipboard(Plugin):
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Error in speakClipboard: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
def getClipboard(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user