[orca] Remove cruft left over after the creation of the settings manager.
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Remove cruft left over after the creation of the settings manager.
- Date: Sun, 1 Apr 2012 01:33:28 +0000 (UTC)
commit 959eebcc4145c4412e4dbfee037024537cdc2d20
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Mar 31 20:37:07 2012 -0400
Remove cruft left over after the creation of the settings manager.
src/orca/Makefile.am | 1 -
src/orca/app_gui_prefs.py | 62 +---
src/orca/app_prefs.py | 417 ++++++++++++++++++++++-
src/orca/backends/json_backend.py | 5 +-
src/orca/bookmarks.py | 7 +-
src/orca/orca.py | 24 +--
src/orca/orca_gui_prefs.py | 6 +-
src/orca/orca_prefs.py | 698 -------------------------------------
src/orca/settings.py | 7 -
src/orca/settings_manager.py | 24 +-
10 files changed, 445 insertions(+), 806 deletions(-)
---
diff --git a/src/orca/Makefile.am b/src/orca/Makefile.am
index 755cd0e..a3ab28e 100644
--- a/src/orca/Makefile.am
+++ b/src/orca/Makefile.am
@@ -48,7 +48,6 @@ orca_python_PYTHON = \
orca_gui_quit.py \
orca_gui_splash.py \
orca_i18n.py \
- orca_prefs.py \
orca_state.py \
outline.py \
phonnames.py \
diff --git a/src/orca/app_gui_prefs.py b/src/orca/app_gui_prefs.py
index debb164..4a93aa3 100644
--- a/src/orca/app_gui_prefs.py
+++ b/src/orca/app_gui_prefs.py
@@ -36,11 +36,10 @@ import debug
import input_event
import keybindings
import orca
-import orca_gtkbuilder
import orca_gui_prefs
-import orca_prefs
import orca_state
import orca_platform
+import settings
import speech
from orca_i18n import _ # for gettext support
@@ -242,7 +241,7 @@ class OrcaSetupGUI(orca_gui_prefs.OrcaSetupGUI):
self.kbindings = self.appKeyBindings
orca_gui_prefs.OrcaSetupGUI._populateKeyBindings(self, False)
- def okButtonClicked(self, widget):
+ def okButtonClicked(self, widget=None):
"""Signal handler for the "clicked" signal for the okButton
GtkButton widget. The user has clicked the OK button.
Write out the users preferences. If GNOME accessibility hadn't
@@ -270,40 +269,6 @@ class OrcaSetupGUI(orca_gui_prefs.OrcaSetupGUI):
orca_state.appOS = None
-class WarningDialogGUI(orca_gtkbuilder.GtkBuilderWrapper):
-
- def getPrefsWarningDialog(self):
- """Return a handle to the Orca Preferences warning dialog.
- """
-
- return self.orcaPrefsWarningDialog
-
- def orcaPrefsWarningDialogDestroyed(self, widget):
- """Signal handler for the "destroyed" signal for the
- orcaPrefsWarningDialog GtkWindow widget. Reset orca_state.orcaWD
- to None, so that the GUI can be rebuilt from the GtkBuilder file the
- next time that this warning dialog has to be displayed.
-
- Arguments:
- - widget: the component that generated the signal.
- """
-
- orca_state.orcaWD = None
-
- def orcaPrefsWarningDialogOKButtonClicked(self, widget):
- """Signal handler for the "clicked" signal for the
- orcaPrefsWarningDialogOKButton GtkButton widget. The user has clicked
- the OK button in the Orca Preferences warning dialog.
- This dialog informs the user that they already have an instance
- of an Orca preferences dialog open, and that they will need to
- close it before opening a new one.
-
- Arguments:
- - widget: the component that generated the signal.
- """
-
- self.orcaPrefsWarningDialog.destroy()
-
def showPreferencesUI():
global applicationName, appScript
@@ -329,7 +294,10 @@ def showPreferencesUI():
line = _("Starting Orca Preferences for %s.") % applicationName
appScript.presentMessage(line)
- prefsDict = orca_prefs.readPreferences()
+ prefsDict = {}
+ for key in settings.userCustomizableSettings:
+ prefsDict[key] = _settingsManager.getSetting(key)
+
orca_state.prefsUIFile = \
os.path.join(orca_platform.prefix,
orca_platform.datadirname,
@@ -342,23 +310,11 @@ def showPreferencesUI():
orca_state.appOS.initAppGUIState(appScript)
orca_state.appOS.init()
+ orca_state.appOS.showGUI()
else:
if not orca_state.orcaWD:
- orca_state.orcaWarningDialogUIFile = \
- os.path.join(orca_platform.prefix,
- orca_platform.datadirname,
- orca_platform.package,
- "ui",
- "orca-preferences-warning.ui")
- orca_state.orcaWD = \
- WarningDialogGUI(orca_state.orcaWarningDialogUIFile,
- "orcaPrefsWarningDialog")
- warningDialog = orca_state.orcaWD.getPrefsWarningDialog()
- warningDialog.realize()
- warningDialog.show()
- return
-
- orca_state.appOS.showGUI()
+ orca_state.orcaWD = orca_gui_prefs.WarningDialogGUI()
+ orca_state.orcaWD.showGUI()
def main():
locale.setlocale(locale.LC_ALL, '')
diff --git a/src/orca/app_prefs.py b/src/orca/app_prefs.py
index dbbb0a6..c53f74e 100644
--- a/src/orca/app_prefs.py
+++ b/src/orca/app_prefs.py
@@ -28,12 +28,22 @@ __copyright__ = "Copyright (c) 2007-2008 Sun Microsystems Inc."
__license__ = "LGPL"
import os
+import pprint
import debug
-import orca_prefs
+import orca
import settings
-class OrcaPrefs(orca_prefs.OrcaPrefs):
+_settingsManager = getattr(orca, '_settingsManager')
+
+# The same fields than in orca_gui_prefs.py:
+#
+(HANDLER, DESCRIP, MOD_MASK1, MOD_USED1, KEY1, CLICK_COUNT1, OLDTEXT1, \
+ TEXT1, MODIF, EDITABLE) = range(10)
+
+(ACTUAL, REPLACEMENT) = range(2)
+
+class OrcaPrefs:
def __init__(self, prefsDict, appName=None, appScript=None,
keyBindingsTreeModel=None,
@@ -52,8 +62,9 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
None if we are writing out console preferences.
"""
- orca_prefs.OrcaPrefs.__init__(self, prefsDict, keyBindingsTreeModel,
- pronunciationTreeModel)
+ self.prefsDict = prefsDict
+ self.keyBindingsTreeModel = keyBindingsTreeModel
+ self.pronunciationTreeModel = pronunciationTreeModel
self.appName = appName
self.appScript = appScript
@@ -66,6 +77,44 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
prefs.writelines("#\n")
prefs.writelines('def overrideAppKeyBindings(script, keyB):\n')
+ def _writeKeyBinding(self, prefs, tupl):
+ """Writes a single keyBinding to the user-settings.py
+ keyBindings section.
+
+ Arguments:
+ - prefs: text string - file to write the key binding to.
+ - tupl: tuple - a tuple with the values of the
+ keybinding (Gtk.TreeStore model columns)
+ """
+
+ prefs.writelines(" keyB.removeByHandler(script.inputEventHandlers['" \
+ + str(tupl[HANDLER])+"'])\n")
+ if not (tupl[TEXT1]):
+ prefs.writelines(" keyB.add(orca.keybindings.KeyBinding(\n")
+ prefs.writelines(" '',\n")
+ prefs.writelines(" %d,\n" % settings.defaultModifierMask)
+ prefs.writelines(" 0,\n")
+ prefs.writelines(' script.inputEventHandlers["' + \
+ str(tupl[HANDLER]) +'"]))\n\n')
+
+ if (tupl[TEXT1]):
+ prefs.writelines(" keyB.add(orca.keybindings.KeyBinding(\n")
+ prefs.writelines(" '" + str(tupl[KEY1]) + "',\n")
+ if tupl[MOD_MASK1] or tupl[MOD_USED1]:
+ prefs.writelines(" " + str(tupl[MOD_MASK1]) + ",\n")
+ prefs.writelines(" " + str(tupl[MOD_USED1]) + ",\n")
+ else:
+ prefs.writelines(" 0,\n")
+ prefs.writelines(" 0,\n")
+ if (tupl[CLICK_COUNT1] == "1"):
+ prefs.writelines(' script.inputEventHandlers["' + \
+ str(tupl[HANDLER]) +'"]))\n\n')
+ else:
+ prefs.writelines(' script.inputEventHandlers["' + \
+ str(tupl[HANDLER]) +'"],\n')
+ prefs.writelines(" " + str(tupl[CLICK_COUNT1]) + \
+ "))\n\n")
+
def _writeAppKeyBindingsPostamble(self, prefs, appName, appScript):
"""Writes the postamble to the
XDG_DATA_HOME/orca/app-settings/<APPNAME>.py keyBindings section.
@@ -79,6 +128,21 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
prefs.writelines(' return keyB')
prefs.writelines("\n\n")
+ def _iterateKeyBindings(self, prefs, treeModel):
+ """Iterate over all the key bindings in the tree model and write
+ out all that the user has modified.
+ """
+
+ thisIter = treeModel.get_iter_first()
+ while thisIter != None:
+ iterChild = treeModel.iter_children(thisIter)
+ while iterChild != None:
+ values = treeModel.get(iterChild, 0,1,2,3,4,5,6,7,8,9)
+ if values[MODIF]:
+ self._writeKeyBinding(prefs, values)
+ iterChild = treeModel.iter_next(iterChild)
+ thisIter = treeModel.iter_next(thisIter)
+
def _writeAppKeyBindingsMap(self, prefs, appName, appScript, treeModel):
"""Write to an application specific configuration file 'prefs', the
key bindings passed in the model treeModel.
@@ -133,6 +197,23 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
prefs.writelines(" orca.pronunciation_dict.setPronunciation(" + \
repr(word) + ", " + repr(value) + ", pronunciations)\n")
+ def _iteratePronunciations(self, prefs, treeModel):
+ """Iterate over each of the entries in the tree model and write out
+ a pronunciation diction entry for them. If any strings with an
+ actual string of "" are found, they are ignored.
+ """
+
+ thisIter = treeModel.get_iter_first()
+ while thisIter != None:
+ values = treeModel.get(thisIter, ACTUAL, REPLACEMENT)
+ word = values[ACTUAL]
+ value = values[REPLACEMENT]
+
+ if word != "":
+ self._writePronunciation(prefs, word, value)
+
+ thisIter = treeModel.iter_next(thisIter)
+
def _writePronunciationMap(self, prefs, treeModel):
"""Write to configuration file 'prefs' the new application specific
pronunciation dictionary entries passed in the model treeModel.
@@ -183,6 +264,314 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
prefs.writelines("except ImportError:\n")
prefs.writelines(" pass\n")
+ def _getSpeechServerFactoryString(self, factory):
+ """Returns a string that represents the speech server factory passed in.
+
+ Arguments:
+ - factory: the speech server factory
+
+ Returns a string suitable for the preferences file.
+ """
+
+ if not factory:
+ return None
+ elif isinstance(factory, basestring):
+ return "'%s'" % factory
+ else:
+ return "'%s'" % factory.__name__
+
+ def _getSpeechServerString(self, server):
+ """Returns a string that represents the speech server passed in.
+
+ Arguments:
+ - server: a speech server
+
+ Returns a string suitable for the preferences file.
+ """
+ if not server:
+ return None
+ elif isinstance(server, [].__class__):
+ return repr(server)
+ else:
+ return repr(server.getInfo())
+
+ def _getVoicesString(self, voices):
+ """Returns a string that represents the list of voices passed in.
+
+ Arguments:
+ - voices: a list of ACSS instances.
+
+ Returns a string suitable for the preferences file.
+ """
+
+ voicesStr = "{\n"
+ for voice in voices:
+ # Hack to deal with the fact that we're creating a string from
+ # a setting in which dictionary keys may be in unicode. This
+ # later causes equality checks to fail. Such nonsense should
+ # go away when app settings are also fully managed by the
+ # settings manager.
+ voiceDict = voices[voice]
+ newDict = {}
+ for key, value in voiceDict.items():
+ newDict[str(key)] = value
+ voicesStr += "'%s' : orca.acss.ACSS(" % voice
+ voicesStr += pprint.pformat(newDict) + "),\n"
+ voicesStr += "}"
+
+ return voicesStr
+
+ def _getKeyboardLayoutString(self, keyboardLayout):
+ """Returns a string that represents the keyboard layout passed in."""
+
+ if keyboardLayout == settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP:
+ return "orca.settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP"
+ else:
+ return "orca.settings.GENERAL_KEYBOARD_LAYOUT_LAPTOP"
+
+ def _getOrcaModifierKeysString(self, orcaModifierKeys):
+ """Returns a string that represents the Orca modifier keys passed in."""
+
+ return "%s" % orcaModifierKeys
+
+ def _getSpokenTextAttributesString(self, enabledSpokenTextAttributes):
+ """ Returns a string that represents the enabled spoken text attributes
+ passed in.
+ """
+
+ return "\"" + enabledSpokenTextAttributes + "\""
+
+ def _getBrailledTextAttributesString(self, enabledBrailledTextAttributes):
+ """ Returns a string that represents the enabled brailled text
+ attributes passed in.
+ """
+
+ return "\"" + enabledBrailledTextAttributes + "\""
+
+ def _getTextAttributesBrailleIndicatorString(self, brailleIndicator):
+ """Returns a string that represents the text attribute braille indicator
+ value passed in."""
+
+ if brailleIndicator == settings.TEXT_ATTR_BRAILLE_NONE:
+ return "orca.settings.TEXT_ATTR_BRAILLE_NONE"
+ elif brailleIndicator == settings.TEXT_ATTR_BRAILLE_7:
+ return "orca.settings.TEXT_ATTR_BRAILLE_7"
+ elif brailleIndicator == settings.TEXT_ATTR_BRAILLE_8:
+ return "orca.settings.TEXT_ATTR_BRAILLE_8"
+ elif brailleIndicator == settings.TEXT_ATTR_BRAILLE_BOTH:
+ return "orca.settings.TEXT_ATTR_BRAILLE_BOTH"
+ else:
+ return "orca.settings.TEXT_ATTR_BRAILLE_NONE"
+
+ def _getBrailleSelectionIndicatorString(self, selectionIndicator):
+ """Returns a string that represents the braille selection indicator
+ value passed in."""
+
+ if selectionIndicator == settings.BRAILLE_SEL_NONE:
+ return "orca.settings.BRAILLE_SEL_NONE"
+ elif selectionIndicator == settings.BRAILLE_SEL_7:
+ return "orca.settings.BRAILLE_SEL_7"
+ elif selectionIndicator == settings.BRAILLE_SEL_8:
+ return "orca.settings.BRAILLE_SEL_8"
+ elif selectionIndicator == settings.BRAILLE_SEL_BOTH:
+ return "orca.settings.BRAILLE_SEL_BOTH"
+ else:
+ return "orca.settings.BRAILLE_SEL_NONE"
+
+ def _getBrailleLinkIndicatorString(self, linkIndicator):
+ """Returns a string that represents the braille link indicator
+ value passed in."""
+
+ if linkIndicator == settings.BRAILLE_LINK_NONE:
+ return "orca.settings.BRAILLE_LINK_NONE"
+ elif linkIndicator == settings.BRAILLE_LINK_7:
+ return "orca.settings.BRAILLE_LINK_7"
+ elif linkIndicator == settings.BRAILLE_LINK_8:
+ return "orca.settings.BRAILLE_LINK_8"
+ elif linkIndicator == settings.BRAILLE_LINK_BOTH:
+ return "orca.settings.BRAILLE_LINK_BOTH"
+ else:
+ return "orca.settings.BRAILLE_LINK_NONE"
+
+ def _getVerbosityString(self, verbosityLevel):
+ """Returns a string that represents the verbosity level passed in."""
+
+ if verbosityLevel == settings.VERBOSITY_LEVEL_BRIEF:
+ return "orca.settings.VERBOSITY_LEVEL_BRIEF"
+ elif verbosityLevel == settings.VERBOSITY_LEVEL_VERBOSE:
+ return "orca.settings.VERBOSITY_LEVEL_VERBOSE"
+ else:
+ return "orca.settings.VERBOSITY_LEVEL_VERBOSE"
+
+ def _getBrailleRolenameStyleString(self, rolenameStyle):
+ """Returns a string that represents the rolename style passed in."""
+
+ if rolenameStyle == settings.BRAILLE_ROLENAME_STYLE_SHORT:
+ return "orca.settings.BRAILLE_ROLENAME_STYLE_SHORT"
+ elif rolenameStyle == settings.BRAILLE_ROLENAME_STYLE_LONG:
+ return "orca.settings.BRAILLE_ROLENAME_STYLE_LONG"
+ else:
+ return "orca.settings.BRAILLE_ROLENAME_STYLE_LONG"
+
+ def _getBrailleAlignmentStyleString(self, brailleAlignmentStyle):
+ """Returns a string that represents the brailleAlignmentStyle
+ passed in."""
+
+ if brailleAlignmentStyle == settings.ALIGN_BRAILLE_BY_WORD:
+ return "orca.settings.ALIGN_BRAILLE_BY_WORD"
+ if brailleAlignmentStyle == settings.ALIGN_BRAILLE_BY_MARGIN:
+ return "orca.settings.ALIGN_BRAILLE_BY_MARGIN"
+ else:
+ return "orca.settings.ALIGN_BRAILLE_BY_EDGE"
+
+ def _getVerbalizePunctuationStyleString(self, punctuationStyle):
+ """Returns a string that represents the punctuation style passed in."""
+
+ if punctuationStyle == settings.PUNCTUATION_STYLE_NONE:
+ return "orca.settings.PUNCTUATION_STYLE_NONE"
+ elif punctuationStyle == settings.PUNCTUATION_STYLE_SOME:
+ return "orca.settings.PUNCTUATION_STYLE_SOME"
+ elif punctuationStyle == settings.PUNCTUATION_STYLE_MOST:
+ return "orca.settings.PUNCTUATION_STYLE_MOST"
+ elif punctuationStyle == settings.PUNCTUATION_STYLE_ALL:
+ return "orca.settings.PUNCTUATION_STYLE_ALL"
+ else:
+ return "orca.settings.PUNCTUATION_STYLE_ALL"
+
+ def _getPresentTimeString(self, val):
+ if val == settings.TIME_FORMAT_24_HMS:
+ return "orca.settings.TIME_FORMAT_24_HMS"
+ elif val == settings.TIME_FORMAT_24_HMS_WITH_WORDS:
+ return "orca.settings.TIME_FORMAT_24_HMS_WITH_WORDS"
+ elif val == settings.TIME_FORMAT_24_HM:
+ return "orca.settings.TIME_FORMAT_24_HM"
+ elif val == settings.TIME_FORMAT_24_HM_WITH_WORDS:
+ return "orca.settings.TIME_FORMAT_24_HM_WITH_WORDS"
+ else:
+ return "orca.settings.TIME_FORMAT_LOCALE"
+
+ def _getPresentDateString(self, val):
+ if val == settings.DATE_FORMAT_NUMBERS_DM:
+ return "orca.settings.DATE_FORMAT_NUMBERS_DM"
+ elif val == settings.DATE_FORMAT_NUMBERS_MD:
+ return "orca.settings.DATE_FORMAT_NUMBERS_MD"
+ elif val == settings.DATE_FORMAT_NUMBERS_DMY:
+ return "orca.settings.DATE_FORMAT_NUMBERS_DMY"
+ elif val == settings.DATE_FORMAT_NUMBERS_MDY:
+ return "orca.settings.DATE_FORMAT_NUMBERS_MDY"
+ elif val == settings.DATE_FORMAT_NUMBERS_YMD:
+ return "orca.settings.DATE_FORMAT_NUMBERS_YMD"
+ elif val == settings.DATE_FORMAT_FULL_DM:
+ return "orca.settings.DATE_FORMAT_FULL_DM"
+ elif val == settings.DATE_FORMAT_FULL_MD:
+ return "orca.settings.DATE_FORMAT_FULL_MD"
+ elif val == settings.DATE_FORMAT_FULL_DMY:
+ return "orca.settings.DATE_FORMAT_FULL_DMY"
+ elif val == settings.DATE_FORMAT_FULL_MDY:
+ return "orca.settings.DATE_FORMAT_FULL_MDY"
+ elif val == settings.DATE_FORMAT_FULL_YMD:
+ return "orca.settings.DATE_FORMAT_FULL_YMD"
+ elif val == settings.DATE_FORMAT_ABBREVIATED_DM:
+ return "orca.settings.DATE_FORMAT_ABBREVIATED_DM"
+ elif val == settings.DATE_FORMAT_ABBREVIATED_MD:
+ return "orca.settings.DATE_FORMAT_ABBREVIATED_MD"
+ elif val == settings.DATE_FORMAT_ABBREVIATED_DMY:
+ return "orca.settings.DATE_FORMAT_ABBREVIATED_DMY"
+ elif val == settings.DATE_FORMAT_ABBREVIATED_MDY:
+ return "orca.settings.DATE_FORMAT_ABBREVIATED_MDY"
+ elif val == settings.DATE_FORMAT_ABBREVIATED_YMD:
+ return "orca.settings.DATE_FORMAT_ABBREVIATED_YMD"
+ else:
+ return "orca.settings.DATE_FORMAT_LOCALE"
+
+ def _getSayAllStyleString(self, sayAllStyle):
+ """Returns a string that represents the say all style passed in."""
+
+ if sayAllStyle == settings.SAYALL_STYLE_LINE:
+ return "orca.settings.SAYALL_STYLE_LINE"
+ elif sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
+ return "orca.settings.SAYALL_STYLE_SENTENCE"
+
+ def _getProgressBarVerbosityString(self, verbosityLevel):
+ """Returns a string that represents the progress bar verbosity level
+ passed in.
+
+ Arguments:
+ - verbosityLevel: verbosity level for progress bars.
+
+ Returns a string suitable for the preferences file.
+ """
+
+ if verbosityLevel == settings.PROGRESS_BAR_ALL:
+ return "orca.settings.PROGRESS_BAR_ALL"
+ elif verbosityLevel == settings.PROGRESS_BAR_WINDOW:
+ return "orca.settings.PROGRESS_BAR_WINDOW"
+ else:
+ return "orca.settings.PROGRESS_BAR_APPLICATION"
+
+ def _getValueForKey(self, prefsDict, key):
+ """Return the value associated with this preferences dictionary key
+
+ Arguments:
+ - prefsDict: a dictionary where the keys are orca preferences
+ names and the values are the values for the preferences.
+ - key: the preferences dictionary key.
+
+ Return the value of the given preferences dictionary key.
+ """
+
+ value = None
+ if key in prefsDict:
+ if key == "voices":
+ value = self._getVoicesString(prefsDict[key])
+ elif key == "speechServerInfo":
+ value = self._getSpeechServerString(prefsDict[key])
+ elif key == "speechServerFactory":
+ value = self._getSpeechServerFactoryString(prefsDict[key])
+ elif key.endswith("VerbosityLevel"):
+ value = self._getVerbosityString(prefsDict[key])
+ elif key == "brailleRolenameStyle":
+ value = self._getBrailleRolenameStyleString(prefsDict[key])
+ elif key == "brailleSelectorIndicator":
+ value = self._getBrailleSelectionIndicatorString(prefsDict[key])
+ elif key == "brailleLinkIndicator":
+ value = self._getBrailleLinkIndicatorString(prefsDict[key])
+ elif key == "brailleAlignmentStyle":
+ value = self._getBrailleAlignmentStyleString(prefsDict[key])
+ elif key == "verbalizePunctuationStyle":
+ value = self._getVerbalizePunctuationStyleString(prefsDict[key])
+ elif key == "presentDateFormat":
+ value = self._getPresentDateString(prefsDict[key])
+ elif key == "presentTimeFormat":
+ value = self._getPresentTimeString(prefsDict[key])
+ elif key == "sayAllStyle":
+ value = self._getSayAllStyleString(prefsDict[key])
+ elif key == "keyboardLayout":
+ value = self._getKeyboardLayoutString(prefsDict[key])
+ elif key == "orcaModifierKeys":
+ value = self._getOrcaModifierKeysString(prefsDict[key])
+ elif key == "enabledSpokenTextAttributes":
+ value = self._getSpokenTextAttributesString(prefsDict[key])
+ elif key == "enabledBrailledTextAttributes":
+ value = self._getBrailledTextAttributesString(prefsDict[key])
+ elif key == "textAttributesBrailleIndicator":
+ value = self._getTextAttributesBrailleIndicatorString( \
+ prefsDict[key])
+ elif key == "progressBarVerbosity":
+ value = self._getProgressBarVerbosityString(prefsDict[key])
+ elif key == "brailleContractionTable":
+ value = "'%s'" % prefsDict[key]
+ elif key == "brailleEOLIndicator":
+ value = "'%s'" % prefsDict[key]
+ elif key == "brailleRequiredStateString":
+ value = "'%s'" % prefsDict[key]
+ elif key == "speechRequiredStateString":
+ value = "'%s'" % prefsDict[key]
+ else:
+ value = prefsDict[key]
+
+ return value
+
@staticmethod
def valueChanged(oldValue, newValue):
"""Work around for the fact that some settings are lists/dictionaries
@@ -197,6 +586,20 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
except:
return True
+ @staticmethod
+ def readPreferences():
+ """Returns a dictionary containing the names and values of the
+ customizable features of Orca."""
+
+ prefsDict = {}
+ for key in settings.userCustomizableSettings:
+ try:
+ prefsDict[key] = getattr(settings, key)
+ except:
+ pass
+
+ return prefsDict
+
def writePreferences(self):
"""Creates the directory and files to hold application specific
user preferences. Write out any preferences that are different
@@ -208,13 +611,11 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
settings to take effect.
"""
- self._setupPreferencesDirs()
-
- oldPrefsDict = orca_prefs.readPreferences()
+ oldPrefsDict = self.readPreferences()
# Write XDG_DATA_HOME/orca/app-settings/<APPNAME>.py
#
- orcaDir = settings.userPrefsDir
+ orcaDir = _settingsManager.getPrefsDir()
orcaSettingsDir = os.path.join(orcaDir, "app-settings")
appFileName = "%s.py" % self.appName
prefs = open(os.path.join(orcaSettingsDir, appFileName), "w")
diff --git a/src/orca/backends/json_backend.py b/src/orca/backends/json_backend.py
index b862d55..ea342db 100644
--- a/src/orca/backends/json_backend.py
+++ b/src/orca/backends/json_backend.py
@@ -33,15 +33,14 @@ from orca import settings, acss
class Backend:
- def __init__(self):
+ def __init__(self, prefsDir):
""" Initialize the JSON Backend.
"""
self.general = {}
self.pronunciations = {}
self.keybindings = {}
self.profiles = {}
- self.settingsFile = os.path.join(settings.userPrefsDir,
- "user-settings.conf")
+ self.settingsFile = os.path.join(prefsDir, "user-settings.conf")
def saveDefaultSettings(self, general, pronunciations, keybindings):
""" Save default settings for all the properties from
diff --git a/src/orca/bookmarks.py b/src/orca/bookmarks.py
index b5929e1..477fcd7 100644
--- a/src/orca/bookmarks.py
+++ b/src/orca/bookmarks.py
@@ -22,12 +22,13 @@
import pickle
import os
+import orca
import speech
-import settings
import orca_state
from orca_i18n import _
+_settingsManager = getattr(orca, '_settingsManager')
class Bookmarks:
"""Represents a default bookmark handler."""
@@ -212,7 +213,7 @@ class Bookmarks:
""" Read saved bookmarks from disk. Currently an unpickled object
that represents a bookmark """
filename = filename or self._script.name.split(' ')[0]
- orcaDir = settings.userPrefsDir
+ orcaDir = _settingsManager.getPrefsDir()
orcaBookmarksDir = os.path.join(orcaDir, "bookmarks")
try:
inputFile = open( os.path.join( orcaBookmarksDir, \
@@ -227,7 +228,7 @@ class Bookmarks:
""" Write bookmarks to disk. bookmarksObj must be a pickleable
object. """
filename = filename or self._script.name.split(' ')[0]
- orcaDir = settings.userPrefsDir
+ orcaDir = _settingsManager.getPrefsDir()
orcaBookmarksDir = os.path.join(orcaDir, "bookmarks")
# create directory if it does not exist. correct place??
try:
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 1c28f96..a796cef 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -2,7 +2,7 @@
#
# Copyright 2004-2009 Sun Microsystems Inc.
# Copyright 2010-2011 The Orca Team
-# Copyright 2012 Igalia
+# Copyright 2012 Igalia, S.L.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -384,16 +384,12 @@ options, invalidOpts = parser.parse_known_args(sys.argv[1].split(),
namespace = Options())
options.validate()
-
-if options.userPrefsDir:
- settings.userPrefsDir = options.userPrefsDir
-
# This needs to occur prior to our importing anything which might in turn
# import anything which might expect to be able to use the Settings Manager
# You have been warned.
#
from settings_manager import SettingsManager
-_settingsManager = SettingsManager()
+_settingsManager = SettingsManager(prefsDir=options.userPrefsDir)
if _settingsManager is None:
print "Could not load the settings manager. Exiting."
sys.exit(1)
@@ -1422,12 +1418,6 @@ def main():
if multipleOrcas():
die(0)
- if not options.userPrefsDir:
- from xdg.BaseDirectory import xdg_data_home
- options.userPrefsDir = os.path.join(xdg_data_home, "orca")
-
- settings.userPrefsDir = options.userPrefsDir
-
if not _settingsManager.isAccessibilityEnabled():
_settingsManager.setAccessibility(True)
@@ -1440,8 +1430,7 @@ def main():
print "environment variable has been set."
return 1
- userprefs = settings.userPrefsDir
- sys.path.insert(0, userprefs)
+ sys.path.insert(0, _settingsManager.getPrefsDir())
sys.path.insert(0, '') # current directory
init(pyatspi.Registry)
@@ -1472,13 +1461,6 @@ def main():
elif not options.bypassSetup \
and (not _userSettings or _settingsManager.isFirstStart()):
if options.desktopRunning:
- if not os.path.exists(userprefs):
- # Hack to work around b.g.o. 601657.
- #
- try:
- os.mkdir(userprefs)
- except:
- debug.printException(debug.LEVEL_FINEST)
showPreferencesGUI()
else:
_showPreferencesConsole()
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 4c0b777..132d884 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -365,7 +365,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
self._initComboBox(self.get_widget("speechFamilies"))
self._initSpeechState()
- self._isInitialSetup = not os.path.exists(settings.userPrefsDir)
+ # TODO - JD: Will this ever be the case??
+ self._isInitialSetup = \
+ not os.path.exists(_settingsManager.getPrefsDir())
self._initGUIState()
@@ -3269,7 +3271,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
self.windowClosed(widget)
self.get_widget("orcaSetupWindow").destroy()
- def okButtonClicked(self, widget = None):
+ def okButtonClicked(self, widget=None):
"""Signal handler for the "clicked" signal for the okButton
GtkButton widget. The user has clicked the OK button.
Write out the users preferences. If GNOME accessibility hadn't
diff --git a/src/orca/settings.py b/src/orca/settings.py
index e60b924..3026de1 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -654,13 +654,6 @@ learnModeEnabled = False
#
listShortcutsModeEnabled = False
-# The location of the user's preferences. By default this is
-# $XDG_DATA_HOME/orca.
-# It can be overridden by the Orca -d command line option.
-#
-from xdg.BaseDirectory import xdg_data_home
-userPrefsDir = os.path.join(xdg_data_home, "orca")
-
# If non-zero, we use time.sleep() in various places to attempt to
# free up the global interpreter lock. Take a look at the following
# URLs for more information:
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 8ffd6a5..d49ce0e 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -33,6 +33,7 @@ import os
import imp
from dbus.mainloop.glib import DBusGMainLoop
from json import load
+from xdg.BaseDirectory import xdg_data_home
import debug
from keybindings import KeyBinding
@@ -58,7 +59,7 @@ class SettingsManager(object):
cls.__instance = object.__new__(cls, *args, **kwargs)
return cls.__instance
- def __init__(self, backend='json'):
+ def __init__(self, backend='json', prefsDir=None):
"""Initialize a SettingsManager Object.
If backend isn't defined then uses default backend, in this
case json-backend.
@@ -70,6 +71,7 @@ class SettingsManager(object):
self._backend = None
self.profile = None
self.backendName = backend
+ self._prefsDir = prefsDir or os.path.join(xdg_data_home, "orca")
# Dictionaries for store the default values
# The keys and values are defined at orca.settings
@@ -102,7 +104,7 @@ class SettingsManager(object):
self._customizationCompleted = False
# Load the backend and the default values
- self._backend = self.backendModule.Backend()
+ self._backend = self.backendModule.Backend(self._prefsDir)
self._setDefaultGeneral()
self._setDefaultPronunciations()
self._setDefaultKeybindings()
@@ -117,8 +119,7 @@ class SettingsManager(object):
# yet, so we need to create the user config directories and store the
# initial default settings
#
- if self.isFirstStart():
- self._createDefaults()
+ self._createDefaults()
# Set the active profile and load its stored settings
if self.profile is None:
@@ -151,7 +152,7 @@ class SettingsManager(object):
# Set up the user's preferences directory
# ($XDG_DATA_HOME/orca by default).
#
- orcaDir = settings.userPrefsDir
+ orcaDir = self._prefsDir
_createDir(orcaDir)
# Set up $XDG_DATA_HOME/orca/orca-scripts as a Python package
@@ -180,10 +181,10 @@ class SettingsManager(object):
if not os.path.exists(userCustomFile):
os.close(os.open(userCustomFile, os.O_CREAT, 0700))
-
- self._backend.saveDefaultSettings(self.defaultGeneral,
- self.defaultPronunciations,
- self.defaultKeybindings)
+ if self.isFirstStart():
+ self._backend.saveDefaultSettings(self.defaultGeneral,
+ self.defaultPronunciations,
+ self.defaultKeybindings)
def _setDefaultPronunciations(self):
"""Get the pronunciations by default from orca.settings"""
@@ -227,7 +228,7 @@ class SettingsManager(object):
likelihood that the results won't be different if we keep trying."""
success = False
- pathList = [settings.userPrefsDir]
+ pathList = [self._prefsDir]
try:
msg = "Attempt to load orca-customizations "
(fileHnd, moduleName, desc) = \
@@ -246,6 +247,9 @@ class SettingsManager(object):
debug.println(debug.LEVEL_ALL, msg)
return success
+ def getPrefsDir(self):
+ return self._prefsDir
+
def setSetting(self, settingName, settingValue):
self._setSettingsRuntime({settingName:settingValue})
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]