[gedit] Respect GNOME22_USER_DIR env variable.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Respect GNOME22_USER_DIR env variable.
- Date: Mon, 29 Mar 2010 20:49:43 +0000 (UTC)
commit 4ab4b2460be6f6c69b17260275e3cd313b063935
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Mar 22 23:17:24 2010 +0100
Respect GNOME22_USER_DIR env variable.
gedit/gedit-dirs.c | 53 +++++++++++++++++++------
plugins/externaltools/tools/library.py | 17 +++++++-
plugins/snippets/snippets/__init__.py | 16 +++++---
plugins/taglist/gedit-taglist-plugin-parser.c | 28 ++++++++++---
4 files changed, 86 insertions(+), 28 deletions(-)
---
diff --git a/gedit/gedit-dirs.c b/gedit/gedit-dirs.c
index 75c59a2..23b44c7 100644
--- a/gedit/gedit-dirs.c
+++ b/gedit/gedit-dirs.c
@@ -36,16 +36,29 @@ gedit_dirs_get_user_config_dir (void)
gchar *config_dir = NULL;
#ifndef G_OS_WIN32
+ const gchar *envvar;
const gchar *home;
-
- home = g_get_home_dir ();
- if (home != NULL)
+ /* Support old libgnome env var */
+ envvar = g_getenv ("GNOME22_USER_DIR");
+ if (envvar != NULL)
{
- config_dir = g_build_filename (home,
- ".gnome2",
+ config_dir = g_build_filename (envvar,
"gedit",
NULL);
+
+ }
+ else
+ {
+ home = g_get_home_dir ();
+
+ if (home != NULL)
+ {
+ config_dir = g_build_filename (home,
+ ".gnome2",
+ "gedit",
+ NULL);
+ }
}
#else
config_dir = g_build_filename (g_get_user_config_dir (),
@@ -90,21 +103,35 @@ gedit_dirs_get_user_accels_file (void)
gchar *accels = NULL;
#ifndef G_OS_WIN32
+ const gchar *envvar;
const gchar *home;
-
- home = g_get_home_dir ();
- if (home != NULL)
+ /* on linux accels are stored in .gnome2/accels
+ * for historic reasons (backward compat with the
+ * old libgnome that took care of saving them */
+
+ /* Support old libgnome env var */
+ envvar = g_getenv ("GNOME22_USER_DIR");
+ if (envvar != NULL)
{
- /* on linux accels are stored in .gnome2/accels
- * for historic reasons (backward compat with the
- * old libgnome that took care of saving them */
- accels = g_build_filename (home,
- ".gnome2",
+ accels = g_build_filename (envvar,
"accels",
"gedit",
NULL);
}
+ else
+ {
+ home = g_get_home_dir ();
+
+ if (home != NULL)
+ {
+ accels = g_build_filename (home,
+ ".gnome2",
+ "accels",
+ "gedit",
+ NULL);
+ }
+ }
#else
{
gchar *config_dir = NULL;
diff --git a/plugins/externaltools/tools/library.py b/plugins/externaltools/tools/library.py
index 618200f..56a1c84 100644
--- a/plugins/externaltools/tools/library.py
+++ b/plugins/externaltools/tools/library.py
@@ -47,9 +47,15 @@ class ToolLibrary(Singleton):
# self.locations[0] is where we save the custom scripts
if platform.platform() == 'Windows':
- self.locations.insert(0, os.path.expanduser('~/gedit/tools'))
+ toolsdir = os.path.expanduser('~/gedit/tools')
else:
- self.locations.insert(0, os.path.expanduser('~/.gnome2/gedit/tools'))
+ userdir = os.getenv('GNOME22_USER_DIR')
+ if userdir:
+ toolsdir = os.path.join(userdir, 'gedit/tools')
+ else:
+ toolsdir = os.path.expanduser('~/.gnome2/gedit/tools')
+
+ self.locations.insert(0, toolsdir);
if not os.path.isdir(self.locations[0]):
os.makedirs(self.locations[0])
@@ -72,7 +78,12 @@ class ToolLibrary(Singleton):
# storage file.
def import_old_xml_store(self):
import xml.etree.ElementTree as et
- filename = os.path.expanduser('~/.gnome2/gedit/gedit-tools.xml')
+ userdir = os.getenv('GNOME22_USER_DIR')
+ if userdir:
+ filename = os.path.join(userdir, 'gedit/gedit-tools.xml')
+ else:
+ filename = os.path.expanduser('~/.gnome2/gedit/gedit-tools.xml')
+
if not os.path.isfile(filename):
return
diff --git a/plugins/snippets/snippets/__init__.py b/plugins/snippets/snippets/__init__.py
index 8afa745..f2990d8 100644
--- a/plugins/snippets/snippets/__init__.py
+++ b/plugins/snippets/snippets/__init__.py
@@ -37,14 +37,18 @@ class SnippetsPlugin(gedit.Plugin):
library = Library()
library.set_accelerator_callback(self.accelerator_activated)
-
+
if platform.platform() == 'Windows':
- userdir = os.path.expanduser('~/gedit/snippets')
- else:
- userdir = os.path.expanduser('~/.gnome2/gedit/snippets')
+ snippetsdir = os.path.expanduser('~/gedit/snippets')
+ else:
+ userdir = os.getenv('GNOME22_USER_DIR')
+ if userdir:
+ snippetsdir = os.path.join(userdir, 'gedit/snippets')
+ else:
+ snippetsdir = os.path.expanduser('~/.gnome2/gedit/snippets')
+
+ library.set_dirs(snippetsdir, self.system_dirs())
- library.set_dirs(userdir, self.system_dirs())
-
def system_dirs(self):
if platform.platform() != 'Windows':
if 'XDG_DATA_DIRS' in os.environ:
diff --git a/plugins/taglist/gedit-taglist-plugin-parser.c b/plugins/taglist/gedit-taglist-plugin-parser.c
index c9854bd..3a838f6 100644
--- a/plugins/taglist/gedit-taglist-plugin-parser.c
+++ b/plugins/taglist/gedit-taglist-plugin-parser.c
@@ -45,7 +45,7 @@
/* we screwed up so we still look here for compatibility */
#define USER_GEDIT_TAGLIST_PLUGIN_LOCATION_LEGACY ".gedit-2/plugins/taglist/"
-#define USER_GEDIT_TAGLIST_PLUGIN_LOCATION ".gnome2/gedit/taglist/"
+#define USER_GEDIT_TAGLIST_PLUGIN_LOCATION "gedit/taglist/"
TagList *taglist = NULL;
static gint taglist_ref_count = 0;
@@ -588,6 +588,8 @@ parse_taglist_dir (const gchar *dir)
TagList* create_taglist (const gchar *data_dir)
{
+ gchar *pdir;
+
gedit_debug_message (DEBUG_PLUGINS, "ref_count: %d", taglist_ref_count);
if (taglist_ref_count > 0)
@@ -599,28 +601,42 @@ TagList* create_taglist (const gchar *data_dir)
#ifndef G_OS_WIN32
const gchar *home;
+ const gchar *envvar;
/* load user's taglists */
+
+ /* legacy dir */
home = g_get_home_dir ();
if (home != NULL)
{
- gchar *pdir;
-
pdir = g_build_filename (home,
USER_GEDIT_TAGLIST_PLUGIN_LOCATION_LEGACY,
NULL);
parse_taglist_dir (pdir);
g_free (pdir);
+ }
+ /* Support old libgnome env var */
+ envvar = g_getenv ("GNOME22_USER_DIR");
+ if (envvar != NULL)
+ {
+ pdir = g_build_filename (envvar,
+ USER_GEDIT_TAGLIST_PLUGIN_LOCATION,
+ NULL);
+ parse_taglist_dir (pdir);
+ g_free (pdir);
+ }
+ else if (home != NULL)
+ {
pdir = g_build_filename (home,
+ ".gnome2",
USER_GEDIT_TAGLIST_PLUGIN_LOCATION,
NULL);
parse_taglist_dir (pdir);
g_free (pdir);
}
-#else
- gchar *pdir;
-
+
+#else
pdir = g_build_filename (g_get_user_config_dir (),
"gedit",
"taglist",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]