[orca] Fix for bug #645278 - Orca is writing out application prefences it should not



commit a60a8d61ab1e3b9efc0ce7b2105707382e7a904b
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sun Mar 20 01:32:22 2011 -0400

    Fix for bug #645278 - Orca is writing out application prefences it should not

 src/orca/app_prefs.py  |   16 +++++++++++++++-
 src/orca/orca_prefs.py |   13 +++++++++++--
 src/orca/settings.py   |    4 ++--
 3 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/app_prefs.py b/src/orca/app_prefs.py
index 8c6ccdf..94bfe4a 100644
--- a/src/orca/app_prefs.py
+++ b/src/orca/app_prefs.py
@@ -178,6 +178,20 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
         prefs.writelines("except ImportError:\n")
         prefs.writelines("    pass\n")
 
+    @staticmethod
+    def valueChanged(oldValue, newValue):
+        """Work around for the fact that some settings are lists/dictionaries
+        stored as strings in which the original list/dictionary contents might
+        be strings or might be unicode."""
+
+        if oldValue == newValue:
+            return False
+
+        try:
+            return eval(oldValue) != eval(newValue)
+        except:
+            return True
+
     def writePreferences(self):
         """Creates the directory and files to hold application specific
         user preferences.  Write out any preferences that are different
@@ -204,7 +218,7 @@ class OrcaPrefs(orca_prefs.OrcaPrefs):
         for key in settings.userCustomizableSettings:
             value = self._getValueForKey(self.prefsDict, key)
             oldValue = self._getValueForKey(oldPrefsDict, key)
-            if oldValue != value:
+            if self.valueChanged(oldValue, value):
                 prefs.writelines("orca.settings.%s = %s\n" % (key, value))
 
         if self.keyBindingsTreeModel:
diff --git a/src/orca/orca_prefs.py b/src/orca/orca_prefs.py
index eccb73c..a259bf6 100644
--- a/src/orca/orca_prefs.py
+++ b/src/orca/orca_prefs.py
@@ -166,7 +166,7 @@ class OrcaPrefs:
         """
 
         if not display:
-            return "''"
+            return "':0.0'"
         else:
             return "'%s'" % display
 
@@ -212,8 +212,17 @@ class OrcaPrefs:
 
         voicesStr = "{\n"
         for voice in voices:
+            # Hack to deal with the fact that we're creating a string from
+            # a setting in which dictionary keys may be in unicode. This
+            # later causes equality checks to fail. Such nonsense should
+            # go away when app settings are also fully managed by the
+            # settings manager.
+            voiceDict = voices[voice]
+            newDict = {}
+            for key, value in voiceDict.items():
+                newDict[str(key)] = value
             voicesStr += "'%s' : orca.acss.ACSS(" % voice
-            voicesStr += pprint.pformat(voices[voice]) + "),\n"
+            voicesStr += pprint.pformat(newDict) + "),\n"
         voicesStr += "}"
 
         return voicesStr
diff --git a/src/orca/settings.py b/src/orca/settings.py
index aa3d8f1..73870a2 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -614,11 +614,11 @@ magPointerFollowsZoomer        = True
 
 # Magnification source display
 #
-magSourceDisplay                 = ''
+magSourceDisplay                 = ':0.0'
 
 # Magnification target display
 #
-magTargetDisplay                 = ''
+magTargetDisplay                 = ':0.0'
 
 # if True, enable character echo.
 # Note that it is allowable for both enableEchoByCharacter and enableKeyEcho



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