Skip to content

Commit 09bc0cf

Browse files
committed
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.
1 parent fa9ea48 commit 09bc0cf

File tree

8 files changed

+98
-87
lines changed

8 files changed

+98
-87
lines changed

addon/globalPlugins/webAccess/__init__.py

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
# This file is part of Web Access for NVDA.
5-
# Copyright (C) 2015-2021 Accessolutions (http://accessolutions.fr)
5+
# Copyright (C) 2015-2024 Accessolutions (http://accessolutions.fr)
66
#
77
# This program is free software: you can redistribute it and/or modify
88
# it under the terms of the GNU General Public License as published by
@@ -45,7 +45,7 @@
4545
"""
4646

4747

48-
__version__ = "2021.03.12"
48+
__version__ = "2024.08.21"
4949
__authors__ = (
5050
"Yannick Plassiard <[email protected]>",
5151
"Frédéric Brugnot <[email protected]>",
@@ -57,57 +57,48 @@
5757

5858
import os
5959
import re
60-
import core
6160
import wx
6261

6362
from NVDAObjects.IAccessible import IAccessible
6463
from NVDAObjects.IAccessible.MSHTML import MSHTML
6564
from NVDAObjects.IAccessible.ia2Web import Ia2Web
6665
from NVDAObjects.IAccessible.mozilla import Mozilla
67-
from scriptHandler import script
6866
import addonHandler
6967
import api
7068
import baseObject
7169
import controlTypes
70+
import core
7271
import eventHandler
7372
import globalPluginHandler
7473
import gui
7574
from logHandler import log
76-
import scriptHandler
77-
import speech
75+
from scriptHandler import script
7876
import ui
7977
import virtualBuffers
8078

81-
from . import nodeHandler
8279
from . import overlay
83-
from . import webAppLib
84-
from .webAppLib import *
85-
from .webAppScheduler import WebAppScheduler
8680
from . import webModuleHandler
81+
from .webAppLib import playWebAccessSound, sleep
82+
from .webAppScheduler import WebAppScheduler
8783

8884

8985
addonHandler.initTranslation()
9086

9187

92-
TRACE = lambda *args, **kwargs: None # @UnusedVariable
93-
#TRACE = log.info
94-
9588
SCRIPT_CATEGORY = "WebAccess"
96-
97-
#
98-
# defines sound directory
99-
#
100-
10189
SOUND_DIRECTORY = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..", "sounds")
90+
SUPPORTED_HOSTS = ['brave', 'firefox', 'chrome', 'java', 'iexplore', 'microsoftedgecp', 'msedge']
91+
TRACE = lambda *args, **kwargs: None # @UnusedVariable
92+
#TRACE = log.info
10293

10394

95+
# Currently dead code, but will likely be revived for issue #17.
96+
activeWebModule = None
10497

105-
supportedWebAppHosts = ['brave', 'firefox', 'chrome', 'java', 'iexplore', 'microsoftedgecp', 'msedge']
106-
107-
activeWebApp = None
10898
webAccessEnabled = True
10999
scheduler = None
110100

101+
111102
class DefaultBrowserScripts(baseObject.ScriptableObject):
112103

113104
def __init__(self, warningMessage):
@@ -118,7 +109,7 @@ def __init__(self, warningMessage):
118109
self.__class__.__gestures["kb:control+shift+%s" % character] = "notAssigned"
119110

120111
def script_notAssigned(self, gesture): # @UnusedVariable
121-
playWebAppSound("keyError")
112+
playWebAccessSound("keyError")
122113
sleep(0.2)
123114
ui.message(self.warningMessage)
124115

@@ -224,7 +215,7 @@ def showWebAccessGui(self):
224215
# Translators: Error message when attempting to show the Web Access GUI.
225216
ui.message(_("The current object does not support Web Access."))
226217
return
227-
if not supportWebApp(obj):
218+
if not canHaveWebAccessSupport(obj):
228219
# Translators: Error message when attempting to show the Web Access GUI.
229220
ui.message(_("You must be in a web browser to use Web Access."))
230221
return
@@ -300,23 +291,23 @@ def script_toggleWebAccessSupport(self, gesture): # @UnusedVariable
300291
ui.message(_("Web Access support enabled.")) # FR: u"Support Web Access activé."
301292

302293

303-
def getActiveWebApp():
304-
global activeWebApp
305-
return activeWebApp
294+
def getActiveWebModule():
295+
global activeWebModule
296+
return activeWebModule
306297

307298

308-
def webAppLoseFocus(obj):
309-
global activeWebApp
310-
if activeWebApp is not None:
311-
sendWebAppEvent('webApp_loseFocus', obj, activeWebApp)
312-
activeWebApp = None
313-
#log.info("Losing webApp focus for object:\n%s\n" % ("\n".join(obj.devInfo)))
299+
def webModuleLoseFocus(obj):
300+
global activeWebModule
301+
if activeWebModule is not None:
302+
sendWebModuleEvent('webModule_loseFocus', obj, activeWebModule)
303+
activeWebModule = None
304+
#log.info("Losing webModule focus for object:\n%s\n" % ("\n".join(obj.devInfo)))
314305

315306

316-
def supportWebApp(obj):
307+
def canHaveWebAccessSupport(obj):
317308
if obj is None or obj.appModule is None:
318-
return None
319-
return obj.appModule.appName in supportedWebAppHosts
309+
return False
310+
return obj.appModule.appName in SUPPORTED_HOSTS
320311

321312

322313
def VirtualBuffer_changeNotify(cls, rootDocHandle, rootID):
@@ -331,10 +322,10 @@ def virtualBuffer_loadBufferDone(self, success=True):
331322
virtualBuffer_loadBufferDone.super.__get__(self)(success=success)
332323

333324

334-
def sendWebAppEvent(eventName, obj, webApp=None):
335-
if webApp is None:
325+
def sendWebModuleEvent(eventName, obj, webModule=None):
326+
if webModule is None:
336327
return
337-
scheduler.send(eventName="webApp", name=eventName, obj=obj, webApp=webApp)
328+
scheduler.send(eventName="webModule", name=eventName, obj=obj, webModule=webModule)
338329

339330

340331
def eventExecuter_gen(self, eventName, obj):
@@ -349,18 +340,18 @@ def eventExecuter_gen(self, eventName, obj):
349340
yield func, (obj, self.next)
350341

351342
# webApp level
352-
if not supportWebApp(obj) and eventName in ["gainFocus"] and activeWebApp is not None:
343+
if not canHaveWebAccessSupport(obj) and eventName in ["gainFocus"] and activeWebModule is not None:
353344
# log.info("Received event %s on a non-hosted object" % eventName)
354345
webAppLoseFocus(obj)
355346
else:
356-
webApp = obj.webAccess.webModule if isinstance(obj, overlay.WebAccessObject) else None
357-
if webApp is None:
358-
if activeWebApp is not None and obj.hasFocus:
347+
webModule = obj.webAccess.webModule if isinstance(obj, overlay.WebAccessObject) else None
348+
if webModule is None:
349+
if activeWebModule is not None and obj.hasFocus:
359350
#log.info("Disabling active webApp event %s" % eventName)
360351
webAppLoseFocus(obj)
361352
else:
362353
# log.info("Getting method %s -> %s" %(webApp.name, funcName))
363-
func = getattr(webApp, funcName, None)
354+
func = getattr(webModule, funcName, None)
364355
if func:
365356
yield func,(obj, self.next)
366357

addon/globalPlugins/webAccess/gui/webModulesManager.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
# See the file COPYING.txt at the root of this distribution for more details.
2121

2222

23-
__version__ = "2024.07.25"
24-
__author__ = "Julien Cochuyt <[email protected]>"
23+
__version__ = "2024.08.21"
24+
__authors__ = (
25+
"Julien Cochuyt <[email protected]>",
26+
"André-Abush Clause <[email protected]>",,
27+
"Gatien Bouyssou <[email protected]>",
28+
)
2529

2630

2731
import os
@@ -229,9 +233,11 @@ def onModulesListItemSelected(self, evt):
229233
self.moduleEditButton.Enable(item is not None)
230234
self.rulesManagerButton.Enable(
231235
item is not None
232-
and hasattr(item, "markerManager")
233-
and item.markerManager.isReady
234-
)
236+
# FIXME: This test never succeeds as a live WebModule is not
237+
# taken from the context.
238+
# TODO: Remove this restriction for issue #42
239+
and item.ruleManager.isReady
240+
)
235241
self.moduleDeleteButton.Enable(item is not None)
236242

237243
def onRulesManager(self, evt=None):
@@ -290,4 +296,4 @@ def Show(self, context):
290296
self.Fit()
291297
self.modulesList.SetFocus()
292298
self.CentreOnScreen()
293-
return super().Show()
299+
return super().Show()

addon/globalPlugins/webAccess/nodeHandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#
2020
# See the file COPYING.txt at the root of this distribution for more details.
2121

22-
__version__ = "2024.08.19"
22+
__version__ = "2024.08.21"
2323
__authors__ = (
2424
"Frédéric Brugnot <[email protected]>",
2525
"Julien Cochuyt <[email protected]>",
@@ -274,7 +274,7 @@ def update(self):
274274
self.identifier = time.time()
275275
# logTime ("Update node manager %d nodes" % len(fields), t)
276276
self.updating = False
277-
# playWebAppSound ("tick")
277+
# playWebAccessSound("tick")
278278
self._curNode = self.caretNode = self.getCaretNode()
279279
try:
280280
info = self.treeInterceptor.makeTextInfo(textInfos.POSITION_LAST)
@@ -550,7 +550,7 @@ def isReady(self):
550550

551551
def checkNodeManager(self):
552552
if self.nodeManager is None or not self.nodeManager.isReady:
553-
playWebAppSound("keyError")
553+
playWebAccessSound("keyError")
554554
return False
555555
else:
556556
return True

addon/globalPlugins/webAccess/overlay.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"""
2525

