def showPreferencesUI(): global applicationName, appScript # There must be an application with focus for this to work. # if not orca_state.locusOfFocus or not orca_state.locusOfFocus.getApplication(): message = _("No application has focus.") braille.displayMessage(message) speech.speak(message) return appScript = orca_state.activeScript # The name of the application that currently has focus. # applicationName = orca_state.activeScript.app.name if not orca_state.appOS and not orca_state.orcaOS: # Translators: Orca Preferences in this case, is a configuration GUI # for allowing users to set application specific settings from within # Orca for the application that currently has focus. # line = _("Starting Orca Preferences for %s.") % applicationName appScript.presentMessage(line) prefsDict = orca_prefs.readPreferences() orca_state.prefsUIFile = os.path.join( orca_platform.prefix, orca_platform.datadirname, orca_platform.package, "ui", "orca-setup.ui" ) orca_state.appOS = OrcaSetupGUI(orca_state.prefsUIFile, "orcaSetupWindow", prefsDict) orca_state.appOS.initAppGUIState(appScript) orca_state.appOS.init() else: if not orca_state.orcaWD: orca_state.orcaWarningDialogUIFile = os.path.join( orca_platform.prefix, orca_platform.datadirname, orca_platform.package, "ui", "orca-preferences-warning.ui", ) orca_state.orcaWD = WarningDialogGUI(orca_state.orcaWarningDialogUIFile, "orcaPrefsWarningDialog") warningDialog = orca_state.orcaWD.getPrefsWarningDialog() warningDialog.realize() warningDialog.show() return orca_state.appOS.showGUI()
def writePreferences(self): """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. Returns True if the user needs to log out for accessibility settings to take effect. """ self._setupPreferencesDirs() oldPrefsDict = orca_prefs.readPreferences() # Write XDG_DATA_HOME/orca/app-settings/<APPNAME>.py # orcaDir = settings.userPrefsDir orcaSettingsDir = os.path.join(orcaDir, "app-settings") appFileName = "%s.py" % self.appName prefs = open(os.path.join(orcaSettingsDir, appFileName), "w") self._writeAppPreferencesPreamble(prefs, self.appName) for key in settings.userCustomizableSettings: value = self._getValueForKey(self.prefsDict, key) oldValue = self._getValueForKey(oldPrefsDict, key) if self.valueChanged(oldValue, value): prefs.writelines("orca.settings.%s = %s\n" % (key, value)) if self.keyBindingsTreeModel: self._writeAppKeyBindingsMap(prefs, self.appName, self.appScript, self.keyBindingsTreeModel) if self.pronunciationTreeModel: self._writePronunciationMap(prefs, self.pronunciationTreeModel) # Write out the application unique preferences (if any) and set the # new values. # self.appScript.setAppPreferences(prefs) self._writeAppPreferencesPostamble(prefs, self.appName) prefs.close() return False # no logout is needed
def _writePreferences(self): """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. """ self._setupPreferencesDirs() oldPrefsDict = orca_prefs.readPreferences() # Write ~/.orca/app-settings/<APPNAME>.py # orcaDir = settings.userPrefsDir orcaSettingsDir = os.path.join(orcaDir, "app-settings") appFileName = "%s.py" % self.appName prefs = open(os.path.join(orcaSettingsDir, appFileName), "w") self._writePreferencesPreamble(prefs, self.appName) for key in settings.userCustomizableSettings: value = self._getValueForKey(self.prefsDict, key) oldValue = self._getValueForKey(oldPrefsDict, key) if oldValue != value: prefs.writelines("orca.settings.%s = %s\n" % (key, value)) if self.keyBindingsTreeModel: self._writeKeyBindingsMap(prefs, self.appName, self.appScript, self.keyBindingsTreeModel) if self.pronunciationTreeModel: self._writePronunciationMap(prefs, self.pronunciationTreeModel) # Write out the application unique preferences (if any) and set the # new values. # self.appScript.setAppPreferences(prefs) self._writePreferencesPostamble(prefs, self.appName) prefs.close()