Skip to content

Commit d10178c

Browse files
committed
Move gnu-module init and gettext init from scm to C.
Move i18n.h.in from src/app-utils to src/bin, where it is used. Remove unneeded gettext init code in src/app-utils git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12337 57a11ea4-9604-0410-9ed3-97b8803252fd
1 parent f12f913 commit d10178c

File tree

8 files changed

+44
-61
lines changed

8 files changed

+44
-61
lines changed

src/app-utils/Makefile.am

+3-20
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ gncinclude_HEADERS = \
6262
gnc-ui-common.h \
6363
gnc-ui-util.h \
6464
guile-util.h \
65-
option-util.h \
66-
i18n.h
65+
option-util.h
6766

6867
noinst_HEADERS = \
6968
gw-app-utils.h
@@ -102,23 +101,7 @@ noinst_DATA = .scm-links
102101
EXTRA_DIST = \
103102
${gncmod_DATA} \
104103
${gncscm_DATA} \
105-
${gwmod_DATA} \
106-
i18n.h.in
107-
108-
## We borrow guile's convention and use @-...-@ as the substitution
109-
## brackets here, instead of the usual @...@. This prevents autoconf
110-
## from substituting the values directly into the left-hand sides of
111-
## the sed substitutions.
112-
i18n.h: i18n.h.in ${top_builddir}/config.status
113-
rm -f $@.tmp
114-
sed < $< > $@.tmp \
115-
-e 's:@-PACKAGE-@:${PACKAGE}:g' \
116-
-e 's:@-LOCALE_DIR-@:${LOCALE_DIR}:g'
117-
mv $@.tmp $@
118-
119-
# This has to be in BUILT_SOURCES because other files depend on it,
120-
# but it's never a target itself.
121-
BUILT_SOURCES = i18n.h
104+
${gwmod_DATA}
122105

123106
if GNUCASH_SEPARATE_BUILDDIR
124107
#For compiling
@@ -147,6 +130,6 @@ gw-app-utils.scm gw-app-utils.c gw-app-utils.h: \
147130
(primitive-load \"./gw-app-utils-spec.scm\") \
148131
(gw:generate-wrapset \"gw-app-utils\")"
149132

150-
BUILT_SOURCES += gw-app-utils.scm gw-app-utils.c gw-app-utils.h
133+
BUILT_SOURCES = gw-app-utils.scm gw-app-utils.c gw-app-utils.h
151134
DISTCLEANFILES = ${SCM_FILE_LINKS} gnucash g-wrapped .scm-links \
152135
gw-app-utils.html

src/app-utils/gnc-gettext-util.c

-14
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <glib/gi18n.h>
2626
#include <string.h>
2727

28-
#include "i18n.h"
2928
#include "gnc-gettext-util.h"
3029

3130
/* ============================================================== */
@@ -36,16 +35,3 @@ gnc_gettext_helper(const char *string)
3635
return strdup(_(string));
3736
}
3837

39-
/* ============================================================== */
40-
41-
void
42-
gnc_setup_gettext(void)
43-
{
44-
#ifdef HAVE_GETTEXT
45-
bindtextdomain (TEXT_DOMAIN, LOCALE_DIR);
46-
textdomain (TEXT_DOMAIN);
47-
bind_textdomain_codeset (TEXT_DOMAIN, "UTF-8");
48-
#endif
49-
}
50-
51-
/* ============================================================== */

src/app-utils/gnc-gettext-util.h

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#ifndef GNC_GETTEXT_UTIL_H
2323
#define GNC_GETTEXT_UTIL_H
2424

25-
void gnc_setup_gettext(void);
2625
char * gnc_gettext_helper(const char * str);
2726

2827
#endif

src/app-utils/gw-app-utils-spec.scm

-8
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,6 @@
9999
(<gw:bool> monetary))
100100
"Parse the expression and return either a gnc numeric or #f.")
101101

102-
(gw:wrap-function
103-
ws
104-
'gnc:setup-gettext
105-
'<gw:void>
106-
"gnc_setup_gettext"
107-
'()
108-
"Runs bindtextdomain and textdomain.")
109-
110102
(gw:wrap-function
111103
ws
112104
'gnc:gettext-helper

src/bin/Makefile.am

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Order is important here.
22
SUBDIRS = . overrides test
33

4-
AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS}
4+
AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS} ${GNOME_CFLAGS} ${GTK_CFLAGS} \
5+
-I${top_builddir}/src/gnc-module
56

67
bin_PROGRAMS = gnucash-bin
78
gnucash_bin_SOURCES = gnucash-bin.c
8-
gnucash_bin_LDADD = ${GUILE_LIBS} ${GLIB_LIBS}
9+
gnucash_bin_LDADD = ${GUILE_LIBS} ${GLIB_LIBS} ${GNOME_LIBS} ${GTK_LIBS} \
10+
${top_srcdir}/src/gnc-module/libgncmodule.la
911

1012
gnucash: gnucash.in ${top_builddir}/config.status
1113
rm -f $@.tmp
@@ -21,6 +23,16 @@ gnucash: gnucash.in ${top_builddir}/config.status
2123
mv $@.tmp $@
2224
chmod u+x $@
2325

26+
BUILT_SOURCES = i18n.h
27+
28+
i18n.h: i18n.h.in ${top_builddir}/config.status
29+
rm -f $@.tmp
30+
sed < $< > $@.tmp \
31+
-e 's:@-PACKAGE-@:${PACKAGE}:g' \
32+
-e 's:@-LOCALE_DIR-@:${LOCALE_DIR}:g'
33+
mv $@.tmp $@
34+
35+
2436
gnucash-valgrind: gnucash-valgrind.in ${top_builddir}/config.status
2537
rm -f $@.tmp
2638
sed < $< > $@.tmp \
@@ -60,7 +72,7 @@ bin_SCRIPTS = ${gnc_common_scripts} update-gnucash-gconf gnucash gnucash-valgrin
6072
# if you change gncoverridedir, make sure you change ./overrides/Makefile.am too.
6173
gncoverridesdir = ${GNC_LIBEXECDIR}/overrides
6274

