-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5fdd82
commit a45e287
Showing
2 changed files
with
29 additions
and
23 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,13 +2,12 @@ | |
# This file is covered by the GNU General Public License. | ||
# See the file COPYING.txt for more details. | ||
# Copyright (C) 2023 Cary-rowen <[email protected]> | ||
|
||
import wx | ||
import api | ||
import addonHandler | ||
import ui | ||
import gui | ||
import addonHandler | ||
import globalPluginHandler | ||
import ui | ||
import wx | ||
from scriptHandler import script, getLastScriptRepeatCount | ||
from . import cues | ||
|
||
|
@@ -25,7 +24,7 @@ def __init__(self): | |
self.watchingObj = None | ||
self.lastAttributeText = None | ||
self.timer = wx.Timer(gui.mainFrame) | ||
gui.mainFrame.Bind(wx.EVT_TIMER, self.onTimerEvent, self.timer) | ||
gui.mainFrame.Bind(wx.EVT_TIMER, handler=self.onTimerEvent, source=self.timer) | ||
|
||
@script( | ||
description=_( | ||
|
@@ -37,26 +36,32 @@ def __init__(self): | |
def script_startOrStopWatcher(self, gesture): | ||
if not self.timer: | ||
return | ||
if getLastScriptRepeatCount() > 0: | ||
if self.timer.IsRunning(): | ||
self.timer.Stop() | ||
cues.Stop() | ||
# Translators: Messages reported when watcher is stopped | ||
ui.message(_("Stopped watcher")) | ||
repeatCount = getLastScriptRepeatCount() | ||
if repeatCount > 0: | ||
self._toggleWatcher() | ||
else: | ||
if self.timer.IsRunning(): | ||
ui.message(self._getWatchingAttribute()) | ||
else: | ||
self.watchingObj = api.getNavigatorObject() | ||
self.timer.Start(WATCHER_TIMER_INTERVAL) | ||
if self.watchingObj: | ||
cues.Start() | ||
# Translators: Messages reported when watcher is start. | ||
ui.message(_("Started watcher {}").format(self._getWatchingAttribute())) | ||
else: | ||
cues.NoObj() | ||
# Translators: Messages reported when No navigation object available to watch. | ||
ui.message(_("No navigation object available to watch")) | ||
self._toggleWatcher() | ||
|
||
def _toggleWatcher(self): | ||
if self.timer.IsRunning(): | ||
self.timer.Stop() | ||
cues.Stop() | ||
# Translators: Messages reported when watcher is stopped | ||
ui.message(_("Stopped watcher")) | ||
else: | ||
self.watchingObj = api.getNavigatorObject() | ||
self.timer.Start(WATCHER_TIMER_INTERVAL) | ||
if self.watchingObj: | ||
cues.Start() | ||
# Translators: Messages reported when watcher is started. | ||
ui.message(_("Started watcher {}").format(self._getWatchingAttribute())) | ||
else: | ||
cues.NoObj() | ||
# Translators: Messages reported when no navigation object available to watch. | ||
ui.message(_("No navigation object available to watch")) | ||
|
||
def onTimerEvent(self, event): | ||
if not self.watchingObj: | ||
|
@@ -72,7 +77,7 @@ def _getWatchingAttribute(self): | |
seen_values = set() | ||
for attr in ['name', 'value', 'description']: | ||
if hasattr(self.watchingObj, attr): | ||
value = getattr(self.watchingObj, attr) | ||
value = getattr(self.watchingObj, attr, None) | ||
if value and value not in seen_values: | ||
non_empty_attributes.append(value) | ||
seen_values.add(value) | ||
|
@@ -83,6 +88,7 @@ def terminate(self): | |
super().terminate() | ||
if self.timer: | ||
self.timer.Stop() | ||
self.timer.Destroy() | ||
self.lastAttributeText = None | ||
self.timer = None | ||
self.watchingObj = None | ||
|
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ def _(arg): | |
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager | ||
"addon_description": _("""This NVDA add-on watches changes to attributes of navigation objects."""), | ||
# version | ||
"addon_version": "0.2.0", | ||
"addon_version": "0.2.1", | ||
# Author(s) | ||
"addon_author": "Cary-rowen <[email protected]>", | ||
# URL for the add-on documentation support | ||
|