Try to fix clipboard and simple plugins.
This commit is contained in:
parent
48575ab6cd
commit
02be96aa69
@ -20,6 +20,8 @@
|
||||
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
|
||||
# Boston MA 02110-1301 USA.
|
||||
#
|
||||
# Fork of Orca Screen Reader (GNOME)
|
||||
# Original source: https://gitlab.gnome.org/GNOME/orca
|
||||
|
||||
"""Clipboard plugin for Cthulhu."""
|
||||
|
||||
@ -62,6 +64,36 @@ class Clipboard(Plugin):
|
||||
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")
|
||||
except Exception as e:
|
||||
logger.error(f"Error activating Clipboard plugin: {e}")
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def deactivate(self, plugin=None):
|
||||
"""Deactivate the plugin."""
|
||||
|
@ -1,9 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2024 Stormux
|
||||
# Copyright (c) 2010-2012 The Orca Team
|
||||
# Copyright (c) 2012 Igalia, S.L.
|
||||
# Copyright (c) 2005-2010 Sun Microsystems Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,8 +17,6 @@
|
||||
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
|
||||
# Boston MA 02110-1301 USA.
|
||||
#
|
||||
# Fork of Orca Screen Reader (GNOME)
|
||||
# Original source: https://gitlab.gnome.org/GNOME/orca
|
||||
|
||||
"""Simple Plugin System for Cthulhu."""
|
||||
|
||||
@ -321,13 +316,24 @@ class SimplePluginSystem(Plugin):
|
||||
This is a compatibility wrapper for the new plugin system.
|
||||
"""
|
||||
try:
|
||||
# Try to get the InputEventManager and register the shortcut
|
||||
input_manager = self.app.getDynamicApiManager().getAPI('InputEventManager')
|
||||
if input_manager:
|
||||
input_manager.registerGestureByString(function, description, shortcut)
|
||||
if self.app:
|
||||
api_helper = self.app.getAPIHelper()
|
||||
if api_helper:
|
||||
api_helper.registerGestureByString(
|
||||
function,
|
||||
description,
|
||||
shortcut,
|
||||
'default',
|
||||
'cthulhu',
|
||||
True,
|
||||
contextName=self.module_name
|
||||
)
|
||||
logger.debug(f"Registered shortcut {shortcut} for {description}")
|
||||
return True
|
||||
else:
|
||||
logger.error("Could not get InputEventManager API")
|
||||
logger.error("Could not get APIHelper")
|
||||
else:
|
||||
logger.error("No app reference available")
|
||||
except Exception as e:
|
||||
logger.error(f"Error registering shortcut {shortcut}: {e}")
|
||||
|
||||
@ -337,13 +343,16 @@ class SimplePluginSystem(Plugin):
|
||||
This is a compatibility wrapper for the new plugin system.
|
||||
"""
|
||||
try:
|
||||
# Try to get the InputEventManager and unregister the shortcut
|
||||
input_manager = self.app.getDynamicApiManager().getAPI('InputEventManager')
|
||||
if input_manager:
|
||||
input_manager.unregisterGestureByString(shortcut)
|
||||
if self.app:
|
||||
api_helper = self.app.getAPIHelper()
|
||||
if api_helper and hasattr(api_helper, 'unregisterShortcut'):
|
||||
api_helper.unregisterShortcut(shortcut)
|
||||
logger.debug(f"Unregistered shortcut {shortcut}")
|
||||
return True
|
||||
else:
|
||||
logger.error("Could not get InputEventManager API")
|
||||
logger.error("Could not get APIHelper or unregisterShortcut method")
|
||||
else:
|
||||
logger.error("No app reference available")
|
||||
except Exception as e:
|
||||
logger.error(f"Error unregistering shortcut {shortcut}: {e}")
|
||||
|
||||
@ -352,10 +361,16 @@ class SimplePluginSystem(Plugin):
|
||||
if not self.loaded:
|
||||
try:
|
||||
logger.info(f"Loading plugins from {self.plugin_repo}")
|
||||
self.plugin_list = glob.glob(self.plugin_repo + '*')
|
||||
plugin_files = glob.glob(self.plugin_repo + '*')
|
||||
self.plugin_list = [] # Reset the plugin list to avoid confusion
|
||||
|
||||
for currplugin in self.plugin_list:
|
||||
for currplugin in plugin_files:
|
||||
try:
|
||||
# Ensure currplugin is a valid path string
|
||||
if not isinstance(currplugin, (str, bytes, os.PathLike)):
|
||||
logger.error(f"Invalid plugin path: {type(currplugin)}")
|
||||
continue
|
||||
|
||||
currPluginSetting = self.initSettings()
|
||||
currPluginSetting = self.getPluginSettings(currplugin, currPluginSetting)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user