Add a new book hook and call the hierarchy druid from there.

Remove some startup cruft.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5404 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-09-21 11:46:50 +00:00
parent 5116c5c721
commit 85e41282fe
9 changed files with 40 additions and 53 deletions

View File

@ -237,6 +237,14 @@ gnc_add_history (GNCBook *book)
g_free (url);
}
static void
gnc_book_opened (void)
{
gh_call2 (gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
}
void
gnc_file_new (void)
{
@ -255,7 +263,7 @@ gnc_file_new (void)
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-closed-hook*"),
gh_str02scm(gnc_book_get_url(book)));
gh_str02scm(gnc_book_get_url(book)));
gnc_book_destroy (book);
current_book = NULL;
@ -265,18 +273,10 @@ gnc_file_new (void)
/* start a new book */
gnc_get_current_book_internal ();
if(gnc_lookup_boolean_option("General",
"No account list setup on new file",
TRUE))
{
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
}
else
{
gnc_ui_hierarchy_druid ();
}
gh_call1(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*new-book-hook*"));
gnc_book_opened ();
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
@ -451,9 +451,7 @@ gnc_post_file_open (const char * filename)
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
gnc_book_opened ();
return FALSE;
}
@ -462,9 +460,7 @@ gnc_post_file_open (const char * filename)
/* close up the old file session (if any) */
current_book = new_book;
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
gnc_book_opened ();
/* --------------- END CORE SESSION CODE -------------- */

View File

@ -225,6 +225,7 @@
(export gnc:*ui-startup-hook*)
(export gnc:*ui-shutdown-hook*)
(export gnc:*book-opened-hook*)
(export gnc:*new-book-hook*)
(export gnc:*book-closed-hook*)
;; utilities

View File

@ -98,6 +98,11 @@
'book-opened-hook
"Run after book open. Hook args: book URL."))
(define gnc:*new-book-hook*
(gnc:hook-define
'new-book-hook
"Run after a new (empty) book is opened, before the book-opened-hook. Hook args: ()"))
(define gnc:*book-closed-hook*
(gnc:hook-define
'book-closed-hook

View File

@ -102,9 +102,6 @@ gboolean gnc_get_username_password (gncUIWidget parent,
char **username,
char **password);
void gnc_ui_new_user_dialog (void);
void gnc_ui_hierarchy_druid (void);
/* Managing the GUI Windows *****************************************/
void gnc_ui_shutdown (void);

View File

@ -124,6 +124,5 @@ gnc_ui_new_user_cancel_dialog (void)
void
gncp_new_user_finish (void)
{
gh_eval_str("(gnc:show-main-window)");
gh_eval_str("(gnc:hook-run-danglers gnc:*book-opened-hook* #f)");
}

View File

@ -605,19 +605,6 @@ gnc_ui_destroy (void)
/* ============================================================== */
int
gnc_ui_show_main_window (void)
{
/* Initialize gnome */
gnucash_ui_init();
/* Get the main window on screen. */
while (gtk_events_pending())
gtk_main_iteration();
return 0;
}
static gboolean
gnc_ui_check_events (gpointer not_used)
{

View File

@ -35,7 +35,6 @@ gboolean gnucash_ui_open_file(const char * name);
GNCMainInfo * gnc_ui_get_data(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);
gboolean gnc_reverse_balance_type(GNCAccountType type);
gboolean gnc_reverse_balance(Account *account);

View File

@ -188,11 +188,3 @@ the account instead of opening a register.") #f))
gnc:main-window-book-open-handler)
(gnc:hook-add-dangler gnc:*book-closed-hook*
gnc:main-window-book-close-handler)
(gnc:hook-add-dangler gnc:*book-opened-hook*
(lambda (file)
(if ((gnc:option-getter
(gnc:lookup-global-option
(N_ "Scheduled Transactions")
(N_ "Run on GnuCash start" ))))
(gnc:sx-since-last-run-wrapper file))) )

View File

@ -168,6 +168,22 @@
(gnc:depend "price-quotes.scm")
(gnc:depend "tip-of-the-day.scm")
(gnc:hook-add-dangler gnc:*book-opened-hook*
(lambda (file)
(if ((gnc:option-getter
(gnc:lookup-global-option
"Scheduled Transactions"
"Run on GnuCash start" )))
(gnc:sx-since-last-run-wrapper file))))
(gnc:hook-add-dangler gnc:*new-book-hook*
(lambda ()
(let ((option (gnc:lookup-global-option
"General"
"No account list setup on new file")))
(if (and option (not (gnc:option-value option)))
(gnc:ui-hierarchy-druid)))))
(if (not (gnc:handle-command-line-args))
(gnc:shutdown 1))
@ -259,7 +275,6 @@
(if (null? gnc:*batch-mode-things-to-do*)
;; We're not in batch mode; we can go ahead and do the normal thing.
(begin
;; (gnc:load-account-file)
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)
(gnc:ui-init)
(if (and
@ -267,13 +282,9 @@
(not (string? (gnc:history-get-last)))
(gnc:option-value
(gnc:lookup-global-option "__new_user" "first_startup")))
(begin
(gnc:new-user-dialog)
(gnc:start-ui-event-loop))
(begin
(gnc:load-account-file)
(gnc:show-main-window)
(gnc:start-ui-event-loop)))
(gnc:new-user-dialog)
(gnc:load-account-file))
(gnc:start-ui-event-loop)
(gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish))
;; else: we're in batch mode. Just do what the user said on the