From 9a24d3b06d748b7e155597be6a5269b2f4dff652 Mon Sep 17 00:00:00 2001 From: ruifontes Date: Wed, 23 Jun 2021 01:31:58 +0100 Subject: [PATCH] 21.06.23 Small corrections in shortcuts and in the paste logic --- addon/GlobalPlugins/frequentText/__init__.py | 95 +++++++++++--------- addon/locale/pt_BR/LC_MESSAGES/nvda.po | 62 ++++++------- addon/locale/pt_PT/LC_MESSAGES/nvda.po | 60 ++++++------- buildVars.py | 2 +- 4 files changed, 109 insertions(+), 110 deletions(-) diff --git a/addon/GlobalPlugins/frequentText/__init__.py b/addon/GlobalPlugins/frequentText/__init__.py index f0596a8..7a85f38 100644 --- a/addon/GlobalPlugins/frequentText/__init__.py +++ b/addon/GlobalPlugins/frequentText/__init__.py @@ -194,6 +194,8 @@ def onRename(self, evt): config.rename(nameCatg, newKeyCatg) config.write() self.listCatgs = config.keys() + #self.listCatgs.append(newKeyCatg) + #self.listCatgs.remove(nameCatg) listCatgs = config.keys() # update the list view. self.updateCatgs(listCatgs, index) @@ -302,7 +304,7 @@ def __init__(self, parent, title, dictBlocks): changeButtonID = wx.Window.NewControlId() # Translators: Button Label that change the blocks of text. - self.changeButton = wx.Button(self, changeButtonID, _("Change &blocks")) + self.changeButton = wx.Button(self, changeButtonID, _("&Change blocks")) buttonsSizer.Add (self.changeButton) moveButtonID = wx.Window.NewControlId() @@ -315,11 +317,6 @@ def __init__(self, parent, title, dictBlocks): self.removeButton = wx.Button (self, removeButtonID, _("&Remove")) buttonsSizer.Add (self.removeButton) - goBackButtonID = wx.Window.NewControlId() - # Translators: Label for button to go back to categories list. - self.goBackButton = wx.Button (self, goBackButtonID, _("&Back to categories")) - buttonsSizer.Add (self.goBackButton) - # Translators: Button Label that closes the add-on. cancelButton = wx.Button(self, wx.ID_CANCEL, _("&Close")) buttonsSizer.Add(cancelButton) @@ -334,7 +331,6 @@ def __init__(self, parent, title, dictBlocks): self.Bind(wx.EVT_BUTTON, self.onChangeBlocks, id = changeButtonID) self.Bind(wx.EVT_BUTTON, self.onMove, id = moveButtonID) self.Bind(wx.EVT_BUTTON, self.onRemove, id = removeButtonID) - self.Bind(wx.EVT_BUTTON, self.goBack, id = goBackButtonID) self.listBox.Bind(wx.EVT_KEY_DOWN, self.onKeyPress) mainSizer.Fit(self) self.SetSizer(mainSizer) @@ -389,6 +385,8 @@ def _addBlock(self, name): self.listBox.Focus (newIndex) self.listBox.Select(newIndex) self.listBox.SetFocus() + #name = "" + #newBlock = [] return def onPaste (self, evt): @@ -403,18 +401,31 @@ def onPaste (self, evt): pasteStr = "\r\n".join(paste) if len(paste) >= 2: pasteStr += "\r\n" - clipboardBackup = api.getClipData() - api.copyToClip(pasteStr) - time.sleep(0.1) - api.processPendingEvents(False) - focus = api.getFocusObject() - if focus.windowClassName == "ConsoleWindowClass": - # Windows console window - Control+V doesn't work here, so using an alternative method here - WM_COMMAND = 0x0111 - watchdog.cancellableSendMessage(focus.windowHandle, WM_COMMAND, 0xfff1, 0) + try: + clipboardBackup = api.getClipData() + except OSError: + api.copyToClip(pasteStr) + time.sleep(0.1) + api.processPendingEvents(False) + focus = api.getFocusObject() + if focus.windowClassName == "ConsoleWindowClass": + # Windows console window - Control+V doesn't work here, so using an alternative method here + WM_COMMAND = 0x0111 + watchdog.cancellableSendMessage(focus.windowHandle, WM_COMMAND, 0xfff1, 0) + else: + KeyboardInputGesture.fromName("Control+v").send() else: - KeyboardInputGesture.fromName("Control+v").send() - core.callLater(300, lambda: api.copyToClip(clipboardBackup)) + api.copyToClip(pasteStr) + time.sleep(0.1) + api.processPendingEvents(False) + focus = api.getFocusObject() + if focus.windowClassName == "ConsoleWindowClass": + # Windows console window - Control+V doesn't work here, so using an alternative method here + WM_COMMAND = 0x0111 + watchdog.cancellableSendMessage(focus.windowHandle, WM_COMMAND, 0xfff1, 0) + else: + KeyboardInputGesture.fromName("Control+v").send() + core.callLater(300, lambda: api.copyToClip(clipboardBackup)) def onRename(self, evt): # Renames the selected block. @@ -451,29 +462,29 @@ def onChangeBlocks(self, evt): config = ConfigObj(_ffIniFile, list_values=True, encoding = "utf-8") blocks = config[Catg] paste = blocks[name] - oldBlock = "" - for x in range(len(paste)): - oldBlock += ("%s \n")%paste[x] - x = x+1 self.dialogActive = True - # Translators: Message dialog box to change a block of text. - dlg = wx.TextEntryDialog(gui.mainFrame, _("Change the block of text as you want and press Tab to Ok button and Enter to confirm"), self.title, style = wx.OK | wx.CANCEL | wx.TE_MULTILINE) - dlg.SetValue(oldBlock) - if dlg.ShowModal() == wx.ID_OK: - nBlock = dlg.GetValue() - else: - dlg.Destroy() - return + changeBlock = [] + for x in range(len(paste)): + # Translators: Message dialog box to change a block of text. + dlg = wx.TextEntryDialog(gui.mainFrame, _("Enter the new block of text or press Enter to confirm"), self.title) + dlg.SetValue(paste[x]) + if dlg.ShowModal() == wx.ID_OK: + nBlock = dlg.GetValue() + else: + dlg.Destroy() + return - if nBlock != "": - changeBlock = nBlock.split("\n") - else: - dlg.Destroy() - return + if nBlock != "": + changeBlock.append(nBlock) + elif nBlock == paste[x]: + changeBlock.append(nBlock) + else: + dlg.Destroy() + return # update the dictionary. - blocks.__delitem__(name) + blocks.__delitem__(name) #, paste) blocks.__setitem__(name, changeBlock) config.write() @@ -516,6 +527,10 @@ def onMove (self, evt): def onRemove (self, evt): # Removes the selected block. evt.Skip() + self.removeItem() + + def removeItem (self): + # Removes the selected block. index=self.listBox.GetFocusedItem() name = self.listBox.GetItemText(index) self.dialogActive = True @@ -531,14 +546,6 @@ def onRemove (self, evt): self.dialogActive = False self.listBox.SetFocus() - def goBack(self, evt): - # Returns to categories list dialog - evt.Skip() - config = ConfigObj(_ffIniFile, list_values = True, encoding = "utf-8") - listCatgs = config.keys() - self.Close() - GlobalPlugin.showFrequentTextCatgsDialog(self, listCatgs) - def onKeyPress(self, evt): # Sets enter key to paste the text and delete to remove it. evt.Skip() diff --git a/addon/locale/pt_BR/LC_MESSAGES/nvda.po b/addon/locale/pt_BR/LC_MESSAGES/nvda.po index ced0001..303d7f8 100644 --- a/addon/locale/pt_BR/LC_MESSAGES/nvda.po +++ b/addon/locale/pt_BR/LC_MESSAGES/nvda.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: FrequentText\n" "Report-Msgid-Bugs-To: 'nvda-translations@groups.io'\n" -"POT-Creation-Date: 2021-06-20 19:32+0100\n" -"PO-Revision-Date: 2021-06-20 19:49+0100\n" +"POT-Creation-Date: 2021-06-23 01:19+0100\n" +"PO-Revision-Date: 2021-06-23 01:24+0100\n" "Last-Translator: Rui Fontes \n" "Language-Team: Equipa portuguesa do NVDA\n" "Language: pt\n" @@ -44,30 +44,30 @@ msgstr "Lista dos blocos de texto" #. Translators: Button Label to show the entries in the selected category #: addon\globalPlugins\frequentText\__init__.py:115 msgid "&Show entries" -msgstr "Mostrar &Entradas" +msgstr "&Mostrar Entradas" #. Translators: Button Label to add a new category #. Translators: Button Label to add a new block. #: addon\globalPlugins\frequentText\__init__.py:120 -#: addon\globalPlugins\frequentText\__init__.py:290 +#: addon\globalPlugins\frequentText\__init__.py:292 msgid "&Add" msgstr "&Adicionar" #. Translators: Button Label that renames the name of the selected block. #: addon\globalPlugins\frequentText\__init__.py:125 -#: addon\globalPlugins\frequentText\__init__.py:300 +#: addon\globalPlugins\frequentText\__init__.py:302 msgid "Re&name" msgstr "&Renomear" #. Translators: Button Label that removes the selected block. #: addon\globalPlugins\frequentText\__init__.py:130 -#: addon\globalPlugins\frequentText\__init__.py:315 +#: addon\globalPlugins\frequentText\__init__.py:317 msgid "&Remove" msgstr "&Eliminar" #. Translators: Button Label that closes the add-on. #: addon\globalPlugins\frequentText\__init__.py:134 -#: addon\globalPlugins\frequentText\__init__.py:324 +#: addon\globalPlugins\frequentText\__init__.py:321 msgid "&Close" msgstr "&Fechar" @@ -78,87 +78,80 @@ msgstr "Introduza um nome para a categoria." #. Translators: Announcement that the category name already exists in the list. #: addon\globalPlugins\frequentText\__init__.py:162 -#: addon\globalPlugins\frequentText\__init__.py:207 +#: addon\globalPlugins\frequentText\__init__.py:209 msgid "There is already a category with this name!" msgstr "Já existe uma categoria com este nome!" #. Translators: Message dialog to rename the category #. Translators: Message dialog to rename the block of text. #: addon\globalPlugins\frequentText\__init__.py:189 -#: addon\globalPlugins\frequentText\__init__.py:426 +#: addon\globalPlugins\frequentText\__init__.py:437 #, python-format msgid "Enter a new name for %s" msgstr "Introduza um novo nome para %s" #. Translators: Message dialog box to remove the selected category #. Translators: Message dialog box to remove the selected block. -#: addon\globalPlugins\frequentText\__init__.py:217 -#: addon\globalPlugins\frequentText\__init__.py:523 +#: addon\globalPlugins\frequentText\__init__.py:219 +#: addon\globalPlugins\frequentText\__init__.py:538 #, python-format msgid "Are you sure you want to remove %s?" msgstr "Tem a certeza que quer eliminar %s da lista de blocos?" #. Translators: Title of the column of the list view. -#: addon\globalPlugins\frequentText\__init__.py:250 -#: addon\globalPlugins\frequentText\__init__.py:554 +#: addon\globalPlugins\frequentText\__init__.py:252 +#: addon\globalPlugins\frequentText\__init__.py:561 msgid "Name" msgstr "Nome" #. Create a label and a list view for Frequent Text list. #. Label is above the list view. #. Translators: Label the list view that contains the Blocks. -#: addon\globalPlugins\frequentText\__init__.py:277 +#: addon\globalPlugins\frequentText\__init__.py:279 #, python-format msgid "List of text blocks of %s category" msgstr "Lista de blocos de texto da categoria %s" #. Translators: Button Label that paste the block to the edit box. -#: addon\globalPlugins\frequentText\__init__.py:295 +#: addon\globalPlugins\frequentText\__init__.py:297 msgid "&Paste" msgstr "&Colar" #. Translators: Button Label that change the blocks of text. -#: addon\globalPlugins\frequentText\__init__.py:305 -msgid "Change &blocks" +#: addon\globalPlugins\frequentText\__init__.py:307 +msgid "&Change blocks" msgstr "Modificar &blocos" #. Translators: Label for btton to move the selected block to other category. -#: addon\globalPlugins\frequentText\__init__.py:310 +#: addon\globalPlugins\frequentText\__init__.py:312 msgid "&Move" msgstr "&Mover" -#. Translators: Label for button to go back to categories list. -#: addon\globalPlugins\frequentText\__init__.py:320 -msgid "&Back to categories" -msgstr "&Voltar a categorias" - #. Translators: Message dialog box to add a name to a new block. -#: addon\globalPlugins\frequentText\__init__.py:346 +#: addon\globalPlugins\frequentText\__init__.py:342 msgid "Enter a name for the block" msgstr "Introduza um nome para o bloco." #. Translators: Announcement that the block name already exists in the list. -#: addon\globalPlugins\frequentText\__init__.py:355 -#: addon\globalPlugins\frequentText\__init__.py:444 +#: addon\globalPlugins\frequentText\__init__.py:351 +#: addon\globalPlugins\frequentText\__init__.py:455 msgid "There is already a block with this name!" msgstr "Já existe um bloco com este nome!" #. Translators: Message dialog box to add a new block of text. -#: addon\globalPlugins\frequentText\__init__.py:365 +#: addon\globalPlugins\frequentText\__init__.py:361 msgid "Enter the block of text" msgstr "Introduza o bloco de texto" #. Translators: Message dialog box to change a block of text. -#: addon\globalPlugins\frequentText\__init__.py:461 -msgid "" -"Change the block of text as you want and press Tab to Ok button and Enter to " -"confirm" +#: addon\globalPlugins\frequentText\__init__.py:470 +msgid "Enter the new block of text or press Enter to confirm" msgstr "" "Altere o bloco de texto como quiser, pressione Tab para o botão Ok e Enter " "para confirmar" #. Translators: Message dialog box to move the selected block to other category. -#: addon\globalPlugins\frequentText\__init__.py:497 +#: addon\globalPlugins\frequentText\__init__.py:508 #, python-format msgid "" "If you really want to move %s from %s category, enter the name of the new, " @@ -168,7 +161,7 @@ msgstr "" "já existente" #. Translators: Announcement that the category does not exists. -#: addon\globalPlugins\frequentText\__init__.py:513 +#: addon\globalPlugins\frequentText\__init__.py:524 msgid "There is no such category!" msgstr "Não existe essa categoria!" @@ -189,6 +182,9 @@ msgstr "" "Armazena e torna possível a introdução de blocos de texto frequentemente " "usados. Comando: Windows+f12." +#~ msgid "&Back to categories" +#~ msgstr "&Voltar a categorias" + #~ msgid "Frequent Text" #~ msgstr "Texto frequente" diff --git a/addon/locale/pt_PT/LC_MESSAGES/nvda.po b/addon/locale/pt_PT/LC_MESSAGES/nvda.po index ced0001..b443054 100644 --- a/addon/locale/pt_PT/LC_MESSAGES/nvda.po +++ b/addon/locale/pt_PT/LC_MESSAGES/nvda.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: FrequentText\n" "Report-Msgid-Bugs-To: 'nvda-translations@groups.io'\n" -"POT-Creation-Date: 2021-06-20 19:32+0100\n" -"PO-Revision-Date: 2021-06-20 19:49+0100\n" +"POT-Creation-Date: 2021-06-23 01:19+0100\n" +"PO-Revision-Date: 2021-06-23 01:25+0100\n" "Last-Translator: Rui Fontes \n" "Language-Team: Equipa portuguesa do NVDA\n" "Language: pt\n" @@ -49,25 +49,25 @@ msgstr "Mostrar &Entradas" #. Translators: Button Label to add a new category #. Translators: Button Label to add a new block. #: addon\globalPlugins\frequentText\__init__.py:120 -#: addon\globalPlugins\frequentText\__init__.py:290 +#: addon\globalPlugins\frequentText\__init__.py:292 msgid "&Add" msgstr "&Adicionar" #. Translators: Button Label that renames the name of the selected block. #: addon\globalPlugins\frequentText\__init__.py:125 -#: addon\globalPlugins\frequentText\__init__.py:300 +#: addon\globalPlugins\frequentText\__init__.py:302 msgid "Re&name" msgstr "&Renomear" #. Translators: Button Label that removes the selected block. #: addon\globalPlugins\frequentText\__init__.py:130 -#: addon\globalPlugins\frequentText\__init__.py:315 +#: addon\globalPlugins\frequentText\__init__.py:317 msgid "&Remove" msgstr "&Eliminar" #. Translators: Button Label that closes the add-on. #: addon\globalPlugins\frequentText\__init__.py:134 -#: addon\globalPlugins\frequentText\__init__.py:324 +#: addon\globalPlugins\frequentText\__init__.py:321 msgid "&Close" msgstr "&Fechar" @@ -78,87 +78,80 @@ msgstr "Introduza um nome para a categoria." #. Translators: Announcement that the category name already exists in the list. #: addon\globalPlugins\frequentText\__init__.py:162 -#: addon\globalPlugins\frequentText\__init__.py:207 +#: addon\globalPlugins\frequentText\__init__.py:209 msgid "There is already a category with this name!" msgstr "Já existe uma categoria com este nome!" #. Translators: Message dialog to rename the category #. Translators: Message dialog to rename the block of text. #: addon\globalPlugins\frequentText\__init__.py:189 -#: addon\globalPlugins\frequentText\__init__.py:426 +#: addon\globalPlugins\frequentText\__init__.py:437 #, python-format msgid "Enter a new name for %s" msgstr "Introduza um novo nome para %s" #. Translators: Message dialog box to remove the selected category #. Translators: Message dialog box to remove the selected block. -#: addon\globalPlugins\frequentText\__init__.py:217 -#: addon\globalPlugins\frequentText\__init__.py:523 +#: addon\globalPlugins\frequentText\__init__.py:219 +#: addon\globalPlugins\frequentText\__init__.py:538 #, python-format msgid "Are you sure you want to remove %s?" msgstr "Tem a certeza que quer eliminar %s da lista de blocos?" #. Translators: Title of the column of the list view. -#: addon\globalPlugins\frequentText\__init__.py:250 -#: addon\globalPlugins\frequentText\__init__.py:554 +#: addon\globalPlugins\frequentText\__init__.py:252 +#: addon\globalPlugins\frequentText\__init__.py:561 msgid "Name" msgstr "Nome" #. Create a label and a list view for Frequent Text list. #. Label is above the list view. #. Translators: Label the list view that contains the Blocks. -#: addon\globalPlugins\frequentText\__init__.py:277 +#: addon\globalPlugins\frequentText\__init__.py:279 #, python-format msgid "List of text blocks of %s category" msgstr "Lista de blocos de texto da categoria %s" #. Translators: Button Label that paste the block to the edit box. -#: addon\globalPlugins\frequentText\__init__.py:295 +#: addon\globalPlugins\frequentText\__init__.py:297 msgid "&Paste" msgstr "&Colar" #. Translators: Button Label that change the blocks of text. -#: addon\globalPlugins\frequentText\__init__.py:305 -msgid "Change &blocks" +#: addon\globalPlugins\frequentText\__init__.py:307 +msgid "&Change blocks" msgstr "Modificar &blocos" #. Translators: Label for btton to move the selected block to other category. -#: addon\globalPlugins\frequentText\__init__.py:310 +#: addon\globalPlugins\frequentText\__init__.py:312 msgid "&Move" msgstr "&Mover" -#. Translators: Label for button to go back to categories list. -#: addon\globalPlugins\frequentText\__init__.py:320 -msgid "&Back to categories" -msgstr "&Voltar a categorias" - #. Translators: Message dialog box to add a name to a new block. -#: addon\globalPlugins\frequentText\__init__.py:346 +#: addon\globalPlugins\frequentText\__init__.py:342 msgid "Enter a name for the block" msgstr "Introduza um nome para o bloco." #. Translators: Announcement that the block name already exists in the list. -#: addon\globalPlugins\frequentText\__init__.py:355 -#: addon\globalPlugins\frequentText\__init__.py:444 +#: addon\globalPlugins\frequentText\__init__.py:351 +#: addon\globalPlugins\frequentText\__init__.py:455 msgid "There is already a block with this name!" msgstr "Já existe um bloco com este nome!" #. Translators: Message dialog box to add a new block of text. -#: addon\globalPlugins\frequentText\__init__.py:365 +#: addon\globalPlugins\frequentText\__init__.py:361 msgid "Enter the block of text" msgstr "Introduza o bloco de texto" #. Translators: Message dialog box to change a block of text. -#: addon\globalPlugins\frequentText\__init__.py:461 -msgid "" -"Change the block of text as you want and press Tab to Ok button and Enter to " -"confirm" +#: addon\globalPlugins\frequentText\__init__.py:470 +msgid "Enter the new block of text or press Enter to confirm" msgstr "" "Altere o bloco de texto como quiser, pressione Tab para o botão Ok e Enter " "para confirmar" #. Translators: Message dialog box to move the selected block to other category. -#: addon\globalPlugins\frequentText\__init__.py:497 +#: addon\globalPlugins\frequentText\__init__.py:508 #, python-format msgid "" "If you really want to move %s from %s category, enter the name of the new, " @@ -168,7 +161,7 @@ msgstr "" "já existente" #. Translators: Announcement that the category does not exists. -#: addon\globalPlugins\frequentText\__init__.py:513 +#: addon\globalPlugins\frequentText\__init__.py:524 msgid "There is no such category!" msgstr "Não existe essa categoria!" @@ -189,6 +182,9 @@ msgstr "" "Armazena e torna possível a introdução de blocos de texto frequentemente " "usados. Comando: Windows+f12." +#~ msgid "&Back to categories" +#~ msgstr "&Voltar a categorias" + #~ msgid "Frequent Text" #~ msgstr "Texto frequente" diff --git a/buildVars.py b/buildVars.py index 84d05ea..7d7cf28 100644 --- a/buildVars.py +++ b/buildVars.py @@ -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": _("""Stores and make possible the entry of frequently used blocks of text. Command: Windows+F12."""), # version - "addon_version": "21.06", + "addon_version": "21.06.23", # Author(s) "addon_author": u"Rui Fontes and Ângelo Abrantes ", # URL for the add-on documentation support