r14822 - gnucash/trunk/src - Replace every hard-coded directory path with the respective call to gnc_path.

Christian Stimming cstim at cvs.gnucash.org
Thu Sep 7 17:02:08 EDT 2006


Author: cstim
Date: 2006-09-07 17:02:07 -0400 (Thu, 07 Sep 2006)
New Revision: 14822
Trac: http://svn.gnucash.org/trac/changeset/14822

Modified:
   gnucash/trunk/src/bin/gnucash-bin.c
   gnucash/trunk/src/engine/gnc-engine.c
   gnucash/trunk/src/engine/gnc-path.c
   gnucash/trunk/src/gnome-utils/Makefile.am
   gnucash/trunk/src/gnome-utils/dialog-utils.c
   gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
   gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
   gnucash/trunk/src/gnome/druid-hierarchy.c
Log:
Replace every hard-coded directory path with the respective call to gnc_path.
(Except for the qsf and dwi backends, but they are not being maintained right now anyway.)

Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/bin/gnucash-bin.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -33,7 +33,7 @@
 #include <libgnome/libgnome.h>
 #include "glib.h"
 #include "gnc-module.h"
-#include "i18n.h"
+#include "gnc-path.h"
 #include "gnc-version.h"
 #include "gnc-engine.h"
 #include "gnc-filepath-utils.h"