63-
EXTRA_DIST = generate-gnc-script update-gnucash-gconf.in
75+
EXTRA_DIST = generate-gnc-script update-gnucash-gconf.in i18n.h.in
6476

6577
## Gnucash scripts -- real code is in overrides, these just get you there.
6678
${gnc_common_scripts}: generate-gnc-script ${top_builddir}/config.status

src/bin/gnucash-bin.c

+13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
#include <stdlib.h>
2525
#include <stdio.h>
2626
#include <libguile.h>
27+
#include <gtk/gtk.h>
2728
#include "glib.h"
29+
#include "gnc-module.h"
30+
#include "i18n.h"
2831

2932
static void
3033
inner_main (void *closure, int argc, char **argv)
@@ -38,6 +41,16 @@ inner_main (void *closure, int argc, char **argv)
3841

3942
int main(int argc, char ** argv)
4043
{
44+
45+
#ifdef HAVE_GETTEXT
46+
bindtextdomain (TEXT_DOMAIN, LOCALE_DIR);
47+
textdomain (TEXT_DOMAIN);
48+
bind_textdomain_codeset (TEXT_DOMAIN, "UTF-8");
49+
#endif
50+
51+
gtk_init (&argc, &argv);
52+
gnc_module_system_init();
53+
4154
scm_boot_guile(argc, argv, inner_main, 0);
4255
exit(0); /* never reached */
4356
}
File renamed without changes.

src/scm/main.scm

+13-15
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,6 @@ string and 'directories' must be a list of strings."
365365
(gnc:debug "starting up (1).")
366366
(gnc:setup-debugging)
367367

368-
;; before doing ANYTHING, set the locale!
369-
(false-if-exception (setlocale LC_ALL ""))
370-
371-
;; initialize the gnucash module system
372-
(gnc:module-system-init)
373-
374368
;; SUPER UGLY HACK -- this should go away when I come back for the
375369
;; second cleanup pass...
376370
(let ((original-module (current-module))
@@ -379,20 +373,21 @@ string and 'directories' must be a list of strings."
379373
(set-current-module bootstrap)
380374

381375
(gnc:module-load "gnucash/app-utils" 0)
382-
(gnc:setup-gettext)
383376
;; Now we can load a bunch of files.
384377
(load-from-path "path.scm")
385378
(load-from-path "command-line.scm") ;; depends on app-utils (N_, etc.)...
386379
)
387380

388-
(gnc:initialize-config-vars)
381+
(gnc:initialize-config-vars) ;; in command-line.scm
382+
;; handle unrecognized command line args
389383
(if (not (gnc:handle-command-line-args))
390384
(gnc:shutdown 1))
385+
;; handle --version
391386
(if (gnc:config-var-value-get gnc:*arg-show-version*)
392387
(begin
393388
(gnc:prefs-show-version)
394389
(gnc:shutdown 0)))
395-
390+
;; handle --help
396391
(if (or (gnc:config-var-value-get gnc:*arg-show-usage*)
397392
(gnc:config-var-value-get gnc:*arg-show-help*))
398393
(begin
@@ -402,9 +397,6 @@ string and 'directories' must be a list of strings."
402397
(define (gnc:startup-pass-2)
403398
(gnc:debug "starting up (2).")
404399

405-
;; initialize the gnucash module system
406-
(gnc:module-system-init)
407-
408400
;; SUPER UGLY HACK -- this should go away when I come back for the
409401
;; second cleanup pass...
410402
(let ((original-module (current-module))
@@ -585,18 +577,23 @@ string and 'directories' must be a list of strings."
585577
;; Now the fun begins.
586578
(gnc:startup-pass-1)
587579
(gnc:print-unstable-message)
580+
588581
(if (null? gnc:*batch-mode-things-to-do*)
589582
(begin
590583
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:gui-finish)
584+
;; We init splash before gui-init, but gui-init will do the
585+
;; splash itself.
591586
(set! gnc:*command-line-remaining*
592587
(gnc:gui-init-splash gnc:*command-line-remaining*))))
593588
(gnc:startup-pass-2)
594589

595590
(if (null? gnc:*batch-mode-things-to-do*)
596591
;; We're not in batch mode; we can go ahead and do the normal thing.
597592
(begin
593+
;; Why are we doing this again?
598594
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:gui-finish)
599-
(let* ((init-window-cons-rest (gnc:gui-init gnc:*command-line-remaining*))
595+
(let* ((init-window-cons-rest
596+
(gnc:gui-init gnc:*command-line-remaining*))
600597
(main-window (car init-window-cons-rest)))
601598
(set! gnc:*command-line-remaining* (cdr init-window-cons-rest))
602599
(if (and
@@ -611,9 +608,10 @@ string and 'directories' must be a list of strings."
611608
(gnc:main-window-set-progressbar-window main-window)
612609
(gnc:load-account-file)
613610
))
614-
;; no matter how or what we loaded, ensure the main-window title is valid...
611+
;; no matter how or what we loaded, ensure the main-window
612+
;; title is valid...
615613
(gnc:hook-run-danglers gnc:*ui-post-startup-hook*)
616-
(gnc:start-ui-event-loop)
614+
(gnc:start-ui-event-loop) ;; this won't return until we're exiting
617615
(gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:gui-finish)))
618616

619617
;; else: we're in batch mode. Just do what the user said on the

0 commit comments

Comments
 (0)