mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* 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:
@@ -6,6 +6,13 @@
|
||||
* business-options.scm: Implement the kvp->scm and scm->kvp methods
|
||||
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>
|
||||
|
||||
* gw-kvp-spec.scm: wrap kvp_slot_set_slot_path_gslist(),
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <glib.h>
|
||||
#include <guile/gh.h>
|
||||
#include <string.h>
|
||||
#include <g-wrap-wct.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "global-options.h"
|
||||
@@ -250,10 +251,12 @@ gnc_add_history (GNCSession * session)
|
||||
static 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_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
|
||||
@@ -272,10 +275,11 @@ gnc_file_new (void)
|
||||
* disable events so we don't get spammed by redraws. */
|
||||
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_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);
|
||||
current_session = NULL;
|
||||
@@ -359,10 +363,12 @@ gnc_post_file_open (const char * filename)
|
||||
|
||||
/* -------------- BEGIN CORE SESSION CODE ------------- */
|
||||
/* -- 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_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);
|
||||
current_session = NULL;
|
||||
|
||||
@@ -569,9 +575,11 @@ gnc_file_save (void)
|
||||
gnc_book_mark_saved (gnc_session_get_book (session));
|
||||
|
||||
/* 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_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 (" ");
|
||||
}
|
||||
@@ -700,10 +708,11 @@ gnc_file_quit (void)
|
||||
* transactions during shutdown would cause massive redraws */
|
||||
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_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);
|
||||
current_session = NULL;
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
(define gnc:*book-opened-hook*
|
||||
(gnc:hook-define
|
||||
'book-opened-hook
|
||||
"Run after book open. Hook args: book URL."))
|
||||
"Run after book open. Hook args: <gnc:Session*>."))
|
||||
|
||||
(define gnc:*new-book-hook*
|
||||
(gnc:hook-define
|
||||
@@ -106,7 +106,7 @@
|
||||
(define gnc:*book-closed-hook*
|
||||
(gnc:hook-define
|
||||
'book-closed-hook
|
||||
"Run before file close. Hook args: book URL"))
|
||||
"Run before file close. Hook args: <gnc:Session*>"))
|
||||
|
||||
(define gnc:*report-hook*
|
||||
(gnc:hook-define
|
||||
|
||||
@@ -2,5 +2,11 @@
|
||||
(define-module (gnucash import-export binary-import))
|
||||
(use-modules (g-wrapped gw-binary-import))
|
||||
(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)
|
||||
|
||||
@@ -118,8 +118,9 @@ the account instead of opening a register.") #f))
|
||||
;; book close.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define (gnc:main-window-save-state book-url)
|
||||
(let* ((conf-file-name (gnc:html-encode-string book-url))
|
||||
(define (gnc:main-window-save-state session)
|
||||
(let* ((book-url (gnc:session-get-url session))
|
||||
(conf-file-name (gnc:html-encode-string book-url))
|
||||
(dotgnucash-dir (build-path (getenv "HOME") ".gnucash"))
|
||||
(file-dir (build-path dotgnucash-dir "books"))
|
||||
(save-file? #f)
|
||||
@@ -151,8 +152,8 @@ the account instead of opening a register.") #f))
|
||||
(force-output)))
|
||||
(gnc:mdi-save (gnc:mdi-get-current) book-url)))))
|
||||
|
||||
(define (gnc:main-window-book-close-handler book-url)
|
||||
(gnc:main-window-save-state book-url)
|
||||
(define (gnc:main-window-book-close-handler session)
|
||||
(gnc:main-window-save-state session)
|
||||
|
||||
(let ((dead-reports '()))
|
||||
;; 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))
|
||||
dead-reports)))
|
||||
|
||||
(define (gnc:main-window-book-open-handler book-url)
|
||||
(define (gnc:main-window-book-open-handler session)
|
||||
(define (try-load file-suffix)
|
||||
(let ((file (build-path (getenv "HOME") ".gnucash" "books" file-suffix)))
|
||||
;; make sure the books directory is there
|
||||
@@ -178,7 +179,8 @@ the account instead of opening a register.") #f))
|
||||
(gnc:warn "failure loading " file)
|
||||
#f))
|
||||
#f)))
|
||||
(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))
|
||||
(dead-reports '()))
|
||||
(if conf-file-name
|
||||
(try-load conf-file-name))
|
||||
|
||||
@@ -401,12 +401,13 @@ string and 'directories' must be a list of strings."
|
||||
(set-current-module original-module))
|
||||
|
||||
(gnc:hook-add-dangler gnc:*book-opened-hook*
|
||||
(lambda (file)
|
||||
(lambda (session)
|
||||
(if ((gnc:option-getter
|
||||
(gnc:lookup-global-option
|
||||
"Scheduled Transactions"
|
||||
"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*
|
||||
(lambda ()
|
||||
|
||||
Reference in New Issue
Block a user