Skip to content

Commit

Permalink
Speech Dictionary dialog: Add a "Remove all" button (nvaccess#11802) PR
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienCochuyt authored and lukaszgo1 committed Feb 2, 2022
1 parent 668c6d7 commit 1da86f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion source/gui/speechDict.py
Expand Up @@ -199,7 +199,15 @@ def makeSettings(self, settingsSizer):
label=_("&Remove")
).Bind(wx.EVT_BUTTON, self.onRemoveClick)

sHelper.addItem(bHelper)
bHelper.sizer.AddStretchSpacer()

bHelper.addButton(
parent=self,
# Translators: The label for a button on the Speech Dictionary dialog.
label=_("Remove all")
).Bind(wx.EVT_BUTTON, self.onRemoveAll)

sHelper.addItem(bHelper, flag=wx.EXPAND)

def postInit(self):
self.dictList.SetFocus()
Expand Down Expand Up @@ -268,6 +276,22 @@ def onRemoveClick(self, evt):
index = self.dictList.GetNextSelected(index)
self.dictList.SetFocus()

def onRemoveAll(self, evt):
if gui.messageBox(
# Translators: A prompt for confirmation on the Speech Dictionary dialog.
_("Are you sure you want to remove all the entries in this dictionary?"),
# Translators: The title on a prompt for confirmation on the Speech Dictionary dialog.
_("Remove all"),
style=wx.YES | wx.NO | wx.NO_DEFAULT
) != wx.YES:
return
# Looping instead of clearing here in order to avoid recreation of the columns
# eventually loosing their manually changed widths.
while self.tempSpeechDict:
self.dictList.DeleteItem(0)
del self.tempSpeechDict[0]
self.dictList.SetFocus()


class DefaultDictionaryDialog(DictionaryDialog):
def __init__(self, parent):
Expand Down
2 changes: 1 addition & 1 deletion user_docs/en/userGuide.t2t
Expand Up @@ -1974,7 +1974,7 @@ They are:
You need to assign custom gestures using the [Input Gestures dialog #InputGestures] if you wish to open any of these dictionary dialogs from anywhere.

All dictionary dialogs contain a list of rules which will be used for processing the speech.
The dialog also contains Add, Edit and Remove buttons.
The dialog also contains Add, Edit, Remove and Remove all buttons.

To add a new rule to the dictionary, press the Add button, and fill in the fields in the dialog box that appears and then press Ok.
You will then see your new rule in the list of rules.
Expand Down

0 comments on commit 1da86f8

Please sign in to comment.