[orca/new-settings] Saved the new profile without reload the preferences



commit be2d4873eb0266ac4334fb8f2e02a13f76bb3f0c
Author: Juanje Ojeda <jojeda emergya es>
Date:   Wed Sep 1 03:42:34 2010 +0200

    Saved the new profile without reload the preferences

 src/orca/orca_gui_prefs.py |   39 ++++++++++++++-------------------------
 1 files changed, 14 insertions(+), 25 deletions(-)
---
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 935416e..f379a96 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -57,6 +57,9 @@ import text_attribute_names
 import orca_gui_profile
 
 from settings_manager import SettingsManager
+_settingsManager = SettingsManager()
+_settingsManager.loadBackend()
+
 
 try:
     import louis
@@ -499,10 +502,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
     def writeUserPreferences(self):
         """Write out the user's generic Orca preferences.
         """
-
-        _settingsManager = SettingsManager()
-        _settingsManager.loadBackend()
-
         if _settingsManager.writeSettings(self.prefsDict, self.keyBindingsModel,
                                        self.pronunciationModel):
             self._say( \
@@ -2193,10 +2192,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         """Get available user profiles or remove profiles page
         if classic backend"""
 
-
-        _settingsManager = SettingsManager()
-        _settingsManager.loadBackend()
-
         if _settingsManager.DEFAULT_BACKEND == 'classic':
             self.get_widget('notebook').remove_page(8)
             return ['default']
@@ -4372,16 +4367,18 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         profileToSave = orca_gui_profile.showProfileUI()
 
-        if isinstance(profileToSave, str) and profileToSave != '' \
-                and not profileToSave in self.__getAvailableProfiles():
-            # If applyButtonClicked is needed, then this code will be uncommented,
-            # then new profile will be stored in profileCombo
-            #profile = {profileToSave: self.profilesComboModel.append([profileToSave])}
-            #activeProfile = int(self.profilesComboModel.get_string_from_iter(profile[profileToSave]))
-            #self.profilesCombo.set_active(activeProfile)
+        def saveActiveProfile():
+            profile = {profileToSave: self.profilesComboModel.append([profileToSave])}
+            activeProfile = int(self.profilesComboModel.get_string_from_iter(profile[profileToSave]))
+            self.profilesCombo.set_active(activeProfile)
 
             self.prefsDict['activeProfile'] = profileToSave.replace(' ','_')
-            self.applyButtonClicked(None)
+            self.writeUserPreferences()
+
+
+        if isinstance(profileToSave, str) and profileToSave != '' \
+                and not profileToSave in self.__getAvailableProfiles():
+            saveActiveProfile()
         else:
             if profileToSave != None:
                 # We're here because given profile name exists, so we have
@@ -4402,8 +4399,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
                 if response == gtk.RESPONSE_YES:
                     dialog.destroy()
-                    self.prefsDict['activeProfile'] = profileToSave.replace(' ','_')
-                    self.applyButtonClicked(None)
+                    saveActiveProfile()
                 else:
                     dialog.destroy()
                 
@@ -4480,9 +4476,6 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         
         orca.loadUserSettings()
         
-        _settingsManager = SettingsManager()
-        _settingsManager.loadBackend()
-
         self.prefsDict = _settingsManager.readPreferences() 
 
         self.init()
@@ -5225,10 +5218,6 @@ def showPreferencesUI():
         braille.displayMessage(line)
         speech.speak(line)
 
-        #prefsDict = orca_prefs.readPreferences()
-        _settingsManager = SettingsManager()
-        _settingsManager.loadBackend()
-
         prefsDict = _settingsManager.readPreferences()
 
         orca_state.prefsUIFile = \



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