[orca/new-settings] Some initial gconf_backend.py clean up
- From: Juanje Ojeda Croissier <jojeda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] Some initial gconf_backend.py clean up
- Date: Mon, 25 Oct 2010 09:38:18 +0000 (UTC)
commit 39632a63133a4cecf2c3102acf4c0b76b774a7f4
Author: Juanje Ojeda <jojeda emergya es>
Date: Mon Oct 25 11:36:23 2010 +0200
Some initial gconf_backend.py clean up
src/orca/backends/gconf_backend.py | 707 +++++-------------------------------
1 files changed, 95 insertions(+), 612 deletions(-)
---
diff --git a/src/orca/backends/gconf_backend.py b/src/orca/backends/gconf_backend.py
index 6ee97f1..b3f712e 100644
--- a/src/orca/backends/gconf_backend.py
+++ b/src/orca/backends/gconf_backend.py
@@ -39,42 +39,12 @@ import types
(ACTUAL, REPLACEMENT) = range(2)
-class GConfKeysDict(dict):
- VALID_KEY_TYPES = (bool, str, int, float, list, tuple)
-
- def __init__(self, *args, **kwargs):
- super(dict, self).__init__(*args, **kwargs)
-
- def __setitem__(self, key, val):
- if not type(val) in self.VALID_KEY_TYPES:
- print "Invalid type %s for gconf key: %s (val: %s)" % (type(val),
- key,
- str(val))
- raise TypeError
- else:
- dict.__setitem__(self, key, val)
-
-
-class OrcaPrefs():
+class Backend():
# set gconf configuration properties
GCONF_BASE_DIR = '/apps/gnome-orca'
VALID_KEY_TYPES = (bool, str, int, list, tuple)
- from orca import orca_prefs
-
- DEFAULTS = orca_prefs.readPreferences()
-
- need2repr = ['brailleEOLIndicator', 'brailleContractionTable',
- 'brailleRequiredStateString', 'enabledBrailledTextAttributes',
- 'enabledSpokenTextAttributes', 'magZoomerBorderColor',
- 'magCursorColor', 'magCrossHairColor', 'magTargetDisplay',
- 'magSourceDisplay', 'speechRequiredStateString',
- 'speechServerFactory', 'presentDateFormat',
- 'presentTimeFormat']
-
-
- def __init__(self, prefsDict=None, keyBindingsTreeModel=None,
- pronunciationTreeModel=None):
+ def __init__(self):
"""Creates a new OrcaPrefs instance that will be used to load/store
application specific preferences.
@@ -95,71 +65,83 @@ class OrcaPrefs():
gconf.CLIENT_PRELOAD_RECURSIVE)
self._notifications = []
- self.options = GConfKeysDict()
- self.options.update(self.DEFAULTS)
-
- # store dicts if needed
- self.prefsDict = prefsDict
- self.keyBindingsTreeModel = keyBindingsTreeModel
- self.pronunciationTreeModel = pronunciationTreeModel
-
- if prefsDict:
- self.options = self.prefsDict
+ self.general = {}
+ self.pronunciations = {}
+ self.keybindings = {}
+ self.profiles = {}
if not self._client.dir_exists(self.__app_key):
self.prefsDict = self.options
self.writePreferences()
- def _createDir(self, dirname):
- """Creates the given directory if it doesn't already exist.
- """
-
- try:
- os.chdir(dirname)
- except:
- os.mkdir(dirname)
-
- def gconf_load(self, path = None):
- casts = {gconf.VALUE_BOOL: gconf.Value.get_bool,
- gconf.VALUE_INT: gconf.Value.get_int,
- gconf.VALUE_FLOAT: gconf.Value.get_float,
- gconf.VALUE_STRING: gconf.Value.get_string,
- gconf.VALUE_LIST: gconf.Value.get_list}
-
- new_settings = False
+ def _checkProfile(self, profile=None):
+ if profile is None:
+ profile = ['Default', 'default']
+ activeProfilePath = '%s/activeProfile' % basePath
+ if not self._client.dir_exists(basePath):
+ self._client.set_list(activeProfilePath,
+ gconf.VALUE_STRING,
+ profile)
+ startingProfilePath = '%s/startingProfile' % basePath
+ self._client.set_list(startingProfilePath,
+ gconf.VALUE_STRING,
+ profile)
+ else:
+ profile = self._client.get_list(activeProfilePath,
+ gconf.VALUE_STRING)
+ profilePath = '%s/%s' % (basePath, profile[1])
+ if not self._client.dir_exists(profilePath):
+ self._client.add_dir(profilePath,
+ gconf.CLIENT_PRELOAD_RECURSIVE)
+ return profile
+
+ def _getGeneralPrefs(self, profilePath):
+ gconfEntries = client.all_entries(profilePath)
+ generalPrefs = {}
+ for entry in gconfEntries:
+ gconfPathKey = entry.get_key()
+ key = gconfPathKey.split('/')[-1]
+ value = entry.get_value()
+ if value.type == gconf.VALUE_STRING:
+ generalPrefs[key] = value.get_string()
+ elif value.type == gconf.VALUE_INT:
+ generalPrefs[key] = value.get_int()
+ elif value.type == gconf.VALUE_FLOAT:
+ generalPrefs[key] = value.get_float()
+ elif value.type == gconf.VALUE_BOOL:
+ generalPrefs[key] = value.get_bool()
+ elif value.type == gconf.VALUE_LIST:
+ values = [item.get_string() for item in value.get_list()]
+ generalPrefs[key] = values
+ else:
+ generalPrefs[key] = None
+ return generalPrefs
+
+ def _getVoicesPrefs(self, voicesPath):
+ from orca.acss import ACSS
+ gconfEntries = self._client.all_entries(voicesPath)
+ voicesPrefs = {}
+ for entry in gconfEntries:
+ gconfPathKey = entry.get_key()
+ key = gconfPathKey.split('/')[-1]
+ key = getattr(settings, key)
+ value = entry.get_value()
+ _value = value.get_string()
+ voicesPrefs[key] = eval(_value)
+ return voicesPrefs
+
+ def _getSettings(self):
+ if profile is None:
+ profile = self.checkProfile()
+ profilePath = '%s/%s' % (basePath, profile[1])
+ voicesPath = '%s/voices' % profilePath
+ generalPrefs = self._getGeneralPrefs(profilePath)
+ voicesPrefs = self._getVoicesPrefs(voicesPath)
+ prefsDict = generalPrefs
+ prefsDict['voices'] = voicesPrefs
+ return prefsDict
- if path:
- self.__app_key = path
- for entry in self._client.all_entries(self.__app_key):
- gval = self._client.get(entry.key)
- if gval == None: continue
-
- if gval.type == gconf.VALUE_LIST:
- string_list = [item.get_string() for item in gval.get_list()]
- if path:
- dictString = ''
- dictString = self.__format_gconf_dir(path, entry)
- dictString += ' = %s ' % string_list
- exec(dictString)
- else:
- self.options[entry.key.split('/')[-1]] = string_list
- else:
- if path:
- dictString = ''
- dictString = self.__format_gconf_dir(path, entry)
- dictString += ' = %s ' % repr(casts[gval.type](gval))
- exec(dictString)
- else:
- self.options[entry.key.split('/')[-1]] = casts[gval.type](gval)
-
- for path in self._client.all_dirs(self.__app_key):
- self.gconf_load(path)
- self.__app_key = \
- self.__app_key.split(reversed(self.__app_key.split('/')).next())[0][:-1]
-
- if not new_settings:
- return True
def __format_gconf_dir(self, path, entry):
formatDir = path.split('/')
@@ -226,450 +208,6 @@ class OrcaPrefs():
return not alreadyEnabled
- def _getDisplayString(self, display):
- """Returns a string that represents the source or target
- magnifier display.
-
- Arguments:
- - display: the magnifier source or taget display string.
-
- Returns a string suitable for the preferences file.
- """
-
- if not display:
- return "''"
- else:
- return "'%s'" % display
-
- def _getSpeechServerFactoryString(self, factory):
- """Returns a string that represents the speech server factory passed in.
-
- Arguments:
- - factory: the speech server factory
-
- Returns a string suitable for the preferences file.
- """
-
- if not factory:
- return None
- elif isinstance(factory, basestring):
- return "'%s'" % factory
- else:
- return "'%s'" % factory.__name__
-
- def _getSpeechServerString(self, server):
- """Returns a string that represents the speech server passed in.
-
- Arguments:
- - server: a speech server
-
- Returns a string suitable for the preferences file.
- """
- if not server:
- return None
- elif isinstance(server, [].__class__):
- return repr(server)
- else:
- return repr(server.getInfo())
-
- def _getVoicesString(self, voices):
- """Returns a string that represents the list of voices passed in.
-
- Arguments:
- - voices: a list of ACSS instances.
-
- Returns a string suitable for the preferences file.
- """
- import pprint
-
- voicesStr = "{\n"
- for voice in voices:
- voicesStr += "'%s' : orca.acss.ACSS(" % voice
- voicesStr += pprint.pformat(voices[voice]) + "),\n"
- voicesStr += "}"
-
- return voicesStr
-
- def _getKeyboardLayoutString(self, keyboardLayout):
- """Returns a string that represents the keyboard layout passed in."""
-
- if keyboardLayout == settings.GENERAL_KEYBOARD_LAYOUT_LAPTOP:
- return "orca.settings.GENERAL_KEYBOARD_LAYOUT_LAPTOP"
- else:
- return "orca.settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP"
-
- def _getOrcaModifierKeysString(self, orcaModifierKeys):
- """Returns a string that represents the Orca modifier keys passed in."""
-
- return "%s" % orcaModifierKeys
-
- def _getSpokenTextAttributesString(self, enabledSpokenTextAttributes):
- """ Returns a string that represents the enabled spoken text attributes
- passed in.
- """
-
- return "\"" + enabledSpokenTextAttributes + "\""
-
- def _getBrailledTextAttributesString(self, enabledBrailledTextAttributes):
- """ Returns a string that represents the enabled brailled text
- attributes passed in.
- """
-
- return "\"" + enabledBrailledTextAttributes + "\""
-
- def _getTextAttributesBrailleIndicatorString(self, brailleIndicator):
- """Returns a string that represents the text attribute braille indicator
- value passed in."""
-
- if brailleIndicator == settings.TEXT_ATTR_BRAILLE_NONE:
- return "orca.settings.TEXT_ATTR_BRAILLE_NONE"
- elif brailleIndicator == settings.TEXT_ATTR_BRAILLE_7:
- return "orca.settings.TEXT_ATTR_BRAILLE_7"
- elif brailleIndicator == settings.TEXT_ATTR_BRAILLE_8:
- return "orca.settings.TEXT_ATTR_BRAILLE_8"
- elif brailleIndicator == settings.TEXT_ATTR_BRAILLE_BOTH:
- return "orca.settings.TEXT_ATTR_BRAILLE_BOTH"
- else:
- return "orca.settings.TEXT_ATTR_BRAILLE_NONE"
-
- def _getBrailleSelectionIndicatorString(self, selectionIndicator):
- """Returns a string that represents the braille selection indicator
- value passed in."""
-
- if selectionIndicator == settings.BRAILLE_SEL_NONE:
- return "orca.settings.BRAILLE_SEL_NONE"
- elif selectionIndicator == settings.BRAILLE_SEL_7:
- return "orca.settings.BRAILLE_SEL_7"
- elif selectionIndicator == settings.BRAILLE_SEL_8:
- return "orca.settings.BRAILLE_SEL_8"
- elif selectionIndicator == settings.BRAILLE_SEL_BOTH:
- return "orca.settings.BRAILLE_SEL_BOTH"
- else:
- return "orca.settings.BRAILLE_SEL_BOTH"
-
- def _getBrailleLinkIndicatorString(self, linkIndicator):
- """Returns a string that represents the braille link indicator
- value passed in."""
-
- if linkIndicator == settings.BRAILLE_LINK_NONE:
- return "orca.settings.BRAILLE_LINK_NONE"
- elif linkIndicator == settings.BRAILLE_LINK_7:
- return "orca.settings.BRAILLE_LINK_7"
- elif linkIndicator == settings.BRAILLE_LINK_8:
- return "orca.settings.BRAILLE_LINK_8"
- elif linkIndicator == settings.BRAILLE_LINK_BOTH:
- return "orca.settings.BRAILLE_LINK_BOTH"
- else:
- return "orca.settings.BRAILLE_LINK_BOTH"
-
- def _getVerbosityString(self, verbosityLevel):
- """Returns a string that represents the verbosity level passed in."""
-
- if verbosityLevel == settings.VERBOSITY_LEVEL_BRIEF:
- return "orca.settings.VERBOSITY_LEVEL_BRIEF"
- elif verbosityLevel == settings.VERBOSITY_LEVEL_VERBOSE:
- return "orca.settings.VERBOSITY_LEVEL_VERBOSE"
- else:
- return "orca.settings.VERBOSITY_LEVEL_VERBOSE"
-
- def _getBrailleRolenameStyleString(self, rolenameStyle):
- """Returns a string that represents the rolename style passed in."""
-
- if rolenameStyle == settings.BRAILLE_ROLENAME_STYLE_SHORT:
- return "orca.settings.BRAILLE_ROLENAME_STYLE_SHORT"
- elif rolenameStyle == settings.BRAILLE_ROLENAME_STYLE_LONG:
- return "orca.settings.BRAILLE_ROLENAME_STYLE_LONG"
- else:
- return "orca.settings.BRAILLE_ROLENAME_STYLE_LONG"
-
- def _getBrailleAlignmentStyleString(self, brailleAlignmentStyle):
- """Returns a string that represents the brailleAlignmentStyle
- passed in."""
-
- if brailleAlignmentStyle == settings.ALIGN_BRAILLE_BY_WORD:
- return "orca.settings.ALIGN_BRAILLE_BY_WORD"
- if brailleAlignmentStyle == settings.ALIGN_BRAILLE_BY_MARGIN:
- return "orca.settings.ALIGN_BRAILLE_BY_MARGIN"
- else:
- return "orca.settings.ALIGN_BRAILLE_BY_EDGE"
-
- def _getVerbalizePunctuationStyleString(self, punctuationStyle):
- """Returns a string that represents the punctuation style passed in."""
-
- if punctuationStyle == settings.PUNCTUATION_STYLE_NONE:
- return "orca.settings.PUNCTUATION_STYLE_NONE"
- elif punctuationStyle == settings.PUNCTUATION_STYLE_SOME:
- return "orca.settings.PUNCTUATION_STYLE_SOME"
- elif punctuationStyle == settings.PUNCTUATION_STYLE_MOST:
- return "orca.settings.PUNCTUATION_STYLE_MOST"
- elif punctuationStyle == settings.PUNCTUATION_STYLE_ALL:
- return "orca.settings.PUNCTUATION_STYLE_ALL"
- else:
- return "orca.settings.PUNCTUATION_STYLE_MOST"
-
- def _getPresentTimeString(self, val):
- if val == settings.TIME_FORMAT_24_HMS:
- return "orca.settings.TIME_FORMAT_24_HMS"
- elif val == settings.TIME_FORMAT_24_HMS_WITH_WORDS:
- return "orca.settings.TIME_FORMAT_24_HMS_WITH_WORDS"
- elif val == settings.TIME_FORMAT_24_HM:
- return "orca.settings.TIME_FORMAT_24_HM"
- elif val == settings.TIME_FORMAT_24_HM_WITH_WORDS:
- return "orca.settings.TIME_FORMAT_24_HM_WITH_WORDS"
- else:
- return "orca.settings.TIME_FORMAT_LOCALE"
-
- def _getPresentDateString(self, val):
- if val == settings.DATE_FORMAT_NUMBERS_DM:
- return "orca.settings.DATE_FORMAT_NUMBERS_DM"
- elif val == settings.DATE_FORMAT_NUMBERS_MD:
- return "orca.settings.DATE_FORMAT_NUMBERS_MD"
- elif val == settings.DATE_FORMAT_NUMBERS_DMY:
- return "orca.settings.DATE_FORMAT_NUMBERS_DMY"
- elif val == settings.DATE_FORMAT_NUMBERS_MDY:
- return "orca.settings.DATE_FORMAT_NUMBERS_MDY"
- elif val == settings.DATE_FORMAT_NUMBERS_YMD:
- return "orca.settings.DATE_FORMAT_NUMBERS_YMD"
- elif val == settings.DATE_FORMAT_FULL_DM:
- return "orca.settings.DATE_FORMAT_FULL_DM"
- elif val == settings.DATE_FORMAT_FULL_MD:
- return "orca.settings.DATE_FORMAT_FULL_MD"
- elif val == settings.DATE_FORMAT_FULL_DMY:
- return "orca.settings.DATE_FORMAT_FULL_DMY"
- elif val == settings.DATE_FORMAT_FULL_MDY:
- return "orca.settings.DATE_FORMAT_FULL_MDY"
- elif val == settings.DATE_FORMAT_FULL_YMD:
- return "orca.settings.DATE_FORMAT_FULL_YMD"
- elif val == settings.DATE_FORMAT_ABBREVIATED_DM:
- return "orca.settings.DATE_FORMAT_ABBREVIATED_DM"
- elif val == settings.DATE_FORMAT_ABBREVIATED_MD:
- return "orca.settings.DATE_FORMAT_ABBREVIATED_MD"
- elif val == settings.DATE_FORMAT_ABBREVIATED_DMY:
- return "orca.settings.DATE_FORMAT_ABBREVIATED_DMY"
- elif val == settings.DATE_FORMAT_ABBREVIATED_MDY:
- return "orca.settings.DATE_FORMAT_ABBREVIATED_MDY"
- elif val == settings.DATE_FORMAT_ABBREVIATED_YMD:
- return "orca.settings.DATE_FORMAT_ABBREVIATED_YMD"
- else:
- return "orca.settings.DATE_FORMAT_LOCALE"
-
- def _getSayAllStyleString(self, sayAllStyle):
- """Returns a string that represents the say all style passed in."""
-
- if sayAllStyle == settings.SAYALL_STYLE_LINE:
- return "orca.settings.SAYALL_STYLE_LINE"
- elif sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
- return "orca.settings.SAYALL_STYLE_SENTENCE"
-
- def _getMagColorString(self, cursorColor):
- """Returns a string that represents the magnification object's color
- passed in.
-
- Arguments:
- - cursorColor: magnification object's color
-
- Returns a string suitable for the preferences file.
- """
-
- cursorColorStr = "'%s'" % cursorColor
-
- return cursorColorStr
-
- def _getMagSmoothingModeString(self, smoothingMode):
- """Returns a string that represents the magnification smoothing mode
- passed in.
-
- Arguments:
- - smoothingMode: magnification smoothing mode.
-
- Returns a string suitable for the preferences file.
- """
-
- if smoothingMode == settings.MAG_SMOOTHING_MODE_BILINEAR:
- return "orca.settings.MAG_SMOOTHING_MODE_BILINEAR"
- elif smoothingMode == settings.MAG_SMOOTHING_MODE_NONE:
- return "orca.settings.MAG_SMOOTHING_MODE_NONE"
- else:
- return "orca.settings.MAG_SMOOTHING_MODE_BILINEAR"
-
- def _getMagMouseTrackingModeString(self, mouseTrackingMode):
- """Returns a string that represents the magnification mouse tracking
- mode passed in.
-
- Arguments:
- - mouseTrackingMode: magnification mouse tracking mode.
-
- Returns a string suitable for the preferences file.
- """
-
- if mouseTrackingMode == settings.MAG_TRACKING_MODE_CENTERED:
- return "orca.settings.MAG_TRACKING_MODE_CENTERED"
- elif mouseTrackingMode == settings.MAG_TRACKING_MODE_NONE:
- return "orca.settings.MAG_TRACKING_MODE_NONE"
- elif mouseTrackingMode == settings.MAG_TRACKING_MODE_PROPORTIONAL:
- return "orca.settings.MAG_TRACKING_MODE_PROPORTIONAL"
- elif mouseTrackingMode == settings.MAG_TRACKING_MODE_PUSH:
- return "orca.settings.MAG_TRACKING_MODE_PUSH"
- else:
- return "orca.settings.MAG_TRACKING_MODE_CENTERED"
-
- def _getMagControlTrackingModeString(self, controlTrackingMode):
- """Returns a string that represents the magnification control
- and menu item tracking mode passed in.
-
- Arguments:
- - controlTrackingMode: magnification control and menu item tracking
- mode.
-
- Returns a string suitable for the preferences file.
- """
-
- if controlTrackingMode == settings.MAG_TRACKING_MODE_CENTERED:
- return "orca.settings.MAG_TRACKING_MODE_CENTERED"
- elif controlTrackingMode == settings.MAG_TRACKING_MODE_NONE:
- return "orca.settings.MAG_TRACKING_MODE_NONE"
- elif controlTrackingMode == settings.MAG_TRACKING_MODE_PUSH:
- return "orca.settings.MAG_TRACKING_MODE_PUSH"
- else:
- return "orca.settings.MAG_TRACKING_MODE_PUSH"
-
- def _getMagTextTrackingModeString(self, textTrackingMode):
- """Returns a string that represents the magnification text cursor
- tracking mode passed in.
-
- Arguments:
- - textTrackingMode: magnification text cursor tracking mode.
-
- Returns a string suitable for the preferences file.
- """
-
- if textTrackingMode == settings.MAG_TRACKING_MODE_CENTERED:
- return "orca.settings.MAG_TRACKING_MODE_CENTERED"
- elif textTrackingMode == settings.MAG_TRACKING_MODE_NONE:
- return "orca.settings.MAG_TRACKING_MODE_NONE"
- elif textTrackingMode == settings.MAG_TRACKING_MODE_PUSH:
- return "orca.settings.MAG_TRACKING_MODE_PUSH"
- else:
- return "orca.settings.MAG_TRACKING_MODE_PUSH"
-
- def _getMagColorFilteringModeString(self, mode):
- """Returns a string that represents the magnification color filtering
- mode passed in.
-
- Arguments:
- - mode: magnification color filtering mode.
-
- Returns a string suitable for the preferences file.
- """
-
- if mode == settings.MAG_COLOR_FILTERING_MODE_NONE:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_NONE"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_SATURATE_RED:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_SATURATE_RED"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_SATURATE_GREEN:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_SATURATE_GREEN"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_SATURATE_BLUE:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_SATURATE_BLUE"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_DESATURATE_RED:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_DESATURATE_RED"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_DESATURATE_GREEN:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_DESATURATE_GREEN"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_DESATURATE_BLUE:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_DESATURATE_BLUE"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_POSITIVE_HUE_SHIFT:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_POSITIVE_HUE_SHIFT"
- elif mode == settings.MAG_COLOR_FILTERING_MODE_NEGATIVE_HUE_SHIFT:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_NEGATIVE_HUE_SHIFT"
- else:
- return "orca.settings.MAG_COLOR_FILTERING_MODE_NONE"
-
- def _getMagZoomerTypeString(self, magZoomerType):
- """Returns a string that represents the magnification zoomer position
- type passed in.
-
- Arguments:
- - magZoomerType: magnification zoomer position type.
-
- Returns a string suitable for the preferences file.
- """
-
- if magZoomerType == settings.MAG_ZOOMER_TYPE_FULL_SCREEN:
- return "orca.settings.MAG_ZOOMER_TYPE_FULL_SCREEN"
- elif magZoomerType == settings.MAG_ZOOMER_TYPE_TOP_HALF:
- return "orca.settings.MAG_ZOOMER_TYPE_TOP_HALF"
- elif magZoomerType == settings.MAG_ZOOMER_TYPE_BOTTOM_HALF:
- return "orca.settings.MAG_ZOOMER_TYPE_BOTTOM_HALF"
- elif magZoomerType == settings.MAG_ZOOMER_TYPE_LEFT_HALF:
- return "orca.settings.MAG_ZOOMER_TYPE_LEFT_HALF"
- elif magZoomerType == settings.MAG_ZOOMER_TYPE_RIGHT_HALF:
- return "orca.settings.MAG_ZOOMER_TYPE_RIGHT_HALF"
- elif magZoomerType == settings.MAG_ZOOMER_TYPE_CUSTOM:
- return "orca.settings.MAG_ZOOMER_TYPE_CUSTOM"
- else:
- return "orca.settings.MAG_ZOOMER_TYPE_FULL_SCREEN"
-
- def _getProgressBarVerbosityString(self, verbosityLevel):
- """Returns a string that represents the progress bar verbosity level
- passed in.
-
- Arguments:
- - verbosityLevel: verbosity level for progress bars.
-
- Returns a string suitable for the preferences file.
- """
-
- if verbosityLevel == settings.PROGRESS_BAR_ALL:
- return "orca.settings.PROGRESS_BAR_ALL"
- elif verbosityLevel == settings.PROGRESS_BAR_WINDOW:
- return "orca.settings.PROGRESS_BAR_WINDOW"
- else:
- return "orca.settings.PROGRESS_BAR_APPLICATION"
-
- def _setupPreferencesDirs(self):
- """Creates the directories and standard files to hold user
- preferences."""
-
- # Set up the user's preferences directory (~/.orca by default).
- #
- orcaDir = settings.userPrefsDir
- self._createDir(orcaDir)
-
- # Set up ~/.orca/orca-scripts as a Python package
- #
- orcaScriptDir = os.path.join(orcaDir, "orca-scripts")
- self._createDir(orcaScriptDir)
- initFile = os.path.join(orcaScriptDir, "__init__.py")
- if not os.path.exists(initFile):
- os.close(os.open(initFile, os.O_CREAT, 0700))
-
- # Set up ~/.orca/app-settings as a Python package.
- #
- orcaSettingsDir = os.path.join(orcaDir, "app-settings")
- self._createDir(orcaSettingsDir)
- initFile = os.path.join(orcaSettingsDir, "__init__.py")
- if not os.path.exists(initFile):
- os.close(os.open(initFile, os.O_CREAT, 0700))
-
-
- def _getValueForKey(self, prefsDict, key):
- """Return the value associated with this preferences dictionary key
-
- Arguments:
- - prefsDict: a dictionary where the keys are orca preferences
- names and the values are the values for the preferences.
- - key: the preferences dictionary key.
-
- Return the value of the given preferences dictionary key.
- """
-
- value = None
- if key in prefsDict:
- if key is 'magCursorColor':
- value = self._getMagColorString(prefsDict[key])
- else:
- return prefsDict[key]
- return value
-
def writePreferences(self):
"""Creates the gconf schema and files to hold user preferences. Note
that callers of this method may want to consider using an ordered
@@ -864,85 +402,30 @@ class OrcaPrefs():
else:
return "'%s'" % new_value
+ def availableProfiles(self):
+ """Returns a list of available profiles
+ It will be a list of strings list like this:
+ ['Label', 'name']
+ """
-def readPreferences():
- """Returns a dictionary containing the names and values of the
- customizable features of Orca."""
-
- prefsDict = {}
- for key in settings.userCustomizableSettings:
- try:
- prefsDict[key] = getattr(settings, key)
- except:
- pass
-
- 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
-
-def writePreferences(prefsDict, keyBindingsTreeModel=None,
- pronunciationTreeModel=None):
- """Creates the directory and files to hold application specific
- user preferences. Write out any preferences that are different
- from the generic Orca preferences for this user. Note that callers
- of this method may want to consider using an ordered dictionary so
- that the keys are output in a deterministic order.
-
- Arguments:
- - prefsDict: a dictionary where the keys are orca preferences
- names and the values are the values for the preferences.
- - keyBindingsTreeModel - key bindings tree model, or None if we are
- writing out console preferences.
- - pronunciationTreeModel - pronunciation dictionary tree model, or
- None if we are writing out console preferences.
-
- Returns True if the user needs to log out for accessibility settings
- to take effect.
- """
-
- orcaPrefs = OrcaPrefs(prefsDict,
- keyBindingsTreeModel,
- pronunciationTreeModel)
- return orcaPrefs.writePreferences()
-
-def loadSettings():
- """Load settings"""
-
- orcaPrefs = OrcaPrefs()
- print '\n## loaded from gconf_backend!!'
+ profilesKeys = self._client.all_dirs(self.GCONF_BASE_DIR)
+ profiles = []
+ for profileKey in profilesKeys:
+ name = profileKey.split('/')[-1]
+ key = path + '/%s/profile' % name
+ profile = self._client.get_list(key, gconf.VALUE_STRING)
+ profiles.append(profile)
- return orcaPrefs.loadSettings()
+ return profiles
-def availableProfiles():
- """Returns a list of available profiles
- It will be a list of strings list like this:
- ['Label', 'name']
- """
+ def isFirstStart(self):
+ """Check if the firstStart key is True or false"""
+ firstStartPath = self.GCONF_BASE_DIR + '/firstStart'
+ return self._client.get_bool(firstStartPath)
- client = gconf.client_get_default()
- path = '/apps/gnome-orca'
- profilesKeys = client.all_dirs(path)
- profiles = []
- for profileKey in profilesKeys:
- name = profileKey.split('/')[-1]
- key = path + '/%s/profile' % name
- profile = client.get_list(key, gconf.VALUE_STRING)
- profiles.append(profile)
-
- return profiles
-
-def isFirstStart():
- """Check if the firstStart key is True or false"""
- client = gconf.client_get_default()
- return client.get_bool('/apps/gnome-orca/firstStart')
-
-def setFirstStart():
- """Set firstStart key to false
- This means the profile is being stored and it isn't a first start
- anymore."""
- client = gconf.client_get_default()
- client.set_bool('/apps/gnome-orca/firstStart', False)
+ def setFirstStart(self):
+ """Set firstStart key to false
+ This means the profile is being stored and it isn't a first start
+ anymore."""
+ firstStartPath = self.GCONF_BASE_DIR + '/firstStart'
+ client.set_bool(firstStartPath, False)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]