Skip to content

Commit

Permalink
Don't include dictionaries when a group is enabled (temporary)
Browse files Browse the repository at this point in the history
  • Loading branch information
AAClause committed Apr 24, 2020
1 parent e84e594 commit ccf57f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions addon/globalPlugins/brailleExtender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down
3 changes: 3 additions & 0 deletions addon/globalPlugins/brailleExtender/brailleTablesExt.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def tablesToGroups(tables, usableIn):
))
return groups

def groupEnabled():
return bool(_groups)

_groups = None
_currentGroup = [None, None]

Expand Down
6 changes: 4 additions & 2 deletions addon/globalPlugins/brailleExtender/dictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from collections import namedtuple
from . import configBE
from .common import *
from . import brailleTablesExt
from . import huc
from logHandler import log

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions addon/globalPlugins/brailleExtender/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ccf57f2

Please sign in to comment.