Esempio n. 1
0
def enableA11y(enable=True):
    """
    Enables accessibility via DConf.
    """
    from gi.repository.Gio import Settings
    InterfaceSettings = Settings(a11yDConfKey)
    InterfaceSettings.set_boolean('toolkit-accessibility', enable)
Esempio n. 2
0
def enableA11y(enable=True):
    """
    Enables accessibility via DConf.
    """
    from gi.repository.Gio import Settings
    InterfaceSettings = Settings(schema=a11yDConfKey)
    InterfaceSettings.set_boolean('toolkit-accessibility', enable)
class Zoomer:
    def __init__(self):
        self.incr = 0.1
        self._refreshSettings()

    def _refreshSettings(self):
        self.a11yAppPrefs = Settings('org.gnome.desktop.a11y.applications')
        self.magPrefs = Settings('org.gnome.desktop.a11y.magnifier')

    def zoomIn(self):
      mag_factor = self.magPrefs.get_double('mag-factor')
      self.magPrefs.set_double('mag-factor', mag_factor + self.incr)
      self.zoomOn()

    def zoomOut(self):
      mag_factor = self.magPrefs.get_double('mag-factor')
      self.magPrefs.set_double('mag-factor', mag_factor - self.incr)
      self.zoomOn()

    def zoomOff(self):
        self.a11yAppPrefs.set_boolean('screen-magnifier-enabled', False)

    def zoomOn(self):
        self.a11yAppPrefs.set_boolean('screen-magnifier-enabled', True)

    def isActive(self):
        return self.a11yAppPrefs.get_boolean('screen-magnifier-enabled')
Esempio n. 4
0
 def setSingleMode(self, single):
   '''
   Toggle single mode on or off.
   
   @param single: True if we want single mode.
   @type single: boolean
   '''
   if isinstance(self._view_model, SingleViewModel) == single:
     return
   gsettings = GSettings(schema=PLUGVIEWS_GSCHEMA)
   gsettings.set_boolean('layout-single', single)
   plugins = self._view_model.getViewedPlugins()
   self._view_model.close()
   del self._view_model
   for plugin in plugins:
     if plugin.get_parent():
       plugin.get_parent().remove(plugin)
   self._initViewModel(single)
   for plugin in plugins:
     self._view_model.addElement(plugin)
Esempio n. 5
0
 def setSingleMode(self, single):
     '''
 Toggle single mode on or off.
 
 @param single: True if we want single mode.
 @type single: boolean
 '''
     if isinstance(self._view_model, SingleViewModel) == single:
         return
     gsettings = GSettings(schema=PLUGVIEWS_GSCHEMA)
     gsettings.set_boolean('layout-single', single)
     plugins = self._view_model.getViewedPlugins()
     self._view_model.close()
     del self._view_model
     for plugin in plugins:
         if plugin.get_parent():
             plugin.get_parent().remove(plugin)
     self._initViewModel(single)
     for plugin in plugins:
         self._view_model.addElement(plugin)
    def _saveVoiceSettings(self, voiceSettings, profile, app=None):
        setEstablished = False

        if app is not None and app != '':
            appSpecific = True
        else:
            appSpecific = False

        for voice in ['default', 'uppercase', 'hyperlink', 'system']:
            if appSpecific == True:
                voiceGSettings = Settings(
                    schema_id='org.gnome.orca.voice',
                    path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' %
                    (profile, app, voice))
                voiceFamilyGSettings = Settings(
                    schema_id='org.gnome.orca.voice.family',
                    path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' %
                    (profile, app, voice))
            else:
                voiceGSettings = Settings(
                    schema_id='org.gnome.orca.voice',
                    path='/org/gnome/orca/profile/%s/voice/%s/' %
                    (profile, voice))
                voiceFamilyGSettings = Settings(
                    schema_id='org.gnome.orca.voice.family',
                    path='/org/gnome/orca/profile/%s/voice/%s/' %
                    (profile, voice))

            if voiceSettings.__contains__(voice):
                if voiceSettings[voice].get('established') is None:
                    for setting in ['average-pitch', 'gain', 'rate']:
                        if voiceSettings[voice].get(setting) is not None:
                            if appSpecific == True:
                                voiceGSettings.set_double(
                                    setting, voiceSettings[voice].get(setting))
                            else:
                                if voiceSettings[voice].get(
                                        setting) is not self.voiceDefaults[
                                            voice].get(setting):
                                    voiceGSettings.set_double(
                                        setting,
                                        voiceSettings[voice].get(setting))
                                    setEstablished = True

                    if appSpecific == True:
                        voiceGSettings.set_boolean('established', True)
                    elif appSpecific == False and setEstablished == True:
                        voiceGSettings.set_boolean('established', True)

                    if voiceSettings[voice].__contains__('family'):
                        for setting in ['name', 'locale', 'dialect']:
                            voiceFamilyGSettings.set_string(
                                setting,
                                voiceSettings[voice]['family'].get(setting))
                        voiceFamilyGSettings.set_boolean('family-set', True)
