[orca/new-settings] Renamed methods called from orca_gui_pref.py and fixed some settings_manager and yaml_backend method



commit e9d87ac9498f55b19d794e157d859d89ffb4ef6a
Author: Juanje Ojeda <jojeda emergya es>
Date:   Tue Oct 26 11:23:42 2010 +0200

    Renamed methods called from orca_gui_pref.py and fixed some settings_manager and yaml_backend methods

 src/orca/backends/yaml_backend.py |    6 -----
 src/orca/orca_gui_prefs.py        |   23 ++++++++++++++++++---
 src/orca/settings_manager.py      |   38 +++++++++++++-----------------------
 3 files changed, 33 insertions(+), 34 deletions(-)
---
diff --git a/src/orca/backends/yaml_backend.py b/src/orca/backends/yaml_backend.py
index 6b380db..b85ab81 100644
--- a/src/orca/backends/yaml_backend.py
+++ b/src/orca/backends/yaml_backend.py
@@ -104,12 +104,6 @@ class Backend:
             keybindings = profileSettings['keybindings']
         return keybindings
 
-    def getPreferences(self, profile='default'):
-        general = getGeneral(profile)
-        pronunciations = getPronunciations(profile)
-        keybindings = getKeybindings(profile)
-        return (general, pronunciations, keybindings)
-
     def isFirstStart(self):
         if os.path.exists(self.settingsFile):
             return False
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index d4cd92b..32bd64b 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -507,8 +507,11 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
     def writeUserPreferences(self):
         """Write out the user's generic Orca preferences.
         """
-        if _settingsManager.writeSettings(self.prefsDict, self.keyBindingsModel,
-                                       self.pronunciationModel):
+        pronunciationDict = getModelDict(self.pronunciationModel)
+        keyBindingsDict = getModelDict(self.keyBindingsModel)
+        if _settingsManager.saveSettings(self.prefsDict,
+                                         keyBindingsDict,
+                                         pronunciationDict):
             self._presentMessage(
                 _("Accessibility support for GNOME has just been enabled."))
             self._presentMessage(
@@ -2298,6 +2301,18 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         activeName = model.get_value(activeIter, 1)
         return [activeLabel, activeName]
 
+    def getModelDict(self, model):
+        """Get the list of values from a list[str,str] model
+        """
+        modelDict = {}
+        currentIter = model.get_iter_first()
+        while currentIter is not None:
+            key, value = model.get(currentIter, ACTUAL, REPLACEMENT)
+            if key != "" and value != "":
+                modelDict[key] = value
+            model.iter_next(currentIter)
+        return modelDict
+
     def showGUI(self):
         """Show the Orca configuration GUI window. This assumes that
         the GUI has already been created.
@@ -4558,7 +4573,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
                          activeProfile)
         
         self.prefsDict['activeProfile'] = activeProfile
-        _settingsManager.loadSettings()
+        _settingsManager.setProfile(activeProfile[1])
         self._initGUIState()
 
         self._initSpeechState()
@@ -5303,7 +5318,7 @@ def showPreferencesUI():
         except:
             pass
 
-        prefsDict = _settingsManager.getPreferences()
+        prefsDict = _settingsManager.getGeneralSettings()
 
         orca_state.prefsUIFile = \
             os.path.join(orca_platform.prefix,
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 186412f..d6a7011 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -204,24 +204,21 @@ class SettingsManager():
         the current profile"""
         if profile is None:
             profile = self.profile
-        generalSettings = self._backend.getGeneral(profile)
-        self.profileGeneral = generalSettings
+        self.general = self._backend.getGeneral(profile)
 
     def _getPronunciations(self, profile=None):
         """Get from the active backend the pronunciations settings for
         the current profile"""
         if profile is None:
             profile = self.profile
-        pronunciationsSettings = self._backend.getPronunciations(self.profile)
-        self.profilePronunciations = pronunciationsSettings
+        self.pronunciations = self._backend.getPronunciations(profile)
 
     def _getKeybindings(self, profile=None):
         """Get from the active backend the keybindings settings for
         the current profile"""
         if profile is None:
             profile = self.profile
-        keybindingsSettings = self._backend.getKeybindings(self.profile)
-        self.profileKeybindings = keybindingsSettings
+        self.keybindings = self._backend.getKeybindings(profile)
 
     def _loadProfileSettings(self, profile=None):
         """Get from the active backend all the settings for the current
@@ -264,29 +261,29 @@ class SettingsManager():
         self._loadProfileSettings(profile)
         self._mergeSettings()
 
-    def getPreferences(self):
-        preferences = self.getGeneralSettings()
-        preferences.update(self.getPronunciations())
-        preferences.update(self.getKeybindings())
-        return preferences
+    def getPreferences(self, profile='default'):
+        general = getGeneral(profile)
+        pronunciations = getPronunciations(profile)
+        keybindings = getKeybindings(profile)
+        return (general, pronunciations, keybindings)
 
-    def getGeneralSettings(self):
+    def getGeneralSettings(self, profile='default'):
         """Return the current general settings.
         Those settings comes from updating the default settings
         with the profiles' ones"""
-        return self.general
+        return self._backend.getGeneral(profile)
 
-    def getPronunciations(self):
+    def getPronunciations(self, profile='default'):
         """Return the current pronunciations settings.
         Those settings comes from updating the default settings
         with the profiles' ones"""
-        return self.pronunciations
+        return self._backend.getPronunciations(profile)
 
-    def getKeybindings(self):
+    def getKeybindings(self, profile='default'):
         """Return the current keybindings settings.
         Those settings comes from updating the default settings
         with the profiles' ones"""
-        return self.keybindings
+        return self._backend.getKeybindings(profile)
 
     def _setProfileGeneral(self):
         """Set the changed general settings from the defaults' ones
@@ -355,10 +352,3 @@ class SettingsManager():
 
         return self._backend.availableProfiles()
 
-    def loadSettings(self):
-        #TODO: is it needed?
-        print "settings_manager::loadSettings"
-
-    def writeSettings(self, preferences, keybindings, pronunciation):
-        #TODO: is it needed?
-        print "settings_manager::writeSettings"



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