From 0a8c78bcc1ea6dc3755591be4dbd24ed0213cc8b Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Thu, 20 Sep 2001 09:18:50 +0000 Subject: [PATCH] Move preferences and configuration variables into app-utils modules. Much module refactoring & cleanup. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5391 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/app-file/gnc-file.c | 3 + src/app-file/gncmod-app-file.c | 20 +-- src/app-utils/Makefile.am | 2 + src/app-utils/app-utils.scm | 55 ++++++ src/{scm => app-utils}/config-var.scm | 9 +- src/app-utils/gnc-ui-util.h | 3 - src/app-utils/gw-app-utils-spec.scm | 20 ++- src/app-utils/option-util.c | 4 +- src/app-utils/options.scm | 7 +- src/{scm => app-utils}/prefs.scm | 128 ++------------ src/backend/file/gncmod-backend-file.c | 26 ++- .../postgres/gncmod-backend-postgres.c | 20 +-- src/backend/rpc/gncmod-backend-rpc.c | 20 +-- src/engine/commodity-table.scm | 8 - src/gnc-module/gnc-module.c | 22 +-- src/gnome-utils/test/Makefile.am | 2 +- src/gnome/top-level.c | 49 +----- src/gnome/top-level.h | 6 +- .../binary-import/gncmod-binary-import.c | 49 +++--- src/register/ledger-core/gncmod-ledger-core.c | 28 ++- .../register-core/gncmod-register-core.c | 22 ++- src/register/register-core/test/Makefile.am | 2 +- .../register-gnome/gncmod-register-gnome.c | 16 +- src/register/register-gnome/gnucash-style.c | 24 +-- src/register/register-gnome/gnucash-style.h | 3 - src/register/register-gnome/test/Makefile.am | 2 +- src/report/report-system/html-style-info.scm | 6 +- src/report/report-system/report-utilities.scm | 4 +- src/scm/Makefile.am | 2 - src/scm/bootstrap.scm.in | 2 +- src/scm/command-line.scm | 162 +++++++++++------- src/scm/main.scm | 25 --- src/scm/price-quotes.scm | 1 - src/scm/tip-of-the-day.scm | 6 - 34 files changed, 329 insertions(+), 429 deletions(-) rename src/{scm => app-utils}/config-var.scm (94%) rename src/{scm => app-utils}/prefs.scm (86%) diff --git a/src/app-file/gnc-file.c b/src/app-file/gnc-file.c index 57315a9ec1..ea7c952791 100644 --- a/src/app-file/gnc-file.c +++ b/src/app-file/gnc-file.c @@ -63,6 +63,9 @@ void gnc_file_init (void) { gnc_set_current_book_handler (gnc_get_current_book_internal); + + /* Make sure we have a curent book. */ + gnc_get_current_book_internal (); } static gboolean diff --git a/src/app-file/gncmod-app-file.c b/src/app-file/gncmod-app-file.c index 2c493563b2..3b60f4af24 100644 --- a/src/app-file/gncmod-app-file.c +++ b/src/app-file/gncmod-app-file.c @@ -43,18 +43,18 @@ lmod(char * mn) int gnc_module_init(int refcount) { + /* load the engine (we depend on it) */ + if(!gnc_module_load("gnucash/engine", 0)) { + return FALSE; + } + + /* load the calculation module (we depend on it) */ + if(!gnc_module_load("gnucash/app-utils", 0)) { + return FALSE; + } + if (refcount == 0) { - /* load the engine (we depend on it) */ - if(!gnc_module_load("gnucash/engine", 0)) { - return FALSE; - } - - /* load the calculation module (we depend on it) */ - if(!gnc_module_load("gnucash/app-utils", 0)) { - return FALSE; - } - gnc_file_init (); } diff --git a/src/app-utils/Makefile.am b/src/app-utils/Makefile.am index d3b4480524..8a92ca3aba 100644 --- a/src/app-utils/Makefile.am +++ b/src/app-utils/Makefile.am @@ -55,9 +55,11 @@ gncmod_DATA = app-utils.scm gncscmdir = ${GNC_SHAREDIR}/scm gncscm_DATA = \ c-interface.scm \ + config-var.scm \ date-utilities.scm \ hooks.scm \ options.scm \ + prefs.scm \ utilities.scm gwmoddir = ${GNC_GWRAP_LIBDIR} diff --git a/src/app-utils/app-utils.scm b/src/app-utils/app-utils.scm index b8ea4ddc44..8a0dbba67c 100644 --- a/src/app-utils/app-utils.scm +++ b/src/app-utils/app-utils.scm @@ -88,6 +88,30 @@ (export gnc:send-options) (export gnc:save-options) +;; config-var.scm +(export gnc:make-config-var) +(export gnc:config-var-description-get) +(export gnc:config-var-action-func-get) +(export gnc:config-var-equality-func-get) +(export gnc:config-var-modified?) +(export gnc:config-var-modified?-set!) +(export gnc:config-var-default-value-get) +(export gnc:config-var-default-value-set!) +(export gnc:config-var-value-get) +(export gnc:config-var-value-set!) +(export gnc:config-var-value-is-default?) + +;; prefs.scm +(export gnc:register-configuration-option) +(export gnc:lookup-global-option) +(export gnc:send-global-options) +(export gnc:global-options-clear-changes) +(export gnc:save-all-options) +(export gnc:get-debit-string) +(export gnc:get-credit-string) +(export gnc:*options-entries*) +(export gnc:config-file-format-version) + ;; date-utilities.scm (export gnc:reldate-list) @@ -210,7 +234,38 @@ (export gnc:backtrace-if-exception) (load-from-path "c-interface.scm") +(load-from-path "config-var.scm") (load-from-path "options.scm") +(load-from-path "prefs.scm") (load-from-path "hooks.scm") (load-from-path "date-utilities.scm") (load-from-path "utilities.scm") + +(gnc:hook-add-dangler gnc:*startup-hook* + (lambda () + (begin + ;; Initialize the C side options code. + ;; Must come after the scheme options are loaded. + (gnc:c-options-init) + + ;; Initialize the expresion parser. + ;; Must come after the C side options initialization. + (gnc:exp-parser-init)))) + +;; add a hook to shut down the expression parser +(gnc:hook-add-dangler gnc:*shutdown-hook* + (lambda () + (begin + ;; Shutdown the expression parser + (gnc:exp-parser-shutdown) + + ;; This saves global options plus (for the + ;; moment) saved report and account tree + ;; window parameters. Reports and parameters + ;; should probably be in a separate file, + ;; with the main data file, or something + ;; else. + (gnc:save-all-options) + + ;; Shut down the C side options code + (gnc:c-options-shutdown)))) diff --git a/src/scm/config-var.scm b/src/app-utils/config-var.scm similarity index 94% rename from src/scm/config-var.scm rename to src/app-utils/config-var.scm index 1be7e77ef2..c567125f05 100644 --- a/src/scm/config-var.scm +++ b/src/app-utils/config-var.scm @@ -33,14 +33,12 @@ ;;; permanent, and if they leave the variable value different from the ;;; default, should be saved to the auto configuration file. -(gnc:support "config-var.scm") - (define (gnc:make-config-var description set-action-func equality-func default) - (let ((var - (vector description set-action-func equality-func #f default default))) + (let ((var (vector description set-action-func + equality-func #f default default))) (gnc:config-var-value-set! var #f default) var)) @@ -54,7 +52,8 @@ (define (gnc:config-var-modified?-set! var value) (vector-set! var 3 value)) (define (gnc:config-var-default-value-get var) (vector-ref var 4)) -(define (gnc:config-var-default-value-set! var value) (vector-set! var 4 value)) +(define (gnc:config-var-default-value-set! var value) + (vector-set! var 4 value)) (define (gnc:config-var-value-get var) (vector-ref var 5)) (define (gnc:config-var-value-set! var is-config-mod? value) diff --git a/src/app-utils/gnc-ui-util.h b/src/app-utils/gnc-ui-util.h index 1c5d470d5c..f845ed4ef3 100644 --- a/src/app-utils/gnc-ui-util.h +++ b/src/app-utils/gnc-ui-util.h @@ -44,9 +44,6 @@ char gnc_get_account_separator (void); gboolean gnc_reverse_balance(Account *account); gboolean gnc_reverse_balance_type(GNCAccountType type); -const char * gnc_register_default_font(void); -const char * gnc_register_default_hint_font(void); - /* Engine enhancements & i18n ***************************************/ void gnc_set_current_book_handler (GNCBookCB cb); diff --git a/src/app-utils/gw-app-utils-spec.scm b/src/app-utils/gw-app-utils-spec.scm index da725b496e..05c190d93f 100644 --- a/src/app-utils/gw-app-utils-spec.scm +++ b/src/app-utils/gw-app-utils-spec.scm @@ -42,6 +42,7 @@ "#include \n" "#include \n" "#include \n" + "#include \n" "#include \n" "#include \n" "#include \n" @@ -84,6 +85,23 @@ mod ' "GNCOptionChangeCallback" "const GNCOptionChangeCallback") + + (gw:wrap-function + mod + 'gnc:exp-parser-init + ' + "gnc_exp_parser_init" + '() + "Initialize the expression parser.") + + (gw:wrap-function + mod + 'gnc:exp-parser-shutdown + ' + "gnc_exp_parser_shutdown" + '() + "Shutdown the expression parser and free any associated memory.") + (gw:wrap-function mod 'gnc:gettext-helper @@ -139,7 +157,7 @@ (gw:wrap-function mod - 'gnc:amount->string-helper + 'gnc:amount->string '( gw:const) "xaccPrintAmount" '(( amount) diff --git a/src/app-utils/option-util.c b/src/app-utils/option-util.c index c05165ec58..606abb5e89 100644 --- a/src/app-utils/option-util.c +++ b/src/app-utils/option-util.c @@ -158,7 +158,9 @@ gnc_option_set_ui_value (GNCOption *option, gboolean use_default) { g_return_if_fail (option != NULL); g_return_if_fail (option->odb != NULL); - g_return_if_fail (option->odb->set_ui_value != NULL); + + if (!option->odb->set_ui_value) + return; option->odb->set_ui_value (option, use_default); } diff --git a/src/app-utils/options.scm b/src/app-utils/options.scm index 91a86779da..1d12cd7549 100644 --- a/src/app-utils/options.scm +++ b/src/app-utils/options.scm @@ -888,12 +888,7 @@ (lambda (option) (let ((value (gnc:option-value option)) (default-value (gnc:option-default-value option))) -; (if (and (pair? default-value)); (eqv? 'commodity-scm (car value))) -; (begin -; (write value) (newline) -; (write default-value) (newline))) - (if - (not (equal? value default-value)) + (if (not (equal? value default-value)) (let* ((generator (gnc:option-generate-restore-form option)) (restore-code (false-if-exception (generator)))) (if restore-code diff --git a/src/scm/prefs.scm b/src/app-utils/prefs.scm similarity index 86% rename from src/scm/prefs.scm rename to src/app-utils/prefs.scm index 7ac5d9376b..0b3779035e 100644 --- a/src/scm/prefs.scm +++ b/src/app-utils/prefs.scm @@ -56,8 +56,6 @@ ;; eq? ;; #f)) -(gnc:support "prefs.scm") - (define gnc:*options-entries* (gnc:new-options)) (define (gnc:register-configuration-option new-option) @@ -76,9 +74,8 @@ ;; it's important to make sure it happens in this order. later the ;; hook should probably revert back to just save-global-options. (define (gnc:save-all-options) - (gnc:save-global-options) -; (gnc:save-report-options); (gnc:save-acct-tree-options) - (gnc:save-style-sheet-options)) + (gnc:save-global-options)) +; (gnc:save-style-sheet-options)) (define (gnc:save-global-options) (gnc:make-home-dir) @@ -240,16 +237,20 @@ and expand the current transaction"))) "h" (N_ "If selected, use a dialog to confirm a change to a reconciled \ transaction.") #t)) +(define (string-take-n string n) + (substring string n (string-length string))) + (gnc:register-configuration-option (gnc:make-font-option (N_ "Register") (N_ "Register font") - "i" (N_ "The font to use in the register") (gnc:register-default-font))) + "i" (N_ "The font to use in the register") + (string-take-n (_ "register-default-font:-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*") 22))) (gnc:register-configuration-option (gnc:make-font-option (N_ "Register") (N_ "Register hint font") "j" (N_ "The font used to show hints in the register") - (gnc:register-default-hint-font))) + (string-take-n (_ "register-hint-font:-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*") 19))) ;; Register Color options @@ -557,8 +558,8 @@ without one.") (gnc:register-configuration-option (gnc:make-number-range-option (N_ "Scheduled Transactions") - (N_ "Default create-in-advance days") - "d" (N_ "Default number of days-in-advance to create new SXes") + (N_ "Default create in advance days") + "d" (N_ "Default number of days in advance to create new SXes") 0 ; default 0 ; min 99999999 ; max @@ -570,14 +571,14 @@ without one.") (gnc:make-number-range-option (N_ "Scheduled Transactions") (N_ "Default remind-in-advance days") - "e" (N_ "Default number of days-in-advance to remind on new SXes") + "e" (N_ "Default number of days in advance to remind on new SXes") 0 ; default 0 ; min 99999 ; max 0 ; num-decimals 1 ; step size )) - + (gnc:register-configuration-option (gnc:make-number-range-option (N_ "Scheduled Transactions") @@ -590,111 +591,6 @@ without one.") 1 ; step size )) -;;; Configuation variables - -(define gnc:*arg-show-version* - (gnc:make-config-var - (N_ "Show version.") - (lambda (var value) (if (boolean? value) (list value) #f)) - eq? - #f)) - -(define gnc:*arg-show-usage* - (gnc:make-config-var - (N_ "Generate an argument summary.") - (lambda (var value) (if (boolean? value) (list value) #f)) - eq? - #f)) - -(define gnc:*arg-show-help* - (gnc:make-config-var - (N_ "Generate an argument summary.") - (lambda (var value) (if (boolean? value) (list value) #f)) - eq? - #f)) - -(define gnc:*arg-no-file* - (gnc:make-config-var - (N_ "Don't load any file, including autoloading the last file.") - (lambda (var value) (if (boolean? value) (list value) #f)) - eq? - #f)) - -(define gnc:*config-dir* - (gnc:make-config-var - (N_ "Configuration directory.") - (lambda (var value) (if (string? value) (list value) #f)) - string=? - gnc:_config-dir-default_)) - -(define gnc:*share-dir* - (gnc:make-config-var - (N_ "Shared files directory.") - (lambda (var value) (if (string? value) (list value) #f)) - string=? - gnc:_share-dir-default_)) - -;; Convert the temporary startup value into a config var. -(let ((current-value gnc:*debugging?*)) - (set! - gnc:*debugging?* - (gnc:make-config-var - (N_ "Enable debugging code.") - (lambda (var value) (if (boolean? value) (list value) #f)) - eq? - #f)) - (gnc:config-var-value-set! gnc:*debugging?* #f current-value)) - -(let ((current-value gnc:*debugging?*)) - (set! - gnc:*develmode* - (gnc:make-config-var - (N_ "Enable developers mode.") - (lambda (var value) (if (boolean? value) (list value) #f)) - eq? - #f)) - (gnc:config-var-value-set! gnc:*develmode* #f current-value)) - -(define gnc:*loglevel* - (gnc:make-config-var - (N_ "Logging level from 0 (least logging) to 5 (most logging).") - (lambda (var value) (if (exact? value) (list value) #f)) - eq? - #f)) - -;; Convert the temporary startup value into a config var. -(let ((current-load-path gnc:*load-path*)) - (set! - gnc:*load-path* - (gnc:make-config-var - (N_ "A list of strings indicating the load path for (gnc:load name). -Each element must be a string representing a directory or a symbol -where 'default expands to the default path, and 'current expands to -the current value of the path.") - (lambda (var value) - (let ((result (gnc:expand-load-path value))) - (if (list? result) - (list result) - #f))) - equal? - '(default))) - (gnc:config-var-value-set! gnc:*load-path* #f current-load-path)) - -(define gnc:*doc-path* - - (gnc:make-config-var - (N_ "A list of strings indicating where to look for html and parsed-html files. \ -Each element must be a string representing a directory or a symbol \ -where 'default expands to the default path, and 'current expands to \ -the current value of the path.") - (lambda (var value) - (let ((result (gnc:_expand-doc-path_ value))) - (if (list? result) - (list result) - #f))) - equal? - '(default))) - ;;; Internal options -- Section names that start with "__" are not ;;; displayed in option dialogs. diff --git a/src/backend/file/gncmod-backend-file.c b/src/backend/file/gncmod-backend-file.c index c725c823ad..5c1203cb18 100644 --- a/src/backend/file/gncmod-backend-file.c +++ b/src/backend/file/gncmod-backend-file.c @@ -36,24 +36,22 @@ gnc_module_description(void) int gnc_module_init(int refcount) { - if(refcount == 0) - { - engine = gnc_module_load("gnucash/engine", 0); - - if(!engine) return FALSE; - } + engine = gnc_module_load("gnucash/engine", 0); + if(!engine) return FALSE; + return TRUE; } int gnc_module_end(int refcount) { - if((refcount == 0) && engine) - { - int unload = gnc_module_unload(engine); - engine = NULL; - return unload; - } - return TRUE; -} + int unload = TRUE; + if (engine) + unload = gnc_module_unload(engine); + + if (refcount == 0) + engine = NULL; + + return unload; +} diff --git a/src/backend/postgres/gncmod-backend-postgres.c b/src/backend/postgres/gncmod-backend-postgres.c index cca4cfba84..549b2abb31 100644 --- a/src/backend/postgres/gncmod-backend-postgres.c +++ b/src/backend/postgres/gncmod-backend-postgres.c @@ -40,24 +40,24 @@ gnc_module_description(void) int gnc_module_init(int refcount) { - if(refcount == 0) { - engine = gnc_module_load("gnucash/engine", 0); + engine = gnc_module_load("gnucash/engine", 0); + if(!engine) return FALSE; - if(!engine) return FALSE; - } return TRUE; } int gnc_module_end(int refcount) { - if((refcount == 0) && engine) - { - int unload = gnc_module_unload(engine); + int unload = TRUE; + + if (engine) + unload = gnc_module_unload(engine); + + if (refcount == 0) engine = NULL; - return unload; - } - return TRUE; + + return unload; } diff --git a/src/backend/rpc/gncmod-backend-rpc.c b/src/backend/rpc/gncmod-backend-rpc.c index 966643b1a3..c95a5b0967 100644 --- a/src/backend/rpc/gncmod-backend-rpc.c +++ b/src/backend/rpc/gncmod-backend-rpc.c @@ -40,24 +40,24 @@ gnc_module_description(void) int gnc_module_init(int refcount) { - if(refcount == 0) { - engine = gnc_module_load("gnucash/engine", 0); + engine = gnc_module_load("gnucash/engine", 0); + if(!engine) return FALSE; - if(!engine) return FALSE; - } return TRUE; } int gnc_module_end(int refcount) { - if((refcount == 0) && engine) - { - int unload = gnc_module_unload(engine); + int unload = TRUE; + + if (engine) + unload = gnc_module_unload(engine); + + if (refcount == 0) engine = NULL; - return unload; - } - return TRUE; + + return unload; } diff --git a/src/engine/commodity-table.scm b/src/engine/commodity-table.scm index ba8ef9b221..0197b43826 100644 --- a/src/engine/commodity-table.scm +++ b/src/engine/commodity-table.scm @@ -3,17 +3,9 @@ ;;; load and save commodity tables ;;; ;;; Bill Gribble 3 Aug 2000 -;;; $Id$ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;(define gnc:*iso-4217-currency-file* -;; (gnc:make-config-var -;; "Database of ISO-4217 currency definitions" -;; (lambda (var value) (if (string? value) (list value) #f)) -;; string=? -;; "iso-4217-currencies.scm")) - (define gnc:*iso-4217-currency-file* "iso-4217-currencies.scm") (define GNC_COMMODITY_NS_ISO "ISO4217") diff --git a/src/gnc-module/gnc-module.c b/src/gnc-module/gnc-module.c index a5e4a47782..fe0b9b4a9c 100644 --- a/src/gnc-module/gnc-module.c +++ b/src/gnc-module/gnc-module.c @@ -277,8 +277,7 @@ gnc_module_get_info(const char * fullpath) } else { - printf("\n** WARNING ** : module '%s' does not match module signature\n", - fullpath); + g_warning ("module '%s' does not match module signature\n", fullpath); lt_dlclose(handle); return NULL; } @@ -294,8 +293,7 @@ gnc_module_get_info(const char * fullpath) } else { - printf("\n** WARNING ** : Failed to dlopen() '%s': %s\n", - fullpath, lt_dlerror()); + g_warning ("Failed to dlopen() '%s': %s\n", fullpath, lt_dlerror()); return NULL; } } @@ -424,10 +422,12 @@ gnc_module_load(char * module_name, gint interface) } else { + g_warning ("module init failed: %s", module_name); return NULL; } } else { + g_warning ("module has no init func: %s", module_name); return NULL; } } @@ -455,7 +455,7 @@ gnc_module_load(char * module_name, gint interface) if(!info->init_func(0)) { /* init failed. unload the module. */ - printf("Initialization failed for module %s\n", module_name); + g_warning ("Initialization failed for module %s\n", module_name); g_hash_table_remove(loaded_modules, info); g_free(info->filename); g_free(info); @@ -467,18 +467,18 @@ gnc_module_load(char * module_name, gint interface) } else { - printf("Module %s (%s) is not a gnc-module.\n", module_name, - modinfo->module_filepath); + g_warning ("Module %s (%s) is not a gnc-module.\n", module_name, + modinfo->module_filepath); lt_dlclose(handle); } return info; } else { - printf("Failed to open module %s", module_name); + g_warning ("Failed to open module %s", module_name); if(modinfo) printf(": %s\n", lt_dlerror()); - else printf(": could not locate %s interface v.%d\n", - module_name, interface); + else g_warning (": could not locate %s interface v.%d\n", + module_name, interface); return NULL; } } @@ -524,7 +524,7 @@ gnc_module_unload(GNCModule module) } else { - printf("Failed to unload module %p (it is not loaded)\n", module); + g_warning ("Failed to unload module %p (it is not loaded)\n", module); return 0; } } diff --git a/src/gnome-utils/test/Makefile.am b/src/gnome-utils/test/Makefile.am index 76c73aaba3..bef2eb5ef0 100644 --- a/src/gnome-utils/test/Makefile.am +++ b/src/gnome-utils/test/Makefile.am @@ -6,7 +6,7 @@ TESTS_ENVIRONMENT= \ GNC_MODULE_PATH=../../engine:../../gnc-module:../../calculation:.. \ GUILE_LOAD_PATH=${G_WRAP_MODULE_DIR}:../../engine:..:../../gnc-module:${top_srcdir}/lib \ LTDL_LIBRARY_PATH=.. \ - LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs:${top_srcdir}/src/calculation:${top_srcdir}/src/calculation/.libs + LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs:${top_srcdir}/src/calculation:${top_srcdir}/src/calculation/.libs:${top_srcdir}/src/network-utils:${top_srcdir}/src/network-utils/.libs LDADD = \ -L${top_srcdir}/src/gnc-module -L${top_srcdir}/src/gnc-module/.libs \ diff --git a/src/gnome/top-level.c b/src/gnome/top-level.c index 79cb9933c3..3f6ba43f54 100644 --- a/src/gnome/top-level.c +++ b/src/gnome/top-level.c @@ -526,7 +526,6 @@ gnucash_ui_init(void) gnc_recn_cell_set_string_getter (gnc_get_reconcile_str); - /* gnc_default_ui_start */ gnucash_style_init(); gnucash_color_init(); @@ -558,17 +557,6 @@ gnucash_ui_init(void) return 0; } -static gboolean hasstarted = FALSE; -void -gnc_default_ui_start(void) -{ - if (!hasstarted) - { - hasstarted = TRUE; - gnc_get_current_book (); - } -} - /* ============================================================== */ void @@ -618,11 +606,10 @@ gnc_ui_destroy (void) /* ============================================================== */ int -gnc_ui_show_main_window(void) +gnc_ui_show_main_window (void) { /* Initialize gnome */ gnucash_ui_init(); - gnc_default_ui_start(); /* Get the main window on screen. */ while (gtk_events_pending()) @@ -707,15 +694,6 @@ gnc_ui_start_event_loop (void) return 0; } - -int -gnc_ui_main(void) -{ - gnc_ui_show_main_window(); - - return gnc_ui_start_event_loop(); -} - /* ============================================================== */ gboolean @@ -726,31 +704,6 @@ gnucash_ui_open_file(const char name[]) /* ============================================================== */ -int -gnucash_ui_select_file(void) -{ - gnc_file_open (); - return 1; -} - -/* ============================================================== */ - -const char * -gnc_register_default_font(void) -{ - return gnucash_style_get_default_register_font_name(); -} - -/* ============================================================== */ - -const char * -gnc_register_default_hint_font(void) -{ - return gnucash_style_get_default_register_hint_font_name(); -} - -/* ============================================================== */ - /* gnc_configure_date_format_cb * Callback called when options change - sets dateFormat to the current * value on the scheme side and refreshes register windows diff --git a/src/gnome/top-level.h b/src/gnome/top-level.h index 5283b82be4..8c3946ad09 100644 --- a/src/gnome/top-level.h +++ b/src/gnome/top-level.h @@ -31,17 +31,13 @@ gboolean gnucash_ui_is_running(void); gboolean gnucash_ui_is_terminating(void); int gnucash_ui_init(void); gboolean gnucash_ui_open_file(const char * name); -int gnucash_ui_select_file(void); GNCMainInfo * gnc_ui_get_data(void); -void gnc_default_ui_start(void); void gnc_ui_shutdown(void); void gnc_ui_destroy(void); int gnc_ui_show_main_window(void); int gnc_ui_start_event_loop(void); -int gnc_ui_main(void); -const char * gnc_register_default_font(void); -const char * gnc_register_default_hint_font(void); gboolean gnc_reverse_balance_type(GNCAccountType type); gboolean gnc_reverse_balance(Account *account); + #endif diff --git a/src/import-export/binary-import/gncmod-binary-import.c b/src/import-export/binary-import/gncmod-binary-import.c index 2d2efe0c80..166c206674 100644 --- a/src/import-export/binary-import/gncmod-binary-import.c +++ b/src/import-export/binary-import/gncmod-binary-import.c @@ -42,34 +42,31 @@ lmod(char * mn) int gnc_module_init(int refcount) { - if (refcount == 0) - { - /* load the engine (we depend on it) */ - if(!gnc_module_load("gnucash/engine", 0)) { - return FALSE; - } - - /* load the calculation module (we depend on it) */ - if(!gnc_module_load("gnucash/app-utils", 0)) { - return FALSE; - } - - /* load the calculation module (we depend on it) */ - if(!gnc_module_load("gnucash/app-file", 0)) { - return FALSE; - } - - /* load the calculation module (we depend on it) */ - if(!gnc_module_load("gnucash/gnome-utils", 0)) { - return FALSE; - } - - /* publish g-wrapped bindings */ - /* load the scheme code */ - lmod("(g-wrapped gw-binary-import)"); - lmod("(gnucash import-export binary-import)"); + /* load the engine (we depend on it) */ + if(!gnc_module_load("gnucash/engine", 0)) { + return FALSE; } + /* load the calculation module (we depend on it) */ + if(!gnc_module_load("gnucash/app-utils", 0)) { + return FALSE; + } + + /* load the calculation module (we depend on it) */ + if(!gnc_module_load("gnucash/app-file", 0)) { + return FALSE; + } + + /* load the calculation module (we depend on it) */ + if(!gnc_module_load("gnucash/gnome-utils", 0)) { + return FALSE; + } + + /* publish g-wrapped bindings */ + /* load the scheme code */ + lmod("(g-wrapped gw-binary-import)"); + lmod("(gnucash import-export binary-import)"); + return TRUE; } diff --git a/src/register/ledger-core/gncmod-ledger-core.c b/src/register/ledger-core/gncmod-ledger-core.c index 9dc12cd5c1..263bf05f42 100644 --- a/src/register/ledger-core/gncmod-ledger-core.c +++ b/src/register/ledger-core/gncmod-ledger-core.c @@ -30,22 +30,20 @@ gnc_module_description(void) { int gnc_module_init(int refcount) { - if(refcount == 0) + if(!gnc_module_load("gnucash/engine", 0)) { - if(!gnc_module_load("gnucash/engine", 0)) - { - return FALSE; - } - - if(!gnc_module_load("gnucash/register/register-core", 0)) - { - return FALSE; - } - - if(!gnc_module_load("gnucash/app-utils", 0)) - { - return FALSE; - } + return FALSE; } + + if(!gnc_module_load("gnucash/register/register-core", 0)) + { + return FALSE; + } + + if(!gnc_module_load("gnucash/app-utils", 0)) + { + return FALSE; + } + return TRUE; } diff --git a/src/register/register-core/gncmod-register-core.c b/src/register/register-core/gncmod-register-core.c index 2683891dee..366adcde81 100644 --- a/src/register/register-core/gncmod-register-core.c +++ b/src/register/register-core/gncmod-register-core.c @@ -30,20 +30,18 @@ gnc_module_description(void) { int gnc_module_init(int refcount) { - if(refcount == 0) + if(!gnc_module_load("gnucash/engine", 0)) { - if(!gnc_module_load("gnucash/engine", 0)) - { - return FALSE; - } - - /* FIXME. We need this for the wide-character functions. - * When fixing, get rid of gnome-utils includes, too. */ - if(!gnc_module_load("gnucash/gnome-utils", 0)) - { - return FALSE; - } + return FALSE; } + + /* FIXME. We need this for the wide-character functions. + * When fixing, get rid of gnome-utils includes, too. */ + if(!gnc_module_load("gnucash/gnome-utils", 0)) + { + return FALSE; + } + return TRUE; } diff --git a/src/register/register-core/test/Makefile.am b/src/register/register-core/test/Makefile.am index b4d15d1c86..818895fa49 100644 --- a/src/register/register-core/test/Makefile.am +++ b/src/register/register-core/test/Makefile.am @@ -6,7 +6,7 @@ TESTS_ENVIRONMENT= \ GNC_MODULE_PATH=../../engine:../../gnc-module:../../calculation:.. \ GUILE_LOAD_PATH=${G_WRAP_MODULE_DIR}:../../engine:..:../../gnc-module:${top_srcdir}/lib \ LTDL_LIBRARY_PATH=.. \ - LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs:${top_srcdir}/src/calculation:${top_srcdir}/src/calculation/.libs + LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs:${top_srcdir}/src/calculation:${top_srcdir}/src/calculation/.libs:${top_srcdir}/src/network-utils:${top_srcdir}/src/network-utils/.libs LDADD = \ -L${top_srcdir}/src/gnc-module -L${top_srcdir}/src/gnc-module/.libs \ diff --git a/src/register/register-gnome/gncmod-register-gnome.c b/src/register/register-gnome/gncmod-register-gnome.c index b113b2e331..73d041995a 100644 --- a/src/register/register-gnome/gncmod-register-gnome.c +++ b/src/register/register-gnome/gncmod-register-gnome.c @@ -36,16 +36,16 @@ gnc_module_description(void) { int gnc_module_init(int refcount) { + if(!gnc_module_load("gnucash/register/register-core", 0)) { + return FALSE; + } + + if(!gnc_module_load("gnucash/gnome-utils", 0)) { + return FALSE; + } + if (refcount == 0) { - if(!gnc_module_load("gnucash/register/register-core", 0)) { - return FALSE; - } - - if(!gnc_module_load("gnucash/gnome-utils", 0)) { - return FALSE; - } - gnc_register_add_cell_type (COMBO_CELL_TYPE_NAME, gnc_combo_cell_new); gnc_register_add_cell_type (DATE_CELL_TYPE_NAME, gnc_date_cell_new); diff --git a/src/register/register-gnome/gnucash-style.c b/src/register/register-gnome/gnucash-style.c index 4876c0df4e..8b39f8adbf 100644 --- a/src/register/register-gnome/gnucash-style.c +++ b/src/register/register-gnome/gnucash-style.c @@ -796,6 +796,18 @@ gnucash_font_load (const char *name) return gdk_font_load (name); } +static const char * +gnucash_style_get_default_register_font_name (void) +{ + return _("register-default-font:-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*") + 22; +} + +static const char * +gnucash_style_get_default_register_hint_font_name (void) +{ + return _("register-hint-font:-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*") + 19; +} + void gnucash_style_set_register_font_name (const char *name) { @@ -1001,18 +1013,6 @@ gnucash_sheet_set_header_widths (GnucashSheet *sheet, } } -const char * -gnucash_style_get_default_register_font_name (void) -{ - return _("register-default-font:-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*") + 22; -} - -const char * -gnucash_style_get_default_register_hint_font_name (void) -{ - return _("register-hint-font:-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*") + 19; -} - void gnucash_style_init (void) { diff --git a/src/register/register-gnome/gnucash-style.h b/src/register/register-gnome/gnucash-style.h index ffb24df51f..eedee62e42 100644 --- a/src/register/register-gnome/gnucash-style.h +++ b/src/register/register-gnome/gnucash-style.h @@ -71,9 +71,6 @@ void gnucash_sheet_style_init(void); void gnucash_style_set_register_font_name(const char *name); void gnucash_style_set_register_hint_font_name(const char *name); -const char * gnucash_style_get_default_register_font_name(void); -const char * gnucash_style_get_default_register_hint_font_name(void); - gint gnucash_style_col_is_resizable (SheetBlockStyle *style, int col); CellDimensions * gnucash_style_get_cell_dimensions (SheetBlockStyle *style, diff --git a/src/register/register-gnome/test/Makefile.am b/src/register/register-gnome/test/Makefile.am index 68c68f19d5..dd2e0963e7 100644 --- a/src/register/register-gnome/test/Makefile.am +++ b/src/register/register-gnome/test/Makefile.am @@ -6,7 +6,7 @@ TESTS_ENVIRONMENT= \ GNC_MODULE_PATH=../../engine:../../gnc-module:../../calculation:.. \ GUILE_LOAD_PATH=${G_WRAP_MODULE_DIR}:../../engine:..:../../gnc-module:${top_srcdir}/lib \ LTDL_LIBRARY_PATH=.. \ - LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs:${top_srcdir}/src/calculation:${top_srcdir}/src/calculation/.libs + LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs:${top_srcdir}/src/calculation:${top_srcdir}/src/calculation/.libs:${top_srcdir}/src/network-utils:${top_srcdir}/src/network-utils/.libs LDADD = \ -L${top_srcdir}/src/gnc-module -L${top_srcdir}/src/gnc-module/.libs \ diff --git a/src/report/report-system/html-style-info.scm b/src/report/report-system/html-style-info.scm index d99652ec26..df4183cf4c 100644 --- a/src/report/report-system/html-style-info.scm +++ b/src/report/report-system/html-style-info.scm @@ -278,15 +278,15 @@ datum) (define (gnc:default-html-gnc-numeric-renderer datum params) - (gnc:amount->string-helper datum (gnc:default-print-info #f))) + (gnc:amount->string datum (gnc:default-print-info #f))) (define (gnc:default-html-gnc-monetary-renderer datum params) - (gnc:amount->string-helper + (gnc:amount->string (gnc:gnc-monetary-amount datum) (gnc:commodity-print-info (gnc:gnc-monetary-commodity datum) #t))) (define (gnc:default-html-number-renderer datum params) - (gnc:amount->string-helper + (gnc:amount->string (gnc:double-to-gnc-numeric datum 100 GNC-RND-ROUND) (gnc:default-print-info #f))) diff --git a/src/report/report-system/report-utilities.scm b/src/report/report-system/report-utilities.scm index 6a870feb29..2af5dfac7e 100644 --- a/src/report/report-system/report-utilities.scm +++ b/src/report/report-system/report-utilities.scm @@ -36,8 +36,6 @@ (set! l (append! l filler)))) l) -(define gnc:amount->string gnc:amount->string-helper) - ;; pair is a list of one gnc:commodity and one gnc:numeric ;; value. Deprecated -- use instead. (define (gnc:commodity-value->string pair) @@ -48,7 +46,7 @@ ;; style-info mechanism and simple plug the into the ;; html-renderer. (define (gnc:monetary->string value) - (gnc:amount->string-helper + (gnc:amount->string (gnc:gnc-monetary-amount value) (gnc:commodity-print-info (gnc:gnc-monetary-commodity value) #t))) diff --git a/src/scm/Makefile.am b/src/scm/Makefile.am index cc978f45ed..c9733a5243 100644 --- a/src/scm/Makefile.am +++ b/src/scm/Makefile.am @@ -11,7 +11,6 @@ gnc_autogen_scm_files = \ gnc_regular_scm_files = \ command-line.scm \ - config-var.scm \ depend.scm \ doc.scm \ extensions.scm \ @@ -19,7 +18,6 @@ gnc_regular_scm_files = \ main.scm \ main-window.scm \ path.scm \ - prefs.scm \ price-quotes.scm \ slib-backup.scm \ startup.scm \ diff --git a/src/scm/bootstrap.scm.in b/src/scm/bootstrap.scm.in index 261887f4cc..9abc6ccdd4 100644 --- a/src/scm/bootstrap.scm.in +++ b/src/scm/bootstrap.scm.in @@ -80,7 +80,7 @@ ;(simple-format #t "load-path == ~S\n" %load-path) -;; These will be converted to config vars later (see prefs.scm) +;; These will be converted to config vars later (see command-line.scm) (define gnc:*load-path* #f) (define gnc:*debugging?* (if (getenv "GNC_DEBUG") #t #f)) (define gnc:*develmode* (if (getenv "GNC_DEVEL_MODE") #t #f)) diff --git a/src/scm/command-line.scm b/src/scm/command-line.scm index d49cf5adbe..34c68b1731 100644 --- a/src/scm/command-line.scm +++ b/src/scm/command-line.scm @@ -15,75 +15,114 @@ ;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652 ;; Boston, MA 02111-1307, USA gnu@gnu.org -;; also "-c" - (define gnc:*command-line-remaining* #f) -(gnc:depend "price-quotes.scm") +;;; Configuration variables -;;(use-modules (ice-9 getopt-long)) +(define gnc:*arg-show-version* + (gnc:make-config-var + (N_ "Show version.") + (lambda (var value) (if (boolean? value) (list value) #f)) + eq? + #f)) -;;(define (gnc:is-boolean-arg? arg) -;; (if (or (string=? arg "true") (string=? arg "false")) #t #f)) +(define gnc:*arg-show-usage* + (gnc:make-config-var + (N_ "Generate an argument summary.") + (lambda (var value) (if (boolean? value) (list value) #f)) + eq? + #f)) -;;(define (gnc:is-integer-arg? arg) -;; (if (string->number arg) #t #f)) +(define gnc:*arg-show-help* + (gnc:make-config-var + (N_ "Generate an argument summary.") + (lambda (var value) (if (boolean? value) (list value) #f)) + eq? + #f)) -;;(define (gnc:convert-arg-to-boolean arg) -;; (if (string=? arg "true") -;; #t -;; (if (string=? arg "false") -;; #f -;; 'abort))) +(define gnc:*arg-no-file* + (gnc:make-config-var + (N_ "Don't load any file, including autoloading the last file.") + (lambda (var value) (if (boolean? value) (list value) #f)) + eq? + #f)) + +(define gnc:*config-dir* + (gnc:make-config-var + (N_ "Configuration directory.") + (lambda (var value) (if (string? value) (list value) #f)) + string=? + gnc:_config-dir-default_)) + +(define gnc:*share-dir* + (gnc:make-config-var + (N_ "Shared files directory.") + (lambda (var value) (if (string? value) (list value) #f)) + string=? + gnc:_share-dir-default_)) + +;; Convert the temporary startup value into a config var. +(let ((current-value gnc:*debugging?*)) + (set! + gnc:*debugging?* + (gnc:make-config-var + (N_ "Enable debugging code.") + (lambda (var value) (if (boolean? value) (list value) #f)) + eq? + #f)) + (gnc:config-var-value-set! gnc:*debugging?* #f current-value)) + +(let ((current-value gnc:*debugging?*)) + (set! + gnc:*develmode* + (gnc:make-config-var + (N_ "Enable developers mode.") + (lambda (var value) (if (boolean? value) (list value) #f)) + eq? + #f)) + (gnc:config-var-value-set! gnc:*develmode* #f current-value)) + +(define gnc:*loglevel* + (gnc:make-config-var + (N_ "Logging level from 0 (least logging) to 5 (most logging).") + (lambda (var value) (if (exact? value) (list value) #f)) + eq? + #f)) + +;; Convert the temporary startup value into a config var. +(let ((current-load-path gnc:*load-path*)) + (set! + gnc:*load-path* + (gnc:make-config-var + (N_ "A list of strings indicating the load path for (gnc:load name). +Each element must be a string representing a directory or a symbol +where 'default expands to the default path, and 'current expands to +the current value of the path.") + (lambda (var value) + (let ((result (gnc:expand-load-path value))) + (if (list? result) + (list result) + #f))) + equal? + '(default))) + (gnc:config-var-value-set! gnc:*load-path* #f current-load-path)) + +(define gnc:*doc-path* + + (gnc:make-config-var + (N_ "A list of strings indicating where to look for html and parsed-html files. \ +Each element must be a string representing a directory or a symbol \ +where 'default expands to the default path, and 'current expands to \ +the current value of the path.") + (lambda (var value) + (let ((result (gnc:_expand-doc-path_ value))) + (if (list? result) + (list result) + #f))) + equal? + '(default))) -;;(define (gnc:convert-arg-to-integer arg) -;; (let ((value (string->number arg))) -;; (if (and (not value) (not (exact? value))) -;; 'abort -;; value))) -;;(define (gnc:convert-arg-defs-to-opt-args arg-defs) -;; (letrec ((return '()) -;; (decide-single-char -;; (let ((single-char-cache '())) -;; (lambda (name) -;; (let ((possible (string-ref name 0))) -;; (if (eq? (assv possible single-char-cache) #f) -;; (begin -;; (set! single-char-cache (acons possible #t -;; single-char-cache)) -;; possible) -;; #f))))) -;; (create-arg-list -;; (lambda (name-sym value pred sc) -;; (let ((ret `(,name-sym (value ,value)))) -;; (if (not (eq? pred #f)) -;; (set! ret (append ret (cons 'predicate pred)))) -;; (if (not (eq? sc #f)) -;; (set! ret (append ret (cons 'single-char sc)))) -;; ret))) -;; (helper -;; (lambda (arg-defs ret) -;; (if (not (pair? arg-defs)) -;; ret -;; (helper -;; (cdr arg-defs) -;; (cons -;; (let* ((one-arg (car arg-defs)) -;; (arg-name (car one-arg)) -;; (arg-sym (string->symbol arg-name)) -;; (arg-oc (decide-single-char arg-name))) -;; (case (cadr one-arg) -;; ((boolean) (create-arg-list arg-sym 'optional -;; gnc:is-boolean-arg? -;; arg-oc)) -;; ((integer) (create-arg-list arg-sym #t -;; gnc:is-integer-arg? -;; arg-oc)) -;; ((string) (create-arg-list arg-sym #t #f arg-oc)))) -;; ret)))))) -;; (helper arg-defs return))) - (define gnc:*arg-defs* (list (list "version" @@ -200,6 +239,7 @@ (set! gnc:*batch-mode-things-to-do* (cons (lambda () + (gnc:depend "price-quotes.scm") (if (not (gnc:add-quotes-to-book-at-url val)) (begin (gnc:error "Failed to add quotes to " val) diff --git a/src/scm/main.scm b/src/scm/main.scm index 8842e7086f..9a855b7f44 100644 --- a/src/scm/main.scm +++ b/src/scm/main.scm @@ -159,10 +159,7 @@ (gnc:module-load "gnucash/report/locale-specific/us" 0) ;; Now we can load a bunch of files. - (gnc:depend "config-var.scm") - (gnc:depend "utilities.scm") (gnc:depend "path.scm") - (gnc:depend "prefs.scm") (gnc:depend "command-line.scm") (gnc:depend "doc.scm") (gnc:depend "extensions.scm") @@ -188,14 +185,6 @@ (gnc:hook-run-danglers gnc:*startup-hook*) - ;; Initialize the C side options code. Must come after the scheme - ;; options are loaded. - (gnc:c-options-init) - - ;; Initialize the expresion parser. Must come after the C side - ;; options initialization. - (gnc:exp-parser-init) - (if (gnc:config-var-value-get gnc:*arg-show-version*) (begin (gnc:prefs-show-version) @@ -267,19 +256,6 @@ (gnc:print-unstable-message) - ;; add a hook to shut down the expression parser - (gnc:hook-add-dangler gnc:*shutdown-hook* gnc:exp-parser-shutdown) - - ;; add a hook to save the user configs on shutdown. this saves - ;; global options plus (for the moment) saved report and account - ;; tree window parameters. reports and parameters should probably - ;; be in a separate file, with the main data file, or something - ;; else. - (gnc:hook-add-dangler gnc:*shutdown-hook* gnc:save-all-options) - - ;; add a hook to shut down the C side options code - (gnc:hook-add-dangler gnc:*shutdown-hook* gnc:c-options-shutdown) - (if (null? gnc:*batch-mode-things-to-do*) ;; We're not in batch mode; we can go ahead and do the normal thing. (begin @@ -296,7 +272,6 @@ (gnc:start-ui-event-loop)) (begin (gnc:load-account-file) - (gnc:default-ui-start) (gnc:show-main-window) (gnc:start-ui-event-loop))) (gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)) diff --git a/src/scm/price-quotes.scm b/src/scm/price-quotes.scm index 5e873964b7..224298b8a9 100644 --- a/src/scm/price-quotes.scm +++ b/src/scm/price-quotes.scm @@ -23,7 +23,6 @@ (use-modules (gnucash process)) (gnc:support "price-quotes.scm") -(gnc:depend "utilities.scm") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; diff --git a/src/scm/tip-of-the-day.scm b/src/scm/tip-of-the-day.scm index 5c61c317fb..c745c676fc 100644 --- a/src/scm/tip-of-the-day.scm +++ b/src/scm/tip-of-the-day.scm @@ -23,9 +23,6 @@ ;; Tips should be written as a list of lists of string. Each list of strings ;; represents one tip -(gnc:depend "config-var.scm") -(gnc:depend "prefs.scm") - (define (non-negative-integer? value) (and (integer? value) (>= value 0))) @@ -105,6 +102,3 @@ "Display \"Tip of the Day\""))) (if (gnc:option-value tip-opt) (gnc:ui-totd-dialog-create-and-run))))) - - -