Skip to content

Commit 265abd4

Browse files
committed
add terminate method in globalPlugin class to free an instance correctly.
update readme and buildVars
1 parent 12449a4 commit 265abd4

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

addon/globalPlugins/beepKeyboard.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def _reportToggleKey(self):
2525
else: tones.beep(1000,40)
2626
if config.conf['beepKeyboard']['announceToggleStatus']: origReportToggleKey(self)
2727

28-
2928
class BeepKeyboardSettingsPanel(gui.SettingsPanel):
3029
# Translators: This is the label for the beepKeyboard settings category in NVDA Settings screen.
3130
title = _("Beep keyboard")
@@ -61,19 +60,31 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
6160
def __init__(self):
6261
super(globalPluginHandler.GlobalPlugin, self).__init__()
6362
gui.settingsDialogs.NVDASettingsDialog.categoryClasses.append(BeepKeyboardSettingsPanel)
64-
self.setExternalReportToggleStatus()
63+
self.setExternalReportToggleStatus(config.conf['beepKeyboard']['beepToggleKeyChanges'])
6564
if hasattr(config, "post_configProfileSwitch"):
66-
config.post_configProfileSwitch.register(self.setExternalReportToggleStatus)
65+
config.post_configProfileSwitch.register(self.handleConfigProfileSwitch)
6766
else:
68-
config.configProfileSwitched.register(self.setExternalReportToggleStatus)
67+
config.configProfileSwitched.register(self.handleConfigProfileSwitch)
6968

7069
def event_typedCharacter(self, obj, nextHandler, ch):
7170
nextHandler()
7271
if ((config.conf['beepKeyboard']['beepUpperWithCapsLock'] and winUser.getKeyState(winUser.VK_CAPITAL)&1 and ch.isupper())
7372
or (config.conf['beepKeyboard']['beepCharacterWithShift'] and (winUser.getKeyState(winUser.VK_LSHIFT) &32768 or winUser.getKeyState(winUser.VK_RSHIFT) &32768))):
7473
tones.beep(3000,40)
7574

76-
def setExternalReportToggleStatus(self):
77-
if config.conf['beepKeyboard']['beepToggleKeyChanges']:
75+
def setExternalReportToggleStatus(self, flag):
76+
if flag:
7877
keyboardHandler.KeyboardInputGesture._reportToggleKey = _reportToggleKey
7978
else: keyboardHandler.KeyboardInputGesture._reportToggleKey = origReportToggleKey
79+
80+
def handleConfigProfileSwitch(self):
81+
self.setExternalReportToggleStatus(config.conf['beepKeyboard']['beepToggleKeyChanges'])
82+
83+
def terminate(self):
84+
super(GlobalPlugin, self).terminate()
85+
self.setExternalReportToggleStatus(False)
86+
gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(BeepKeyboardSettingsPanel)
87+
if hasattr(config, "post_configProfileSwitch"):
88+
config.post_configProfileSwitch.unregister(self.handleConfigProfileSwitch)
89+
else:
90+
config.configProfileSwitched.unregister(self.handleConfigProfileSwitch)

beepKeyboard.pot

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#, fuzzy
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: 'beepKeyboard' '0.1b1'\n"
9+
"Project-Id-Version: 'beepKeyboard' '0.1b2'\n"
1010
"Report-Msgid-Bugs-To: '[email protected]'\n"
11-
"POT-Creation-Date: 2019-04-12 20:20-0600\n"
11+
"POT-Creation-Date: 2019-04-13 09:13-0600\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -20,27 +20,27 @@ msgstr ""
2020
#. Translators: This is the label for the beepKeyboard settings category in NVDA Settings screen.
2121
#. Add-on summary, usually the user visible name of the addon.
2222
#. Translators: Summary for this add-on to be shown on installation and add-on information.
23-
#: addon\globalPlugins\beepKeyboard.py:31 buildVars.py:17
23+
#: addon\globalPlugins\beepKeyboard.py:30 buildVars.py:17
2424
msgid "Beep keyboard"
2525
msgstr ""
2626

2727
#. Translators: label for a checkbox option in the settings panel.
28-
#: addon\globalPlugins\beepKeyboard.py:36
28+
#: addon\globalPlugins\beepKeyboard.py:35
2929
msgid "Beep for uppercases when &caps lock is on"
3030
msgstr ""
3131

3232
#. Translators: label for a checkbox option in the settings panel.
33-
#: addon\globalPlugins\beepKeyboard.py:39
33+
#: addon\globalPlugins\beepKeyboard.py:38
3434
msgid "Beep for typed characters when &shift is pressed"
3535
msgstr ""
3636

3737
#. Translators: label for a checkbox option in the settings panel.
38-
#: addon\globalPlugins\beepKeyboard.py:42
38+
#: addon\globalPlugins\beepKeyboard.py:41
3939
msgid "Beep for &toggle keys changes"
4040
msgstr ""
4141

4242
#. Translators: label for a checkbox option in the settings panel.
43-
#: addon\globalPlugins\beepKeyboard.py:45
43+
#: addon\globalPlugins\beepKeyboard.py:44
4444
msgid ""
4545
"&Announce toggle keys changes (if Beep for toggle keys changes is disabled "
4646
"NVDA will have the original behavior)"

buildVars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
2020
"addon_description" : _("""This add-on beeps with some keyboard events."""),
2121
# version
22-
"addon_version" : "0.1b1",
22+
"addon_version" : "0.1b2",
2323
# Author(s)
2424
"addon_author" : u"David CM <[email protected]>",
2525
# URL for the add-on documentation support

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This add-on allows the user to configure NVDA to beeps with some keyboard events
33

44
Copyright (C) 2019 David CM <[email protected]>
55

6-
This package is distributed under the terms of the GNU General Public License, version 2 or later. Please see the file COPYING.txt for further details.
6+
This package is distributed under the terms of the GNU General Public License, version 2 or later.
77

88
## Features
99

0 commit comments

Comments
 (0)