Index: docs/pydoc/Makefile.am
===================================================================
RCS file: /cvs/gnome/orca/docs/pydoc/Makefile.am,v
retrieving revision 1.15
diff -u -r1.15 Makefile.am
--- docs/pydoc/Makefile.am	25 Oct 2006 22:49:19 -0000	1.15
+++ docs/pydoc/Makefile.am	3 Nov 2006 17:43:16 -0000
@@ -4,6 +4,7 @@
 DOC_FILES = \
 	orca \
 	orca.acss \
+	orca.appsettings \
 	orca.atspi \
 	orca.braille \
 	orca.braillegenerator \
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/gnome/orca/po/POTFILES.in,v
retrieving revision 1.25
diff -u -r1.25 POTFILES.in
--- po/POTFILES.in	1 Nov 2006 10:46:27 -0000	1.25
+++ po/POTFILES.in	3 Nov 2006 17:43:16 -0000
@@ -3,6 +3,7 @@
 [encoding: UTF-8]
 
 orca.desktop.in
+src/orca/appsettings.py
 src/orca/braille.py
 src/orca/braillegenerator.py
 src/orca/chnames.py
Index: src/orca/Makefile.am
===================================================================
RCS file: /cvs/gnome/orca/src/orca/Makefile.am,v
retrieving revision 1.39
diff -u -r1.39 Makefile.am
--- src/orca/Makefile.am	21 Oct 2006 17:22:18 -0000	1.39
+++ src/orca/Makefile.am	3 Nov 2006 17:43:16 -0000
@@ -9,6 +9,7 @@
 orca_python_PYTHON = \
 	__init__.py \
 	acss.py \
+	appsettings.py \
 	atspi.py \
 	braille.py \
 	braillegenerator.py \
Index: src/orca/appsettings.py
===================================================================
RCS file: src/orca/appsettings.py
diff -N src/orca/appsettings.py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/orca/appsettings.py	3 Nov 2006 17:43:16 -0000
@@ -0,0 +1,50 @@
+# Orca
+#
+# Copyright 2004-2006 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""The default Settings used to set individual application settings."""
+
+__id__        = "$Id:$"
+__version__   = "$Revision:$"
+__date__      = "$Date:$"
+__copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+class Settings:
+
+    def __init__(self, app):
+        """Creates a new applications settings for the given application.
+
+        Arguments:
+        - app: the application to create the settings for.
+        """
+
+        self.app = app
+
+    def loadNewSettings(self):
+        """Load the application specific settings. Note that it is upto
+        the individual application settings scripts, to save away the
+        previous value of each setting that it overrides, so that it can
+        later be restored correctly. """
+
+        pass
+
+    def restoreOldSettings(self):
+        """Restore the previous settings."""
+
+        pass
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	3 Nov 2006 17:43:17 -0000
@@ -30,6 +30,7 @@
 import threading
 import time
 
+import appsettings
 import atspi
 import braille
 import default
@@ -68,6 +69,7 @@
         #
         self.registry        = atspi.Registry()
         self._knownScripts   = {}
+        self._knownAppSettings = {}
         self._eventQueue     = Queue.Queue(0)
         self._gidleId        = 0
         self._gidleLock      = threading.Lock()
@@ -296,6 +298,96 @@
 
     ########################################################################
     #                                                                      #
+    # METHODS FOR KEEPING TRACK OF APPLICATION SETTINGS.                   #
+    #                                                                      #
+    ########################################################################
+
+    def _createAppSettings(self, app):
+        """For the given application name, create a new appsettings instance.
+        We'll first see if a mapping from appName to module name exists.
+        If it does, we use that.  If it doesn't, we try the app name.
+        If all else fails, we fall back to the default appsettings.
+        """
+
+        appSettings = None
+
+        # Look for custom application settings first.
+        #
+        # We'll use the LEVEL_FINEST level for debug output here as
+        # it really isn't an error if the script cannot be found.
+        # But, sometimes a script cannot be "found" because it has
+        # a syntax error in it, so we want to give script writers
+        # a vehicle for debugging these types of things.
+        #
+        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)
+                    module = __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)
+                except:
+                    debug.printException(debug.LEVEL_SEVERE)
+                    debug.println(debug.LEVEL_SEVERE,
+                                  "While attempting to import %s" % name)
+        if module:
+            try:
+                appSettings = module.Settings(app)
+            except:
+                # We do not want this method to fail.  If it does, we want 
+                # to let the script developer know what went wrong,
+                # but we also want to move along without crashing Orca.
+                #
+                debug.printException(debug.LEVEL_SEVERE)
+
+        if not appSettings:
+            appSettings = appsettings.Settings(app)
+
+        return appSettings
+
+    def _getSettings(self, app):
+        """Get the application specific settings for an app.
+
+        Arguments:
+        - app: the Python app
+
+        Returns an instance of a AppSettings.
+        """
+
+        # We might not know what the app is.  In this case, just defer
+        # to the default appsettings for support.
+        #
+        if not app:
+            if not self._defaultAppSettings:
+                self._defaultAppSettings = appsettings.Settings(None)
+            appSettings = self._defaultAppSettings
+        elif self._knownAppSettings.has_key(app):
+            appSettings = self._knownAppSettings[app]
+        else:
+            appSettings = self._createAppSettings(app)
+            self._knownAppSettings[app] = appSettings
+
+        return appSettings
+
+    ########################################################################
+    #                                                                      #
     # METHODS FOR PRE-PROCESSING AND MASSAGING AT-SPI OBJECT EVENTS        #
     # for processing by the rest of Orca.                                  #
     #                                                                      #
@@ -437,7 +529,22 @@
                         debug.println(debug.LEVEL_FINE, "ACTIVE SCRIPT: " \
                                       + orca_state.activeScript.name)
                     s = self._getScript(event.source.app)
+
+                    # Load an application specific settings.
+                    #
+                    appSettings = self._getSettings(event.source.app)
+                    if appSettings:
+                        appSettings.loadNewSettings()
+
                     s.processObjectEvent(event)
+
+                    # Restore previous settings. Note that it's upto the
+                    # application script to have saved away the previous
+                    # values and to restore them correctly.
+                    #
+                    if appSettings:
+                        appSettings.restoreOldSettings()
+
                     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	3 Nov 2006 17:43:18 -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	3 Nov 2006 17:43:18 -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
