* hooks.scm: fix documentation

* gnc-file.c: change the open/closed book hooks to take a
	  <gnc:Session*> instead of a string.
	* binary-import.scm: fix the book-opened-hook.
	* main-window.scm: fix the book-opened/closed-hook calls
	* main.scm: fix the book-opened/closed-hook calls


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7095 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-07-08 00:13:12 +00:00
parent d461f68d6f
commit 25e3a16191
6 changed files with 47 additions and 22 deletions

View File

@@ -6,6 +6,13 @@
* business-options.scm: Implement the kvp->scm and scm->kvp methods * business-options.scm: Implement the kvp->scm and scm->kvp methods
for the business options. for the business options.
* hooks.scm: fix documentation
* gnc-file.c: change the open/closed book hooks to take a
<gnc:Session*> instead of a string.
* binary-import.scm: fix the book-opened-hook.
* main-window.scm: fix the book-opened/closed-hook calls
* main.scm: fix the book-opened/closed-hook calls
2002-07-06 Derek Atkins <derek@ihtfp.com> 2002-07-06 Derek Atkins <derek@ihtfp.com>
* gw-kvp-spec.scm: wrap kvp_slot_set_slot_path_gslist(), * gw-kvp-spec.scm: wrap kvp_slot_set_slot_path_gslist(),

View File

@@ -24,6 +24,7 @@
#include <glib.h> #include <glib.h>
#include <guile/gh.h> #include <guile/gh.h>
#include <string.h> #include <string.h>
#include <g-wrap-wct.h>
#include "Backend.h" #include "Backend.h"
#include "global-options.h" #include "global-options.h"
@@ -250,10 +251,12 @@ gnc_add_history (GNCSession * session)
static void static void
gnc_book_opened (void) gnc_book_opened (void)
{ {
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
gh_call2 (gh_eval_str("gnc:hook-run-danglers"), gh_call2 (gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"), gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm((char *) gnc_session_get_url(current_session))); (current_session ?
gw_wcp_assimilate_ptr (current_session,
gh_eval_str("<gnc:Session*>")) :
SCM_BOOL_F));
} }
void void
@@ -272,10 +275,11 @@ gnc_file_new (void)
* disable events so we don't get spammed by redraws. */ * disable events so we don't get spammed by redraws. */
gnc_engine_suspend_events (); gnc_engine_suspend_events ();
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
gh_call2(gh_eval_str("gnc:hook-run-danglers"), gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-closed-hook*"), gh_eval_str("gnc:*book-closed-hook*"),
gh_str02scm((char *) gnc_session_get_url(session))); (session ?
gw_wcp_assimilate_ptr (session, gh_eval_str("<gnc:Session*>")) :
SCM_BOOL_F));
gnc_session_destroy (session); gnc_session_destroy (session);
current_session = NULL; current_session = NULL;
@@ -359,10 +363,12 @@ gnc_post_file_open (const char * filename)
/* -------------- BEGIN CORE SESSION CODE ------------- */ /* -------------- BEGIN CORE SESSION CODE ------------- */
/* -- this code is almost identical in FileOpen and FileSaveAs -- */ /* -- this code is almost identical in FileOpen and FileSaveAs -- */
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
gh_call2(gh_eval_str("gnc:hook-run-danglers"), gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-closed-hook*"), gh_eval_str("gnc:*book-closed-hook*"),
gh_str02scm((char *) gnc_session_get_url(current_session))); (current_session ?
gw_wcp_assimilate_ptr (current_session,
gh_eval_str("<gnc:Session*>")) :
SCM_BOOL_F));
gnc_session_destroy (current_session); gnc_session_destroy (current_session);
current_session = NULL; current_session = NULL;
@@ -569,9 +575,11 @@ gnc_file_save (void)
gnc_book_mark_saved (gnc_session_get_book (session)); gnc_book_mark_saved (gnc_session_get_book (session));
/* save the main window state */ /* save the main window state */
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
gh_call1 (gh_eval_str("gnc:main-window-save-state"), gh_call1 (gh_eval_str("gnc:main-window-save-state"),
gh_str02scm((char *) gnc_session_get_url(current_session))); (current_session ?
gw_wcp_assimilate_ptr (current_session,
gh_eval_str("<gnc:Session*>")) :
SCM_BOOL_F));
LEAVE (" "); LEAVE (" ");
} }
@@ -700,10 +708,11 @@ gnc_file_quit (void)
* transactions during shutdown would cause massive redraws */ * transactions during shutdown would cause massive redraws */
gnc_engine_suspend_events (); gnc_engine_suspend_events ();
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
gh_call2(gh_eval_str("gnc:hook-run-danglers"), gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-closed-hook*"), gh_eval_str("gnc:*book-closed-hook*"),
gh_str02scm((char *) gnc_session_get_url(session))); (session ?
gw_wcp_assimilate_ptr (session, gh_eval_str("<gnc:Session*>")) :
SCM_BOOL_F));
gnc_session_destroy (session); gnc_session_destroy (session);
current_session = NULL; current_session = NULL;

