[Patch Preview] move module-init and locale setup from scm to C

Chris Shoemaker c.shoemaker at cox.net
Wed Jan 11 01:11:52 EST 2006


Something like this would be a next logical small step for migrating
the startup sequence from scheme to C.  I've given this some light
testing with alternate locales and it seems to work for me, but I'm
not very familiar with gettext/intl stuff, so please speak up if this
looks wrong.

-chris


Index: src/bin/Makefile.am
===================================================================
--- src/bin/Makefile.am.orig
+++ src/bin/Makefile.am
@@ -1,11 +1,13 @@
 # Order is important here.
 SUBDIRS = . overrides test
 
-AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS}
+AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS} ${GNOME_CFLAGS} ${GTK_CFLAGS} \
+-I${top_builddir}/src/gnc-module
 
 bin_PROGRAMS = gnucash-bin
 gnucash_bin_SOURCES = gnucash-bin.c
-gnucash_bin_LDADD = ${GUILE_LIBS} ${GLIB_LIBS}
+gnucash_bin_LDADD = ${GUILE_LIBS} ${GLIB_LIBS} ${GNOME_LIBS} ${GTK_LIBS} \
+${top_srcdir}/src/gnc-module/libgncmodule.la
 
 gnucash: gnucash.in ${top_builddir}/config.status
 	rm -f $@.tmp
Index: src/bin/gnucash-bin.c
===================================================================
--- src/bin/gnucash-bin.c.orig
+++ src/bin/gnucash-bin.c
@@ -25,6 +25,8 @@
 #include <stdio.h>
 #include <libguile.h>
 #include "glib.h"
+#include <gtk/gtk.h>
+#include "gnc-module.h"
 
 static void
 inner_main (void *closure, int argc, char **argv)
@@ -38,6 +40,17 @@ inner_main (void *closure, int argc, cha
 
 int main(int argc, char ** argv)
 {
+
+    /* Does order matter here? */
+#ifdef HAVE_GETTEXT
+    bindtextdomain (TEXT_DOMAIN, LOCALE_DIR);
+    textdomain (TEXT_DOMAIN);
+    bind_textdomain_codeset (TEXT_DOMAIN, "UTF-8");
+#endif
+
+    gtk_init (&argc, &argv);
+    gnc_module_system_init();
+
     scm_boot_guile(argc, argv, inner_main, 0);
     exit(0); /* never reached */
 }
Index: src/scm/main.scm
===================================================================
--- src/scm/main.scm.orig
+++ src/scm/main.scm
@@ -366,10 +366,10 @@ string and 'directories' must be a list 
   (gnc:setup-debugging)
 
   ;; before doing ANYTHING, set the locale!
-  (false-if-exception (setlocale LC_ALL ""))
+  ;;;(false-if-exception (setlocale LC_ALL ""))
 
   ;; initialize the gnucash module system 
-  (gnc:module-system-init)
+  ;;;(gnc:module-system-init)
   
   ;; SUPER UGLY HACK -- this should go away when I come back for the
   ;; second cleanup pass...
@@ -379,20 +379,22 @@ string and 'directories' must be a list 
     (set-current-module bootstrap)
     
     (gnc:module-load "gnucash/app-utils" 0)
-    (gnc:setup-gettext)
+    ;;(gnc:setup-gettext)
     ;; Now we can load a bunch of files.
     (load-from-path "path.scm")
     (load-from-path "command-line.scm") ;; depends on app-utils (N_, etc.)...
     )
 
-  (gnc:initialize-config-vars)
+  (gnc:initialize-config-vars) ;; in command-line.scm
+  ;; handle unrecognized command line args
   (if (not (gnc:handle-command-line-args))
       (gnc:shutdown 1))
+  ;; handle --version
   (if (gnc:config-var-value-get gnc:*arg-show-version*)
       (begin
         (gnc:prefs-show-version)
         (gnc:shutdown 0)))
-
+  ;; handle --help
   (if (or (gnc:config-var-value-get gnc:*arg-show-usage*)
           (gnc:config-var-value-get gnc:*arg-show-help*))
       (begin
@@ -403,7 +405,7 @@ string and 'directories' must be a list 
   (gnc:debug "starting up (2).")
 
   ;; initialize the gnucash module system 
-  (gnc:module-system-init)
+  ;;;(gnc:module-system-init)
   
   ;; SUPER UGLY HACK -- this should go away when I come back for the
   ;; second cleanup pass...


More information about the gnucash-devel mailing list