From ccf57f204a134d6d54d7ef20488462c299fc2adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9-Abush=20Clause?= Date: Fri, 24 Apr 2020 04:17:39 +0200 Subject: [PATCH] Don't include dictionaries when a group is enabled (temporary) --- addon/globalPlugins/brailleExtender/__init__.py | 5 ++--- addon/globalPlugins/brailleExtender/brailleTablesExt.py | 3 +++ addon/globalPlugins/brailleExtender/dictionaries.py | 6 ++++-- addon/globalPlugins/brailleExtender/utils.py | 4 +--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addon/globalPlugins/brailleExtender/__init__.py b/addon/globalPlugins/brailleExtender/__init__.py index 45d580a4..0fce127b 100644 --- a/addon/globalPlugins/brailleExtender/__init__.py +++ b/addon/globalPlugins/brailleExtender/__init__.py @@ -203,7 +203,6 @@ def __init__(self): self.backup__addTextWithFields = braille.TextInfoRegion._addTextWithFields self.backup__update = braille.TextInfoRegion.update self.backup__getTypeformFromFormatField = braille.TextInfoRegion._getTypeformFromFormatField - self.backup__brailleTableDict = config.conf["braille"]["translationTable"] braille.TextInfoRegion._addTextWithFields = decorator(braille.TextInfoRegion._addTextWithFields, "addTextWithFields") braille.TextInfoRegion.update = decorator(braille.TextInfoRegion.update, "update") braille.TextInfoRegion._getTypeformFromFormatField = decorator(braille.TextInfoRegion._getTypeformFromFormatField, "_getTypeformFromFormatField") @@ -250,7 +249,6 @@ def event_gainFocus(self, obj, nextHandler): configBE.curBD = braille.handler.display.name self.onReload(None, 1) - if self.backup__brailleTableDict != config.conf["braille"]["translationTable"]: self.reloadBrailleTables() nextHandler() return @@ -307,7 +305,6 @@ def createMenu(self): self.submenu_item = gui.mainFrame.sysTrayIcon.menu.InsertMenu(2, wx.ID_ANY, "%s (%s)" % (_("&Braille Extender"), addonVersion), self.submenu) def reloadBrailleTables(self): - self.backup__brailleTableDict = config.conf["braille"]["translationTable"] dictionaries.setDictTables() dictionaries.notifyInvalidTables() if config.conf["brailleExtender"]["tabSpace"]: @@ -871,6 +868,7 @@ def script_switchInputBrailleTable(self, gesture): e=newGroup ) if not res: raise RuntimeError("error") + self.reloadBrailleTables() utils.refreshBD() dictionaries.setDictTables() desc = (newGroup.name + (" (%s)" % _("group") if len(newGroup.members) > 1 else '') if newGroup else _("Default")) @@ -892,6 +890,7 @@ def script_switchOutputBrailleTable(self, gesture): e=newGroup ) if not res: raise RuntimeError("error") + self.reloadBrailleTables() utils.refreshBD() dictionaries.setDictTables() desc = (newGroup.name + (" (%s)" % _("group") if len(newGroup.members) > 1 else '') if newGroup else _("Default")) diff --git a/addon/globalPlugins/brailleExtender/brailleTablesExt.py b/addon/globalPlugins/brailleExtender/brailleTablesExt.py index 2ee2e0af..54b5154c 100644 --- a/addon/globalPlugins/brailleExtender/brailleTablesExt.py +++ b/addon/globalPlugins/brailleExtender/brailleTablesExt.py @@ -183,6 +183,9 @@ def tablesToGroups(tables, usableIn): )) return groups +def groupEnabled(): + return bool(_groups) + _groups = None _currentGroup = [None, None] diff --git a/addon/globalPlugins/brailleExtender/dictionaries.py b/addon/globalPlugins/brailleExtender/dictionaries.py index 6403429d..87a1e30f 100644 --- a/addon/globalPlugins/brailleExtender/dictionaries.py +++ b/addon/globalPlugins/brailleExtender/dictionaries.py @@ -18,6 +18,7 @@ from collections import namedtuple from . import configBE from .common import * +from . import brailleTablesExt from . import huc from logHandler import log @@ -64,6 +65,7 @@ def getValidPathsDict(): return [path for path in paths if valid(path)] def getPathDict(type_): + if brailleTablesExt.groupEnabled(): return '' if type_ == "table": path = os.path.join(configDir, "brailleDicts", config.conf["braille"]["translationTable"]) elif type_ == "tmp": path = os.path.join(configDir, "brailleDicts", "tmp") else: path = os.path.join(configDir, "brailleDicts", "default") @@ -294,7 +296,7 @@ def __init__(self, parent=None, title=_("Edit Dictionary Entry"), textPattern='' if specifyDict: # Translators: This is a label for an edit field in add dictionary entry dialog. dictText = _("Dictionary") - outTable = configBE.tablesTR[configBE.tablesFN.index(config.conf["braille"]["translationTable"])] + outTable = brailleTablesExt.fileName2displayName(config.conf["braille"]["translationTable"]) dictChoices = [_("Global"), _("Table")+(" (%s)" % outTable), _("Temporary")] self.dictRadioBox = sHelper.addItem(wx.RadioBox(self, label=dictText, choices=dictChoices)) self.dictRadioBox.SetSelection(1) @@ -340,7 +342,7 @@ def __init__(self, parent=None, title=_("Edit Dictionary Entry"), textPattern='' def onSeeEntriesClick(self, evt): - outTable = configBE.tablesTR[configBE.tablesFN.index(config.conf["braille"]["translationTable"])] + outTable = brailleTablesExt.fileName2displayName(config.conf["braille"]["translationTable"]) label = [_("Global dictionary"), _("Table dictionary")+(" (%s)" % outTable), _("Temporary dictionary")][self.dictRadioBox.GetSelection()] type_ = self.getType_() self.Destroy() diff --git a/addon/globalPlugins/brailleExtender/utils.py b/addon/globalPlugins/brailleExtender/utils.py index 346f5d12..a14fad82 100644 --- a/addon/globalPlugins/brailleExtender/utils.py +++ b/addon/globalPlugins/brailleExtender/utils.py @@ -261,9 +261,7 @@ def getTextInBraille(t=None, table=[]): if not t: t = getTextSelection() if not t.strip(): return '' if not table or "current" in table: - currentTable = os.path.join(brailleTables.TABLES_DIR, config.conf["braille"]["translationTable"]) - if "current" in table: table[table.index("current")] = currentTable - else: table.append(currentTable) + table = getCurrentBrailleTables() nt = [] res = '' t = t.split("\n")