View File

@@ -96,7 +96,7 @@
(define gnc:*book-opened-hook* (define gnc:*book-opened-hook*
(gnc:hook-define (gnc:hook-define
'book-opened-hook 'book-opened-hook
"Run after book open. Hook args: book URL.")) "Run after book open. Hook args: <gnc:Session*>."))
(define gnc:*new-book-hook* (define gnc:*new-book-hook*
(gnc:hook-define (gnc:hook-define
@@ -106,7 +106,7 @@
(define gnc:*book-closed-hook* (define gnc:*book-closed-hook*
(gnc:hook-define (gnc:hook-define
'book-closed-hook 'book-closed-hook
"Run before file close. Hook args: book URL")) "Run before file close. Hook args: <gnc:Session*>"))
(define gnc:*report-hook* (define gnc:*report-hook*
(gnc:hook-define (gnc:hook-define

View File

@@ -2,5 +2,11 @@
(define-module (gnucash import-export binary-import)) (define-module (gnucash import-export binary-import))
(use-modules (g-wrapped gw-binary-import)) (use-modules (g-wrapped gw-binary-import))
(use-modules (gnucash app-utils)) (use-modules (gnucash app-utils))
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/engine" 0)
(gnc:hook-add-dangler gnc:*book-opened-hook* gnc:import-legacy-commodities) (define (import-commodities session)
(let ((book-url (gnc:session-get-url session)))
(gnc:import-legacy-commodities book-url)))
(gnc:hook-add-dangler gnc:*book-opened-hook* import-commodities)

View File

@@ -118,8 +118,9 @@ the account instead of opening a register.") #f))
;; book close. ;; book close.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (gnc:main-window-save-state book-url) (define (gnc:main-window-save-state session)
(let* ((conf-file-name (gnc:html-encode-string book-url)) (let* ((book-url (gnc:session-get-url session))
(conf-file-name (gnc:html-encode-string book-url))
(dotgnucash-dir (build-path (getenv "HOME") ".gnucash")) (dotgnucash-dir (build-path (getenv "HOME") ".gnucash"))
(file-dir (build-path dotgnucash-dir "books")) (file-dir (build-path dotgnucash-dir "books"))
(save-file? #f) (save-file? #f)
@@ -151,8 +152,8 @@ the account instead of opening a register.") #f))
(force-output))) (force-output)))
(gnc:mdi-save (gnc:mdi-get-current) book-url))))) (gnc:mdi-save (gnc:mdi-get-current) book-url)))))
(define (gnc:main-window-book-close-handler book-url) (define (gnc:main-window-book-close-handler session)
(gnc:main-window-save-state book-url) (gnc:main-window-save-state session)
(let ((dead-reports '())) (let ((dead-reports '()))
;; get a list of the reports we'll be needing to nuke ;; get a list of the reports we'll be needing to nuke
@@ -168,7 +169,7 @@ the account instead of opening a register.") #f))
(hash-remove! *gnc:_reports_* dr)) (hash-remove! *gnc:_reports_* dr))
dead-reports))) dead-reports)))
(define (gnc:main-window-book-open-handler book-url) (define (gnc:main-window-book-open-handler session)
(define (try-load file-suffix) (define (try-load file-suffix)
(let ((file (build-path (getenv "HOME") ".gnucash" "books" file-suffix))) (let ((file (build-path (getenv "HOME") ".gnucash" "books" file-suffix)))
;; make sure the books directory is there ;; make sure the books directory is there
@@ -178,8 +179,9 @@ the account instead of opening a register.") #f))
(gnc:warn "failure loading " file) (gnc:warn "failure loading " file)
#f)) #f))
#f))) #f)))
(let ((conf-file-name (gnc:html-encode-string book-url)) (let* ((book-url (gnc:session-get-url session))
(dead-reports '())) (conf-file-name (gnc:html-encode-string book-url))
(dead-reports '()))
(if conf-file-name (if conf-file-name
(try-load conf-file-name)) (try-load conf-file-name))
(gnc:mdi-restore (gnc:mdi-get-current) book-url))) (gnc:mdi-restore (gnc:mdi-get-current) book-url)))

View File

@@ -401,12 +401,13 @@ string and 'directories' must be a list of strings."
(set-current-module original-module)) (set-current-module original-module))
(gnc:hook-add-dangler gnc:*book-opened-hook* (gnc:hook-add-dangler gnc:*book-opened-hook*
(lambda (file) (lambda (session)
(if ((gnc:option-getter (if ((gnc:option-getter
(gnc:lookup-global-option (gnc:lookup-global-option
"Scheduled Transactions" "Scheduled Transactions"
"Run on GnuCash start" ))) "Run on GnuCash start" )))
(gnc:sx-since-last-run-wrapper file)))) (gnc:sx-since-last-run-wrapper
(gnc:session-get-url session)))))
(gnc:hook-add-dangler gnc:*new-book-hook* (gnc:hook-add-dangler gnc:*new-book-hook*
(lambda () (lambda ()