Index: src/orca/focus_tracking_presenter.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/focus_tracking_presenter.py,v
retrieving revision 1.90
diff -u -r1.90 focus_tracking_presenter.py
--- src/orca/focus_tracking_presenter.py	1 Nov 2006 13:09:34 -0000	1.90
+++ src/orca/focus_tracking_presenter.py	7 Nov 2006 21:56:40 -0000
@@ -68,6 +68,7 @@
         #
         self.registry        = atspi.Registry()
         self._knownScripts   = {}
+        self._knownAppSettings = {}
         self._eventQueue     = Queue.Queue(0)
         self._gidleId        = 0
         self._gidleLock      = threading.Lock()
@@ -296,6 +297,44 @@
 
     ########################################################################
     #                                                                      #
+    # METHODS FOR KEEPING TRACK OF APPLICATION SETTINGS.                   #
+    #                                                                      #
+    ########################################################################
+
+    def loadAppSettings(self, app):
+        """Load the users application specific settings for an app.
+
+        Arguments:
+        - app: the Python app
+        """
+
+        settingsPackages = settings.settingsPackages
+        moduleName = settings.getScriptModuleName(app)
+        module = None
+
+        if moduleName and len(moduleName):
+            for package in settingsPackages:
+                if len(package):
+                    name = package + "." + moduleName
+                else:
+                    name = moduleName
+                try:
+                    debug.println(debug.LEVEL_FINEST,
+                                  "Looking for settings at %s.py..." % name)
+                    if self. _knownAppSettings.has_key(name):
+                        reload(self._knownAppSettings[name])
+                    else:
+                        self._knownAppSettings[name] = \
+                            __import__(name, globals(), locals(), [''])
+                    debug.println(debug.LEVEL_FINEST,
+                                  "...found %s.py" % name)
+                    break
+                except ImportError:
+                    debug.println(debug.LEVEL_FINEST,
+                                  "...could not find %s.py" % name)
+
+    ########################################################################
+    #                                                                      #
     # METHODS FOR PRE-PROCESSING AND MASSAGING AT-SPI OBJECT EVENTS        #
     # for processing by the rest of Orca.                                  #
     #                                                                      #
@@ -437,7 +476,24 @@
                         debug.println(debug.LEVEL_FINE, "ACTIVE SCRIPT: " \
                                       + orca_state.activeScript.name)
                     s = self._getScript(event.source.app)
+
+                    # If this is the active script (or we want to present
+                    # if inactive), save existing application specific 
+                    # settings and load in the application specific settings 
+                    # for the app for this event (if found).
+                    #
+                    if orca_state.activeScript == s or s.presentIfInactive:
+                        oldAppSettings = util.saveOldAppSettings()
+                        appSettings = self.loadAppSettings(event.source.app)
+
                     s.processObjectEvent(event)
+
+                    # If this is the active script (or we want to present
+                    # if inactive), restore previous settings.
+                    #
+                    if orca_state.activeScript == s or s.presentIfInactive:
+                        util.restoreOldAppSettings(oldAppSettings)
+
                     if retryCount:
                         debug.println(debug.LEVEL_WARNING,
                                       "  SUCCEEDED AFTER %d TRIES" % retryCount)
Index: src/orca/orca_prefs.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/orca_prefs.py,v
retrieving revision 1.14
diff -u -r1.14 orca_prefs.py
--- src/orca/orca_prefs.py	2 Nov 2006 16:07:46 -0000	1.14
+++ src/orca/orca_prefs.py	7 Nov 2006 21:56:41 -0000
@@ -302,6 +302,14 @@
     if not os.path.exists(initFile):
         os.close(os.open(initFile, os.O_CREAT, 0700))
 
+    # Set up ~/.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, 0700))
+
     # Write ~/.orca/user-settings.py
     #
     prefs = open(os.path.join(orcaDir, "user-settings.py"), "w")
Index: src/orca/settings.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/settings.py,v
retrieving revision 1.84
diff -u -r1.84 settings.py
--- src/orca/settings.py	2 Nov 2006 16:07:46 -0000	1.84
+++ src/orca/settings.py	7 Nov 2006 21:56:41 -0000
@@ -416,6 +416,14 @@
 doubleClickTimeout = 0.5
 
 # Which packages to search, and the order in which to search,
+# for application settings.  These packages are expected to be on
+# the PYTHONPATH and/or subpackages of the "orca" package.
+# REMEMBER: to make something a package, the directory has to
+# have a __init__.py file in it.
+#
+settingsPackages          = ["app-settings"]
+
+# Which packages to search, and the order in which to search,
 # for custom scripts.  These packages are expected to be on
 # the PYTHONPATH and/or subpackages of the "orca" package.
 # REMEMBER: to make something a package, the directory has to
Index: src/orca/util.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/util.py,v
retrieving revision 1.51
diff -u -r1.51 util.py
--- src/orca/util.py	6 Nov 2006 16:41:04 -0000	1.51
+++ src/orca/util.py	7 Nov 2006 21:56:42 -0000
@@ -41,6 +41,7 @@
 import chnames
 import debug
 import input_event
+import orca_prefs
 import orca_state
 import phonnames
 import punctuation_settings
@@ -1186,6 +1187,23 @@
                 debug.printException(debug.LEVEL_FINEST)
 
     return window
+
+def saveOldAppSettings():
+    """Save a copy of all the existing application specific settings
+    (as specified by the settings.userCustomizableSettings dictionary)."""
+
+    return orca_prefs.readPreferences()
+
+def restoreOldAppSettings(prefsDict):
+    """Restore a copy of all the previous saved application settings.
+
+    Arguments:
+    - prefsDict: the dictionary containing the old application settings.
+    """
+
+    for key in settings.userCustomizableSettings:
+        if prefsDict.has_key(key):
+            settings.__dict__[key] = prefsDict[key]
 
 ########################################################################
 #                                                                      #
