[orca] Convert the application settings to use the settings manager's backend



commit fe10012cbcb7953f4a6001a77d8b21e9af49ef61
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sun May 18 23:04:40 2014 -0400

    Convert the application settings to use the settings manager's backend

 src/orca/Makefile.am                               |    2 -
 src/orca/app_gui_prefs.py                          |  313 ---------
 src/orca/app_prefs.py                              |  672 --------------------
 src/orca/backends/json_backend.py                  |   25 +
 src/orca/chat.py                                   |   52 +--
 src/orca/orca.py                                   |   43 +-
 src/orca/orca_gui_prefs.py                         |  192 ++----
 src/orca/orca_state.py                             |    9 -
 src/orca/script.py                                 |   54 +--
 src/orca/script_utilities.py                       |   27 +-
 src/orca/scripts/apps/Instantbird/script.py        |   12 +-
 src/orca/scripts/apps/Thunderbird/Makefile.am      |    1 -
 src/orca/scripts/apps/Thunderbird/script.py        |   35 +-
 .../scripts/apps/Thunderbird/script_settings.py    |   30 -
 src/orca/scripts/apps/empathy/script.py            |   12 +-
 src/orca/scripts/apps/gajim/script.py              |   12 +-
 src/orca/scripts/apps/gedit/script.py              |    7 +-
 src/orca/scripts/apps/pidgin/script.py             |   12 +-
 src/orca/scripts/apps/soffice/Makefile.am          |    1 -
 src/orca/scripts/apps/soffice/__init__.py          |    1 -
 src/orca/scripts/apps/soffice/script.py            |   65 +--
 src/orca/scripts/apps/soffice/script_settings.py   |   34 -
 src/orca/scripts/apps/soffice/speech_generator.py  |    4 +-
 src/orca/scripts/default.py                        |    2 +-
 src/orca/scripts/toolkits/Gecko/Makefile.am        |    1 -
 src/orca/scripts/toolkits/Gecko/__init__.py        |    1 -
 src/orca/scripts/toolkits/Gecko/script.py          |  160 ++----
 src/orca/scripts/toolkits/Gecko/script_settings.py |   70 --
 src/orca/scripts/toolkits/WebKitGtk/Makefile.am    |    3 +-
 src/orca/scripts/toolkits/WebKitGtk/script.py      |   27 +-
 .../scripts/toolkits/WebKitGtk/script_settings.py  |   31 -
 src/orca/settings.py                               |   25 +-
 src/orca/settings_manager.py                       |  187 ++----
 src/orca/spellcheck.py                             |   26 +-
 34 files changed, 327 insertions(+), 1821 deletions(-)
---
diff --git a/src/orca/Makefile.am b/src/orca/Makefile.am
index ff6239d..5f75653 100644
--- a/src/orca/Makefile.am
+++ b/src/orca/Makefile.am
@@ -8,8 +8,6 @@ gfxdir=$(datadir)/orca/gfx
 orca_python_PYTHON = \
        __init__.py \
        acss.py \
-       app_gui_prefs.py \
-       app_prefs.py \
        bookmarks.py \
        braille.py \
        braille_generator.py \
diff --git a/src/orca/backends/json_backend.py b/src/orca/backends/json_backend.py
index 0325d25..ac37ba9 100644
--- a/src/orca/backends/json_backend.py
+++ b/src/orca/backends/json_backend.py
@@ -41,6 +41,7 @@ class Backend:
         self.keybindings = {}
         self.profiles = {}
         self.settingsFile = os.path.join(prefsDir, "user-settings.conf")
+        self.appPrefsDir = os.path.join(prefsDir, "app-settings")
 
     def saveDefaultSettings(self, general, pronunciations, keybindings):
         """ Save default settings for all the properties from
@@ -64,6 +65,30 @@ class Backend:
         dump(prefs, settingsFile, indent=4)
         settingsFile.close()
 
+    def getAppSettings(self, appName):
+        fileName = os.path.join(self.appPrefsDir, "%s.conf" % appName)
+        if os.path.exists(fileName):
+            settingsFile = open(fileName, 'r')
+            prefs = load(settingsFile)
+            settingsFile.close()
+        else:
+            prefs = {}
+
+        return prefs
+
+    def saveAppSettings(self, appName, profile, general, pronunciations, keybindings):
+        prefs = self.getAppSettings(appName)
+        profiles = prefs.get('profiles', {})
+        profiles[profile] = {'general': general,
+                             'pronunciations': pronunciations,
+                             'keybindings': keybindings}
+        prefs['profiles'] = profiles
+
+        fileName = os.path.join(self.appPrefsDir, "%s.conf" % appName)
+        settingsFile = open(fileName, 'w')
+        dump(prefs, settingsFile, indent=4)
+        settingsFile.close()
+
     def saveProfileSettings(self, profile, general,
                                   pronunciations, keybindings):
         """ Save minimal subset defined in the profile against current 
diff --git a/src/orca/chat.py b/src/orca/chat.py
index 2473ce4..47c9336 100644
--- a/src/orca/chat.py
+++ b/src/orca/chat.py
@@ -461,46 +461,22 @@ class Chat:
 
         return grid
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        prefix = "orca.settings"
-
-        value = self.speakNameCheckButton.get_active()
-        _settingsManager.setSetting('chatSpeakRoomName', value)
-        prefs.writelines("\n")
-        prefs.writelines("%s.chatSpeakRoomName = %s\n" % (prefix, value))
-
-        value = self.buddyTypingCheckButton.get_active()
-        _settingsManager.setSetting('chatAnnounceBuddyTyping', value)
-        prefs.writelines("%s.chatAnnounceBuddyTyping = %s\n" % (prefix, value))
-
-        value = self.chatRoomHistoriesCheckButton.get_active()
-        _settingsManager.setSetting('chatRoomHistories', value)
-        prefs.writelines("%s.chatRoomHistories = %s\n" % (prefix, value))
-
-        value = None
-        option = None
-        if self.allMessagesRadioButton.get_active():
-            value = settings.CHAT_SPEAK_ALL
-            option = ("%s.CHAT_SPEAK_ALL" % prefix)
-        elif self.allChannelsRadioButton.get_active():
-            value = settings.CHAT_SPEAK_ALL_IF_FOCUSED
-            option = ("%s.CHAT_SPEAK_ALL_IF_FOCUSED" % prefix)
+        if self.allChannelsRadioButton.get_active():
+            verbosity = settings.CHAT_SPEAK_ALL_IF_FOCUSED
         elif self.focusedChannelRadioButton.get_active():
-            value = settings.CHAT_SPEAK_FOCUSED_CHANNEL
-            option = ("%s.CHAT_SPEAK_FOCUSED_CHANNEL" % prefix)
-
-        if value and option:
-            _settingsManager.setSetting('chatMessageVerbosity', value)
-            prefs.writelines("\n")
-            prefs.writelines("%s.chatMessageVerbosity = %s\n" % \
-                            (prefix, option))
+            verbosity = settings.CHAT_SPEAK_FOCUSED_CHANNEL
+        else:
+            verbosity = settings.CHAT_SPEAK_ALL
+
+        return {
+            'chatMessageVerbosity': verbosity,
+            'chatSpeakRoomName': self.speakNameCheckButton.get_active(),
+            'chatAnnounceBuddyTyping': self.buddyTypingCheckButton.get_active(),
+            'chatRoomHistories': self.chatRoomHistoriesCheckButton.get_active(),
+        }
 
     ########################################################################
     #                                                                      #
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 8378512..ba1bbb9 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -64,6 +64,7 @@ from . import logger
 from . import messages
 from . import notification_messages
 from . import orca_state
+from . import orca_platform
 from . import script_manager
 from . import settings
 from . import settings_manager
@@ -434,6 +435,8 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
         except:
             debug.printException(debug.LEVEL_SEVERE)
 
+    _settingsManager.loadAppSettings(script)
+
     if _settingsManager.getSetting('enableSpeech'):
         try:
             speech.init()
@@ -483,6 +486,27 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
 
     return True
 
+def _showPreferencesUI(script, prefs):
+    if orca_state.orcaOS:
+        orca_state.orcaOS.showGUI()
+        return
+
+    try:
+        module = importlib.import_module('.orca_gui_prefs', 'orca')
+    except:
+        debug.printException(debug.LEVEL_SEVERE)
+        return
+
+    uiFile = os.path.join(orca_platform.prefix,
+                          orca_platform.datadirname,
+                          orca_platform.package,
+                          "ui",
+                          "orca-setup.ui")
+
+    orca_state.orcaOS = module.OrcaSetupGUI(uiFile, "orcaSetupWindow", prefs)
+    orca_state.orcaOS.init(script)
+    orca_state.orcaOS.showGUI()
+
 def showAppPreferencesGUI(script=None, inputEvent=None):
     """Displays the user interace to configure the settings for a
     specific applications within Orca and set up those app-specific
@@ -491,11 +515,12 @@ def showAppPreferencesGUI(script=None, inputEvent=None):
     Returns True to indicate the input event has been consumed.
     """
 
-    try:
-        module = importlib.import_module('.app_gui_prefs', 'orca')
-        module.showPreferencesUI()
-    except:
-        debug.printException(debug.LEVEL_SEVERE)
+    prefs = {}
+    for key in settings.userCustomizableSettings:
+        prefs[key] = _settingsManager.getSetting(key)
+
+    script = script or orca_state.activeScript
+    _showPreferencesUI(script, prefs)
 
     return True
 
