diff --git a/src/cthulhu/plugins/DisplayVersion/DisplayVersion.py b/src/cthulhu/plugins/DisplayVersion/DisplayVersion.py index 894bc25..e52fee9 100644 --- a/src/cthulhu/plugins/DisplayVersion/DisplayVersion.py +++ b/src/cthulhu/plugins/DisplayVersion/DisplayVersion.py @@ -35,14 +35,27 @@ class DisplayVersion(GObject.Object, Peas.Activatable, plugin.Plugin): __gtype_name__ = 'displayversion' object = GObject.Property(type=GObject.Object) + def __init__(self): plugin.Plugin.__init__(self) + self._api = None + def do_activate(self): - API = self.object - self.registerGestureByString(self.speakText, _(f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}'), 'kb:cthulhu+shift+v') + self._api = self.object + self.registerGestureByString( + self.speakText, + _(f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}'), + 'kb:cthulhu+x' + ) + def do_deactivate(self): - API = self.object + self._api = None + def speakText(self, script=None, inputEvent=None): - API = self.object - API.app.getDynamicApiManager().getAPI('CthulhuState').activeScript.presentMessage(f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}', resetStyles=False) + if not self._api: + return False + self._api.app.getDynamicApiManager().getAPI('CthulhuState').activeScript.presentMessage( + f'Cthulhu screen reader version {cthulhuVersion.version}-{cthulhuVersion.codeName}', + resetStyles=False + ) return True