[orca/new-settings] Moved out some methods as functions, added new functions for getting real values and changed back so
- From: Juanje Ojeda Croissier <jojeda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] Moved out some methods as functions, added new functions for getting real values and changed back so
- Date: Tue, 26 Oct 2010 18:14:51 +0000 (UTC)
commit 7e8c66e71a35047f8edc1c671fc6c16b3190adbe
Author: Juanje Ojeda <jojeda emergya es>
Date: Tue Oct 26 19:49:35 2010 +0200
Moved out some methods as functions, added new functions for getting real values and changed back some settings.[] as non strings. Still testing the voices and how Orca get the settings from the settings manager.
src/orca/settings.py | 31 +++++++------
src/orca/settings_manager.py | 104 +++++++++++++++++++++++------------------
2 files changed, 75 insertions(+), 60 deletions(-)
---
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 0dea4e2..a96380f 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -327,7 +327,7 @@ PUNCTUATION_STYLE_NONE = 3
PUNCTUATION_STYLE_SOME = 2
PUNCTUATION_STYLE_MOST = 1
PUNCTUATION_STYLE_ALL = 0
-verbalizePunctuationStyle = 'PUNCTUATION_STYLE_MOST'
+verbalizePunctuationStyle = PUNCTUATION_STYLE_MOST
# Say All styles (see sayAllStyle).
#
@@ -392,21 +392,24 @@ speechFactoryModules = ["gnomespeechfactory",
speechServerFactory = "speechdispatcherfactory"
speechServerInfo = None # None means let the factory decide.
-# FIXME: Check against GConf backend.
-#DEFAULT_VOICE = "default"
-DEFAULT_VOICE = "DEFAULT_VOICE"
-#UPPERCASE_VOICE = "uppercase"
-UPPERCASE_VOICE = "UPPERCASE_VOICE"
-#HYPERLINK_VOICE = "hyperlink"
-HYPERLINK_VOICE = "HYPERLINK_VOICE"
-#SYSTEM_VOICE = "system"
-SYSTEM_VOICE = "SYSTEM_VOICE"
+DEFAULT_VOICE = "default"
+UPPERCASE_VOICE = "uppercase"
+HYPERLINK_VOICE = "hyperlink"
+SYSTEM_VOICE = "system"
+
+voicesKeys = {
+"DEFAULT_VOICE" : "default",
+"UPPERCASE_VOICE" : "uppercase",
+"HYPERLINK_VOICE" : "hyperlink",
+"SYSTEM_VOICE" : "system"
+}
+
voices = {
- 'DEFAULT_VOICE' : ACSS({}),
- 'UPPERCASE_VOICE' : ACSS({ACSS.AVERAGE_PITCH : 5.6}),
- 'HYPERLINK_VOICE' : ACSS({}),
- 'SYSTEM_VOICE' : ACSS({}),
+ DEFAULT_VOICE : ACSS({}),
+ UPPERCASE_VOICE : ACSS({ACSS.AVERAGE_PITCH : 5.6}),
+ HYPERLINK_VOICE : ACSS({}),
+ SYSTEM_VOICE : ACSS({}),
}
# If True, enable speaking of speech indentation and justification.
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index cbe4996..0a964b9 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -87,7 +87,7 @@ class SettingsManager():
self._setDefaultGeneral()
self._setDefaultPronunciations()
self._setDefaultKeybindings()
- self.defaultGeneralValues = self._getRealValues(self.defaultGeneral)
+ self.defaultGeneralValues = getRealValues(self.defaultGeneral)
self.general = self.defaultGeneralValues
self.pronunciations = self.defaultPronunciations
self.keybindings = self.defaultKeybindings
@@ -165,40 +165,6 @@ 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."""
- need2repr = ['brailleEOLIndicator', 'brailleContractionTable',
- 'brailleRequiredStateString', 'enabledBrailledTextAttributes',
- 'enabledSpokenTextAttributes', 'magZoomerBorderColor',
- 'magCursorColor', 'magCrossHairColor', 'magTargetDisplay',
- 'magSourceDisplay', 'speechRequiredStateString',
- 'speechServerFactory', 'presentDateFormat',
- 'presentTimeFormat']
-
- 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, profile=None):
"""Get from the active backend the general settings for
the current profile"""
@@ -234,7 +200,7 @@ class SettingsManager():
def _mergeSettings(self):
"""Update the changed values on the profile settings
over the current and active settings"""
- profileGeneral = self._getRealValues(self.profileGeneral) or {}
+ profileGeneral = getRealValues(self.profileGeneral) or {}
self.general.update(profileGeneral)
self.pronunciations.update(self.profilePronunciations)
self.keybindings.update(self.profileKeybindings)
@@ -285,32 +251,32 @@ class SettingsManager():
with the profiles' ones"""
return self._backend.getKeybindings(profile)
- def _setProfileGeneral(self):
+ def _setProfileGeneral(self, general):
"""Set the changed general settings from the defaults' ones
as the profile's."""
self.profileGeneral = {}
- for key, value in self.general.items():
+ for key, value in general.items():
if key != 'profile' and \
value != self.defaultGeneralValues[key]:
self.profileGeneral[key] = value
- def _setProfilePronunciations(self):
+ def _setProfilePronunciations(self, pronunciations):
"""Set the changed pronunciations settings from the defaults' ones
as the profile's."""
self.profilePronunciations = {}
- for key, value in self.pronunciations.items():
+ for key, value in pronunciations.items():
if value != self.defaultPronunciations[key]:
self.profilePronunciations[key] = value
- def _setProfileKeybindings(self):
+ def _setProfileKeybindings(self, keybindings):
"""Set the changed keybindings settings from the defaults' ones
as the profile's."""
self.profileKeybindings = {}
- for key, value in self.keybindings.items():
+ for key, value in keybindings.items():
if value != self.defaultKeybindings[key]:
self.profileKeybindings[key] = value
- def saveSettings(self):
+ def saveSettings(self, general, pronunciations, keybindings):
"""Let the active backend to store the default settings and
the profiles' ones."""
# The default settings should already exist but we save them anyway
@@ -318,9 +284,9 @@ class SettingsManager():
self._backend.saveDefaultSettings(self.defaultGeneral,
self.defaultPronunciations,
self.defaultKeybindings)
- self._setProfileGeneral()
- self._setProfilePronunciations()
- self._setProfileKeybindings()
+ self._setProfileGeneral(general)
+ self._setProfilePronunciations(pronunciations)
+ self._setProfileKeybindings(keybindings)
self._backend.saveProfileSettings(self.profile,
self.profileGeneral,
self.profilePronunciations,
@@ -353,3 +319,49 @@ class SettingsManager():
return self._backend.availableProfiles()
+
+def getVoiceKey(voice):
+ voicesKeys = getattr(settings, 'voicesKeys')
+ for key in voicesKeys.keys():
+ if voicesKeys[key] == voice:
+ return key
+ return ""
+
+def getValueForKey(prefsDict, key):
+ need2repr = ['brailleEOLIndicator', 'brailleContractionTable',
+ 'brailleRequiredStateString', 'enabledBrailledTextAttributes',
+ 'enabledSpokenTextAttributes', 'magZoomerBorderColor',
+ 'magCursorColor', 'magCrossHairColor', 'magTargetDisplay',
+ 'magSourceDisplay', 'speechRequiredStateString',
+ 'speechServerFactory', 'presentDateFormat',
+ 'presentTimeFormat']
+
+ 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]
+ elif key == 'voices':
+ key = getVoiceKey(key)
+ value = prefsDict[key]
+ else:
+ try:
+ value = getattr(settings, prefsDict[key])
+ except:
+ print "Something wrong with - ", key
+ else:
+ value = prefsDict[key]
+ return value
+
+def getRealValues(prefs):
+ """Get the actual values for any constant stored on a
+ general settings dictionary.
+ prefs is a dictionary with the userCustomizableSettings keys
+ and values."""
+ for key in prefs.keys():
+ prefs[key] = getValueForKey(prefs, key)
+ from pprint import pprint
+ pprint(prefs)
+ return prefs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]