Esempio n. 7
0
class Backend:
    def __init__(self, prefsDir):
        self.baseSettings = Settings(schema_id='org.gnome.orca',
                                     path='/org/gnome/orca/')
        self.voiceDefaults = {}

    def saveDefaultSettings(self, general, pronunciations, keybindings):
        # GSettings stores the defaults, no need to do anything here, except
        # for voice defaults, as the defaults can vary between speech
        # backends.
        if general.__contains__('voices'):
            self.voiceDefaults = general['voices']

    def getAppSettings(self, appName):
        prefs = {}
        profiles = {}

        availableProfiles = self.baseSettings.get_strv('profiles')

        for profile in availableProfiles:
            profileSettings = {}
            generalSettings = {}
            voiceSettings = {}
            pronunciationSettings = {}
            keybindingSettings = {}

            profileBaseSettings = Settings(schema_id='org.gnome.orca',
                                           path='/org/gnome/orca/profile/%s/' %
                                           profile)
            profileApps = profileBaseSettings.get_strv('apps')

            if appName in profileApps:
                generalSettings = self._getGeneralSettings(profile, appName)
                voiceSettings = self._getVoiceSettings(profile, appName)

                if voiceSettings != {}:
                    generalSettings['voices'] = voiceSettings

                pronunciationSettings = self._getPronunciations(
                    profile, appName)
                keybindingSettings = self._getKeybindings(profile, appName)

                profileSettings['general'] = generalSettings
                profileSettings['keybindings'] = keybindingSettings
                profileSettings['pronunciations'] = pronunciationSettings
                profiles[profile] = profileSettings

        if profiles != {}:
            prefs['profiles'] = profiles

        return prefs

    def saveAppSettings(self, appName, profile, general, pronunciations,
                        keybindings):
        profiles = self.baseSettings.get_strv('profiles')

        if profile in profiles:
            profileBaseSettings = Settings(schema_id='org.gnome.orca',
                                           path='/org/gnome/orca/profile/%s/' %
                                           profile)
            apps = profileBaseSettings.get_strv('apps')

            if appName not in apps:
                apps.append(appName)
                profileBaseSettings.set_strv('apps', apps)

            self._saveGeneralSettings(general, profile, appName)

            if general.__contains__('voices'):
                self._saveVoiceSettings(general['voices'], profile, appName)

            self._savePronunciations(pronunciations, profile, appName)
            self._saveKeybindings(keybindings, profile, appName)

    def saveProfileSettings(self, profile, general, pronunciations,
                            keybindings):
        if profile is None:
            profile = 'default'

        profiles = self.baseSettings.get_strv('profiles')

        if profile not in profiles:
            profiles.append(profile)
            self.baseSettings.set_strv('profiles', profiles)

        self._saveGeneralSettings(general, profile)

        if general.__contains__('voices'):
            self._saveVoiceSettings(general['voices'], profile)

        self._savePronunciations(pronunciations, profile)
        self._saveKeybindings(keybindings, profile)

    def getGeneral(self, profile='default'):
        profiles = self.baseSettings.get_strv('profiles')
        startingProfile = self.baseSettings.get_strv('starting-profile')
        generalSettings = {}
        voiceSettings = {}

        generalSettings['startingProfile'] = startingProfile

        if profile in profiles:
            profileGeneralSettings = Settings(
                schema_id='org.gnome.orca.general',
                path='/org/gnome/orca/profile/%s/' % profile)

            generalSettings = self._getGeneralSettings(profile)
            voiceSettings = self._getVoiceSettings(profile)
            generalSettings['voices'] = voiceSettings

        generalSettings['activeProfile'] = profileGeneralSettings.get_strv(
            'profile')

        self.baseSettings.set_strv('active-profile',
                                   generalSettings['activeProfile'])

        return generalSettings

    def getPronunciations(self, profile='default'):
        profiles = self.baseSettings.get_strv('profiles')
        pronunciationSettings = {}

        if profile in profiles:
            pronunciationSettings = self._getPronunciations(profile)

        return pronunciationSettings

    def getKeybindings(self, profile='default'):
        profiles = self.baseSettings.get_strv('profiles')
        keybindingSettings = {}

        if profile in profiles:
            keybindingSettings = self._getKeybindings(profile)

        return keybindingSettings

    def isFirstStart(self):
        """ Check if we're in first start. """

        return self.baseSettings.get_boolean('first-start')

    def _setProfileKey(self, key, value):
        # This method is currently used for setting the startingProfile setting only.
        if key == 'startingProfile':
            self.baseSettings.set_strv('starting-profile', value)

    def setFirstStart(self, value=False):
        """Set firstStart. This user-configurable settting is primarily
        intended to serve as an indication as to whether or not initial
        configuration is needed."""
        self.baseSettings.set_boolean('first-start', value)

    def availableProfiles(self):
        """ List available profiles. """
        profileList = self.baseSettings.get_strv('profiles')
        profiles = []

        for profile in profileList:
            profileSettings = Settings(schema_id='org.gnome.orca.general',
                                       path='/org/gnome/orca/profile/%s/' %
                                       profile)
            profiles.append(profileSettings.get_strv('profile'))

        return profiles

    def _getGSetting(self, gSetting, gSettingName, gSettingType):
        """Uses the GSettings get method suitable for the given
        data type."""
        if gSettingType == 'bool':
            return gSetting.get_boolean(gSettingName)
        elif gSettingType == 'int':
            return gSetting.get_int(gSettingName)
        elif gSettingType == 'string':
            return gSetting.get_string(gSettingName)
        elif gSettingType == 'strv':
            settingStrv = gSetting.get_strv(gSettingName)
            if settingStrv == []:
                return None
            return settingStrv
        elif gSettingType == 'double':
            return gSetting.get_double(gSettingName)

    def _setGSetting(self, gSetting, gSettingName, gSettingType, gSettingVal):
        """Uses the GSettings set method suitable for the given
        data type."""
        if gSettingVal is None:
            return
        debug.println(
            debug.LEVEL_FINEST,
            'INFO: Gsettings backend: Setting %s of type %s with value %s' %
            (gSettingName, gSettingType, gSettingVal))
        if gSettingType == 'bool':
            gSetting.set_boolean(gSettingName, gSettingVal)
        elif gSettingType == 'int':
            gSetting.set_int(gSettingName, gSettingVal)
        elif gSettingType == 'string':
            gSetting.set_string(gSettingName, gSettingVal)
        elif gSettingType == 'strv':
            gSetting.set_strv(gSettingName, gSettingVal)
        elif gSettingType == 'double':
            gSetting.set_double(gSettingName, gSettingVal)

    def _getGeneralSettings(self, profile, app=None):
        generalSettings = {}

        if app is not None and app != '':
            generalGSettings = Settings(
                schema_id='org.gnome.orca.general',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecificGSettings = Settings(
                schema_id='org.gnome.orca.general.app',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            speechGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.speech',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            brailleGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.braille',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            soundGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.sound',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecific = True
        else:
            generalGSettings = Settings(schema_id='org.gnome.orca.general',
                                        path='/org/gnome/orca/profile/%s/' %
                                        profile)
            speechGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.speech',
                path='/org/gnome/orca/profile/%s/' % profile)
            brailleGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.braille',
                path='/org/gnome/orca/profile/%s/' % profile)
            soundGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.sound',
                path='/org/gnome/orca/profile/%s/' % profile)
            appSpecific = False

        for setting in orcaToGSettingsMapGeneral.keys():
            gSetting = orcaToGSettingsMapGeneral.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]

            # GSettings will always return a value, even if the user has not
            # Set one, but if a setting is not set for an app, we don't want
            # to set anything, so the global setting is used, which may be
            # different from the default.
            if appSpecific == True:
                if generalGSettings.get_user_value(gSettingName) is not None:
                    gSettingsVal = self._getGSetting(generalGSettings,
                                                     gSettingName,
                                                     gSettingType)
                    debug.println(
                        debug.LEVEL_FINEST,
                        'INFO: GSettings backend: Getting %s of type %s = %s' %
                        (gSettingName, gSettingType, gSettingsVal))
                    generalSettings[setting] = gSettingsVal
            else:
                gSettingsVal = self._getGSetting(generalGSettings,
                                                 gSettingName, gSettingType)
                debug.println(
                    debug.LEVEL_FINEST,
                    'INFO: GSettings backend: Getting %s of type %s = %s' %
                    (gSettingName, gSettingType, gSettingsVal))
                generalSettings[setting] = gSettingsVal

        for setting in orcaToGSettingsMapGeneralSpeech.keys():
            gSetting = orcaToGSettingsMapGeneralSpeech.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]

            # GSettings will always return a value, even if the user has not
            # Set one, but if a setting is not set for an app, we don't want
            # to set anything, so the global setting is used, which may be
            # different from the default.
            if appSpecific == True:
                if speechGeneralGSettings.get_user_value(
                        gSettingName) is not None:
                    gSettingsVal = self._getGSetting(speechGeneralGSettings,
                                                     gSettingName,
                                                     gSettingType)
                    debug.println(
                        debug.LEVEL_FINEST,
                        'INFO: GSettings backend: Getting %s of type %s = %s' %
                        (gSettingName, gSettingType, gSettingsVal))
                    generalSettings[setting] = gSettingsVal
            else:
                gSettingsVal = self._getGSetting(speechGeneralGSettings,
                                                 gSettingName, gSettingType)
                debug.println(
                    debug.LEVEL_FINEST,
                    'INFO: GSettings backend: Getting %s of type %s = %s' %
                    (gSettingName, gSettingType, gSettingsVal))
                generalSettings[setting] = gSettingsVal

        for setting in orcaToGSettingsMapGeneralSound.keys():
            gSetting = orcaToGSettingsMapGeneralSound.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]

            # GSettings will always return a value, even if the user has not
            # Set one, but if a setting is not set for an app, we don't want
            # to set anything, so the global setting is used, which may be
            # different from the default.
            if appSpecific == True:
                if soundGeneralGSettings.get_user_value(
                        gSettingName) is not None:
                    gSettingsVal = self._getGSetting(soundGeneralGSettings,
                                                     gSettingName,
                                                     gSettingType)
                    debug.println(
                        debug.LEVEL_FINEST,
                        'INFO: GSettings backend: Getting %s of type %s = %s' %
                        (gSettingName, gSettingType, gSettingsVal))
                    generalSettings[setting] = gSettingsVal
            else:
                gSettingsVal = self._getGSetting(soundGeneralGSettings,
                                                 gSettingName, gSettingType)
                debug.println(
                    debug.LEVEL_FINEST,
                    'INFO: GSettings backend: Getting %s of type %s = %s' %
                    (gSettingName, gSettingType, gSettingsVal))
                generalSettings[setting] = gSettingsVal

        for setting in orcaToGSettingsMapGeneralBraille.keys():
            gSetting = orcaToGSettingsMapGeneralBraille.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]

            # GSettings will always return a value, even if the user has not
            # Set one, but if a setting is not set for an app, we don't want
            # to set anything, so the global setting is used, which may be
            # different from the default.
            if appSpecific == True:
                if brailleGeneralGSettings.get_user_value(
                        gSettingName) is not None:
                    gSettingsVal = self._getGSetting(brailleGeneralGSettings,
                                                     gSettingName,
                                                     gSettingType)
                    debug.println(
                        debug.LEVEL_FINEST,
                        'INFO: GSettings backend: Getting %s of type %s = %s' %
                        (gSettingName, gSettingType, gSettingsVal))
                    generalSettings[setting] = gSettingsVal
            else:
                gSettingsVal = self._getGSetting(brailleGeneralGSettings,
                                                 gSettingName, gSettingType)
                debug.println(
                    debug.LEVEL_FINEST,
                    'INFO: GSettings backend: Getting %s of type %s = %s' %
                    (gSettingName, gSettingType, gSettingsVal))
                generalSettings[setting] = gSettingsVal

        if appSpecific == True:
            for setting in orcaToGSettingsMapGeneralApp.keys():
                gSetting = orcaToGSettingsMapGeneralApp.get(setting)
                gSettingName = gSetting[0]
                gSettingType = gSetting[1]
                if appSpecificGSettings.get_user_value(
                        gSettingName) is not None:
                    gSettingsVal = self._getGSetting(appSpecificGSettings,
                                                     gSettingName,
                                                     gSettingType)
                    debug.println(
                        debug.LEVEL_FINEST,
                        'INFO: GSettings backend: Getting %s of type %s = %s' %
                        (gSettingName, gSettingType, gSettingsVal))
                    generalSettings[setting] = gSettingsVal

        return generalSettings

    def _getVoiceSettings(self, profile, app=None):
        voiceSettings = {}

        if app is not None and app != '':
            appSpecific = True
        else:
            appSpecific = False

        for voice in ['default', 'uppercase', 'hyperlink', 'system']:
            if appSpecific == True:
                voiceGSettings = Settings(
                    schema_id='org.gnome.orca.voice',
                    path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' %
                    (profile, app, voice))
                voiceGSettingsFamily = Settings(
                    schema_id='org.gnome.orca.voice.family',
                    path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' %
                    (profile, app, voice))
            else:
                voiceGSettings = Settings(
                    schema_id='org.gnome.orca.voice',
                    path='/org/gnome/orca/profile/%s/voice/%s/' %
                    (profile, voice))
                voiceGSettingsFamily = Settings(
                    schema_id='org.gnome.orca.voice.family',
                    path='/org/gnome/orca/profile/%s/voice/%s/' %
                    (profile, voice))

            # Used to quickly determine whether a voice's settings have been
            # set and are different from the defaults
            voiceEstablished = voiceGSettings.get_boolean('established')

            voiceSetting = {}
            voiceSettingFamily = {}

            if appSpecific == False and self.voiceDefaults.__contains__(voice):
                voiceSetting = self.voiceDefaults[voice].copy()

            if voiceEstablished == True:
                if appSpecific == False and voiceSetting.__contains__(
                        'established'):
                    voiceSetting.pop('established')
                for setting in ['average-pitch', 'gain', 'rate']:
                    if voiceGSettings.get_user_value(setting) is not None:
                        gSettingsVal = voiceGSettings.get_double(setting)
                        debug.println(
                            debug.LEVEL_FINEST,
                            'INFO: GSettings backend: Getting voice setting for voice %s with name %s = %s'
                            % (voice, setting, gSettingsVal))
                        voiceSetting[setting] = gSettingsVal

                if voiceGSettingsFamily.get_boolean('family-set') == True:
                    for setting in ['name', 'locale', 'dialect']:
                        gSettingsVal = voiceGSettingsFamily.get_string(setting)
                        debug.println(
                            debug.LEVEL_FINEST,
                            'INFO: GSettings backend: Getting voice family setting for voice %s with name %s = %s'
                            % (voice, setting, gSettingsVal))
                        voiceSettingFamily[setting] = gSettingsVal
                    voiceSetting['family'] = voiceSettingFamily

            # The JSON backend uses acss the same way, not sure why, so will
            # just duplicate here to be compatible.
            if voiceSetting != {}:
                if appSpecific == True:
                    voiceSettings[voice] = voiceSetting
                else:
                    voiceSettings[voice] = acss.ACSS(voiceSetting)

        return voiceSettings

    def _getPronunciations(self, profile, app=None):
        pronunciationSettings = {}

        if app is not None and app != '':
            baseGSettings = Settings(
                schema_id='org.gnome.orca',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecific = True
        else:
            baseGSettings = Settings(schema_id='org.gnome.orca',
                                     path='/org/gnome/orca/profile/%s/' %
                                     profile)
            appSpecific = False

        pronunciations = baseGSettings.get_strv('pronunciations')
        for pronunciation in pronunciations:
            if appSpecific == True:
                pronunciationSetting = Settings(
                    schema_id='org.gnome.orca.pronunciation',
                    path='/org/gnome/orca/profile/%s/app/%s/pronunciation/%s/'
                    % (profile, app, pronunciation))
            else:
                pronunciationSetting = Settings(
                    schema_id='org.gnome.orca.pronunciation',
                    path='/org/gnome/orca/profile/%s/pronunciation/%s/' %
                    (profile, pronunciation))

            actualSetting = pronunciationSetting.get_string('actual')
            replacementSetting = pronunciationSetting.get_string('replacement')
            pronunciationSettings[pronunciation] = [
                actualSetting, replacementSetting
            ]

        return pronunciationSettings

    def _getKeybindings(self, profile, app=None):
        keybindingSettings = {}

        if app is not None and app != '':
            baseGSettings = Settings(
                schema_id='org.gnome.orca',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecific = True
        else:
            baseGSettings = Settings(schema_id='org.gnome.orca',
                                     path='/org/gnome/orca/profile/%s/' %
                                     profile)
            appSpecific = False

        keybindings = baseGSettings.get_strv('keybindings')
        for keybinding in keybindings:
            if appSpecific == True:
                keybindingSetting = Settings(
                    schema_id='org.gnome.orca.keybinding',
                    path='/org/gnome/orca/profile/%s/app/%s/keybinding/%s/' %
                    (profile, app, keybinding))
            else:
                keybindingSetting = Settings(
                    schema_id='org.gnome.orca.keybinding',
                    path='/org/gnome/orca/profile/%s/keybinding/%s/' %
                    (profile, keybinding))

            keySetting = keybindingSetting.get_string('key')
            modMaskSetting = keybindingSetting.get_string('mod-mask')
            modUsedSetting = keybindingSetting.get_string('mod-used')
            clickCountSetting = keybindingSetting.get_string('click-count')
            keybindingSettings[keybinding] = [[
                keySetting, modMaskSetting, modUsedSetting, clickCountSetting
            ]]

        return keybindingSettings

    def _saveGeneralSettings(self, generalSettings, profile, app=None):
        if app is not None and app != '':
            generalGSettings = Settings(
                schema_id='org.gnome.orca.general',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            speechGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.speech',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            brailleGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.braille',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            soundGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.sound',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecificGSettings = Settings(
                schema_id='org.gnome.orca.general.app',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecific = True
        else:
            generalGSettings = Settings(schema_id='org.gnome.orca.general',
                                        path='/org/gnome/orca/profile/%s/' %
                                        profile)
            speechGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.speech',
                path='/org/gnome/orca/profile/%s/' % profile)
            brailleGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.braille',
                path='/org/gnome/orca/profile/%s/' % profile)
            soundGeneralGSettings = Settings(
                schema_id='org.gnome.orca.general.sound',
                path='/org/gnome/orca/profile/%s/' % profile)
            appSpecific = False

        for setting in orcaToGSettingsMapGeneral.keys():
            gSetting = orcaToGSettingsMapGeneral.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]
            self._setGSetting(generalGSettings, gSettingName, gSettingType,
                              generalSettings.get(setting))

        for setting in orcaToGSettingsMapGeneralSpeech.keys():
            gSetting = orcaToGSettingsMapGeneralSpeech.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]
            self._setGSetting(speechGeneralGSettings, gSettingName,
                              gSettingType, generalSettings.get(setting))

        for setting in orcaToGSettingsMapGeneralSound.keys():
            gSetting = orcaToGSettingsMapGeneralSound.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]
            self._setGSetting(soundGeneralGSettings, gSettingName,
                              gSettingType, generalSettings.get(setting))

        for setting in orcaToGSettingsMapGeneralBraille.keys():
            gSetting = orcaToGSettingsMapGeneralBraille.get(setting)
            gSettingName = gSetting[0]
            gSettingType = gSetting[1]
            self._setGSetting(brailleGeneralGSettings, gSettingName,
                              gSettingType, generalSettings.get(setting))

        if appSpecific == True:
            for setting in orcaToGSettingsMapGeneralApp.keys():
                gSetting = orcaToGSettingsMapGeneralApp.get(setting)
                gSettingName = gSetting[0]
                gSettingType = gSetting[1]
                self._setGSetting(appSpecificGSettings, gSettingName,
                                  gSettingType, generalSettings.get(setting))

    def _saveVoiceSettings(self, voiceSettings, profile, app=None):
        if app is not None and app != '':
            appSpecific = True
        else:
            appSpecific = False

        for voice in ['default', 'uppercase', 'hyperlink', 'system']:
            if appSpecific == True:
                voiceGSettings = Settings(
                    schema_id='org.gnome.orca.voice',
                    path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' %
                    (profile, app, voice))
                voiceFamilyGSettings = Settings(
                    schema_id='org.gnome.orca.voice.family',
                    path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' %
                    (profile, app, voice))
            else:
                voiceGSettings = Settings(
                    schema_id='org.gnome.orca.voice',
                    path='/org/gnome/orca/profile/%s/voice/%s/' %
                    (profile, voice))
                voiceFamilyGSettings = Settings(
                    schema_id='org.gnome.orca.voice.family',
                    path='/org/gnome/orca/profile/%s/voice/%s/' %
                    (profile, voice))

            if voiceSettings.__contains__(voice):
                if voiceSettings[voice].get('established') is None:
                    for setting in ['average-pitch', 'gain', 'rate']:
                        if voiceSettings[voice].get(setting) is not None:
                            if appSpecific == True:
                                voiceGSettings.set_double(
                                    setting, voiceSettings[voice].get(setting))
                            else:
                                if voiceSettings[voice].get(
                                        setting) is not self.voiceDefaults[
                                            voice].get(setting):
                                    voiceGSettings.set_double(
                                        setting,
                                        voiceSettings[voice].get(setting))
                                    setEstablished = True

                    if appSpecific == True:
                        voiceGSettings.set_boolean('established', True)
                    elif appSpecific == False and setEstablished == True:
                        voiceGSettings.set_boolean('established', True)

                    if voiceSettings[voice].__contains__('family'):
                        for setting in ['name', 'locale', 'dialect']:
                            voiceFamilyGSettings.set_string(
                                setting,
                                voiceSettings[voice]['family'].get(setting))
                        voiceFamilyGSettings.set_boolean('family-set', True)

    def _savePronunciations(self, pronunciations, profile, app=None):
        if app is not None and app != '':
            baseGSettings = Settings(
                schema_id='org.gnome.orca',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecific = True
        else:
            baseGSettings = Settings(schema_id='org.gnome.orca',
                                     path='/org/gnome/orca/profile/%s/' %
                                     profile)
            appSpecific = False

        pronunciationList = baseGSettings.get_strv('pronunciations')
        for pronunciation in pronunciations.keys():
            if appSpecific == True:
                pronunciationSettings = Settings(
                    schema_id='org.gnome.orca.pronunciation',
                    path='/org/gnome/orca/profile/%s/app/%s/pronunciation/%s/'
                    % (profile, app, pronunciation))
            else:
                pronunciationSettings = Settings(
                    schema_id='org.gnome.orca.pronunciation',
                    path='/org/gnome/orca/profile/%s/pronunciation/%s/' %
                    (profile, pronunciation))

            if pronunciation not in pronunciationList:
                pronunciationList.append(pronunciation)
                pronunciationVal = pronunciations[pronunciation]
                pronunciationSettings.set_string('actual', pronunciationVal[0])
                pronunciationSettings.set_string('replacement',
                                                 pronunciationVal[1])

        # Now we remove any deleted pronunciations from GSettings.
        for pronunciation in pronunciationList:
            if pronunciation not in pronunciations.keys():
                if appSpecific == True:
                    pronunciationSettings = Settings(
                        schema_id='org.gnome.orca.pronunciation',
                        path=
                        '/org/gnome/orca/profile/%s/app/%s/pronunciation/%s/' %
                        (profile, app, pronunciation))
                else:
                    pronunciationSettings = Settings(
                        schema_id='org.gnome.orca.pronunciation',
                        path='/org/gnome/orca/profile/%s/pronunciation/%s/' %
                        (profile, pronunciation))

                pronunciationList.remove(pronunciation)

                pronunciationSettings.reset('actual')
                pronunciationSettings.reset('replacement')

        if pronunciationList == []:
            baseGSettings.reset('pronunciations')
        else:
            baseGSettings.set_strv('pronunciations', pronunciationList)

    def _saveKeybindings(self, keybindings, profile, app=None):
        if app is not None and app != '':
            baseGSettings = Settings(
                schema_id='org.gnome.orca',
                path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app))
            appSpecific = True
        else:
            baseGSettings = Settings(schema_id='org.gnome.orca',
                                     path='/org/gnome/orca/profile/%s/' %
                                     profile)
            appSpecific = False

        keybindingList = baseGSettings.get_strv('keybindings')
        for keybinding in keybindings.keys():
            if appSpecific == True:
                keybindingSettings = Settings(
                    schema_id='org.gnome.orca.keybinding',
                    path='/org/gnome/orca/profile/%s/app/%s/keybinding/%s/' %
                    (profile, app, keybinding))
            else:
                keybindingSettings = Settings(
                    schema_id='org.gnome.orca.keybinding',
                    path='/org/gnome/orca/profile/%s/keybinding/%s/' %
                    (profile, keybinding))

            if keybinding not in keybindingList:
                keybindingList.append(keybinding)

            keybindingVal = keybindings[keybinding][0]
            keybindingSettings.set_string('key', keybindingVal[0])
            keybindingSettings.set_string('mod-mask', keybindingVal[1])
            keybindingSettings.set_string('mod-used', keybindingVal[2])
            keybindingSettings.set_string('click-count', keybindingVal[3])

        # Now we remove any deleted keybindings from Gsettings.
        for keybinding in keybindingList:
            if keybinding not in keybindings.keys():
                if appSpecific == True:
                    keybindingSettings = Settings(
                        schema_id='org.gnome.orca.keybinding',
                        path='/org/gnome/orca/profile/%s/app/%s/keybinding/%s/'
                        % (profile, app, keybinding))
                else:
                    keybindingSettings = Settings(
                        schema_id='org.gnome.orca.keybinding',
                        path='/org/gnome/orca/profile/%s/keybinding/%s/' %
                        (profile, keybinding))

                keybindingList.remove(keybinding)

                keybindingSettings.reset('key')
                keybindingSettings.reset('mod-mask')
                keybindingSettings.reset('mod-used')
                keybindingSettings.reset('click-count')

        if keybindingList == []:
            baseGSettings.reset('keybindings')
        else:
            baseGSettings.set_strv('keybindings', keybindingList)