Commit ba900faf authored by William Jon McCann's avatar William Jon McCann Committed by Javier Hernández

Fix for bug #674884 - Use XDG base directory instead of $HOME

parent 036689e7
......@@ -14,6 +14,7 @@ import gi
from gi.repository import Gtk as gtk
from gi.repository import GObject
from gi.repository import GLib
import os
import traceback
......@@ -26,7 +27,7 @@ from accerciser.i18n import _, N_, DOMAIN
import pyatspi
UI_FILE = os.path.join(os.path.dirname(__file__), 'validate.ui')
USER_SCHEMA_PATH = os.path.join(os.environ['HOME'], '.accerciser',
USER_SCHEMA_PATH = os.path.join(GLib.get_user_data_dir(), 'accerciser',
'plugindata', 'validate')
SYS_SCHEMA_PATH = os.path.join(sys.prefix, 'share', 'accerciser',
'plugindata', 'validate')
......
......@@ -13,12 +13,23 @@ available under the terms of the BSD which accompanies this distribution, and
is available at U{http://www.opensource.org/licenses/bsd-license.php}
'''
import gi
from gi.repository import GLib
import sys, os
def migrate_data (old_path, new_path):
if os.path.exists(old_path) and not os.path.exists(new_path):
mask = os.umask(077)
try:
os.renames(old_path, new_path)
except:
print "Unable to migrate ", old_path
os.umask(mask)
# Load gail module no matter what the desktop-wide settings are.
os.environ['GTK_MODULES'] = 'gail:atk-bridge'
# make the ~/.accerciser directory part of the path to aid user imports
sys.path.append(os.path.join(os.environ['HOME'], '.accerciser'))
# make the accerciser directory part of the path to aid user imports
sys.path.append(os.path.join(GLib.get_user_config_dir(), 'accerciser'))
# We can't rely on prefix if we're installed by relocated RPM. Instead, we
# use __file__ and for now hope that lib is relative to bin.
sys.prefix = '@prefix@'
......@@ -49,6 +60,17 @@ except Exception:
else:
# TODO: REVIEW
gtk.Window.set_default_icon_list(icons)
# Try migration
old_plugin_dir = os.path.join(os.environ['HOME'], '.accerciser', 'plugins')
new_plugin_dir = os.path.join(GLib.get_user_data_dir(), 'accerciser', 'plugins')
migrate_data(old_plugin_dir, new_plugin_dir)
old_bookmarks = os.path.join(os.environ['HOME'], '.accerciser', 'bookmarks.xml')
new_bookmarks = os.path.join(GLib.get_user_config_dir(), 'accerciser', 'bookmarks.xml')
migrate_data(old_bookmarks, new_bookmarks)
old_plugindata = os.path.join(os.environ['HOME'], '.accerciser', 'plugindata')
new_plugindata = os.path.join(GLib.get_user_data_dir(), 'accerciser', 'plugindata')
import accerciser
accerciser.main()
from gi.repository import GLib
from gi.repository import Gtk as gtk
from gi.repository import Atk as atk
......@@ -14,7 +15,7 @@ COL_APP = 1
COL_PATH = 2
_BM_ATTRIBS = ['title', 'app', 'path']
BOOKMARKS_PATH = os.path.join(os.environ['HOME'], '.accerciser')
BOOKMARKS_PATH = os.path.join(GLib.get_user_config_dir(), 'accerciser')
BOOKMARKS_FILE = 'bookmarks.xml'
class BookmarkStore(gtk.ListStore):
......
......@@ -13,6 +13,7 @@ is available at U{http://www.opensource.org/licenses/bsd-license.php}
import gi
from gi.repository import GLib
from gi.repository import Gtk as gtk
from gi.repository.Gio import Settings as GSettings
......@@ -108,8 +109,8 @@ class PluginManager(gtk.ListStore, Tools):
@rtype: tuple
'''
plugin_file_list = []
plugin_dir_local = os.path.join(os.environ['HOME'],
'.accerciser', 'plugins')
plugin_dir_local = os.path.join(GLib.get_user_data_dir(),
'accerciser', 'plugins')
plugin_dir_global = os.path.join(sys.prefix, 'share',
'accerciser', 'plugins')
for plugin_dir in (plugin_dir_local, plugin_dir_global):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment