From d3ded67d47f0a0cbb0769ef1ec5be0b89bf7e481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Wed, 1 Nov 2006 19:36:06 +0000 Subject: [PATCH] Automatically update the gconf search path on windows. Add a force_slashes parameter to gnc_path_get_gconfdir to get a slash separated path instead of using G_DIR_SEPARATOR (backslash). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15067 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/gnc-path.c | 18 +++++++++++++++--- src/engine/gnc-path.h | 5 ++++- src/gnome-utils/druid-gconf-setup.c | 23 +++++++++++++++++++++-- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/engine/gnc-path.c b/src/engine/gnc-path.c index bc84fc160c..29b34b2373 100644 --- a/src/engine/gnc-path.c +++ b/src/engine/gnc-path.c @@ -121,11 +121,23 @@ gchar *gnc_path_get_accountsdir() * "$prefix/etc/gconf/gconf.xml.defaults". * * @returns A newly allocated string. */ -gchar *gnc_path_get_gconfdir() +gchar *gnc_path_get_gconfdir(gboolean force_slashes) { gchar *sysconfdir = gbr_find_etc_dir (SYSCONFDIR); - gchar *result = g_build_filename (sysconfdir, "gconf", - "gconf.xml.defaults", (char*)NULL); + gchar *separator = G_DIR_SEPARATOR_S; + gchar *result; + + if (force_slashes) { + gchar **splitted; + splitted = g_strsplit (sysconfdir, "\\", -1); + g_free (sysconfdir); + sysconfdir = g_strjoinv ("/", splitted); + g_strfreev (splitted); + separator = "/"; + } + + result = g_build_path (separator, sysconfdir, "gconf", "gconf.xml.defaults", + (gchar*)NULL); g_free (sysconfdir); //printf("Returning gconfdir %s\n", result); return result; diff --git a/src/engine/gnc-path.h b/src/engine/gnc-path.h index a733f1bc6a..c54dacf942 100644 --- a/src/engine/gnc-path.h +++ b/src/engine/gnc-path.h @@ -77,8 +77,11 @@ gchar *gnc_path_get_accountsdir(void); /** Returns the gconf schema config source path, usually * "$prefix/etc/gconf/gconf.xml.defaults". * + * @param force_slashes Use slashes as separator of the elements + * of the path. + * * @returns A newly allocated string. */ -gchar *gnc_path_get_gconfdir(void); +gchar *gnc_path_get_gconfdir(gboolean force_slashes); diff --git a/src/gnome-utils/druid-gconf-setup.c b/src/gnome-utils/druid-gconf-setup.c index 0bef0c5028..276f266c57 100644 --- a/src/gnome-utils/druid-gconf-setup.c +++ b/src/gnome-utils/druid-gconf-setup.c @@ -152,7 +152,7 @@ druid_gconf_update_path (GError **error) fprintf(output, "\n######## The following lines were added by GnuCash. ########\n"); if (!found_user_dir) fprintf(output, PATH_STRING1); - gconfdir = gnc_path_get_gconfdir (); + gconfdir = gnc_path_get_gconfdir (TRUE); fprintf(output, PATH_STRING2, gconfdir); g_free (gconfdir); fprintf(output, "############## End of lines added by GnuCash. ##############\n"); @@ -287,7 +287,7 @@ druid_gconf_update_page_prepare (GnomeDruidPage *druidpage, GtkTextBuffer *textbuffer; GtkWidget *textview; gchar *msg; - gchar *gconfdir = gnc_path_get_gconfdir (); + gchar *gconfdir = gnc_path_get_gconfdir (TRUE); textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_text"); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); @@ -614,6 +614,25 @@ druid_gconf_install_check_schemas (void) return; } +#ifdef _WIN32 + { + /* automatically update the search path on windows */ + GError *error = NULL; + if (!druid_gconf_update_path (&error)) { + gnc_error_dialog (NULL, error->message); + g_error_free (error); + exit(42); + } else { + if (!g_spawn_command_line_sync("gconftool-2 --shutdown", NULL, NULL, + NULL, &error)) { + gnc_warning_dialog(NULL, error->message); + g_error_free(error); + } + return; + } + } +#endif /* _WIN32 */ + xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Query"); dialog = glade_xml_get_widget (xml, "GConf Query"); do {