Still fighting with plugins.
This commit is contained in:
parent
987be0eee2
commit
bb1ff5c579
@ -90,3 +90,9 @@ class Plugin:
|
||||
contextName=self.module_name
|
||||
)
|
||||
return None
|
||||
|
||||
def connectSignal(self, signal_name, callback):
|
||||
"""Connect to an application signal."""
|
||||
if self.app and self.app.getSignalManager():
|
||||
return self.app.getSignalManager().connectSignal(signal_name, callback)
|
||||
return None
|
||||
|
@ -232,6 +232,7 @@ class PluginSystemManager:
|
||||
return self._active_plugins
|
||||
|
||||
def setActivePlugins(self, activePlugins):
|
||||
"""Set active plugins and sync their state."""
|
||||
logger.info(f"Setting active plugins: {activePlugins}")
|
||||
|
||||
# Make sure we have scanned for plugins first
|
||||
@ -242,13 +243,13 @@ class PluginSystemManager:
|
||||
# Create a clean list of valid active plugins
|
||||
available_plugins = [p.get_module_name() for p in self.plugins]
|
||||
valid_active_plugins = []
|
||||
|
||||
|
||||
for plugin_name in activePlugins:
|
||||
# Check for exact match first
|
||||
if plugin_name in available_plugins:
|
||||
valid_active_plugins.append(plugin_name)
|
||||
continue
|
||||
|
||||
|
||||
# Try case-insensitive match
|
||||
plugin_name_lower = plugin_name.lower()
|
||||
matched = False
|
||||
@ -262,7 +263,7 @@ class PluginSystemManager:
|
||||
|
||||
if not matched:
|
||||
logger.warning(f"Plugin '{plugin_name}' not found, skipping")
|
||||
|
||||
|
||||
# Only use valid plugins
|
||||
self._active_plugins = valid_active_plugins
|
||||
|
||||
|
@ -16,12 +16,12 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class HelloWorld(Plugin):
|
||||
"""Hello World plugin."""
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the plugin."""
|
||||
super().__init__(*args, **kwargs)
|
||||
logger.info("HelloWorld plugin initialized")
|
||||
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def activate(self, plugin=None):
|
||||
"""Activate the plugin."""
|
||||
@ -31,7 +31,7 @@ class HelloWorld(Plugin):
|
||||
|
||||
try:
|
||||
logger.info("Activating Hello World plugin")
|
||||
|
||||
|
||||
# Register our keyboard shortcut
|
||||
self.registerGestureByString(
|
||||
self.speakTest,
|
||||
@ -41,19 +41,19 @@ class HelloWorld(Plugin):
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error activating Hello World 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
|
||||
|
||||
|
||||
try:
|
||||
logger.info("Deactivating Hello World plugin")
|
||||
except Exception as e:
|
||||
logger.error(f"Error deactivating Hello World plugin: {e}")
|
||||
|
||||
|
||||
def speakTest(self, script=None, inputEvent=None):
|
||||
"""Speak a test message."""
|
||||
try:
|
||||
@ -62,7 +62,7 @@ class HelloWorld(Plugin):
|
||||
'hello world',
|
||||
resetStyles=False
|
||||
)
|
||||
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Error in speakTest: {e}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user