Updated version presentation to be more similar to orca.

This commit is contained in:
Storm Dragon
2026-01-07 11:52:46 -05:00
parent 8932dacc33
commit 42bfacdd2c
4 changed files with 90 additions and 10 deletions

View File

@@ -91,7 +91,7 @@ from cthulhu import messages
from cthulhu import settings
from cthulhu.ax_object import AXObject
from cthulhu.ax_utilities import AXUtilities
from cthulhu.cthulhu_platform import version
from cthulhu.cthulhu_platform import version, revision
class ListApps(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
@@ -115,6 +115,26 @@ class ListApps(argparse.Action):
parser.exit()
class PrintVersion(argparse.Action):
"""Action to print the version of Cthulhu."""
def __call__(self, parser, namespace, values, option_string=None):
msg = version
if revision:
msg += f" (rev {revision})"
atspi_version = Atspi.get_version()
msg += f", AT-SPI2 version: {atspi_version[0]}.{atspi_version[1]}.{atspi_version[2]}"
session_type = os.environ.get("XDG_SESSION_TYPE") or ""
session_desktop = os.environ.get("XDG_SESSION_DESKTOP") or ""
session = f"{session_type} {session_desktop}".strip()
if session:
msg += f", Session: {session}"
print(msg)
parser.exit()
class Settings(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
settingsDict = getattr(namespace, 'settings', {})
@@ -151,7 +171,7 @@ class Parser(argparse.ArgumentParser):
self.add_argument(
"-h", "--help", action="help", help=messages.CLI_HELP)
self.add_argument(
"-v", "--version", action="version", version=version, help=messages.CLI_VERSION)
"-v", "--version", action=PrintVersion, nargs=0, help=messages.CLI_VERSION)
self.add_argument(
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
self.add_argument(

View File

@@ -49,7 +49,7 @@ from cthulhu import messages
from cthulhu import settings
from cthulhu.ax_object import AXObject
from cthulhu.ax_utilities import AXUtilities
from cthulhu.cthulhu_platform import version
from cthulhu.cthulhu_platform import version, revision
class ListApps(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
@@ -73,6 +73,26 @@ class ListApps(argparse.Action):
parser.exit()
class PrintVersion(argparse.Action):
"""Action to print the version of Cthulhu."""
def __call__(self, parser, namespace, values, option_string=None):
msg = version
if revision:
msg += f" (rev {revision})"
atspi_version = Atspi.get_version()
msg += f", AT-SPI2 version: {atspi_version[0]}.{atspi_version[1]}.{atspi_version[2]}"
session_type = os.environ.get("XDG_SESSION_TYPE") or ""
session_desktop = os.environ.get("XDG_SESSION_DESKTOP") or ""
session = f"{session_type} {session_desktop}".strip()
if session:
msg += f", Session: {session}"
print(msg)
parser.exit()
class Settings(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
settingsDict = getattr(namespace, 'settings', {})
@@ -109,7 +129,7 @@ class Parser(argparse.ArgumentParser):
self.add_argument(
"-h", "--help", action="help", help=messages.CLI_HELP)
self.add_argument(
"-v", "--version", action="version", version=version, help=messages.CLI_VERSION)
"-v", "--version", action=PrintVersion, nargs=0, help=messages.CLI_VERSION)
self.add_argument(
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
self.add_argument(

View File

@@ -29,6 +29,7 @@ __license__ = "LGPL"
import enum
import inspect
import os
from typing import Callable, Optional
try:
@@ -43,6 +44,10 @@ except ImportError:
from gi.repository import GLib
import gi
gi.require_version("Atspi", "2.0")
from gi.repository import Atspi
from . import debug
from . import cthulhu_platform # pylint: disable=no-name-in-module
from . import script_manager
@@ -482,12 +487,21 @@ if _dasbus_available:
return True
def GetVersion(self) -> str: # pylint: disable=invalid-name
"""Returns Cthulhu's version and revision if available."""
"""Returns Cthulhu's version, AT-SPI version, and session information."""
result = cthulhu_platform.version
if cthulhu_platform.revision:
result += f" (rev {cthulhu_platform.revision})"
atspi_version = Atspi.get_version()
result += f", AT-SPI2 version: {atspi_version[0]}.{atspi_version[1]}.{atspi_version[2]}"
session_type = os.environ.get("XDG_SESSION_TYPE") or ""
session_desktop = os.environ.get("XDG_SESSION_DESKTOP") or ""
session = f"{session_type} {session_desktop}".strip()
if session:
result += f", Session: {session}"
msg = f"DBUS SERVICE: GetVersion called, returning: {result}"
debug.printMessage(debug.LEVEL_INFO, msg, True)
return result

View File

@@ -10,21 +10,45 @@
"""Display Version plugin for Cthulhu."""
import logging
import os
import gi
gi.require_version("Atspi", "2.0")
from gi.repository import Atspi
from cthulhu.plugin import Plugin, cthulhu_hookimpl
from cthulhu import cthulhuVersion
from cthulhu import cthulhu_platform
from cthulhu import debug
logger = logging.getLogger(__name__)
class DisplayVersion(Plugin):
"""Plugin that announces the current Cthulhu version."""
def __init__(self, *args, **kwargs):
"""Initialize the plugin."""
super().__init__(*args, **kwargs)
debug.printMessage(debug.LEVEL_INFO, "DisplayVersion: Plugin initialized", True)
self._kb_binding = None
self._activated = False
def _get_version_string(self):
"""Generate the full version string with AT-SPI and session information."""
msg = f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}'
if cthulhu_platform.revision:
msg += f' revision {cthulhu_platform.revision}'
atspi_version = Atspi.get_version()
msg += f', AT-SPI2 version {atspi_version[0]}.{atspi_version[1]}.{atspi_version[2]}'
session_type = os.environ.get('XDG_SESSION_TYPE') or ''
session_desktop = os.environ.get('XDG_SESSION_DESKTOP') or ''
session = f'{session_type} {session_desktop}'.strip()
if session:
msg += f', Session {session}'
return msg
@cthulhu_hookimpl
def activate(self, plugin=None):
@@ -51,10 +75,11 @@ class DisplayVersion(Plugin):
# Register keyboard shortcut
gesture_string = 'kb:cthulhu+shift+v'
debug.printMessage(debug.LEVEL_INFO, f"DisplayVersion: Registering gesture: {gesture_string}", True)
version_message = self._get_version_string()
self._kb_binding = self.registerGestureByString(
self.speakText,
f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}',
self.speakText,
version_message,
gesture_string
)
@@ -87,8 +112,9 @@ class DisplayVersion(Plugin):
if self.app:
state = self.app.getDynamicApiManager().getAPI('CthulhuState')
if state.activeScript:
version_message = self._get_version_string()
state.activeScript.presentMessage(
f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}',
version_message,
resetStyles=False
)
return True