1998-11-04 00:14:45 -06:00
|
|
|
(define (gnc:startup)
|
|
|
|
(gnc:debug "starting up.")
|
1998-11-19 21:42:06 -06:00
|
|
|
(if (not (gnc:handle-command-line-args))
|
|
|
|
(gnc:shutdown 1))
|
1999-12-30 18:05:41 -06:00
|
|
|
|
2000-03-13 00:56:27 -06:00
|
|
|
(gnc:setup-debugging)
|
|
|
|
|
1999-12-30 18:05:41 -06:00
|
|
|
;; Load the srfis
|
|
|
|
(gnc:load "srfi/srfi-8.guile.scm")
|
|
|
|
(gnc:load "srfi/srfi-1.unclear.scm")
|
|
|
|
(gnc:load "srfi/srfi-1.r5rs.scm")
|
|
|
|
|
|
|
|
(gnc:load "depend.scm")
|
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
;; Now we can load a bunch of files.
|
1999-12-30 18:05:41 -06:00
|
|
|
|
|
|
|
(gnc:depend "doc.scm")
|
2000-02-27 16:14:58 -06:00
|
|
|
(gnc:depend "extensions.scm")
|
1999-12-30 18:05:41 -06:00
|
|
|
(gnc:depend "text-export.scm")
|
|
|
|
(gnc:depend "importqif.scm")
|
|
|
|
(gnc:depend "report.scm")
|
2000-03-05 18:17:25 -06:00
|
|
|
(gnc:depend "report/report-list.scm")
|
1999-12-30 18:05:41 -06:00
|
|
|
|
2000-02-06 23:27:35 -06:00
|
|
|
;; Load the system configs
|
1998-11-19 21:42:06 -06:00
|
|
|
(if (not (gnc:load-system-config-if-needed))
|
|
|
|
(gnc:shutdown 1))
|
1999-12-30 18:05:41 -06:00
|
|
|
|
2000-02-06 23:27:35 -06:00
|
|
|
;; Load the user configs
|
|
|
|
(gnc:load-user-config-if-needed)
|
|
|
|
|
|
|
|
;; Clear the change flags caused by loading the configs
|
|
|
|
(gnc:global-options-clear-changes)
|
1998-12-01 03:02:47 -06:00
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
(gnc:hook-run-danglers gnc:*startup-hook*)
|
1999-12-30 18:05:41 -06:00
|
|
|
|
|
|
|
(if (gnc:config-var-value-get gnc:*arg-show-version*)
|
|
|
|
(begin
|
|
|
|
(gnc:prefs-show-version)
|
|
|
|
(gnc:shutdown 0)))
|
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
(if (or (gnc:config-var-value-get gnc:*arg-show-usage*)
|
|
|
|
(gnc:config-var-value-get gnc:*arg-show-help*))
|
|
|
|
(begin
|
|
|
|
(gnc:prefs-show-usage)
|
1999-05-29 18:46:49 -05:00
|
|
|
(gnc:shutdown 0))))
|
1998-11-04 00:14:45 -06:00
|
|
|
|
2000-02-06 23:27:35 -06:00
|
|
|
|
1998-11-04 00:14:45 -06:00
|
|
|
(define (gnc:shutdown exit-status)
|
|
|
|
(gnc:debug "Shutdown -- exit-status: " exit-status)
|
1999-10-17 22:18:20 -05:00
|
|
|
|
|
|
|
(cond ((gnc:ui-is-running?)
|
|
|
|
(if (not (gnc:ui-is-terminating?))
|
|
|
|
(begin
|
|
|
|
(gnc:hook-run-danglers gnc:*ui-shutdown-hook*)
|
|
|
|
(gnc:ui-shutdown))))
|
|
|
|
|
|
|
|
(else
|
|
|
|
(gnc:ui-destroy)
|
2000-02-27 16:14:58 -06:00
|
|
|
(gnc:hook-run-danglers gnc:*shutdown-hook*)
|
1999-10-17 22:18:20 -05:00
|
|
|
(exit exit-status))))
|
|
|
|
|
|
|
|
(define (gnc:ui-finish)
|
|
|
|
(gnc:debug "UI Shutdown hook.")
|
|
|
|
|
1999-12-30 18:05:41 -06:00
|
|
|
(gnc:ui-destroy-all-subwindows)
|
1999-10-17 22:18:20 -05:00
|
|
|
(gnc:file-query-save)
|
|
|
|
(gnc:file-quit))
|
1998-11-04 00:14:45 -06:00
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
(define (gnc:main)
|
1999-10-17 22:18:20 -05:00
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
;; Now the fun begins.
|
1998-11-04 00:14:45 -06:00
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
(gnc:startup)
|
1999-10-17 22:18:20 -05:00
|
|
|
|
1999-05-29 18:46:49 -05:00
|
|
|
(if (not (= (gnc:lowlev-app-init) 0))
|
1998-11-19 21:42:06 -06:00
|
|
|
(gnc:shutdown 0))
|
1999-12-30 18:05:41 -06:00
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
(if (pair? gnc:*command-line-files*)
|
|
|
|
;; You can only open single files right now...
|
1999-07-06 01:04:39 -05:00
|
|
|
(gnc:ui-open-file (car gnc:*command-line-files*)))
|
1999-10-17 22:18:20 -05:00
|
|
|
|
2000-02-06 23:27:35 -06:00
|
|
|
;; add a hook to save the user configs on shutdown
|
|
|
|
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:save-global-options)
|
|
|
|
|
1999-10-17 22:18:20 -05:00
|
|
|
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)
|
|
|
|
|
|
|
|
(gnc:ui-main)
|
|
|
|
|
|
|
|
(gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)
|
1999-12-30 18:05:41 -06:00
|
|
|
|
1998-11-19 21:42:06 -06:00
|
|
|
(gnc:shutdown 0))
|