2626
__version__ = "2024.07.24"
27-
__author__ = "Julien Cochuyt <[email protected]>"
27+
__authors__ = (
28+
"Julien Cochuyt <[email protected]>",
29+
"André-Abush Clause <[email protected]>",
30+
"Gatien Bouyssou <[email protected]>",
31+
)
2832

2933

3034
import weakref
@@ -193,7 +197,7 @@ def treeInterceptor(self):
193197

194198
@property
195199
def webModule(self):
196-
from . import supportWebApp, webAccessEnabled
200+
from . import canHaveWebAccessSupport, webAccessEnabled
197201
if not webAccessEnabled:
198202
return None
199203
ti = self.treeInterceptor
@@ -203,7 +207,7 @@ def webModule(self):
203207
webModule = self._webModule
204208
if not webModule:
205209
obj = ti.rootNVDAObject
206-
if not supportWebApp(obj):
210+
if not canHaveWebAccessSupport(obj):
207211
return None
208212
from . import webModuleHandler
209213
try:

addon/globalPlugins/webAccess/ruleHandler/__init__.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
from ..webAppLib import (
6161
html,
6262
logTimeStart,
63-
playWebAppSound,
63+
playWebAccessSound,
6464
)
6565
from .. import webAppScheduler
6666
from . import ruleTypes
@@ -101,7 +101,7 @@ def showManager(context):
101101
webModule = context["webModule"]
102102
mgr = webModule.ruleManager
103103
if not mgr.isReady:
104-
playWebAppSound("keyError")
104+
playWebAccessSound("keyError")
105105
time.sleep(0.2)
106106
speech.cancelSpeech()
107107
ui.message(_("Not ready"))
@@ -123,7 +123,7 @@ def __init__(self, warningMessage):
123123
self.__class__.__gestures["kb:control+shift+%s" % character] = "notAssigned"
124124