@@ -506,11 +531,9 @@ def showPreferencesGUI(script=None, inputEvent=None):
     Returns True to indicate the input event has been consumed.
     """
 
-    try:
-        module = importlib.import_module('.orca_gui_prefs', 'orca')
-        module.showPreferencesUI()
-    except:
-        debug.printException(debug.LEVEL_SEVERE)
+    prefs = _settingsManager.getGeneralSettings(_settingsManager.profile)
+    script = _scriptManager.getDefaultScript()
+    _showPreferencesUI(script, prefs)
 
     return True
 
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index fb12d01..f675539 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -26,13 +26,11 @@ __copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
 import os
-import sys
 from gi.repository import Gdk
 from gi.repository import GLib
 from gi.repository import Gtk
 from gi.repository import GObject
 from gi.repository import Pango
-import locale
 import pyatspi
 import time
 
@@ -45,7 +43,6 @@ from . import orca_gtkbuilder
 from . import orca_gui_profile
 from . import orca_state
 from . import orca_platform
-from . import script_manager
 from . import settings
 from . import settings_manager
 from . import input_event
@@ -56,7 +53,6 @@ from . import speech
 from . import speechserver
 from . import text_attribute_names
 
-_scriptManager = script_manager.getManager()
 _settingsManager = settings_manager.getManager()
 
 try:
@@ -95,24 +91,23 @@ if louis and not tablesdir:
 
 class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
-    def __init__(self, fileName, windowName, prefsDict = None):
+    def __init__(self, fileName, windowName, prefsDict):
         """Initialize the Orca configuration GUI.
 
         Arguments:
         - fileName: name of the GtkBuilder file.
-        - windowName: name of the component to get from the GtkBuilder
-          file.
+        - windowName: name of the component to get from the GtkBuilder file.
+        - prefsDict: dictionary of preferences to use during initialization
         """
 
         orca_gtkbuilder.GtkBuilderWrapper.__init__(self, fileName, windowName)
-        self.prefsDict = self._getGeneralSettings(prefsDict)
+        self.prefsDict = prefsDict
 
         # Initialize variables to None to keep pylint happy.
         #
         self.bbindings = None
         self.cellRendererText = None
         self.defaultVoice = None
-        self.defKeyBindings = None
         self.disableKeyGrabPref = None
         self.getTextAttributesView = None
         self.hyperlinkVoice = None
@@ -149,23 +144,17 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         self.profilesComboModel = None
         self.startingProfileCombo = None
         self._capturedKey = []
+        self.script = None
 
-    def _getGeneralSettings(self, prefsDict):
-        if prefsDict is None:
-            generalSettings  = _settingsManager.getGeneralSettings()
-            activeProfile = generalSettings.get('startingProfile')
-        else:
-            activeProfile = prefsDict['activeProfile']
-
-        return _settingsManager.getGeneralSettings(activeProfile[1])
-
-    def init(self):
+    def init(self, script):
         """Initialize the Orca configuration GUI. Read the users current
         set of preferences and set the GUI state to match. Setup speech
         support and populate the combo box lists on the Speech Tab pane
         accordingly.
         """
 
+        self.script = script
+
         # Restore the default rate/pitch/gain,
         # in case the user played with the sliders.
         #        
@@ -355,6 +344,11 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         self._isInitialSetup = \
             not os.path.exists(_settingsManager.getPrefsDir())
 
+        appPage = self.script.getAppPreferencesGUI()
+        if appPage:
+            label = Gtk.Label(label=self.script.app.name)
+            self.get_widget("notebook").append_page(appPage, label)
+
         self._initGUIState()
 
     def _getACSSForVoiceType(self, voiceType):
@@ -384,7 +378,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         """
         pronunciationDict = self.getModelDict(self.pronunciationModel)
         keyBindingsDict = self.getKeyBindingsModelDict(self.keyBindingsModel)
