r15067 - gnucash/trunk/src - Automatically update the gconf search path on windows. Add a

Andreas Köhler andi5 at cvs.gnucash.org
Wed Nov 1 14:36:07 EST 2006


Author: andi5
Date: 2006-11-01 14:36:06 -0500 (Wed, 01 Nov 2006)
New Revision: 15067
Trac: http://svn.gnucash.org/trac/changeset/15067

Modified:
   gnucash/trunk/src/engine/gnc-path.c
   gnucash/trunk/src/engine/gnc-path.h
   gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
Log:
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).


Modified: gnucash/trunk/src/engine/gnc-path.c
===================================================================
--- gnucash/trunk/src/engine/gnc-path.c	2006-11-01 00:01:35 UTC (rev 15066)
+++ gnucash/trunk/src/engine/gnc-path.c	2006-11-01 19:36:06 UTC (rev 15067)
@@ -121,11 +121,23 @@
  * "$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;

Modified: gnucash/trunk/src/engine/gnc-path.h
===================================================================
--- gnucash/trunk/src/engine/gnc-path.h	2006-11-01 00:01:35 UTC (rev 15066)
+++ gnucash/trunk/src/engine/gnc-path.h	2006-11-01 19:36:06 UTC (rev 15067)
@@ -77,8 +77,11 @@
 /** 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);
 
 
 

Modified: gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-gconf-setup.c	2006-11-01 00:01:35 UTC (rev 15066)
+++ gnucash/trunk/src/gnome-utils/druid-gconf-setup.c	2006-11-01 19:36:06 UTC (rev 15067)
@@ -152,7 +152,7 @@
   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 @@
   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 @@
     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 {



More information about the gnucash-changes mailing list