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