[orca/new-settings] Some changes for using defaults settings from settings.py instead of backends/gconf_defaults.py by t



commit 0c1240853dc3f3679688cc8a47d89cc7e4d72ccc
Author: Juanje Ojeda <jojeda emergya es>
Date:   Wed Oct 20 16:16:21 2010 +0200

    Some changes for using defaults settings from settings.py instead of backends/gconf_defaults.py by the gconf backend

 src/orca/backends/gconf_backend.py |  107 ++++++++----------------------------
 src/orca/orca_gui_prefs.py         |   10 +++-
 2 files changed, 31 insertions(+), 86 deletions(-)
---
diff --git a/src/orca/backends/gconf_backend.py b/src/orca/backends/gconf_backend.py
index ba675a1..82dccd2 100644
--- a/src/orca/backends/gconf_backend.py
+++ b/src/orca/backends/gconf_backend.py
@@ -59,9 +59,10 @@ class OrcaPrefs():
     # set gconf configuration properties
     GCONF_BASE_DIR = '/apps/gnome-orca'
     VALID_KEY_TYPES = (bool, str, int, list, tuple)
-    import gconf_defaults
 
-    DEFAULTS = gconf_defaults.defaults
+    from orca import orca_prefs
+
+    DEFAULTS = orca_prefs.readPreferences()
     
     need2repr = ['brailleEOLIndicator', 'brailleContractionTable',
                  'brailleRequiredStateString', 'enabledBrailledTextAttributes',
@@ -663,74 +664,7 @@ class OrcaPrefs():
 
         value = None
         if key in prefsDict:
-            if key == "voices":
-                value = self._getVoicesString(prefsDict[key])
-            elif key == "speechServerInfo":
-                if isinstance(prefsDict[key], str):
-                    prefsDict[key] = prefsDict[key].replace('[','').replace(']','').split(',')
-                value = self._getSpeechServerString(prefsDict[key])
-            elif key == "speechServerFactory":
-                value = self._getSpeechServerFactoryString(prefsDict[key])
-            elif key.endswith("VerbosityLevel"):
-                value = self._getVerbosityString(prefsDict[key])
-            elif key == "brailleRolenameStyle":
-                value = self._getBrailleRolenameStyleString(prefsDict[key])
-            elif key == "brailleSelectorIndicator":
-                value = self._getBrailleSelectionIndicatorString(prefsDict[key])
-            elif key == "brailleLinkIndicator":
-                value = self._getBrailleLinkIndicatorString(prefsDict[key])
-            elif key == "brailleAlignmentStyle":
-                value = self._getBrailleAlignmentStyleString(prefsDict[key])
-            elif key == "verbalizePunctuationStyle":
-                value = self._getVerbalizePunctuationStyleString(prefsDict[key])
-            elif key == "presentDateFormat":
-                value = self._getPresentDateString(prefsDict[key])
-            elif key == "presentTimeFormat":
-                value = self._getPresentTimeString(prefsDict[key])
-            elif key == "sayAllStyle":
-                value = prefsDict[key]
-            elif key in ["magCursorColor",
-                         "magCrossHairColor",
-                         "magZoomerBorderColor"]:
-                value = self._getMagColorString(prefsDict[key])
-            elif key == "magSmoothingMode":
-                value = self._getMagSmoothingModeString(prefsDict[key])
-            elif key == "magMouseTrackingMode":
-                value = self._getMagMouseTrackingModeString(prefsDict[key])
-            elif key == "magControlTrackingMode":
-                value = self._getMagControlTrackingModeString(prefsDict[key])
-            elif key == "magTextTrackingMode":
-                value = self._getMagTextTrackingModeString(prefsDict[key])
-            elif key == "magZoomerType":
-                value = self._getMagZoomerTypeString(prefsDict[key])
-            elif key == "magColorFilteringMode":
-                value = self._getMagColorFilteringModeString(prefsDict[key])
-            elif key == "magSourceDisplay" or key == "magTargetDisplay":
-                value = self._getDisplayString(prefsDict[key])
-            elif key == "keyboardLayout":
-                value = self._getKeyboardLayoutString(prefsDict[key])
-            elif key == "orcaModifierKeys":
-                value = self._getOrcaModifierKeysString(prefsDict[key])
-            elif key == "enabledSpokenTextAttributes":
-                value = self._getSpokenTextAttributesString(prefsDict[key])
-            elif key == "enabledBrailledTextAttributes":
-                value = self._getBrailledTextAttributesString(prefsDict[key])
-            elif key == "textAttributesBrailleIndicator":
-                value = self._getTextAttributesBrailleIndicatorString( \
-                                                              prefsDict[key])
-            elif key == "progressBarVerbosity":
-                value = self._getProgressBarVerbosityString(prefsDict[key])
-            elif key == "brailleContractionTable":
-                value = "'%s'" % prefsDict[key]
-            elif key == "brailleEOLIndicator":
-                value = "'%s'" % prefsDict[key]
-            elif key == "brailleRequiredStateString":
-                value = "'%s'" % prefsDict[key]
-            elif key == "speechRequiredStateString":
-                value = "'%s'" % prefsDict[key]
-            else:
-                value = prefsDict[key]
-
+            return prefsDict[key]
         return value
 
     def writePreferences(self):
@@ -768,7 +702,7 @@ class OrcaPrefs():
             self.__app_key += '/%s' % activeProfileName
 
             for key in settings.userCustomizableSettings:
-                if key not in ['voices', 'firstStart']:
+                if key not in ['voices', 'firstStart', 'speechServerInfo']:
                     self.prefsDict[key] = self._getValueForKey(self.prefsDict, key)
                 if key in self.need2repr:
                     self.prefsDict[key] = self._fix_quotes(self.prefsDict[key])
@@ -833,10 +767,12 @@ class OrcaPrefs():
         #  show preferences dialog
         if not self._client.all_entries(self.__app_key):
             return False
-        else:
+        elif isFirstStart():
             path = '/apps/gnome-orca/startingProfile'
-            profileKey = self._client.get_list(path, gconf.VALUE_STRING)
-            self.__app_key += '/%s' % profileKey[1]
+        else:
+            path = '/apps/gnome-orca/activeProfile'
+        profileKey = self._client.get_list(path, gconf.VALUE_STRING)
+        self.__app_key += '/%s' % profileKey[1]
         #    self.options = self.DEFAULTS
         #    self.gconf_save()
  
@@ -870,15 +806,18 @@ class OrcaPrefs():
         #
         import orca.pronunciation_dict
 
-        orca.pronunciation_dict.pronunciation_dict = {}
-        for key, value in self.settingsDict['pronunciations'].items():
-            orca.pronunciation_dict.setPronunciation(str(key), str(value))
+        if self.settingsDict.has_key('pronunciations'):
+            orca.pronunciation_dict.pronunciation_dict = {}
+            for key, value in self.settingsDict['pronunciations'].items():
+                orca.pronunciation_dict.setPronunciation(str(key), str(value))
 
         import orca.orca_state
 
         # Load keybindings
         #
-        settings.overrideKeyBindings = self.__loadOverridenKeyBindings
+        #FIXME: This make no sense, we need to do another thing to overwrite
+        # the overrideKeyBindings
+        #settings.overrideKeyBindings = self.__loadOverridenKeyBindings
 
         try:
             reload(orca.orca_state.orcaCustomizations)
@@ -936,12 +875,12 @@ def readPreferences():
         except:
             pass 
 
-    # must be in userCustomizableSettings
-    # profile support
-    client = gconf.client_get_default()
-    path = '/apps/gnome-orca/startingProfile'
-    prefsDict['startingProfile'] = client.get_list(path, gconf.VALUE_STRING)
-    prefsDict['activeProfile'] = prefsDict['startingProfile']
+    print "\t*** DEBUG: inside gconf_backend.readPreferences() ***"
+    if isFirstStart():
+        client = gconf.client_get_default()
+        path = '/apps/gnome-orca/startingProfile'
+        prefsDict['startingProfile'] = client.get_list(path, gconf.VALUE_STRING)
+        prefsDict['activeProfile'] = prefsDict['startingProfile']
 
     return prefsDict
 
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 77bd620..d7722d3 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -4552,13 +4552,19 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         gclient = gconf.client_get_default()
         activeProfile = self.getComboBoxList(self.profilesCombo)
+        self.prefsDict['activeProfile'] = activeProfile
+        print "\tDEBUG: self.prefsDict['activeProfile'] = ", self.prefsDict['activeProfile']
+        print "\tDEBUG: activeProfile: ", activeProfile
         gclient.set_list('/apps/gnome-orca/activeProfile',
                          gconf.VALUE_STRING,
                          activeProfile)
         
         #orca.loadUserSettings()
-        self.prefsDict = _settingsManager.readPreferences() 
-        self.init()
+        print "\tDEBUG: self.prefsDict['activeProfile'] = ", self.prefsDict['activeProfile']
+        self.prefsDict['activeProfile'] = activeProfile
+        self._initGUIState()
+        print "DEBUG: after self.init()"
+        print "\tDEBUG: self.prefsDict['activeProfile'] = ", self.prefsDict['activeProfile']
 
         self._initSpeechState()
 



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