[orca/new-settings] Override current settings with the settings defines orca-customizations.py.
- From: Alejandro Leiva <aleiva src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] Override current settings with the settings defines orca-customizations.py.
- Date: Fri, 10 Dec 2010 16:54:49 +0000 (UTC)
commit 590f428a38858346aaa1e0172f8535c37938111e
Author: Alejandro Leiva <aleiva emergya es>
Date: Fri Dec 10 17:54:03 2010 +0100
Override current settings with the settings defines orca-customizations.py.
src/orca/settings_manager.py | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 99235e6..be36044 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -28,12 +28,12 @@ __copyright__ = "Copyright (c) 2010 Consorcio Fernando de los Rios."
__license__ = "LGPL"
import os
+import imp
from yaml import load
-import settings
import debug
from keybindings import KeyBinding
-
+import settings
try:
import gconf
@@ -135,12 +135,13 @@ class SettingsManager(object):
if not os.path.isdir(dirName):
os.mkdir(dirName)
- # Set up the user's preferences directory (~/.orca by default).
+ # Set up the user's preferences directory
+ # ($XDG_DATA_HOME/orca by default).
#
orcaDir = settings.userPrefsDir
_createDir(orcaDir)
- # Set up ~/.orca/orca-scripts as a Python package
+ # Set up $XDG_DATA_HOME/orca/orca-scripts as a Python package
#
orcaScriptDir = os.path.join(orcaDir, "orca-scripts")
_createDir(orcaScriptDir)
@@ -148,7 +149,7 @@ class SettingsManager(object):
if not os.path.exists(initFile):
os.close(os.open(initFile, os.O_CREAT, 0700))
- # Set up ~/.orca/app-settings as a Python package.
+ # Set up $XDG_DATA_HOME/orca/app-settings as a Python package.
#
orcaSettingsDir = os.path.join(orcaDir, "app-settings")
_createDir(orcaSettingsDir)
@@ -156,6 +157,17 @@ class SettingsManager(object):
if not os.path.exists(initFile):
os.close(os.open(initFile, os.O_CREAT, 0700))
+ # Set up $XDG_DATA_HOME/orca/orca-customizations.py empty file and
+ # define orcaDir as a Python package.
+ initFile = os.path.join(orcaDir, "__init__.py")
+ if not os.path.exists(initFile):
+ os.close(os.open(initFile, os.O_CREAT, 0700))
+
+ userCustomFile = os.path.join(orcaDir, "orca-customizations.py")
+ if not os.path.exists(userCustomFile):
+ os.close(os.open(userCustomFile, os.O_CREAT, 0700))
+
+
self._backend.saveDefaultSettings(self.defaultGeneral,
self.defaultPronunciations,
self.defaultKeybindings)
@@ -170,6 +182,8 @@ class SettingsManager(object):
def _setDefaultGeneral(self):
"""Get the general settings by default from orca.settings"""
+ if not self.isFirstStart():
+ self._loadUserCustomizations()
self.defaultGeneral = {}
for key in settings.userCustomizableSettings:
try:
@@ -177,6 +191,16 @@ class SettingsManager(object):
except:
pass
+ def _loadUserCustomizations(self):
+ pathList = [settings.userPrefsDir]
+ (fileHnd, moduleName, Desc) = imp.find_module("orca-customizations", pathList)
+ try:
+ imp.load_module("orca-customizations", fileHnd, moduleName, Desc)
+ except:
+ pass
+ finally:
+ fileHnd.close()
+
def _getGeneral(self, profile=None):
"""Get from the active backend the general settings for
the current profile"""
@@ -268,6 +292,7 @@ class SettingsManager(object):
def _setSettingsRuntime(self, settingsDict):
for key, value in settingsDict.items():
setattr(settings, str(key), value)
+ self._loadUserCustomizations()
def getGeneralSettings(self, profile='default'):
"""Return the current general settings.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]