125125
def script_notAssigned(self, gesture):
126-
playWebAppSound("keyError")
126+
playWebAccessSound("keyError")
127127
callLater(200, ui.message, self.warningMessage)
128128

129129
__gestures = {}
@@ -391,7 +391,7 @@ def update(self, nodeManager=None, force=False):
391391
self.zone = None
392392
#logTime("update marker", t)
393393
if self.isReady:
394-
webAppScheduler.scheduler.send(eventName="markerManagerUpdated", markerManager=self)
394+
webAppScheduler.scheduler.send(eventName="ruleManagerUpdated", ruleManager=self)
395395
self.timerCheckAutoAction = threading.Timer(
396396
1, # Accepts floating point number for sub-second precision
397397
self.checkAutoAction
@@ -410,7 +410,12 @@ def checkPageTitle(self):
410410
webModule = self.webModule
411411
if title != webModule.activePageTitle:
412412
webModule.activePageTitle = title
413-
webAppScheduler.scheduler.send(eventName="webApp", name="webApp_pageChanged", obj=title, webApp=webModule)
413+
webAppScheduler.scheduler.send(
414+
eventName="webModule",
415+
name="webModule_pageChanged",
416+
obj=title,
417+
webModule=webModule
418+
)
414419
return True
415420
return False
416421

@@ -435,7 +440,7 @@ def checkAutoAction(self):
435440
if (lastText is None or text != lastText):
436441
self.triggeredIdentifiers[controlIdentifier] = text
437442
if autoActionName == "speak":
438-
playWebAppSound("errorMessage")
443+
playWebAccessSound("errorMessage")
439444
elif autoActionName == "moveto":
440445
if lastText is None:
441446
# only if it's a new identifier
@@ -642,7 +647,7 @@ def quickNav(
642647
quiet=False,
643648
):
644649
if not self.isReady:
645-
playWebAppSound("keyError")
650+
playWebAccessSound("keyError")
646651
ui.message(_("Not ready"))
647652
return None
648653

@@ -651,7 +656,7 @@ def quickNav(
651656
position = html.getCaretInfo()
652657

653658
if position is None:
654-
playWebAppSound("keyError")
659+
playWebAccessSound("keyError")
655660
ui.message(_("Not ready"))
656661
return None
657662

@@ -669,11 +674,11 @@ def quickNav(
669674
)
670675
if result:
671676
if not relative:
672-
playWebAppSound("loop")
677+
playWebAccessSound("loop")
673678
time.sleep(0.2)
674679
break
675680
else:
676-
playWebAppSound("keyError")
681+
playWebAccessSound("keyError")
677682
time.sleep(0.2)
678683
if quiet:
679684
return False

0 commit comments

Comments
 (0)