Andreas Köhler wrote:
Author: andi5
Date: 2007-03-21 18:50:12 -0400 (Wed, 21 Mar 2007)
New Revision: 15746
Trac: http://svn.gnucash.org/trac/changeset/15746
Modified:
gnucash/trunk/src/engine/gnc-filepath-utils.c
Log:
Patch from James Radley to allow override of the dotfile location.
Read environment variable GNC_DOT_DIR and, if available, use this
instead of `g_get_home_dir`/.gnucash. This allows one develop without
impacting an existing stable installation, excepting shared GConf
keys. Setting HOME does not help, because g_get_home_dir prefers
passwd entries.
Thanks for applying the patch Andreas.
After your comment above, I've had a play with the GConf settings as
well, and I've got a patch that allows you to override the gconf base
path. It's not quite as clean in use as the DOT_DIR override, but we can
set the base path ( currently fixed at /apps/gnucash ) to something
else, and ItWorksForMe :-)
GC seems to whinge a bit if it can't find the schemas at startup, so if
you are going to override the GConf settings, I'd suggest doing a
$ export GNC_GCONF_PATH=/my/new/gconf/path
$ gconftool-2 --dump /schemas/apps/gnucash > /tmp/gnc.schemas
$ gconftool-2 --dump /apps/gnucash > /tmp/gnc.apps
Then edit the two /tmp files to change the second line
<entrylist base="/schemas/apps/gnucash">
to
<entrylist base="/schemas/my/new/gconf/path">
then
$ gconftool-2 --load /tmp/gnc.schemas
$ gconftool-2 --load /tmp/gnc.apps
which should populate the gnucash gconf schemas for your new path, and
make everything work okay.
James
Index: src/core-utils/gnc-gconf-utils.c
===================================================================
--- src/core-utils/gnc-gconf-utils.c (revision 15738)
+++ src/core-utils/gnc-gconf-utils.c (working copy)
@@ -249,13 +249,29 @@
/************************************************************/
/* Gconf Utilities */
/************************************************************/
+const gchar *
+gnc_gconf_app_path ( )
+{
+ static gchar *app_path = NULL;
+
+ if(app_path) {
+ return app_path;
+ }
+
+ app_path = g_strdup(g_getenv("GNC_GCONF_PATH"));
+ if(!app_path) {
+ app_path = g_strdup(APP_GNUCASH);
+ }
+
+ return app_path;
+}
char *
gnc_gconf_section_name (const char *name)
{
if (name == NULL) {
/* Need to return a newly allocated string */
- return g_strdup(APP_GNUCASH);
+ return g_strdup(gnc_gconf_app_path());
}
if (*name == '/') {
/* Need to return a newly allocated string */
@@ -268,7 +284,7 @@
* order to keep this file completely "gnome-free" this approach was
* used.
*/
- return g_strjoin("/", APP_GNUCASH, name, NULL);
+ return g_strjoin("/", gnc_gconf_app_path(), name, NULL);
}
char *
@@ -285,7 +301,7 @@
* order to keep this file completely "gnome-free" this approach was
* used.
*/
- return g_strconcat("/schemas", APP_GNUCASH, "/", name, NULL);
+ return g_strconcat("/schemas", gnc_gconf_app_path(), "/", name, NULL);
}
static gchar *
Index: src/core-utils/gnc-gconf-utils.h
===================================================================
--- src/core-utils/gnc-gconf-utils.h (revision 15738)
+++ src/core-utils/gnc-gconf-utils.h (working copy)
@@ -107,6 +107,17 @@
const gchar *name,
gint default_value);
+/** Return the base of the GConf path
+ *
+ * This function returns the name of the standard gnucash gconf path
+ * that is used for the construction of the other gconf entries. By
+ * default, this value is /apps/gnucash but may be overridden with
+ * the GNC_GCONF_PATH environment variable, if set
+ *
+ * @return A pointer to the key string. The key is constant
+ */
+const gchar* gnc_gconf_app_path(void);
+
/** Convert a local key name to a full gconf path name.
*
* This function takes a gconf key name and converts it into a fully
Index: src/engine/gnc-filepath-utils.c
===================================================================
--- src/engine/gnc-filepath-utils.c (revision 15738)
+++ src/engine/gnc-filepath-utils.c (working copy)
@@ -382,14 +382,17 @@
if (dotgnucash)
return dotgnucash;
- home = g_get_home_dir();
- if (!home) {
- g_warning("Cannot find home directory. Using tmp directory instead.");
- home = g_get_tmp_dir();
+ dotgnucash = g_strdup(g_getenv("GNC_DOT_DIR"));
+ if(!dotgnucash) {
+ home = g_get_home_dir();
+ if (!home) {
+ g_warning("Cannot find home directory. Using tmp directory instead.");
+ home = g_get_tmp_dir();
+ }
+ g_assert(home);
+
+ dotgnucash = g_build_filename(home, ".gnucash", (gchar *)NULL);
}
- g_assert(home);
-
- dotgnucash = g_build_filename(home, ".gnucash", (gchar *)NULL);
gnc_validate_directory(dotgnucash);
/* Since we're in code that is only executed once.... */
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel