Updated version presentation to be more similar to orca.
This commit is contained in:
+22
-2
@@ -91,7 +91,7 @@ from cthulhu import messages
|
|||||||
from cthulhu import settings
|
from cthulhu import settings
|
||||||
from cthulhu.ax_object import AXObject
|
from cthulhu.ax_object import AXObject
|
||||||
from cthulhu.ax_utilities import AXUtilities
|
from cthulhu.ax_utilities import AXUtilities
|
||||||
from cthulhu.cthulhu_platform import version
|
from cthulhu.cthulhu_platform import version, revision
|
||||||
|
|
||||||
class ListApps(argparse.Action):
|
class ListApps(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
@@ -115,6 +115,26 @@ class ListApps(argparse.Action):
|
|||||||
|
|
||||||
parser.exit()
|
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):
|
class Settings(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
settingsDict = getattr(namespace, 'settings', {})
|
settingsDict = getattr(namespace, 'settings', {})
|
||||||
@@ -151,7 +171,7 @@ class Parser(argparse.ArgumentParser):
|
|||||||
self.add_argument(
|
self.add_argument(
|
||||||
"-h", "--help", action="help", help=messages.CLI_HELP)
|
"-h", "--help", action="help", help=messages.CLI_HELP)
|
||||||
self.add_argument(
|
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(
|
self.add_argument(
|
||||||
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
|
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
|
||||||
self.add_argument(
|
self.add_argument(
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ from cthulhu import messages
|
|||||||
from cthulhu import settings
|
from cthulhu import settings
|
||||||
from cthulhu.ax_object import AXObject
|
from cthulhu.ax_object import AXObject
|
||||||
from cthulhu.ax_utilities import AXUtilities
|
from cthulhu.ax_utilities import AXUtilities
|
||||||
from cthulhu.cthulhu_platform import version
|
from cthulhu.cthulhu_platform import version, revision
|
||||||
|
|
||||||
class ListApps(argparse.Action):
|
class ListApps(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
@@ -73,6 +73,26 @@ class ListApps(argparse.Action):
|
|||||||
|
|
||||||
parser.exit()
|
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):
|
class Settings(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
settingsDict = getattr(namespace, 'settings', {})
|
settingsDict = getattr(namespace, 'settings', {})
|
||||||
@@ -109,7 +129,7 @@ class Parser(argparse.ArgumentParser):
|
|||||||
self.add_argument(
|
self.add_argument(
|
||||||
"-h", "--help", action="help", help=messages.CLI_HELP)
|
"-h", "--help", action="help", help=messages.CLI_HELP)
|
||||||
self.add_argument(
|
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(
|
self.add_argument(
|
||||||
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
|
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
|
||||||
self.add_argument(
|
self.add_argument(
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ __license__ = "LGPL"
|
|||||||
|
|
||||||
import enum
|
import enum
|
||||||
import inspect
|
import inspect
|
||||||
|
import os
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -43,6 +44,10 @@ except ImportError:
|
|||||||
|
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
|
||||||
|
import gi
|
||||||
|
gi.require_version("Atspi", "2.0")
|
||||||
|
from gi.repository import Atspi
|
||||||
|
|
||||||
from . import debug
|
from . import debug
|
||||||
from . import cthulhu_platform # pylint: disable=no-name-in-module
|
from . import cthulhu_platform # pylint: disable=no-name-in-module
|
||||||
from . import script_manager
|
from . import script_manager
|
||||||
@@ -482,12 +487,21 @@ if _dasbus_available:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def GetVersion(self) -> str: # pylint: disable=invalid-name
|
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
|
result = cthulhu_platform.version
|
||||||
if cthulhu_platform.revision:
|
if cthulhu_platform.revision:
|
||||||
result += f" (rev {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}"
|
msg = f"DBUS SERVICE: GetVersion called, returning: {result}"
|
||||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -10,21 +10,45 @@
|
|||||||
"""Display Version plugin for Cthulhu."""
|
"""Display Version plugin for Cthulhu."""
|
||||||
|
|
||||||
import logging
|
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.plugin import Plugin, cthulhu_hookimpl
|
||||||
from cthulhu import cthulhuVersion
|
from cthulhu import cthulhuVersion
|
||||||
|
from cthulhu import cthulhu_platform
|
||||||
from cthulhu import debug
|
from cthulhu import debug
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class DisplayVersion(Plugin):
|
class DisplayVersion(Plugin):
|
||||||
"""Plugin that announces the current Cthulhu version."""
|
"""Plugin that announces the current Cthulhu version."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize the plugin."""
|
"""Initialize the plugin."""
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
debug.printMessage(debug.LEVEL_INFO, "DisplayVersion: Plugin initialized", True)
|
debug.printMessage(debug.LEVEL_INFO, "DisplayVersion: Plugin initialized", True)
|
||||||
self._kb_binding = None
|
self._kb_binding = None
|
||||||
self._activated = False
|
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
|
@cthulhu_hookimpl
|
||||||
def activate(self, plugin=None):
|
def activate(self, plugin=None):
|
||||||
@@ -51,10 +75,11 @@ class DisplayVersion(Plugin):
|
|||||||
# Register keyboard shortcut
|
# Register keyboard shortcut
|
||||||
gesture_string = 'kb:cthulhu+shift+v'
|
gesture_string = 'kb:cthulhu+shift+v'
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"DisplayVersion: Registering gesture: {gesture_string}", True)
|
debug.printMessage(debug.LEVEL_INFO, f"DisplayVersion: Registering gesture: {gesture_string}", True)
|
||||||
|
|
||||||
|
version_message = self._get_version_string()
|
||||||
self._kb_binding = self.registerGestureByString(
|
self._kb_binding = self.registerGestureByString(
|
||||||
self.speakText,
|
self.speakText,
|
||||||
f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}',
|
version_message,
|
||||||
gesture_string
|
gesture_string
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -87,8 +112,9 @@ class DisplayVersion(Plugin):
|
|||||||
if self.app:
|
if self.app:
|
||||||
state = self.app.getDynamicApiManager().getAPI('CthulhuState')
|
state = self.app.getDynamicApiManager().getAPI('CthulhuState')
|
||||||
if state.activeScript:
|
if state.activeScript:
|
||||||
|
version_message = self._get_version_string()
|
||||||
state.activeScript.presentMessage(
|
state.activeScript.presentMessage(
|
||||||
f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}',
|
version_message,
|
||||||
resetStyles=False
|
resetStyles=False
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user