@@ -491,14 +491,15 @@
 
 int main(int argc, char ** argv)
 {
-
+    gchar *localedir = gnc_path_get_localedir ();
 #ifdef HAVE_GETTEXT
     /* setlocale (LC_ALL, ""); is already called by gtk_set_locale()
        via gtk_init(). */
-    bindtextdomain (TEXT_DOMAIN, LOCALE_DIR);
-    textdomain (TEXT_DOMAIN);
-    bind_textdomain_codeset (TEXT_DOMAIN, "UTF-8");
+    bindtextdomain (GETTEXT_PACKAGE, localedir);
+    textdomain (GETTEXT_PACKAGE);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 #endif
+    g_free (localedir);
 
     gnc_module_system_init();
     envt_override();

Modified: gnucash/trunk/src/engine/gnc-engine.c
===================================================================
--- gnucash/trunk/src/engine/gnc-engine.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/engine/gnc-engine.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -42,7 +42,7 @@
 #define GNC_LIB_NAME "gnc-backend-file"
 
 /* gnc-backend-file location */
-#include "gncla-dir.h"
+#include "gnc-path.h"
 
 static GList * engine_init_hooks = NULL;
 static int engine_is_initialized = 0;
@@ -76,17 +76,17 @@
 gnc_engine_init(int argc, char ** argv)
 {
   static struct {
-    const gchar* dir;
     const gchar* lib;
     gboolean required;
   } libs[] = {
-    { GNC_LIBDIR, GNC_LIB_NAME, TRUE },
+    { GNC_LIB_NAME, TRUE },
     /* shouldn't the PG gnc-module do this instead of US doing it? */
-    { GNC_LIBDIR, "gnc-backend-postgres", FALSE },
-    { NULL, NULL, FALSE } }, *lib;
+    { "gnc-backend-postgres", FALSE },
+    { NULL, FALSE } }, *lib;
   gnc_engine_init_hook_t hook;
   GList * cur;
   gchar *tracefilename;
+  gchar *pkglibdir;
 
   if (1 == engine_is_initialized) return;
 
@@ -107,15 +107,16 @@
   /* Now register our core types */
   cashobjects_register();
 
-  for (lib = libs; lib->dir && lib->lib ; lib++)
+  pkglibdir = gnc_path_get_pkglibdir ();
+  for (lib = libs; lib->lib ; lib++)
   {
-      if (qof_load_backend_library(lib->dir, lib->lib))
+      if (qof_load_backend_library(pkglibdir, lib->lib))
       {
           engine_is_initialized = 1;
       }
       else
       {
-          g_message("failed to load %s from %s\n", lib->lib, lib->dir);
+	  g_message("failed to load %s from %s\n", lib->lib, pkglibdir);
 	  /* If this is a required library, stop now! */
 	  if (lib->required)
 	  {
@@ -123,6 +124,7 @@
 	  }
       }
   }
+  g_free (pkglibdir);
 
   /* call any engine hooks */
   for (cur = engine_init_hooks; cur; cur = cur->next)

Modified: gnucash/trunk/src/engine/gnc-path.c
===================================================================
--- gnucash/trunk/src/engine/gnc-path.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/engine/gnc-path.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -71,7 +71,14 @@
  * @returns A newly allocated string. */
 gchar *gnc_path_get_gladedir()
 {
-  return g_strdup (GNC_GLADE_DIR);
+  gchar *result;
+#ifdef G_OS_WIN32
+  result = g_win32_get_package_installation_subdirectory
+    (GETTEXT_PACKAGE, NULL, "share\\gnucash\\glade");
+#else
+  result = g_strdup (GNC_GLADE_DIR);
+#endif
+  return result;
 }
 
 /** Returns the localedir path, usually
@@ -89,7 +96,15 @@
  * @returns A newly allocated string. */
 gchar *gnc_path_get_accountsdir()
 {
-  return g_strdup (GNC_ACCOUNTS_DIR);
+  gchar *result;
+#ifdef G_OS_WIN32
+  result = 
+    g_win32_get_package_installation_subdirectory
+    (GETTEXT_PACKAGE, NULL, "share\\gnucash\\accounts");
+#else
+  result = g_strdup (GNC_ACCOUNTS_DIR);
+#endif
+  return result;
 }
 
 /** Returns the gconf schema config source path, usually

Modified: gnucash/trunk/src/gnome/druid-hierarchy.c
===================================================================
--- gnucash/trunk/src/gnome/druid-hierarchy.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/gnome/druid-hierarchy.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -43,7 +43,7 @@
 #include "gnc-gconf-utils.h"
 #include "gnc-hooks.h"
 #include "gnc-component-manager.h"
-#include "../gnome-utils/gnc-dir.h"
+#include "gnc-path.h"
 #include "gnc-gui-query.h"
 #include "gnc-tree-view-account.h"
 #include "gnc-ui-util.h"
@@ -367,13 +367,7 @@
 	GtkTreeSelection *selection;
 	GtkTreePath *path;
 
-#ifdef G_OS_WIN32
-	gnc_accounts_dir = 
-	  g_win32_get_package_installation_subdirectory
-	  (GETTEXT_PACKAGE, NULL, "share\\gnucash\\accounts");
-#else
-	gnc_accounts_dir = g_strdup (GNC_ACCOUNTS_DIR);
-#endif
+	gnc_accounts_dir = gnc_path_get_accountsdir ();
 	locale_dir = gnc_get_ea_locale_dir (gnc_accounts_dir);
  	list = gnc_load_example_account_list (data->temporary,
 					      locale_dir);

Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/gnome-utils/Makefile.am	2006-09-07 21:02:07 UTC (rev 14822)
@@ -6,10 +6,6 @@
 # Note that src/gnome-utils CANNOT depend on src/gnome!
 
 AM_CFLAGS = \
-  -DPREFIX=\"${prefix}\" \
-  -DSYSCONFDIR=\"${GNC_CONFIGDIR}\" \
-  -DDATADIR=\"${GNC_SHAREDIR}\" \
-  -DLIBDIR=\"${GNC_LIBDIR}\" \
   -I${top_srcdir}/src/core-utils \
   -I${top_srcdir}/src/gnc-module \
   -I${top_srcdir}/src/engine \

Modified: gnucash/trunk/src/gnome-utils/dialog-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-utils.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/gnome-utils/dialog-utils.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -38,7 +38,7 @@
 #include "dialog-utils.h"
 #include "gnc-commodity.h"
 #include "Group.h"
-#include "gnc-dir.h"
+#include "gnc-path.h"
 #include "gnc-engine.h"
 #include "gnc-euro.h"
 #include "gnc-ui-util.h"
@@ -821,13 +821,7 @@
     glade_inited = TRUE;
   }
 
-#ifdef G_OS_WIN32
-  gnc_glade_dir = g_win32_get_package_installation_subdirectory
-    (GETTEXT_PACKAGE, NULL, "share\\gnucash\\glade");
-#else
-  gnc_glade_dir = g_strdup (GNC_GLADE_DIR);
-#endif
-
+  gnc_glade_dir = gnc_path_get_gladedir ();
   fname = g_build_filename(gnc_glade_dir, filename, (char *)NULL);
   g_free (gnc_glade_dir);
 

Modified: gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-gconf-setup.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/gnome-utils/druid-gconf-setup.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -41,7 +41,7 @@
 #include "dialog-utils.h"
 #include "druid-gconf-setup.h"
 #include "druid-utils.h"
-#include "gnc-dir.h"
+#include "gnc-path.h"
 #include "gnc-gconf-utils.h"
 #include "gnc-gui-query.h"
 #include "gnc-gnome-utils.h"
@@ -113,6 +113,7 @@
   gchar *contents, **lines, *line;
   gboolean found_user_dir = FALSE;
   FILE *output;
+  gchar *gconfdir;
 
   data_filename = g_build_filename(g_get_home_dir(), ".gconf", (char *)NULL);
   path_filename = g_build_filename(g_get_home_dir(), ".gconf.path", (char *)NULL);
@@ -151,7 +152,9 @@
   fprintf(output, "\n######## The following lines were added by GnuCash. ########\n");
   if (!found_user_dir)
     fprintf(output, PATH_STRING1);
-  fprintf(output, PATH_STRING2, GNC_GCONF_DIR);
+  gconfdir = gnc_path_get_gconfdir ();
+  fprintf(output, PATH_STRING2, gconfdir);
+  g_free (gconfdir);
   fprintf(output,   "############## End of lines added by GnuCash. ##############\n");
   if (fclose(output) != 0)  {
     *error = g_error_new (G_FILE_ERROR,
@@ -284,11 +287,13 @@
   GtkTextBuffer *textbuffer;
   GtkWidget *textview;
   gchar *msg;
+  gchar *gconfdir = gnc_path_get_gconfdir ();
 
   textview = gnc_glade_lookup_widget(GTK_WIDGET(druidpage), "update_text");
   textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
-  msg = g_strdup_printf(PATH_STRING1 PATH_STRING2, GNC_GCONF_DIR);
+  msg = g_strdup_printf(PATH_STRING1 PATH_STRING2, gconfdir);
   gtk_text_buffer_set_text(textbuffer, msg, -1);
+  g_free (gconfdir);
 }
 
 

Modified: gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c	2006-09-07 20:37:53 UTC (rev 14821)
+++ gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c	2006-09-07 21:02:07 UTC (rev 14822)
@@ -38,6 +38,7 @@
 #include "gnc-gnome-utils.h"
 #include "gnc-html.h"
 #include "gnc-engine.h"
+#include "gnc-path.h"
 #include "gnc-ui.h"
 #include "gnc-file.h"
 #include "gnc-hooks.h"
@@ -193,12 +194,24 @@
 {
   char *fullname;
   GError *error = NULL;
+  gchar *prefix = gnc_path_get_prefix ();
+  gchar *sysconfdir = gnc_path_get_sysconfdir ();
+  gchar *datadir = gnc_path_get_datadir ();
+  gchar *libdir = gnc_path_get_libdir ();
 
   gnc_gtk_add_rc_file();
   gnucash_program = gnome_program_init(
       "gnucash", version, LIBGNOMEUI_MODULE,
       argc, argv,
-      GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_NONE);
+      GNOME_PARAM_APP_PREFIX, prefix,
+      GNOME_PARAM_APP_SYSCONFDIR, sysconfdir,
+      GNOME_PARAM_APP_DATADIR, datadir,
+      GNOME_PARAM_APP_LIBDIR, libdir,
+      GNOME_PARAM_NONE);
+  g_free (prefix);
+  g_free (sysconfdir);
+  g_free (datadir);
+  g_free (libdir);
 
   /* initialization required for gtkhtml */
   gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());



More information about the gnucash-changes mailing list