-        _settingsManager.saveSettings(self.prefsDict,
+        self.prefsDict.update(self.script.getPreferencesFromGUI())
+        _settingsManager.saveSettings(self.script,
+                                      self.prefsDict,
                                       pronunciationDict,
                                       keyBindingsDict)
 
@@ -869,11 +865,10 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         model = view.get_model()
         view.set_model(None)
-        defScript = _scriptManager.getDefaultScript()
 
         [attrList, attrDict] = \
-           defScript.utilities.stringToKeysAndDict(setAttributes)
-        [allAttrList, allAttrDict] = defScript.utilities.stringToKeysAndDict(
+           self.script.utilities.stringToKeysAndDict(setAttributes)
+        [allAttrList, allAttrDict] = self.script.utilities.stringToKeysAndDict(
             _settingsManager.getSetting('allTextAttributes'))
 
         for i in range(0, len(attrList)):
@@ -909,10 +904,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         model = view.get_model()
         view.set_model(None)
 
-        defScript = _scriptManager.getDefaultScript()
         [attrList, attrDict] = \
-            defScript.utilities.stringToKeysAndDict(setAttributes)
-        [allAttrList, allAttrDict] = defScript.utilities.stringToKeysAndDict(
+            self.script.utilities.stringToKeysAndDict(setAttributes)
+        [allAttrList, allAttrDict] = self.script.utilities.stringToKeysAndDict(
                 _settingsManager.getSetting('allTextAttributes'))
 
         for i in range(0, len(attrList)):
@@ -939,7 +933,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         otherwise.
         """
 
-        return attributeName
+        return self.script.getAppNameForAttribute(attributeName)
 
     def _updateTextDictEntry(self):
         """The user has updated the text attribute list in some way. Update
@@ -1069,8 +1063,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         # Initially setup the list store model based on the values of all
         # the known text attributes.
         #
-        defScript = _scriptManager.getDefaultScript()
-        [allAttrList, allAttrDict] = defScript.utilities.stringToKeysAndDict(
+        [allAttrList, allAttrDict] = self.script.utilities.stringToKeysAndDict(
             _settingsManager.getSetting('allTextAttributes'))
         for i in range(0, len(allAttrList)):
             thisIter = model.append()
@@ -1196,16 +1189,12 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
                     self.pronunciationView.set_search_column(i)
                     break
 
-    def _createPronunciationTreeView(self, pronunciations=None):
+    def _createPronunciationTreeView(self):
         """Create the pronunciation dictionary tree view. The view is the
         pronunciationTreeView GtkTreeView widget. The view will consist
         of a list containing two columns:
           ACTUAL      - the actual text string (word).
           REPLACEMENT - the string that is used to pronounce that word.
-
-        Arguments:
-        - pronunciations: an optional dictionary used to get the 
-          pronunciation from.
         """
 
         self.pronunciationView = self.get_widget("pronunciationTreeView")
@@ -1218,10 +1207,12 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
                               GObject.TYPE_STRING)
 
         # Initially setup the list store model based on the values of all
-        # existing entries in the pronunciation dictionary.
+        # existing entries in the pronunciation dictionary -- unless it's
+        # the default script.
         #
-        if pronunciations != None:
-            pronDict = pronunciations
+        if not self.script.app:
+            _profile = self.prefsDict.get('activeProfile')[1]
+            pronDict = _settingsManager.getPronunciations(_profile)
         else:
             pronDict = pronunciation_dict.pronunciation_dict
         for pronKey in sorted(pronDict.keys()):
@@ -1545,9 +1536,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         # Pronunciation dictionary pane.
         #
-        _profile = self.prefsDict.get('activeProfile')[1]
-        pronunciationsDict = _settingsManager.getPronunciations(_profile)
-        self._createPronunciationTreeView(pronunciationsDict)
+        self._createPronunciationTreeView()
 
         # General pane.
         #
@@ -1565,6 +1554,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         self.startingProfileCombo = self.get_widget('availableProfilesComboBox2')
         self.profilesComboModel = self.get_widget('model9')
         self.__initProfileCombo()
+        if self.script.app:
+            self.get_widget('profilesFrame').set_sensitive(False)
 
     def __initProfileCombo(self):
         """Adding available profiles and setting active as the active one"""
@@ -1652,8 +1643,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
                 key, modified = model.get(child, HANDLER, MODIF)
                 if modified or not modifiedOnly:
                     value = []
-                    value.append(model.get(
-                            child, KEY1, MOD_MASK1, MOD_USED1, CLICK_COUNT1))
+                    value.append(list(model.get(
+                            child, KEY1, MOD_MASK1, MOD_USED1, CLICK_COUNT1)))
                     modelDict[key] = value
                 child = model.iter_next(child)
             node = model.iter_next(node)
@@ -1703,6 +1694,10 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
                 _settingsManager.getSetting('enabledSpokenTextAttributes'),
                 True, True)
 
+        if self.script.app:
+            title = guilabels.PREFERENCES_APPLICATION_TITLE % self.script.app.name
+            orcaSetupWindow.set_title(title)
+
         orcaSetupWindow.show()
 
     def _initComboBox(self, combobox):
@@ -1755,10 +1750,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         - interrupt: if True, interrupt any speech currently being spoken
         """
 
-        defScript = _scriptManager.getDefaultScript()
-        defScript.speakMessage(text, interrupt=interrupt)
+        self.script.speakMessage(text, interrupt=interrupt)
         try:
-            defScript.displayBrailleMessage(text, flashTime=-1)
+            self.script.displayBrailleMessage(text, flashTime=-1)
         except:
             pass
 
@@ -1893,10 +1887,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         """
 
         try:
-            defScript = _scriptManager.getDefaultScript()
-            defScript.setupInputEventHandlers()
+            self.script.setupInputEventHandlers()
             keyBinds = keybindings.KeyBindings()
-            keyBinds = settings.overrideKeyBindings(defScript, keyBinds)
+            keyBinds = _settingsManager.overrideKeyBindings(self.script, keyBinds)
             keyBind = keybindings.KeyBinding(None, None, None, None)
             treeModel = self.keyBindingsModel
 
@@ -1929,29 +1922,33 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
             self.keyBindingsModel.clear()
             self.kbindings = None
 
-        iterOrca = self._getIterOf(guilabels.KB_GROUP_DEFAULT) \
-            or self._createNode(guilabels.KB_GROUP_DEFAULT)
-        iterUnbound = self._getIterOf(guilabels.KB_GROUP_UNBOUND) \
-                      or self._createNode(guilabels.KB_GROUP_UNBOUND)
+        try:
+            appName = self.script.app.name
+        except:
+            appName = ""
 
-        defScript = _scriptManager.getDefaultScript()
+        iterApp = self._createNode(appName)
+        iterOrca = self._createNode(guilabels.KB_GROUP_DEFAULT)
+        iterUnbound = self._createNode(guilabels.KB_GROUP_UNBOUND)
 
-        # If we are in the app-specific preferences, we already have
-        # populated our tree with bindings.  Otherwise, we need to
-        # start from scratch.
-        #
         if not self.kbindings:
             self.kbindings = keybindings.KeyBindings()
-            defScript.setupInputEventHandlers()
-            self.defKeyBindings = defScript.getKeyBindings()
-            for kb in self.defKeyBindings.keyBindings:
+            self.script.setupInputEventHandlers()
+            allKeyBindings = self.script.getKeyBindings()
+            defKeyBindings = self.script.getDefaultKeyBindings()
+            for kb in allKeyBindings.keyBindings:
                 if not self.kbindings.hasKeyBinding(kb, "strict"):
-                    handl = defScript.getInputEventHandlerKey(kb.handler)
-                    if kb.keysymstring:
+                    handl = self.script.getInputEventHandlerKey(kb.handler)
+                    if not defKeyBindings.hasKeyBinding(kb, "description"):
+                        self._insertRow(handl, kb, iterApp)
+                    elif kb.keysymstring:
                         self._insertRow(handl, kb, iterOrca)
                     else:
                         self._insertRow(handl, kb, iterUnbound)
-                self.kbindings.add(kb)
+                    self.kbindings.add(kb)
+
+        if not self.keyBindingsModel.iter_has_child(iterApp):
+            self.keyBindingsModel.remove(iterApp)
 
         if not self.keyBindingsModel.iter_has_child(iterUnbound):
             self.keyBindingsModel.remove(iterUnbound)
@@ -1959,9 +1956,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         self._updateOrcaModifier()
         self._markModified()
         iterBB = self._createNode(guilabels.KB_GROUP_BRAILLE)
-        self.bbindings = defScript.getBrailleBindings()
+        self.bbindings = self.script.getBrailleBindings()
         for com, inputEvHand in list(self.bbindings.items()):
-            handl = defScript.getInputEventHandlerKey(inputEvHand)
+            handl = self.script.getInputEventHandlerKey(inputEvHand)
             self._insertRowBraille(handl, com, inputEvHand, iterBB)
 
         self.keyBindView.set_model(self.keyBindingsModel)
@@ -2979,7 +2976,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         self.writeUserPreferences()
 
-        orca.loadUserSettings()
+        orca.loadUserSettings(self.script)
 
         self._initSpeechState()
 
@@ -3146,66 +3143,3 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         self.__initProfileCombo()
 
-class WarningDialogGUI(Gtk.MessageDialog):
-
-    def __init__(self):
-        Gtk.MessageDialog.__init__(self)
-        self.set_property('message-type', Gtk.MessageType.INFO)
-        self.set_property('text', messages.PREFERENCES_WARNING_DIALOG)
-        self.add_button('gtk-ok', Gtk.ResponseType.OK)
-        self.connect('response', self.onResponse)
-        self.connect('destroy', self.onDestroy)
-
-    def init(self):
-        pass
-
-    def showGUI(self):
-        """Show the Warning dialog."""
-
-        ts = orca_state.lastInputEventTimestamp
-        if ts == 0:
-            ts = Gtk.get_current_event_time()
-        self.present_with_time(ts)
-
-    def onResponse(self, widget, response):
-        """Signal handler for the responses emitted by the dialog."""
-
-        if response == Gtk.ResponseType.OK:
-            self.destroy()
-
-    def onDestroy(self, widget):
-        """Signal handler for the 'destroy' signal of the Warning dialog."""
-
-        orca_state.orcaWD = None
-
-def showPreferencesUI():
-    if not orca_state.appOS and not orca_state.orcaOS:
-        startingProfile = _settingsManager.profile
-        prefsDict = _settingsManager.getGeneralSettings(startingProfile)
-
-        orca_state.prefsUIFile = \
-            os.path.join(orca_platform.prefix,
-                         orca_platform.datadirname,
-                         orca_platform.package,
-                         "ui",
-                         "orca-setup.ui")
-
-        orca_state.orcaOS = OrcaSetupGUI(orca_state.prefsUIFile,
-                                         "orcaSetupWindow", prefsDict)
-        orca_state.orcaOS.init()
-        orca_state.orcaOS.showGUI()
-    else:
-        if not orca_state.orcaWD:
-            orca_state.orcaWD = WarningDialogGUI()
-        orca_state.orcaWD.showGUI()
-
-def main():
-    locale.setlocale(locale.LC_ALL, '')
-
-    showPreferencesUI()
-
-    Gtk.main()
-    sys.exit(0)
-
-if __name__ == "__main__":
-    main()
diff --git a/src/orca/orca_state.py b/src/orca/orca_state.py
index 250854d..b3279d6 100644
--- a/src/orca/orca_state.py
+++ b/src/orca/orca_state.py
@@ -111,12 +111,3 @@ usePronunciationDictionary = True
 # Handle to the Orca Preferences Glade GUI object.
 #
 orcaOS = None
-
-# Handle to the Orca application specific preferences Glade GUI object.
-#
-appOS = None
-
-# Handle to the Glade warning dialog object that is displayed, if the 
-# user has attempted to start a second instance of a preferences dialog.
-#
-orcaWD = None
diff --git a/src/orca/script.py b/src/orca/script.py
index 3d7488a..737cd48 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -106,7 +106,6 @@ class Script:
         self.setupInputEventHandlers()
         self.keyBindings = self.getKeyBindings()
         self.brailleBindings = self.getBrailleBindings()
-        self.app_pronunciation_dict = self.getPronunciations()
 
         self.formatting = self.getFormatting()
         self.brailleGenerator = self.getBrailleGenerator()
@@ -182,15 +181,6 @@ class Script:
         """
         return {}
 
-    def getPronunciations(self):
-        """Defines the application specific pronunciations for this script.
-
-        Returns a dictionary where the keys are the actual text strings and
-        the values are the replacement strings that are spoken instead.
-        """
-
-        return {}
-
     def getBrailleCommandsForInputHandler(self, inputEventHandler):
         """Returns a list of BrlTTY commands (they're in braille.py) that
         match the given inputEventHandler passed as argument.
@@ -283,48 +273,10 @@ class Script:
         """
         return None
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values.
-
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-        pass
-
-    def overrideAppKeyBindings(self, script, keyBindings):
-        """Allow for the customization of application specific key bindings.
-
-        Arguments:
-        - script: the application script.
-        - keyBindings: the set of key bindings for this script.
-        """
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        return keyBindings
-
-    def overridePronunciations(self, script, pronunciations):
-        """Allow for the customization of application specific pronunciations.
-
-        Arguments:
-        - script: the application script.
-        - pronunciations: the dictionary of pronunciations for this script.
-        """
-
-        return pronunciations
-
-    def getAppState(self):
-        """Returns an object that can be passed to setAppState.  This
-        object will be used by setAppState to restore any state
-        information that was being maintained by the script."""
-        return None
-
-    def setAppState(self, appState):
-        """Sets the application state using the given appState object.
-
-        Arguments:
-        - appState: an object obtained from getAppState
-        """
-        return
+        return {}
 
     def registerEventListeners(self):
         """Tells the event manager to start listening for all the event types
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 70616e0..7838f0a 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -40,6 +40,7 @@ from . import input_event
 from . import messages
 from . import mouse_review
 from . import orca_state
+from . import pronunciation_dict
 from . import settings
 
 #############################################################################
@@ -2206,30 +2207,6 @@ class Utilities:
 
         return line
 
-    def _pronunciationForSegment(self, segment):
-        """Adjust the word segment to potentially replace it with what
-        those words actually sound like. Two pronunciation dictionaries
-        are checked. First the application specific one (which might be
-        empty), then the default (global) one.
-
-        Arguments:
-        - segment: the string to adjust for words in the pronunciation
-          dictionaries.
-
-        Returns: a new word segment adjusted for words found in the
-        pronunciation dictionaries, or the original word segment if there
-        was no dictionary entry.
-        """
-
-        from . import pronunciation_dict
-
-        newSegment = pronunciation_dict.getPronunciation(
-            segment, self._script.app_pronunciation_dict)
-        if newSegment == segment:
-            newSegment = pronunciation_dict.getPronunciation(segment)
-
-        return newSegment
-
     def adjustForLinks(self, obj, line, startOffset):
         """Adjust line to include the word "link" after any hypertext links.
 
@@ -2296,7 +2273,7 @@ class Utilities:
 
         newLine = ""
         words = self.WORDS_RE.split(line)
-        newLine = ''.join(map(self._pronunciationForSegment, words))
+        newLine = ''.join(map(pronunciation_dict.getPronunciation, words))
 
         return newLine
 
diff --git a/src/orca/scripts/apps/Instantbird/script.py b/src/orca/scripts/apps/Instantbird/script.py
index 1d1290b..b0db7fa 100644
--- a/src/orca/scripts/apps/Instantbird/script.py
+++ b/src/orca/scripts/apps/Instantbird/script.py
@@ -108,16 +108,10 @@ class Script(Gecko.Script):
 
         return self.chat.getAppPreferencesGUI()
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values. The chat-related options get written out by the chat
-        module.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        self.chat.setAppPreferences(prefs)
+        return self.chat.getPreferencesFromGUI()
 
     def onTextDeleted(self, event):
         """Called whenever text is deleted from an object.
diff --git a/src/orca/scripts/apps/Thunderbird/Makefile.am b/src/orca/scripts/apps/Thunderbird/Makefile.am
index 1825bbd..2c3d82c 100644
--- a/src/orca/scripts/apps/Thunderbird/Makefile.am
+++ b/src/orca/scripts/apps/Thunderbird/Makefile.am
@@ -2,7 +2,6 @@ orca_python_PYTHON = \
        __init__.py \
        formatting.py \
        script.py \
-       script_settings.py \
        script_utilities.py \
        speech_generator.py \
        spellcheck.py
diff --git a/src/orca/scripts/apps/Thunderbird/script.py b/src/orca/scripts/apps/Thunderbird/script.py
index 962622a..aca1863 100644
--- a/src/orca/scripts/apps/Thunderbird/script.py
+++ b/src/orca/scripts/apps/Thunderbird/script.py
@@ -40,7 +40,6 @@ from .formatting import Formatting
 from .speech_generator import SpeechGenerator
 from .spellcheck import SpellCheck
 from .script_utilities import Utilities
-from . import script_settings
 
 _settingsManager = settings_manager.getManager()
 
@@ -65,6 +64,9 @@ class Script(Gecko.Script):
         #
         self._lastAutoComplete = ""
 
+        if _settingsManager.getSetting('sayAllOnLoad') == None:
+            _settingsManager.setSetting('sayAllOnLoad', False)
+
         Gecko.Script.__init__(self, app)
 
     def getFormatting(self):
@@ -92,9 +94,8 @@ class Script(Gecko.Script):
 
         grid = Gecko.Script.getAppPreferencesGUI(self)
 
-        # Reapply "say all on load" using the Thunderbird specific setting.
-        #
-        self.sayAllOnLoadCheckButton.set_active(script_settings.sayAllOnLoad)
+        self.sayAllOnLoadCheckButton.set_active(
+            _settingsManager.getSetting('sayAllOnLoad'))
 
         spellcheck = self.spellcheck.getAppPreferencesGUI()
         grid.attach(spellcheck, 0, len(grid.get_children()), 1, 1)
@@ -102,26 +103,14 @@ class Script(Gecko.Script):
 
         return grid
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values.
-
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        Gecko.Script.setAppPreferences(self, prefs)
-
-        # Write the Thunderbird specific settings.
-        #
-        prefix = "orca.scripts.apps.Thunderbird.script_settings"
-        prefs.writelines("import %s\n\n" % prefix)
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        value = self.sayAllOnLoadCheckButton.get_active()
-        prefs.writelines("%s.sayAllOnLoad = %s\n" % (prefix, value))
-        script_settings.sayAllOnLoad = value
+        prefs = Gecko.Script.getPreferencesFromGUI(self)
+        prefs['sayAllOnLoad'] = self.sayAllOnLoadCheckButton.get_active()
+        prefs.update(self.spellcheck.getPreferencesFromGUI())
 
-        self.spellcheck.setAppPreferences(prefs)
+        return prefs
 
     def doWhereAmI(self, inputEvent, basicOnly):
         """Performs the whereAmI operation."""
@@ -357,7 +346,7 @@ class Script(Gecko.Script):
 
         [obj, offset] = self.findFirstCaretContext(documentFrame, 0)
         self.setCaretPosition(obj, offset)
-        if not script_settings.sayAllOnLoad:
+        if not _settingsManager.getSetting('sayAllOnLoad'):
             self.presentLine(obj, offset)
         elif _settingsManager.getSetting('enableSpeech'):
             self.sayAll(None)
diff --git a/src/orca/scripts/apps/empathy/script.py b/src/orca/scripts/apps/empathy/script.py
index 5de885c..c001424 100644
--- a/src/orca/scripts/apps/empathy/script.py
+++ b/src/orca/scripts/apps/empathy/script.py
@@ -83,16 +83,10 @@ class Script(gtk.Script):
 
         return self.chat.getAppPreferencesGUI()
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values. The chat-related options get written out by the chat
-        module.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        self.chat.setAppPreferences(prefs)
+        return self.chat.getPreferencesFromGUI()
 
     def skipObjectEvent(self, event):
         """Gives us, and scripts, the ability to decide an event isn't
diff --git a/src/orca/scripts/apps/gajim/script.py b/src/orca/scripts/apps/gajim/script.py
index 72ed844..f36dff9 100644
--- a/src/orca/scripts/apps/gajim/script.py
+++ b/src/orca/scripts/apps/gajim/script.py
@@ -78,16 +78,10 @@ class Script(default.Script):
 
         return self.chat.getAppPreferencesGUI()
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values. The chat-related options get written out by the chat
-        module.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        self.chat.setAppPreferences(prefs)
+        return self.chat.getPreferencesFromGUI()
 
     def onTextInserted(self, event):
         """Called whenever text is added to an object."""
diff --git a/src/orca/scripts/apps/gedit/script.py b/src/orca/scripts/apps/gedit/script.py
index d17ba31..099c524 100644
--- a/src/orca/scripts/apps/gedit/script.py
+++ b/src/orca/scripts/apps/gedit/script.py
@@ -57,11 +57,10 @@ class Script(gtk.Script):
 
         return grid
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values."""
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        self.spellcheck.setAppPreferences(prefs)
+        return self.spellcheck.getPreferencesFromGUI()
 
     def doWhereAmI(self, inputEvent, basicOnly):
         """Performs the whereAmI operation."""
diff --git a/src/orca/scripts/apps/pidgin/script.py b/src/orca/scripts/apps/pidgin/script.py
index f3d892a..0578ccb 100644
--- a/src/orca/scripts/apps/pidgin/script.py
+++ b/src/orca/scripts/apps/pidgin/script.py
@@ -99,16 +99,10 @@ class Script(GAIL.Script):
 
         return self.chat.getAppPreferencesGUI()
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values. The chat-related options get written out by the chat
-        module.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        self.chat.setAppPreferences(prefs)
+        return self.chat.getPreferencesFromGUI()
 
     def onChildrenChanged(self, event):
         """Called whenever a child object changes in some way.
diff --git a/src/orca/scripts/apps/soffice/Makefile.am b/src/orca/scripts/apps/soffice/Makefile.am
index 1a84cdc..918701e 100644
--- a/src/orca/scripts/apps/soffice/Makefile.am
+++ b/src/orca/scripts/apps/soffice/Makefile.am
@@ -3,7 +3,6 @@ orca_python_PYTHON = \
        braille_generator.py \
        formatting.py \
        script.py \
-       script_settings.py \
        script_utilities.py \
        speech_generator.py \
        structural_navigation.py
diff --git a/src/orca/scripts/apps/soffice/__init__.py b/src/orca/scripts/apps/soffice/__init__.py
index e5c3334..585c964 100644
--- a/src/orca/scripts/apps/soffice/__init__.py
+++ b/src/orca/scripts/apps/soffice/__init__.py
@@ -1,2 +1 @@
 from .script import Script
-from . import script_settings
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 05e45d9..54cc987 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -48,7 +48,6 @@ from .braille_generator import BrailleGenerator
 from .formatting import Formatting
 from .structural_navigation import StructuralNavigation
 from .script_utilities import Utilities
-from . import script_settings
 
 _settingsManager = settings_manager.getManager()
 
@@ -227,7 +226,7 @@ class Script(default.Script):
         grid.set_border_width(12)
 
         label = guilabels.SPREADSHEET_SPEAK_CELL_COORDINATES
-        value = script_settings.speakSpreadsheetCoordinates
+        value = _settingsManager.getSetting('speakSpreadsheetCoordinates')
         self.speakSpreadsheetCoordinatesCheckButton = \
             Gtk.CheckButton.new_with_mnemonic(label)
         self.speakSpreadsheetCoordinatesCheckButton.set_active(value)
@@ -278,60 +277,16 @@ class Script(default.Script):
 
         return grid
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        prefs.writelines("\n")
-        prefix = "orca.scripts.apps.soffice.script_settings"
-        prefs.writelines("import %s\n\n" % prefix)
-
-        script_settings.speakSpreadsheetCoordinates = \
-            self.speakSpreadsheetCoordinatesCheckButton.get_active()
-        prefs.writelines("%s.speakSpreadsheetCoordinates = %s\n" % \
-                        (prefix, script_settings.speakSpreadsheetCoordinates))
-
-        value = self.speakCellCoordinatesCheckButton.get_active()
-        _settingsManager.setSetting('speakCellCoordinates', value)
-        prefs.writelines("orca.settings.speakCellCoordinates = %s\n" % value)
-
-        value = self.speakCellSpanCheckButton.get_active()
-        _settingsManager.setSetting('speakCellSpan', value)
-        prefs.writelines("orca.settings.speakCellSpan = %s\n" % value)
-
-        value = self.speakCellHeadersCheckButton.get_active()
-        _settingsManager.setSetting('speakCellHeaders', value)
-        prefs.writelines("orca.settings.speakCellHeaders = %s\n" % value)
-
-        value = self.skipBlankCellsCheckButton.get_active()
-        _settingsManager.setSetting('skipBlankCells', value)
-        prefs.writelines("orca.settings.skipBlankCells = %s\n" % value)
-
-    def getAppState(self):
-        """Returns an object that can be passed to setAppState.  This
-        object will be use by setAppState to restore any state information
-        that was being maintained by the script."""
-        return [default.Script.getAppState(self),
-                self.dynamicColumnHeaders,
-                self.dynamicRowHeaders]
-
-    def setAppState(self, appState):
-        """Sets the application state using the given appState object.
-
-        Arguments:
-        - appState: an object obtained from getAppState
-        """
-        try:
-            [defaultAppState,
-             self.dynamicColumnHeaders,
-             self.dynamicRowHeaders] = appState
-            default.Script.setAppState(self, defaultAppState)
-        except:
-            debug.printException(debug.LEVEL_WARNING)
+        return {
+            'speakCellSpan': self.speakCellSpanCheckButton.get_active(),
+            'speakCellHeaders': self.speakCellHeadersCheckButton.get_active(),
+            'skipBlankCells': self.skipBlankCellsCheckButton.get_active(),
+            'speakCellCoordinates': self.speakCellCoordinatesCheckButton.get_active(),
+            'speakSpreadsheetCoordinates': self.speakSpreadsheetCoordinatesCheckButton.get_active(),
+        }
 
     def isStructuralNavigationCommand(self, inputEvent=None):
         """Checks to see if the inputEvent was a structural navigation
diff --git a/src/orca/scripts/apps/soffice/speech_generator.py 
b/src/orca/scripts/apps/soffice/speech_generator.py
index dbe7dd7..bf4d94d 100644
--- a/src/orca/scripts/apps/soffice/speech_generator.py
+++ b/src/orca/scripts/apps/soffice/speech_generator.py
@@ -31,8 +31,6 @@ import orca.messages as messages
 import orca.settings_manager as settings_manager
 import orca.speech_generator as speech_generator
 
-from . import script_settings
-
 _settingsManager = settings_manager.getManager()
 
 class SpeechGenerator(speech_generator.SpeechGenerator):
@@ -352,7 +350,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
             return result
 
         isBasicWhereAmI = args.get('formatType') == 'basicWhereAmI'
-        speakCoordinates = script_settings.speakSpreadsheetCoordinates
+        speakCoordinates = _settingsManager.getSetting('speakSpreadsheetCoordinates')
         if speakCoordinates and not isBasicWhereAmI:
             result.append(self._script.utilities.spreadSheetCellName(obj))
 
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 47f6c86..a93e3e5 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -635,7 +635,7 @@ class Script(script.Script):
         keyBindings.load(common_keyboardmap.keymap, self.inputEventHandlers)
 
         try:
-            keyBindings = settings.overrideKeyBindings(self, keyBindings)
+            keyBindings = _settingsManager.overrideKeyBindings(self, keyBindings)
         except:
             debug.println(debug.LEVEL_WARNING,
                           "WARNING: problem overriding keybindings:")
diff --git a/src/orca/scripts/toolkits/Gecko/Makefile.am b/src/orca/scripts/toolkits/Gecko/Makefile.am
index cee60b8..bb54589 100644
--- a/src/orca/scripts/toolkits/Gecko/Makefile.am
+++ b/src/orca/scripts/toolkits/Gecko/Makefile.am
@@ -5,7 +5,6 @@ orca_python_PYTHON = \
        formatting.py \
        keymaps.py \
        script.py \
-       script_settings.py \
        script_utilities.py \
        speech_generator.py \
        structural_navigation.py
diff --git a/src/orca/scripts/toolkits/Gecko/__init__.py b/src/orca/scripts/toolkits/Gecko/__init__.py
index 72b9161..a2b1964 100644
--- a/src/orca/scripts/toolkits/Gecko/__init__.py
+++ b/src/orca/scripts/toolkits/Gecko/__init__.py
@@ -2,4 +2,3 @@ from .script import Script
 from .speech_generator import SpeechGenerator
 from .braille_generator import BrailleGenerator
 from .script_utilities import Utilities
-from . import script_settings
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 5cdd038..123c655 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -65,7 +65,6 @@ import orca.speech as speech
 import orca.speechserver as speechserver
 
 from . import keymaps
-from . import script_settings
 from .braille_generator import BrailleGenerator
 from .speech_generator import SpeechGenerator
 from .formatting import Formatting
@@ -134,12 +133,12 @@ class Script(default.Script):
              Script.monitorLiveRegions,
              Script.reviewLiveAnnouncement]
 
-        if script_settings.controlCaretNavigation:
-            debug.println(debug.LEVEL_CONFIGURATION,
-                          "Orca is controlling the caret.")
-        else:
-            debug.println(debug.LEVEL_CONFIGURATION,
-                          "Gecko is controlling the caret.")
+        if _settingsManager.getSetting('caretNavigationEnabled') == None:
+            _settingsManager.setSetting('caretNavigationEnabled', True)
+        if _settingsManager.getSetting('caretArrowToLineBeginning') == None:
+            _settingsManager.setSetting('caretArrowToLineBeginning', True)
+        if _settingsManager.getSetting('sayAllOnLoad') == None:
+            _settingsManager.setSetting('sayAllOnLoad', True)
 
         # We keep track of whether we're currently in the process of
         # loading a page.
@@ -305,7 +304,7 @@ class Script(default.Script):
         """Returns the 'structural navigation' class for this script.
         """
         types = self.getEnabledStructuralNavigationTypes()
-        enable = script_settings.structuralNavigationEnabled
+        enable = _settingsManager.getSetting('structuralNavigationEnabled')
         return GeckoStructuralNavigation(self, types, enable)
 
     def setupInputEventHandlers(self):
@@ -451,7 +450,7 @@ class Script(default.Script):
         else:
             keyBindings.load(keymaps.laptopKeymap, self.inputEventHandlers)
 
-        if script_settings.controlCaretNavigation:
+        if _settingsManager.getSetting('caretNavigationEnabled'):
             for keyBinding in self.__getArrowBindings().keyBindings:
                 keyBindings.add(keyBinding)
 
@@ -482,7 +481,7 @@ class Script(default.Script):
         generalAlignment.add(generalGrid)
 
         label = guilabels.USE_CARET_NAVIGATION
-        value = script_settings.controlCaretNavigation
+        value = _settingsManager.getSetting('caretNavigationEnabled')
         self.controlCaretNavigationCheckButton = \
             Gtk.CheckButton.new_with_mnemonic(label)
         self.controlCaretNavigationCheckButton.set_active(value) 
@@ -496,14 +495,14 @@ class Script(default.Script):
         generalGrid.attach(self.structuralNavigationCheckButton, 0, 1, 1, 1)
 
         label = guilabels.CARET_NAVIGATION_START_OF_LINE
-        value = script_settings.arrowToLineBeginning
+        value = _settingsManager.getSetting('caretArrowToLineBeginning')
         self.arrowToLineBeginningCheckButton = \
             Gtk.CheckButton.new_with_mnemonic(label)
         self.arrowToLineBeginningCheckButton.set_active(value)
         generalGrid.attach(self.arrowToLineBeginningCheckButton, 0, 3, 1, 1)
 
         label = guilabels.READ_PAGE_UPON_LOAD
-        value = script_settings.sayAllOnLoad
+        value = _settingsManager.getSetting('sayAllOnLoad')
         self.sayAllOnLoadCheckButton = Gtk.CheckButton.new_with_mnemonic(label)
         self.sayAllOnLoadCheckButton.set_active(value)
         generalGrid.attach(self.sayAllOnLoadCheckButton, 0, 4, 1, 1)
@@ -562,15 +561,17 @@ class Script(default.Script):
         findGrid = Gtk.Grid()
         findAlignment.add(findGrid)
 
+        verbosity = _settingsManager.getSetting('findResultsVerbosity')
+
         label = guilabels.FIND_SPEAK_RESULTS
-        value = script_settings.speakResultsDuringFind
+        value = verbosity != settings.FIND_SPEAK_NONE
         self.speakResultsDuringFindCheckButton = \
             Gtk.CheckButton.new_with_mnemonic(label)
         self.speakResultsDuringFindCheckButton.set_active(value)
         findGrid.attach(self.speakResultsDuringFindCheckButton, 0, 0, 1, 1)
 
         label = guilabels.FIND_ONLY_SPEAK_CHANGED_LINES
-        value = script_settings.onlySpeakChangedLinesDuringFind
+        value = verbosity == settings.FIND_SPEAK_IF_LINE_CHANGED
         self.changedLinesOnlyCheckButton = \
             Gtk.CheckButton.new_with_mnemonic(label)
         self.changedLinesOnlyCheckButton.set_active(value)
@@ -585,7 +586,7 @@ class Script(default.Script):
         hgrid.attach(self.minimumFindLengthLabel, 0, 0, 1, 1)
 
         self.minimumFindLengthAdjustment = \
-                   Gtk.Adjustment(script_settings.minimumFindLength, 0, 20, 1)
+                   Gtk.Adjustment(_settingsManager.getSetting('findResultsMinimumLength'), 0, 20, 1)
         self.minimumFindLengthSpinButton = Gtk.SpinButton()
         self.minimumFindLengthSpinButton.set_adjustment(
             self.minimumFindLengthAdjustment)
@@ -597,90 +598,28 @@ class Script(default.Script):
 
         return grid
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values.
-
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        prefs.writelines("\n")
-        prefix = "orca.scripts.toolkits.Gecko.script_settings"
-        prefs.writelines("import %s\n\n" % prefix)
-
-        value = self.controlCaretNavigationCheckButton.get_active()
-        prefs.writelines("%s.controlCaretNavigation = %s\n" % (prefix, value))
-        script_settings.controlCaretNavigation = value
-
-        value = self.structuralNavigationCheckButton.get_active()
-        prefs.writelines("%s.structuralNavigationEnabled = %s\n" \
-                         % (prefix, value))
-        script_settings.structuralNavigationEnabled = value
-
-        value = self.arrowToLineBeginningCheckButton.get_active()
-        prefs.writelines("%s.arrowToLineBeginning = %s\n" % (prefix, value))
-        script_settings.arrowToLineBeginning = value
-
-        value = self.sayAllOnLoadCheckButton.get_active()
-        prefs.writelines("%s.sayAllOnLoad = %s\n" % (prefix, value))
-        script_settings.sayAllOnLoad = value
-
-        value = self.speakResultsDuringFindCheckButton.get_active()
-        prefs.writelines("%s.speakResultsDuringFind = %s\n" % (prefix, value))
-        script_settings.speakResultsDuringFind = value
-
-        value = self.changedLinesOnlyCheckButton.get_active()
-        prefs.writelines("%s.onlySpeakChangedLinesDuringFind = %s\n"\
-                         % (prefix, value))
-        script_settings.onlySpeakChangedLinesDuringFind = value
-
-        value = self.minimumFindLengthSpinButton.get_value()
-        prefs.writelines("%s.minimumFindLength = %s\n" % (prefix, value))
-        script_settings.minimumFindLength = value
-
-        # These structural navigation settings used to be application-
-        # specific preferences because at the time structural navigation
-        # was implemented it was part of the Gecko script. These settings
-        # are now part of settings.py so that other scripts can implement
-        # structural navigation. But until that happens, there's no need
-        # to move these controls/change the preferences dialog.
-        # 
-        value = self.speakCellCoordinatesCheckButton.get_active()
-        prefs.writelines("orca.settings.speakCellCoordinates = %s\n" % value)
-        _settingsManager.setSetting('speakCellCoordinates', value)
-
-        value = self.speakCellSpanCheckButton.get_active()
-        prefs.writelines("orca.settings.speakCellSpan = %s\n" % value)
-        _settingsManager.setSetting('speakCellSpan', value)
-
-        value = self.speakCellHeadersCheckButton.get_active()
-        prefs.writelines("orca.settings.speakCellHeaders = %s\n" % value)
-        _settingsManager.setSetting('speakCellHeaders', value)
-
-        value = self.skipBlankCellsCheckButton.get_active()
-        prefs.writelines("orca.settings.skipBlankCells = %s\n" % value)
-        _settingsManager.setSetting('skipBlankCells', value)
-
-    def getAppState(self):
-        """Returns an object that can be passed to setAppState.  This
-        object will be use by setAppState to restore any state information
-        that was being maintained by the script."""
-        return [default.Script.getAppState(self),
-                self._documentFrameCaretContext]
-
-    def setAppState(self, appState):
-        """Sets the application state using the given appState object.
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        Arguments:
-        - appState: an object obtained from getAppState
-        """
-        try:
-            [defaultAppState,
-             self._documentFrameCaretContext] = appState
-            default.Script.setAppState(self, defaultAppState)
-        except:
-            debug.printException(debug.LEVEL_WARNING)
+        if not self.speakResultsDuringFindCheckButton.get_active():
+            verbosity = settings.FIND_SPEAK_NONE
+        elif self.changedLinesOnlyCheckButton.get_active():
+            verbosity = settings.FIND_SPEAK_IF_LINE_CHANGED
+        else:
+            verbosity = settings.FIND_SPEAK_ALL
+
+        return {
+            'findResultsVerbosity': verbosity,
+            'findResultsMinimumLength': self.minimumFindLengthSpinButton.get_value(),
+            'sayAllOnLoad': self.sayAllOnLoadCheckButton.get_active(),
+            'structuralNavigationEnabled': self.structuralNavigationCheckButton.get_active(),
+            'caretNavigationEnabled': self.controlCaretNavigationCheckButton.get_active(),
+            'caretArrowToLineBeginning': self.arrowToLineBeginningCheckButton.get_active(),
+            'speakCellCoordinates': self.speakCellCoordinatesCheckButton.get_active(),
+            'speakCellSpan': self.speakCellSpanCheckButton.get_active(),
+            'speakCellHeaders': self.speakCellHeadersCheckButton.get_active(),
+            'skipBlankCells': self.skipBlankCellsCheckButton.get_active()
+        }
 
     def consumesKeyboardEvent(self, keyboardEvent):
         """Called when a key is pressed on the keyboard.
@@ -871,7 +810,7 @@ class Script(default.Script):
         if text and text.getNSelections():
             [start, end] = text.getSelection(0)
             offset = max(offset, start)
-            if end - start >= script_settings.minimumFindLength:
+            if end - start >= _settingsManager.getSetting('findResultsMinimumLength'):
                 enoughSelected = True
 
         # Haing done that, update the caretContext. If the user wants
@@ -880,7 +819,8 @@ class Script(default.Script):
         #
         origObj, origOffset = self.getCaretContext()
         self.setCaretContext(obj, offset)
-        if enoughSelected and script_settings.speakResultsDuringFind:
+        verbosity = _settingsManager.getSetting('findResultsVerbosity')
+        if enoughSelected and verbosity != settings.FIND_SPEAK_NONE:
             origExtents = self.getExtents(origObj, origOffset - 1, origOffset)
             newExtents = self.getExtents(obj, offset - 1, offset)
             lineChanged = not self.onSameLine(origExtents, newExtents)
@@ -898,7 +838,7 @@ class Script(default.Script):
                 self.madeFindAnnouncement = False
 
             if lineChanged or not self.madeFindAnnouncement or \
-               not script_settings.onlySpeakChangedLinesDuringFind:
+               verbosity != settings.FIND_SPEAK_IF_LINE_CHANGED:
                 self.presentLine(obj, offset)
                 self.madeFindAnnouncement = True
 
@@ -947,7 +887,7 @@ class Script(default.Script):
             return
 
         self.setCaretContext(obj, event.detail1)
-        if not script_settings.controlCaretNavigation \
+        if not _settingsManager.getSetting('caretNavigationEnabled') \
            or obj.getState().contains(pyatspi.STATE_EDITABLE):
             orca.setLocusOfFocus(event, obj, False)
 
@@ -1099,7 +1039,7 @@ class Script(default.Script):
         self.updateBraille(obj)
         if obj.getState().contains(pyatspi.STATE_FOCUSABLE):
             speech.speak(self.speechGenerator.generateSpeech(obj))
-        elif not script_settings.sayAllOnLoad:
+        elif not _settingsManager.getSetting('sayAllOnLoad'):
             self.speakContents(
                 self.getLineContentsAtOffset(obj, characterOffset))
         elif _settingsManager.getSetting('enableSpeech'):
@@ -1222,7 +1162,7 @@ class Script(default.Script):
         if not event.detail1:
             return
 
-        if not script_settings.controlCaretNavigation:
+        if not _settingsManager.getSetting('caretNavigationEnabled'):
             default.Script.onFocusedChanged(self, event)
             return
 
@@ -1816,7 +1756,7 @@ class Script(default.Script):
         """Returns True if we should do our own caret navigation.
         """
 
-        if not script_settings.controlCaretNavigation:
+        if not _settingsManager.getSetting('caretNavigationEnabled'):
             return False
 
         if not self.inDocumentContent():
@@ -3968,7 +3908,7 @@ class Script(default.Script):
         [prevObj, prevOffset] = self.findNextCaretInOrder(prevObj,
                                                           prevOffset - 1)
 
-        if not script_settings.arrowToLineBeginning:
+        if not _settingsManager.getSetting('caretArrowToLineBeginning'):
             extents = self.getExtents(obj,
                                       characterOffset,
                                       characterOffset + 1)
@@ -4079,7 +4019,7 @@ class Script(default.Script):
         [nextObj, nextOffset] = \
                   self.findNextCaretInOrder(nextObj, max(0, nextOffset) - 1)
 
-        if not script_settings.arrowToLineBeginning:
+        if not _settingsManager.getSetting('caretArrowToLineBeginning'):
             extents = self.getExtents(obj,
                                       characterOffset,
                                       characterOffset + 1)
@@ -4389,13 +4329,13 @@ class Script(default.Script):
     def toggleCaretNavigation(self, inputEvent):
         """Toggles between Firefox native and Orca caret navigation."""
 
-        if script_settings.controlCaretNavigation:
+        if _settingsManager.getSetting('caretNavigationEnabled'):
             for keyBinding in self.__getArrowBindings().keyBindings:
                 self.keyBindings.removeByHandler(keyBinding.handler)
-            script_settings.controlCaretNavigation = False
+            _settingsManager.setSetting('caretNavigationEnabled', False)
             string = messages.CARET_CONTROL_GECKO
         else:
-            script_settings.controlCaretNavigation = True
+            _settingsManager.setSetting('caretNavigationEnabled', True)
             for keyBinding in self.__getArrowBindings().keyBindings:
                 self.keyBindings.add(keyBinding)
             string = messages.CARET_CONTROL_ORCA
diff --git a/src/orca/scripts/toolkits/WebKitGtk/Makefile.am b/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
index c542eb8..f769e6c 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
+++ b/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
@@ -2,9 +2,8 @@ orca_python_PYTHON = \
        __init__.py \
        braille_generator.py \
        script.py \
-       script_settings.py \
        speech_generator.py \
        script_utilities.py \
        structural_navigation.py
 
-orca_pythondir=$(pkgpythondir)/scripts/toolkits/WebKitGtk
\ No newline at end of file
+orca_pythondir=$(pkgpythondir)/scripts/toolkits/WebKitGtk
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 347c754..17dae82 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -43,7 +43,6 @@ import orca.speechserver as speechserver
 import orca.orca_state as orca_state
 import orca.speech as speech
 
-from . import script_settings
 from .structural_navigation import StructuralNavigation
 from .braille_generator import BrailleGenerator
 from .speech_generator import SpeechGenerator
@@ -72,9 +71,11 @@ class Script(default.Script):
         self._loadingDocumentContent = False
         self._isBrowser = isBrowser
         self._lastCaretContext = None, -1
-
         self.sayAllOnLoadCheckButton = None
 
+        if _settingsManager.getSetting('sayAllOnLoad') == None:
+            _settingsManager.setSetting('sayAllOnLoad', True)
+
     def setupInputEventHandlers(self):
         """Defines InputEventHandler fields for this script that can be
         called by the key and braille bindings."""
@@ -117,28 +118,18 @@ class Script(default.Script):
         label = guilabels.READ_PAGE_UPON_LOAD
         self.sayAllOnLoadCheckButton = \
             Gtk.CheckButton.new_with_mnemonic(label)
-        self.sayAllOnLoadCheckButton.set_active(script_settings.sayAllOnLoad)
+        self.sayAllOnLoadCheckButton.set_active(
+            _settingsManager.getSetting('sayAllOnLoad'))
         grid.attach(self.sayAllOnLoadCheckButton, 0, 0, 1, 1)
 
         grid.show_all()
 
         return grid
 
-    def setAppPreferences(self, prefs):
-        """Write out the application specific preferences lines and set the
-        new values.
-
-        Arguments:
-        - prefs: file handle for application preferences.
-        """
-
-        prefs.writelines("\n")
-        prefix = "orca.scripts.toolkits.WebKitGtk.script_settings"
-        prefs.writelines("import %s\n\n" % prefix)
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
 
-        value = self.sayAllOnLoadCheckButton.get_active()
-        prefs.writelines("%s.sayAllOnLoad = %s\n" % (prefix, value))
-        script_settings.sayAllOnLoad = value
+        return {'sayAllOnLoad': self.sayAllOnLoadCheckButton.get_active()}
 
     def getBrailleGenerator(self):
         """Returns the braille generator for this script."""
@@ -238,7 +229,7 @@ class Script(default.Script):
         orca.setLocusOfFocus(event, obj, False)
 
         self.updateBraille(obj)
-        if script_settings.sayAllOnLoad \
+        if _settingsManager.getSetting('sayAllOnLoad') \
            and _settingsManager.getSetting('enableSpeech'):
             self.sayAll(None)
 
diff --git a/src/orca/settings.py b/src/orca/settings.py
index ae3a22e..67b5e0e 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -88,10 +88,12 @@ userCustomizableSettings = [
     "enableMouseReview",
     "mouseDwellDelay",
     "speakCellCoordinates",
+    "speakSpreadsheetCoordinates",
     "speakCellSpan",
     "speakCellHeaders",
     "skipBlankCells",
     "largeObjectTextLength",
+    "structuralNavigationEnabled",
     "wrappedStructuralNavigation",
     "presentRequiredState",
     "brailleRequiredStateString",
@@ -113,6 +115,8 @@ userCustomizableSettings = [
     "spellcheckSpellSuggestion",
     "spellcheckPresentContext",
     "useColorNames",
+    "findResultsVerbosity",
+    "findResultsMinimumLength",
 ]
 
 excludeKeys = ["pronunciations",
@@ -616,18 +620,6 @@ chatAnnounceBuddyTyping = False
 #
 chatRoomHistories = False
 
-# Allow for the customization of key bindings.
-#
-def overrideKeyBindings(script, keyBindings):
-    from . import settings_manager
-    _settingsManager = settings_manager.getManager()
-    return _settingsManager.overrideKeyBindings(script, keyBindings)
-
-# Allow for user customization of pronunciations.
-#
-def overridePronunciations(script, pronunciations):
-    return pronunciations
-
 # This is a list of events that Orca should immediately drop and never look at.
 #
 ignoredEventsList = ['object:bounds-changed']
@@ -650,6 +642,7 @@ brailleContractionTable = ''
 # from cell to cell in a table.
 #
 speakCellCoordinates = True
+speakSpreadsheetCoordinates = True
 
 # Whether or not to speak the number of cells spanned by a cell
 # that occupies more than one row or column of a table.
@@ -833,3 +826,11 @@ spellcheckSpellSuggestion = True
 spellcheckPresentContext = True
 
 useColorNames = True
+
+FIND_SPEAK_NONE = 0
+FIND_SPEAK_IF_LINE_CHANGED  = 1
+FIND_SPEAK_ALL = 2
+findResultsVerbosity = FIND_SPEAK_ALL
+findResultsMinimumLength = 4
+
+structuralNavigationEnabled = True
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 691a246..e689a2f 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -83,10 +83,7 @@ class SettingsManager(object):
         # Dictionaries for store the default values
         # The keys and values are defined at orca.settings
         #
-        ## self.defaultGeneral contain some constants names as values
         self.defaultGeneral = {}
-        ## self.defaultGeneralValues contain the actual values, no constants
-        self.defaultGeneralValues = {}
         self.defaultPronunciations = {}
         self.defaultKeybindings = {}
 
@@ -104,6 +101,11 @@ class SettingsManager(object):
         self.pronunciations = {}
         self.keybindings = {}
 
+        self._activeApp = ""
+        self._appGeneral = {}
+        self._appPronunciations = {}
+        self._appKeybindings = {}
+
         if not self._loadBackend():
             raise Exception('SettingsManager._loadBackend failed.')
 
@@ -127,8 +129,7 @@ class SettingsManager(object):
         self._setDefaultGeneral()
         self._setDefaultPronunciations()
         self._setDefaultKeybindings()
-        self.defaultGeneralValues = getRealValues(self.defaultGeneral)
-        self.general = self.defaultGeneralValues.copy()
+        self.general = self.defaultGeneral.copy()
         if not self.isFirstStart():
             self.general.update(self._backend.getGeneral())
         self.pronunciations = self.defaultPronunciations.copy()
@@ -179,13 +180,8 @@ class SettingsManager(object):
         if not os.path.exists(initFile):
             os.close(os.open(initFile, os.O_CREAT, 0o700))
 
-        # Set up $XDG_DATA_HOME/orca/app-settings as a Python package.
-        #
         orcaSettingsDir = os.path.join(orcaDir, "app-settings")
         _createDir(orcaSettingsDir)
-        initFile = os.path.join(orcaSettingsDir, "__init__.py")
-        if not os.path.exists(initFile):
-            os.close(os.open(initFile, os.O_CREAT, 0o700))
 
         # Set up $XDG_DATA_HOME/orca/orca-customizations.py empty file and
         # define orcaDir as a Python package.
@@ -270,7 +266,7 @@ class SettingsManager(object):
         self._setSettingsRuntime({settingName:settingValue})
 
     def getSetting(self, settingName):
-        return getattr(settings, settingName)
+        return getattr(settings, settingName, None)
 
     def getVoiceLocale(self, voice='default'):
         voices = self.getSetting('voices')
@@ -295,8 +291,11 @@ class SettingsManager(object):
     def _mergeSettings(self):
         """Update the changed values on the profile settings
         over the current and active settings"""
-        profileGeneral = getRealValues(self.profileGeneral) or {}
-        self.general.update(profileGeneral)
+        self.profileGeneral.update(self._appGeneral)
+        self.profilePronunciations.update(self._appPronunciations)
+        self.profileKeybindings.update(self._appKeybindings)
+
+        self.general.update(self.profileGeneral)
         self.pronunciations.update(self.profilePronunciations)
         self.keybindings.update(self.profileKeybindings)
 
@@ -366,24 +365,16 @@ class SettingsManager(object):
             orca_i18n.setLocaleForMessages(newVoiceLocale)
             orca_i18n.setLocaleForGUI(newVoiceLocale)
 
-    def getPreferences(self, profile='default'):
-        general = self.getGeneralSettings(profile)
-        pronunciations = self.getPronunciations(profile)
-        keybindings = self.getKeybindings(profile)
-        return (general, pronunciations, keybindings)
-
     def _setSettingsRuntime(self, settingsDict):
         for key, value in list(settingsDict.items()):
             setattr(settings, str(key), value)
         self._getCustomizedSettings()
         for key, value in list(self.customizedSettings.items()):
             setattr(settings, str(key), value)
-        self._setPronunciationsRuntime()
 
-    def _setPronunciationsRuntime(self):
+    def _setPronunciationsRuntime(self, pronunciationsDict):
         pronunciation_dict.pronunciation_dict = {}
-        for pron in self.pronunciations:
-            key, value = self.pronunciations[pron]
+        for key, value in pronunciationsDict.values():
             if key and value:
                 pronunciation_dict.setPronunciation(key, value)
 
@@ -391,9 +382,7 @@ class SettingsManager(object):
         """Return the current general settings.
         Those settings comes from updating the default settings
         with the profiles' ones"""
-        generalDict = self._backend.getGeneral(profile)
-        self._setSettingsRuntime(generalDict)
-        return generalDict
+        return self._backend.getGeneral(profile)
 
     def getPronunciations(self, profile='default'):
         """Return the current pronunciations settings.
@@ -417,7 +406,7 @@ class SettingsManager(object):
                 continue
             elif key == 'profile':
                 self.profileGeneral[key] = value
-            elif value != self.defaultGeneralValues.get(key):
+            elif value != self.defaultGeneral.get(key):
                 self.profileGeneral[key] = value
             elif self.general.get(key) != value:
                 self.profileGeneral[key] = value
@@ -434,9 +423,39 @@ class SettingsManager(object):
         self.profileKeybindings = self.defaultKeybindings.copy()
         self.profileKeybindings.update(keybindings)
 
-    def saveSettings(self, general, pronunciations, keybindings):
-        """Let the active backend to store the default settings and
-        the profiles' ones."""
+    def _saveAppSettings(self, appName, general, pronunciations, keybindings):
+        appGeneral = {}
+        profileGeneral = self.getGeneralSettings(self.profile)
+        for key, value in general.items():
+            if value != profileGeneral.get(key):
+                appGeneral[key] = value
+
+        appPronunciations = {}
+        profilePronunciations = self.getPronunciations(self.profile)
+        for key, value in pronunciations.items():
+            if value != profilePronunciations.get(key):
+                appPronunciations[key] = value
+
+        appKeybindings = {}
+        profileKeybindings = self.getKeybindings(self.profile)
+        for key, value in keybindings.items():
+            if value != profileKeybindings.get(key):
+                appKeybindings[key] = value
+
+        self._backend.saveAppSettings(appName,
+                                      self.profile,
+                                      appGeneral,
+                                      appPronunciations,
+                                      appKeybindings)
+
+    def saveSettings(self, script, general, pronunciations, keybindings):
+        """Save the settings provided for the script provided."""
+
+        app = script.app
+        if app:
+            self._saveAppSettings(app.name, general, pronunciations, keybindings)
+            return
+
         # Assign current profile
         _profile = general.get('profile', settings.profile)
         currentProfile = _profile[1]
@@ -469,7 +488,7 @@ class SettingsManager(object):
         return bindingTuple
 
     def overrideKeyBindings(self, script, scriptKeyBindings):
-        keybindingsSettings = self.getKeybindings(self.profile)
+        keybindingsSettings = self.profileKeybindings
         for handlerString, bindingTuples in list(keybindingsSettings.items()):
             handler = script.inputEventHandlers.get(handlerString)
             if not handler:
@@ -501,103 +520,31 @@ class SettingsManager(object):
 
     def loadAppSettings(self, script):
         """Load the users application specific settings for an app.
-        Note that currently the settings manager does not manage
-        application settings in Orca; instead the old/"classic" files
-        are used. This is scheduled to change.
 
         Arguments:
         - script: the current active script.
         """
 
-        self._loadProfileSettings()
-        script.voices = self.getSetting('voices')
-
-        app = script.app
-        moduleName = _scriptManager.getModuleName(app)
-        if not moduleName:
+        if not (script and script.app):
             return
 
-        module = None
-        for package in self.settingsPackages:
-            name = '.'.join((package, moduleName))
-            debug.println(debug.LEVEL_FINEST, "Looking for %s.py" % name)
-            try:
-                module = importlib.import_module(name)
-            except ImportError:
-                debug.println(
-                    debug.LEVEL_FINEST, "Could not import %s.py" % name)
-                continue
-            try:
-                imp.reload(module)
-            except:
-                debug.println(debug.LEVEL_FINEST, "Could not load %s.py" % name)
-                module = None
-            else:
-                debug.println(debug.LEVEL_FINEST, "Loaded %s.py" % name)
-                break
-
-        if not module:
-            return
+        for key in self._appPronunciations.keys():
+            self.pronunciations.pop(key)
 
-        if self.profile == 'default':
-            appVoices = self.getSetting('voices')
-            for voiceType, voiceDef in list(appVoices.items()):
-                script.voices[voiceType].update(voiceDef)
-        else:
-            self.setSetting('voices', script.voices)
-
-        keybindings = getattr(module, 'overrideAppKeyBindings', None)
-        if keybindings:
-            script.overrideAppKeyBindings = keybindings
-            script.keyBindings = keybindings(script, script.keyBindings)
-
-        pronunciations = getattr(module, 'overridePronunciations', None)
-        if pronunciations:
-            script.overridePronunciations = pronunciations
-            script.app_pronunciation_dict = \
-                pronunciations(script, script.app_pronunciation_dict)
-
-def getVoiceKey(voice):
-    voicesKeys = getattr(settings, 'voicesKeys')
-    for key in list(voicesKeys.keys()):
-        if voicesKeys[key] == voice:
-            return key
-    return ""
-
-def getValueForKey(prefsDict, key):
-    need2repr = ['brailleEOLIndicator', 'brailleContractionTable',
-                 'brailleRequiredStateString', 'enabledBrailledTextAttributes',
-                 'enabledSpokenTextAttributes', 'speechRequiredStateString',
-                 'speechServerFactory', 'presentDateFormat',
-                 'presentTimeFormat']
-
-    value = None
-    if key in prefsDict:
-        if isinstance(prefsDict[key], str):
-            if key in need2repr:
-                value = "\'%s\'" % prefsDict[key]
-            elif key  == 'voices':
-                key = getVoiceKey(key)
-                value = prefsDict[key]
-            else:
-                try:
-                    value = getattr(settings, prefsDict[key])
-                except:
-                    debug.println(debug.LEVEL_SEVERE,
-                                  "Something went wront with key: " % key)
-                    debug.printStack(debug.LEVEL_FINEST)
-        else:
-            value = prefsDict[key]
-    return value
-
-def getRealValues(prefs):
-    """Get the actual values for any constant stored on a
-    general settings dictionary.
-    prefs is a dictionary with the userCustomizableSettings keys
-    and values."""
-    #for key in prefs.keys():
-    #    prefs[key] = getValueForKey(prefs, key)
-    return prefs
+        prefs = self._backend.getAppSettings(script.app.name)
+        profiles = prefs.get('profiles', {})
+        profilePrefs = profiles.get(self.profile, {})
+
+        self._appGeneral = profilePrefs.get('general', {})
+        self._appKeybindings = profilePrefs.get('keybindings', {})
+        self._appPronunciations = profilePrefs.get('pronunciations', {})
+        self._activeApp = script.app.name
+
+        self._loadProfileSettings()
+        self._mergeSettings()
+        self._setSettingsRuntime(self.general)
+        self._setPronunciationsRuntime(self.pronunciations)
+        script.keyBindings = self.overrideKeyBindings(script, script.getKeyBindings())
 
 _manager = SettingsManager()
 
diff --git a/src/orca/spellcheck.py b/src/orca/spellcheck.py
index 412dad9..e6e30de 100644
--- a/src/orca/spellcheck.py
+++ b/src/orca/spellcheck.py
@@ -290,21 +290,11 @@ class SpellCheck:
 
         return frame
 
-    def setAppPreferences(self, prefs):
-
-        prefix = "orca.settings"
-
-        value = self.spellErrorCheckButton.get_active()
-        _settingsManager.setSetting('spellcheckSpellError', value)
-        prefs.writelines("\n")
-        prefs.writelines("%s.spellcheckSpellError = %s\n" % (prefix, value))
-
-        value = self.spellSuggestionCheckButton.get_active()
-        _settingsManager.setSetting('spellcheckSpellSuggestion', value)
-        prefs.writelines("\n")
-        prefs.writelines("%s.spellcheckSpellSuggestion = %s\n" % (prefix, value))
-
-        value = self.presentContextCheckButton.get_active()
-        _settingsManager.setSetting('spellcheckPresentContext', value)
-        prefs.writelines("\n")
-        prefs.writelines("%s.spellcheckPresentContext = %s\n" % (prefix, value))
+    def getPreferencesFromGUI(self):
+        """Returns a dictionary with the app-specific preferences."""
+
+        return {
+            'spellcheckSpellError': self.spellErrorCheckButton.get_active(),
+            'spellcheckSpellSuggestion': self.spellSuggestionCheckButton.get_active(),
+            'spellcheckPresentContext': self.presentContextCheckButton.get_active()
+        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]