-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename more legacy "WebApp" and "MarkerManager" leftovers
Notably: - in `webAccess`: `supportWebApp` -> `canHaveWebAccessSupport` - in `webAppLib`: `playWebAppSound` -> `playWebAccessSound` - in `webAppScheduler`: `event_webApp` -> `event_webModule` - in `webAppScheduler`: `event_markerManagerUpdated` -> `event_ruleManagerUpdated` - in `WebModule`: `event_webApp_gainFocus` -> `event_webModule_gainFocus` - in `WebModule`: `event_webApp_loseFocus` -> `event_webModule_loseFocus` The latter two are currently dead code but will likely be revived for issue #17.
- Loading branch information
1 parent
fa9ea48
commit 09bc0cf
Showing
8 changed files
with
98 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of Web Access for NVDA. | ||
# Copyright (C) 2015-2021 Accessolutions (http://accessolutions.fr) | ||
# Copyright (C) 2015-2024 Accessolutions (http://accessolutions.fr) | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -45,7 +45,7 @@ | |
""" | ||
|
||
|
||
__version__ = "2021.03.12" | ||
__version__ = "2024.08.21" | ||
__authors__ = ( | ||
"Yannick Plassiard <[email protected]>", | ||
"Frédéric Brugnot <[email protected]>", | ||
|
@@ -57,57 +57,48 @@ | |
|
||
import os | ||
import re | ||
import core | ||
import wx | ||
|
||
from NVDAObjects.IAccessible import IAccessible | ||
from NVDAObjects.IAccessible.MSHTML import MSHTML | ||
from NVDAObjects.IAccessible.ia2Web import Ia2Web | ||
from NVDAObjects.IAccessible.mozilla import Mozilla | ||
from scriptHandler import script | ||
import addonHandler | ||
import api | ||
import baseObject | ||
import controlTypes | ||
import core | ||
import eventHandler | ||
import globalPluginHandler | ||
import gui | ||
from logHandler import log | ||
import scriptHandler | ||
import speech | ||
from scriptHandler import script | ||
import ui | ||
import virtualBuffers | ||
|
||
from . import nodeHandler | ||
from . import overlay | ||
from . import webAppLib | ||
from .webAppLib import * | ||
from .webAppScheduler import WebAppScheduler | ||
from . import webModuleHandler | ||
from .webAppLib import playWebAccessSound, sleep | ||
from .webAppScheduler import WebAppScheduler | ||
|
||
|
||
addonHandler.initTranslation() | ||
|
||
|
||
TRACE = lambda *args, **kwargs: None # @UnusedVariable | ||
#TRACE = log.info | ||
|
||
SCRIPT_CATEGORY = "WebAccess" | ||
|
||
# | ||
# defines sound directory | ||
# | ||
|
||
SOUND_DIRECTORY = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..", "sounds") | ||
SUPPORTED_HOSTS = ['brave', 'firefox', 'chrome', 'java', 'iexplore', 'microsoftedgecp', 'msedge'] | ||
TRACE = lambda *args, **kwargs: None # @UnusedVariable | ||
#TRACE = log.info | ||
|
||
|
||
# Currently dead code, but will likely be revived for issue #17. | ||
activeWebModule = None | ||
|
||
supportedWebAppHosts = ['brave', 'firefox', 'chrome', 'java', 'iexplore', 'microsoftedgecp', 'msedge'] | ||
|
||
activeWebApp = None | ||
webAccessEnabled = True | ||
scheduler = None | ||
|
||
|
||
class DefaultBrowserScripts(baseObject.ScriptableObject): | ||
|
||
def __init__(self, warningMessage): | ||
|
@@ -118,7 +109,7 @@ def __init__(self, warningMessage): | |
self.__class__.__gestures["kb:control+shift+%s" % character] = "notAssigned" | ||
|
||
def script_notAssigned(self, gesture): # @UnusedVariable | ||
playWebAppSound("keyError") | ||
playWebAccessSound("keyError") | ||
sleep(0.2) | ||
ui.message(self.warningMessage) | ||
|
||
|
@@ -224,7 +215,7 @@ def showWebAccessGui(self): | |
# Translators: Error message when attempting to show the Web Access GUI. | ||
ui.message(_("The current object does not support Web Access.")) | ||
return | ||
if not supportWebApp(obj): | ||
if not canHaveWebAccessSupport(obj): | ||
# Translators: Error message when attempting to show the Web Access GUI. | ||
ui.message(_("You must be in a web browser to use Web Access.")) | ||
return | ||
|
@@ -300,23 +291,23 @@ def script_toggleWebAccessSupport(self, gesture): # @UnusedVariable | |
ui.message(_("Web Access support enabled.")) # FR: u"Support Web Access activé." | ||
|
||
|
||
def getActiveWebApp(): | ||
global activeWebApp | ||
return activeWebApp | ||
def getActiveWebModule(): | ||
global activeWebModule | ||
return activeWebModule | ||
|
||
|
||
def webAppLoseFocus(obj): | ||
global activeWebApp | ||
if activeWebApp is not None: | ||
sendWebAppEvent('webApp_loseFocus', obj, activeWebApp) | ||
activeWebApp = None | ||
#log.info("Losing webApp focus for object:\n%s\n" % ("\n".join(obj.devInfo))) | ||
def webModuleLoseFocus(obj): | ||
global activeWebModule | ||
if activeWebModule is not None: | ||
sendWebModuleEvent('webModule_loseFocus', obj, activeWebModule) | ||
activeWebModule = None | ||
#log.info("Losing webModule focus for object:\n%s\n" % ("\n".join(obj.devInfo))) | ||
|
||
|
||
def supportWebApp(obj): | ||
def canHaveWebAccessSupport(obj): | ||
if obj is None or obj.appModule is None: | ||
return None | ||
return obj.appModule.appName in supportedWebAppHosts | ||
return False | ||
return obj.appModule.appName in SUPPORTED_HOSTS | ||
|
||
|
||
def VirtualBuffer_changeNotify(cls, rootDocHandle, rootID): | ||
|
@@ -331,10 +322,10 @@ def virtualBuffer_loadBufferDone(self, success=True): | |
virtualBuffer_loadBufferDone.super.__get__(self)(success=success) | ||
|
||
|
||
def sendWebAppEvent(eventName, obj, webApp=None): | ||
if webApp is None: | ||
def sendWebModuleEvent(eventName, obj, webModule=None): | ||
if webModule is None: | ||
return | ||
scheduler.send(eventName="webApp", name=eventName, obj=obj, webApp=webApp) | ||
scheduler.send(eventName="webModule", name=eventName, obj=obj, webModule=webModule) | ||
|
||
|
||
def eventExecuter_gen(self, eventName, obj): | ||
|
@@ -349,18 +340,18 @@ def eventExecuter_gen(self, eventName, obj): | |
yield func, (obj, self.next) | ||
|
||
# webApp level | ||
if not supportWebApp(obj) and eventName in ["gainFocus"] and activeWebApp is not None: | ||
if not canHaveWebAccessSupport(obj) and eventName in ["gainFocus"] and activeWebModule is not None: | ||
# log.info("Received event %s on a non-hosted object" % eventName) | ||
webAppLoseFocus(obj) | ||
else: | ||
webApp = obj.webAccess.webModule if isinstance(obj, overlay.WebAccessObject) else None | ||
if webApp is None: | ||
if activeWebApp is not None and obj.hasFocus: | ||
webModule = obj.webAccess.webModule if isinstance(obj, overlay.WebAccessObject) else None | ||
if webModule is None: | ||
if activeWebModule is not None and obj.hasFocus: | ||
#log.info("Disabling active webApp event %s" % eventName) | ||
webAppLoseFocus(obj) | ||
else: | ||
# log.info("Getting method %s -> %s" %(webApp.name, funcName)) | ||
func = getattr(webApp, funcName, None) | ||
func = getattr(webModule, funcName, None) | ||
if func: | ||
yield func,(obj, self.next) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,12 @@ | |
# See the file COPYING.txt at the root of this distribution for more details. | ||
|
||
|
||
__version__ = "2024.07.25" | ||
__author__ = "Julien Cochuyt <[email protected]>" | ||
__version__ = "2024.08.21" | ||
__authors__ = ( | ||
"Julien Cochuyt <[email protected]>", | ||
"André-Abush Clause <[email protected]>",, | ||
"Gatien Bouyssou <[email protected]>", | ||
) | ||
|
||
|
||
import os | ||
|
@@ -229,9 +233,11 @@ def onModulesListItemSelected(self, evt): | |
self.moduleEditButton.Enable(item is not None) | ||
self.rulesManagerButton.Enable( | ||
item is not None | ||
and hasattr(item, "markerManager") | ||
and item.markerManager.isReady | ||
) | ||
# FIXME: This test never succeeds as a live WebModule is not | ||
# taken from the context. | ||
# TODO: Remove this restriction for issue #42 | ||
and item.ruleManager.isReady | ||
) | ||
self.moduleDeleteButton.Enable(item is not None) | ||
|
||
def onRulesManager(self, evt=None): | ||
|
@@ -290,4 +296,4 @@ def Show(self, context): | |
self.Fit() | ||
self.modulesList.SetFocus() | ||
self.CentreOnScreen() | ||
return super().Show() | ||
return super().Show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
# | ||
# See the file COPYING.txt at the root of this distribution for more details. | ||
|
||
__version__ = "2024.08.19" | ||
__version__ = "2024.08.21" | ||
__authors__ = ( | ||
"Frédéric Brugnot <[email protected]>", | ||
"Julien Cochuyt <[email protected]>", | ||
|
@@ -274,7 +274,7 @@ def update(self): | |
self.identifier = time.time() | ||
# logTime ("Update node manager %d nodes" % len(fields), t) | ||
self.updating = False | ||
# playWebAppSound ("tick") | ||
# playWebAccessSound("tick") | ||
self._curNode = self.caretNode = self.getCaretNode() | ||
try: | ||
info = self.treeInterceptor.makeTextInfo(textInfos.POSITION_LAST) | ||
|
@@ -550,7 +550,7 @@ def isReady(self): | |
|
||
def checkNodeManager(self): | ||
if self.nodeManager is None or not self.nodeManager.isReady: | ||
playWebAppSound("keyError") | ||
playWebAccessSound("keyError") | ||
return False | ||
else: | ||
return True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,11 @@ | |
""" | ||
|
||
__version__ = "2024.07.24" | ||
__author__ = "Julien Cochuyt <[email protected]>" | ||
__authors__ = ( | ||
"Julien Cochuyt <[email protected]>", | ||
"André-Abush Clause <[email protected]>", | ||
"Gatien Bouyssou <[email protected]>", | ||
) | ||
|
||
|
||
import weakref | ||
|
@@ -193,7 +197,7 @@ def treeInterceptor(self): | |
|
||
@property | ||
def webModule(self): | ||
from . import supportWebApp, webAccessEnabled | ||
from . import canHaveWebAccessSupport, webAccessEnabled | ||
if not webAccessEnabled: | ||
return None | ||
ti = self.treeInterceptor | ||
|
@@ -203,7 +207,7 @@ def webModule(self): | |
webModule = self._webModule | ||
if not webModule: | ||
obj = ti.rootNVDAObject | ||
if not supportWebApp(obj): | ||
if not canHaveWebAccessSupport(obj): | ||
return None | ||
from . import webModuleHandler | ||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.