Working on plugin conversion.
This commit is contained in:
parent
0b7cf681c3
commit
7876a18c12
@ -1,6 +0,0 @@
|
||||
[Plugin]
|
||||
Module=HelloCthulhu
|
||||
Loader=python3
|
||||
Name=Cthulhu say hello
|
||||
Description=startup announcement for Cthulhu
|
||||
Authors=Chrys chrys@linux-a11y.org
|
@ -1,48 +0,0 @@
|
||||
#!/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
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# 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
|
||||
|
||||
from cthulhu import plugin
|
||||
|
||||
import gi
|
||||
gi.require_version('Peas', '1.0')
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Peas
|
||||
|
||||
class HelloCthulhu(GObject.Object, Peas.Activatable, plugin.Plugin):
|
||||
#__gtype_name__ = 'HelloCthulhu'
|
||||
|
||||
object = GObject.Property(type=GObject.Object)
|
||||
def __init__(self):
|
||||
plugin.Plugin.__init__(self)
|
||||
def do_activate(self):
|
||||
API = self.object
|
||||
self.connectSignal("start-application-completed", self.process)
|
||||
def do_deactivate(self):
|
||||
API = self.object
|
||||
def do_update_state(self):
|
||||
API = self.object
|
||||
def process(self, app):
|
||||
messages = app.getDynamicApiManager().getAPI('Messages')
|
||||
app.getDynamicApiManager().getAPI('CthulhuState').activeScript.presentMessage(messages.START_CTHULHU, resetStyles=False)
|
@ -1,7 +1,7 @@
|
||||
cthulhu_python_PYTHON = \
|
||||
__init__.py \
|
||||
HelloCthulhu.plugin \
|
||||
HelloCthulhu.py
|
||||
plugin.info \
|
||||
plugin.py
|
||||
|
||||
cthulhu_pythondir=$(pkgpythondir)/plugins/HelloCthulhu
|
||||
|
||||
|
7
src/cthulhu/plugins/HelloCthulhu/plugin.info
Normal file
7
src/cthulhu/plugins/HelloCthulhu/plugin.info
Normal file
@ -0,0 +1,7 @@
|
||||
[Plugin]
|
||||
Name = Cthulhu say hello
|
||||
Module = HelloCthulhu
|
||||
Description = Startup announcement for Cthulhu
|
||||
Authors = Storm Dragon <storm_dragon@stormux.org>
|
||||
Version = 1.0
|
||||
Category = Interaction
|
84
src/cthulhu/plugins/HelloCthulhu/plugin.py
Normal file
84
src/cthulhu/plugins/HelloCthulhu/plugin.py
Normal file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2024 Stormux
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
|
||||
# Boston MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
"""Hello Cthulhu plugin for Cthulhu."""
|
||||
|
||||
import logging
|
||||
from cthulhu.plugin import Plugin, cthulhu_hookimpl
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class HelloCthulhu(Plugin):
|
||||
"""Plugin that speaks a welcome message when Cthulhu starts up."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the plugin."""
|
||||
super().__init__(*args, **kwargs)
|
||||
logger.info("HelloCthulhu plugin initialized")
|
||||
self._signal_handler_id = None
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def activate(self, plugin=None):
|
||||
"""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 HelloCthulhu plugin")
|
||||
try:
|
||||
# Connect to the start-application-completed signal
|
||||
signal_manager = self.app.getSignalManager()
|
||||
self._signal_handler_id = signal_manager.connectSignal(
|
||||
"start-application-completed",
|
||||
self.process,
|
||||
"default" # Add profile parameter
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error activating HelloCthulhu 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 HelloCthulhu plugin")
|
||||
try:
|
||||
# Disconnect signal if we have an ID
|
||||
if self._signal_handler_id is not None:
|
||||
signal_manager = self.app.getSignalManager()
|
||||
# Use disconnectSignalByFunction instead since disconnectSignal doesn't exist
|
||||
signal_manager.disconnectSignalByFunction(
|
||||
self.process
|
||||
)
|
||||
self._signal_handler_id = None
|
||||
except Exception as e:
|
||||
logger.error(f"Error deactivating HelloCthulhu plugin: {e}")
|
||||
|
||||
def process(self, app):
|
||||
"""Process the start-application-completed signal."""
|
||||
try:
|
||||
messages = app.getDynamicApiManager().getAPI('Messages')
|
||||
state = app.getDynamicApiManager().getAPI('CthulhuState')
|
||||
if state.activeScript:
|
||||
state.activeScript.presentMessage(messages.START_CTHULHU, resetStyles=False)
|
||||
except Exception as e:
|
||||
logger.error(f"Error in HelloCthulhu process: {e}")
|
@ -20,6 +20,7 @@ class HelloWorld(Plugin):
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the plugin."""
|
||||
super().__init__(*args, **kwargs)
|
||||
print("Plugin hello world initialized.")
|
||||
logger.info("HelloWorld plugin initialized")
|
||||
|
||||
@cthulhu_hookimpl
|
||||
|
Loading…
x
Reference in New Issue
Block a user