[orca/new-settings] Added method for getting the real values for the settings' contants in any general settings dictiona
- From: Juanje Ojeda Croissier <jojeda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] Added method for getting the real values for the settings' contants in any general settings dictiona
- Date: Sun, 24 Oct 2010 23:07:47 +0000 (UTC)
commit 64d59c2f28ca704f5e3ca7204fb9108a445c603a
Author: Juanje Ojeda <jojeda emergya es>
Date: Mon Oct 25 00:50:24 2010 +0200
Added method for getting the real values for the settings' contants in any general settings dictionary
src/orca/settings_manager.py | 45 ++++++++++++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 3321db7..125004c 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -53,6 +53,7 @@ class SettingsManager():
self.profile = profile
self.backendName = backend
self.defaultGeneral = {}
+ self.defaultGeneralValues = {}
self.defaultPronunciations = {}
self.defaultKeybindings = {}
self.profileGeneral = {}
@@ -69,7 +70,8 @@ class SettingsManager():
self.defaultGeneral = self._getDefaultGeneral()
self.defaultPronunciations = self._getDefaultPronunciations()
self.defaultKeybindings = self._getDefaultKeybindings()
- self.general = self.defaultGeneral
+ self.defaultGeneralValues = self.getRealValues(self.defaultGeneral)
+ self.general = self.defaultGeneralValues
self.pronunciations = self.defaultPronunciations
self.keybindings = self.defaultKeybindings
@@ -95,9 +97,9 @@ class SettingsManager():
"""Let the active backend to create the initial structure
for storing the settings and save the default ones from
orca.settings"""
- self._backend.createGeneral(self.general,
- self.pronunciations,
- self.keybindings)
+ self._backend.createGeneral(self.defaultGeneral,
+ self.defaultPronunciations,
+ self.defaultKeybindings)
def _getDefaultGeneral(self):
"""Get the general settings by default from orca.settings"""
@@ -108,6 +110,32 @@ class SettingsManager():
except:
pass
+ def _getRealValues(self, prefs):
+ """Get the actual values for any constant stored on a
+ general settings dictionary.
+ prefs is a dictionary with the userCustomizableSettings keys
+ and values."""
+ def getValueForKey(prefsDict, key):
+ value = None
+ if key in prefsDict:
+ if type(prefsDict[key]) is str:
+ if key == 'magZoomerLeft':
+ value = eval('settings.%s' % prefsDict[key])
+ elif key in need2repr:
+ value = "\'%s\'" % prefsDict[key]
+ else:
+ try:
+ value = getattr(settings, prefsDict[key])
+ except:
+ print "Something wrong with - ", key
+ else:
+ value = prefsDict[key]
+ return value
+
+ for key in prefs.keys():
+ prefs[key] = getValueForKey(prefs, key)
+ return prefs
+
def _getGeneral(self):
"""Get from the active backend the general settings for
the current profile"""
@@ -140,6 +168,7 @@ class SettingsManager():
def _mergeSettings():
"""Update the changed values on the profile settings
over the current and active settings"""
+ profileGeneral = self.getRealValues(self.profileGeneral)
self.general.update(self.profileGeneral)
self.pronunciations.update(self.profilePronunciation)
self.keybindings.update(self.profileKeybindings)
@@ -175,7 +204,7 @@ class SettingsManager():
as the profile's."""
self.profileGeneral = {}
for key, value in self.general.items():
- if value != self.defaultGeneral[key]:
+ if value != self.defaultGeneralValues[key]:
self.profileGeneral[key] = value
def _setProfilePronunciations(self):
@@ -199,9 +228,9 @@ class SettingsManager():
the profiles' ones."""
# The default settings should already exist but we save them anyway
# just in case the default settings have changed at orca.settings
- self._backend.saveDefaultSettings(self.general,
- self.pronunciations,
- self.keybindings)
+ self._backend.saveDefaultSettings(self.defaultGeneral,
+ self.defaultPronunciations,
+ self.defaultKeybindings)
self._setProfileGeneral()
self._setProfilePronunciations()
self._setProfileKeybindings()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]