1 new commit in nvda: https://bitbucket.org/nvdaaddonteam/nvda/commits/8e8fa04144e7/ Changeset: 8e8fa04144e7 Branch: t4354 User: norrumar Date: 2014-11-08 05:58:35+00:00 Summary: Managing pending removals. Focused symbols list also if an added symbol is canceled. Affected #: 2 files diff --git a/source/characterProcessing.py b/source/characterProcessing.py index afbba2c..87cdb4f 100644 --- a/source/characterProcessing.py +++ b/source/characterProcessing.py @@ -371,12 +371,10 @@ class SpeechSymbolProcessor(object): """ self.locale = locale - self.pendingRemovals = [] - # We need to merge symbol data from several sources. sources = self.sources = [] builtin, user = self.localeSymbols.fetchLocaleData(locale,fallback=False) - self.builtinSources = [builtin.symbols] + self.builtinSources = [builtin] self.userSymbols = user sources.append(user) sources.append(builtin) @@ -384,8 +382,9 @@ class SpeechSymbolProcessor(object): # Always use English as a base. if locale != "en": # Only the builtin data. - sources.append(self.localeSymbols.fetchLocaleData("en")[0]) - self.builtinSources.extend(self.localeSymbols.fetchLocaleData("en")[0].symbols) + enBaseSymbols = self.localeSymbols.fetchLocaleData("en")[0] + sources.append(enBaseSymbols) + self.builtinSources.append(enBaseSymbols) # The computed symbol information from all sources. symbols = self.computedSymbols = collections.OrderedDict() @@ -564,17 +563,13 @@ class SpeechSymbolProcessor(object): return True def deleteSymbol(self, symbol): - self.pendingRemovals.append(symbol) + try: + del self.userSymbols.symbols[symbol.identifier] + except KeyError: + pass def isBuiltin(self, symbolIdentifier): - if symbolIdentifier in self.builtinSources: - return True - return False - - def isPendingRemoval(self, symbol): - if symbol in self.pendingRemovals: - return True - return False + return any(symbolIdentifier in source.symbols for source in self.builtinSources) _localeSpeechSymbolProcessors = LocaleDataMap(SpeechSymbolProcessor) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index 44f4975..9687a33 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -1509,6 +1509,7 @@ class SpeechSymbolsDialog(SettingsDialog): symbolProcessor = characterProcessing._localeSpeechSymbolProcessors.fetchLocaleData("en") self.symbolProcessor = symbolProcessor symbols = self.symbols = [copy.copy(symbol) for symbol in self.symbolProcessor.computedSymbols.itervalues()] + self.pendingRemovals = [] sizer = wx.BoxSizer(wx.HORIZONTAL) # Translators: The label for symbols list in symbol pronunciation dialog. @@ -1552,12 +1553,8 @@ class SpeechSymbolsDialog(SettingsDialog): self.removeButton=wx.Button(self,label=_("Re&move")) self.removeButton.Disable() entryButtonsSizer.Add(self.removeButton) - self.restoreButton=wx.Button(self,label=_("Res&tore")) - self.restoreButton.Disable() - entryButtonsSizer.Add(self.restoreButton) addButton.Bind(wx.EVT_BUTTON,self.OnAddClick) self.removeButton.Bind(wx.EVT_BUTTON,self.OnRemoveClick) - self.restoreButton.Bind(wx.EVT_BUTTON,self.OnRestoreClick) settingsSizer.Add(entryButtonsSizer) self.editingItem = None @@ -1578,8 +1575,7 @@ class SpeechSymbolsDialog(SettingsDialog): symbol.replacement = self.replacementEdit.Value symbol.level = characterProcessing.SPEECH_SYMBOL_LEVELS[self.levelList.Selection] self.updateListItem(item, symbol) - self.removeButton.Enabled = not self.symbolProcessor.isBuiltin(symbol.identifier) and not self.symbolProcessor.isPendingRemoval(symbol) - self.restoreButton.Enabled = self.symbolProcessor.isPendingRemoval(symbol) + self.removeButton.Enabled = not self.symbolProcessor.isBuiltin(symbol.identifier) def onListItemFocused(self, evt): # Update the editing controls to reflect the newly selected symbol. @@ -1600,11 +1596,18 @@ class SpeechSymbolsDialog(SettingsDialog): else: evt.Skip() + def isPendingRemoval(self, symbol): + return any(symbol.identifier for symbol in self.pendingRemovals) + def OnAddClick(self,evt): # Translators: This is the label for the add symbol dialog. entryDialog=AddSymbolDialog(self) if entryDialog.ShowModal()==wx.ID_OK: addedSymbol = characterProcessing.SpeechSymbol(entryDialog.identifierTextCtrl.GetValue()) + if self.isPendingRemoval(addedSymbol): + for index, symbol in enumerate(self.pendingRemovals): + if symbol.identifier == addedSymbol.identifier: + del self.pendingRemovals[index] addedSymbol.displayName = entryDialog.identifierTextCtrl.GetValue() addedSymbol.replacement = "" addedSymbol.level = characterProcessing.SYMLVL_ALL @@ -1614,30 +1617,23 @@ class SpeechSymbolsDialog(SettingsDialog): addedIndex=self.symbolsList.GetItemCount()-1 self.symbolsList.Select(addedIndex) self.symbolsList.Focus(addedIndex) - self.symbolsList.SetFocus() + self.symbolsList.SetFocus() entryDialog.Destroy() def OnRemoveClick(self,evt): index=self.symbolsList.GetFirstSelected() symbol = self.symbols[index] - self.symbolProcessor.deleteSymbol(symbol) - self.symbolsList.SetFocus() - - def OnRestoreClick(self,evt): - index=self.symbolsList.GetFirstSelected() - symbol = self.symbols[index] - self.symbolProcessor.pendingRemovals.remove(symbol) + self.pendingRemovals.append(symbol) + del self.symbols[index] + self.symbolsList.DeleteItem(index) self.symbolsList.SetFocus() def onOk(self, evt): self.onSymbolEdited(None) self.editingItem = None + for symbol in self.pendingRemovals: + self.symbolProcessor.deleteSymbol(symbol) for symbol in self.symbols: - if self.symbolProcessor.isPendingRemoval(symbol): - try: - del self.symbolProcessor.userSymbols.symbols[symbol.identifier] - except KeyError: - continue if symbol.replacement == "": continue self.symbolProcessor.updateSymbol(symbol) Repository URL: https://bitbucket.org/nvdaaddonteam/nvda/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.