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

Neil Williams linux at codehelp.co.uk
Wed Jan 11 04:42:10 EST 2006


On Wednesday 11 January 2006 6:11 am, Chris Shoemaker wrote:
> Something like this would be a next logical small step for migrating
> the startup sequence from scheme to C.

I've gone one stage further than this in the cashutil branch but some of the 
changes in this step could help me get that working. I'm skipping the loading 
of modules via scheme and loading the splash screen and main window via C.

It'd be nice if we could work together on that version.

> 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.

You need a setlocale() call first and IIRC, ENABLE_NLS is the standard macro 
test, rather than our own HAVE_GETTEXT.

> +    /* Does order matter here? */
> +#ifdef HAVE_GETTEXT
> +    bindtextdomain (TEXT_DOMAIN, LOCALE_DIR);
> +    textdomain (TEXT_DOMAIN);
> +    bind_textdomain_codeset (TEXT_DOMAIN, "UTF-8");
> +#endif

        #ifdef ENABLE_NLS
        setlocale (LC_ALL, "");
        bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
        #endif

I'm not sure why you're using TEXT_DOMAIN and my snippet uses GETTEXT_PACKAGE. 
What's the content of TEXT_DOMAIN?

One alternative is to skip the lot and just call:
        gtk_set_locale ();
;-)

> +
> +    gtk_init (&argc, &argv);
> +    gnc_module_system_init();
> +
>      scm_boot_guile(argc, argv, inner_main, 0);

I've moved that one stage deeper, removing the need for commandline.scm and 
main.scm.

>      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 ""))

Here's your setlocale() call. I think this should be moved to within the 
#ifdef in the C. In effect, you've disabled the setlocalte() call in scheme 
without replicating it in C. (AFAICT anyway).

>      (gnc:module-load "gnucash/app-utils" 0)
> -    (gnc:setup-gettext)
> +    ;;(gnc:setup-gettext)

I suspect this is where TEXT_DOMAIN comes from too, only it won't anymore.

-- 

Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20060111/35166c6e/attachment.bin


More information about the gnucash-devel mailing list