Skip to content

Commit

Permalink
Created independent methods (outside the scripts) to stop local/remot…
Browse files Browse the repository at this point in the history
…e logging.
  • Loading branch information
Luke Davis authored and XLTechie committed Aug 31, 2023
1 parent 2d062c2 commit 7648ad4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 24 additions & 11 deletions addon/globalPlugins/speechLogger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def speechLogger_speakWithoutPauses( # noqa: C901
SpeechWithoutPauses.speakWithoutPauses = speechLogger_speakWithoutPauses

def terminate(self) -> None:
log.debug("\t\tTerminating...")
# Remove the NVDA settings panel
if not globalVars.appArgs.secure:
gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(SpeechLoggerSettings)
Expand Down Expand Up @@ -201,6 +200,28 @@ def startLocalLog(self, automatic: bool = True) -> bool:
else:
return False

def stopLocalLog(self) -> bool:
if self.flags.localActive: # Currently logging, stop
# Write a message to the log stating that we are no longer logging
self.logToFile(self.files.local, None, self.dynamicLogStoppedText)
self.flags.localActive = False
self.flags.startedLocalLog = False
log.info("Stopped logging local speech.")
return True
else:
return False

def stopRemoteLog(self) -> bool:
if self.flags.remoteActive: # We were logging, stop
# Write a message to the log stating that we have stopped logging
self.logToFile(self.files.remote, None, self.dynamicLogStoppedText)
self.flags.remoteActive = False
self.flags.startedRemoteLog = False
log.info("Stopped logging remote speech.")
return True
else:
return False

def applyUserConfig(self, triggeredByExtensionPoint: bool = True) -> None:
"""Configures internal variables according to those set in NVDA config.
Expand Down Expand Up @@ -396,11 +417,7 @@ def _registerCallback(self) -> bool:
)
def script_toggleLocalSpeechLogging(self, gesture):
"""Toggles whether we are actively logging local speech."""
if self.flags.localActive: # Currently logging, stop
# Write a message to the log stating that we are no longer logging
self.logToFile(self.files.local, None, self.dynamicLogStoppedText)
self.flags.localActive = False
self.flags.startedLocalLog = False
if self.stopLocalLog(): # Stop the local log; returns True if logging was stopped
# Translators: message to tell the user that we are no longer logging.
ui.message(_("Stopped logging local speech."))
else: # Currently not logging, start
Expand All @@ -419,11 +436,7 @@ def script_toggleLocalSpeechLogging(self, gesture):
)
def script_toggleRemoteSpeechLogging(self, gesture):
"""Toggles whether we are actively logging remote speech."""
if self.flags.remoteActive: # We were logging, stop
# Write a message to the log stating that we have stopped logging
self.logToFile(self.files.remote, None, self.dynamicLogStoppedText)
self.flags.remoteActive = False
self.flags.startedRemoteLog = False
if self.stopRemoteLog(): # Stops remote logging if we were; returns True if stopped
# Translators: message to tell the user that we are no longer logging.
ui.message(_("Stopped logging remote speech."))
else: # We weren't logging, start
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": _("""Logs speech utterances to a file. Can also log NVDA remote session speech from the NVDA Remote add-on, to the same or another file."""),
# version
"addon_version": "23.3.003",
"addon_version": "23.3.004",
# Author(s)
"addon_author": "Luke Davis <XLTechie@newanswertech.com>, James Scholes",
# URL for the add-on documentation support
Expand Down

0 comments on commit 7648ad4

Please sign in to comment.