8 Commits

Author SHA1 Message Date
Storm Dragon
d36b664319 Merge branch 'testing'
Plugins are in a much better state now, mostly working. The exception is, plugins that create a keyboard shortcut don't actually bind the shortcut. That one is turning out to be a lot harder to fix than I originally thought.
2025-04-05 16:32:17 -04:00
Storm Dragon
02be96aa69 Try to fix clipboard and simple plugins. 2025-04-04 18:04:58 -04:00
Storm Dragon
3f7d60763d Merge branch 'testing'
Plugins are currently broken as Cthulhu moves over to pluggy. Libpeas and pygobject no longer play nicely together after latest updates. I really did not want to make a new release yet, because it is not ready, but a screen reader that at least reads instead of crashing at launch is better than nothing.
2025-04-03 20:17:14 -04:00
Storm Dragon
6bbf3d0e67 Merge branch 'testing' latest changes merged. 2024-12-22 19:04:57 -05:00
Storm Dragon
cbe3424e29 Fix the version.py file in preparation for merging. 2024-12-22 19:04:39 -05:00
Storm Dragon
327ad99e49 Preparing for stable tag release. 2024-12-18 19:49:25 -05:00
Storm Dragon
c46cf1c939 Merge branch 'testing' fixed preferences GUI. 2024-12-18 19:45:59 -05:00
Storm Dragon
a97bb30ed3 New version system merged. 2024-12-18 11:42:52 -05:00
2 changed files with 86 additions and 39 deletions

View File

@@ -20,6 +20,8 @@
# Free Software Foundation, Inc., Franklin Street, Fifth Floor, # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA 02110-1301 USA. # Boston MA 02110-1301 USA.
# #
# Fork of Orca Screen Reader (GNOME)
# Original source: https://gitlab.gnome.org/GNOME/orca
"""Clipboard plugin for Cthulhu.""" """Clipboard plugin for Cthulhu."""
@@ -62,6 +64,36 @@ class Clipboard(Plugin):
except Exception as e: except Exception as e:
logger.error(f"Error activating Clipboard plugin: {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 @cthulhu_hookimpl
def deactivate(self, plugin=None): def deactivate(self, plugin=None):
"""Deactivate the plugin.""" """Deactivate the plugin."""

View File

@@ -1,9 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# #
# Copyright (c) 2024 Stormux # 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 # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@@ -20,8 +17,6 @@
# Free Software Foundation, Inc., Franklin Street, Fifth Floor, # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA 02110-1301 USA. # Boston MA 02110-1301 USA.
# #
# Fork of Orca Screen Reader (GNOME)
# Original source: https://gitlab.gnome.org/GNOME/orca
"""Simple Plugin System for Cthulhu.""" """Simple Plugin System for Cthulhu."""
@@ -321,13 +316,24 @@ class SimplePluginSystem(Plugin):
This is a compatibility wrapper for the new plugin system. This is a compatibility wrapper for the new plugin system.
""" """
try: try:
# Try to get the InputEventManager and register the shortcut if self.app:
input_manager = self.app.getDynamicApiManager().getAPI('InputEventManager') api_helper = self.app.getAPIHelper()
if input_manager: if api_helper:
input_manager.registerGestureByString(function, description, shortcut) api_helper.registerGestureByString(
logger.debug(f"Registered shortcut {shortcut} for {description}") 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 APIHelper")
else: else:
logger.error("Could not get InputEventManager API") logger.error("No app reference available")
except Exception as e: except Exception as e:
logger.error(f"Error registering shortcut {shortcut}: {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. This is a compatibility wrapper for the new plugin system.
""" """
try: try:
# Try to get the InputEventManager and unregister the shortcut if self.app:
input_manager = self.app.getDynamicApiManager().getAPI('InputEventManager') api_helper = self.app.getAPIHelper()
if input_manager: if api_helper and hasattr(api_helper, 'unregisterShortcut'):
input_manager.unregisterGestureByString(shortcut) api_helper.unregisterShortcut(shortcut)
logger.debug(f"Unregistered shortcut {shortcut}") logger.debug(f"Unregistered shortcut {shortcut}")
return True
else:
logger.error("Could not get APIHelper or unregisterShortcut method")
else: else:
logger.error("Could not get InputEventManager API") logger.error("No app reference available")
except Exception as e: except Exception as e:
logger.error(f"Error unregistering shortcut {shortcut}: {e}") logger.error(f"Error unregistering shortcut {shortcut}: {e}")
@@ -352,10 +361,16 @@ class SimplePluginSystem(Plugin):
if not self.loaded: if not self.loaded:
try: try:
logger.info(f"Loading plugins from {self.plugin_repo}") 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: 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.initSettings()
currPluginSetting = self.getPluginSettings(currplugin, currPluginSetting) currPluginSetting = self.getPluginSettings(currplugin, currPluginSetting)