From 1da86f894814059e3d81cd666693bc0f29ad694f Mon Sep 17 00:00:00 2001 From: Julien Cochuyt Date: Mon, 10 May 2021 01:13:49 +0200 Subject: [PATCH] Speech Dictionary dialog: Add a "Remove all" button (#11802) PR #13294 --- source/gui/speechDict.py | 26 +++++++++++++++++++++++++- user_docs/en/userGuide.t2t | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/gui/speechDict.py b/source/gui/speechDict.py index c8260b8e1d5..908b6878e92 100644 --- a/source/gui/speechDict.py +++ b/source/gui/speechDict.py @@ -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() @@ -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): diff --git a/user_docs/en/userGuide.t2t b/user_docs/en/userGuide.t2t index d30e70a7684..a324901196d 100644 --- a/user_docs/en/userGuide.t2t +++ b/user_docs/en/userGuide.t2t @@ -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.