mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
5116c5c721
commit
85e41282fe
@ -237,6 +237,14 @@ gnc_add_history (GNCBook *book)
|
|||||||
g_free (url);
|
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
|
void
|
||||||
gnc_file_new (void)
|
gnc_file_new (void)
|
||||||
{
|
{
|
||||||
@ -255,7 +263,7 @@ gnc_file_new (void)
|
|||||||
|
|
||||||
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(gnc_book_get_url(book)));
|
gh_str02scm(gnc_book_get_url(book)));
|
||||||
|
|
||||||
gnc_book_destroy (book);
|
gnc_book_destroy (book);
|
||||||
current_book = NULL;
|
current_book = NULL;
|
||||||
@ -265,18 +273,10 @@ gnc_file_new (void)
|
|||||||
/* start a new book */
|
/* start a new book */
|
||||||
gnc_get_current_book_internal ();
|
gnc_get_current_book_internal ();
|
||||||
|
|
||||||
if(gnc_lookup_boolean_option("General",
|
gh_call1(gh_eval_str("gnc:hook-run-danglers"),
|
||||||
"No account list setup on new file",
|
gh_eval_str("gnc:*new-book-hook*"));
|
||||||
TRUE))
|
|
||||||
{
|
gnc_book_opened ();
|
||||||
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 ();
|
|
||||||
}
|
|
||||||
|
|
||||||
gnc_engine_resume_events ();
|
gnc_engine_resume_events ();
|
||||||
gnc_gui_refresh_all ();
|
gnc_gui_refresh_all ();
|
||||||
@ -451,9 +451,7 @@ gnc_post_file_open (const char * filename)
|
|||||||
gnc_engine_resume_events ();
|
gnc_engine_resume_events ();
|
||||||
gnc_gui_refresh_all ();
|
gnc_gui_refresh_all ();
|
||||||
|
|
||||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
gnc_book_opened ();
|
||||||
gh_eval_str("gnc:*book-opened-hook*"),
|
|
||||||
gh_str02scm(gnc_book_get_url(current_book)));
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -462,9 +460,7 @@ gnc_post_file_open (const char * filename)
|
|||||||
/* close up the old file session (if any) */
|
/* close up the old file session (if any) */
|
||||||
current_book = new_book;
|
current_book = new_book;
|
||||||
|
|
||||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
gnc_book_opened ();
|
||||||
gh_eval_str("gnc:*book-opened-hook*"),
|
|
||||||
gh_str02scm(gnc_book_get_url(current_book)));
|
|
||||||
|
|
||||||
/* --------------- END CORE SESSION CODE -------------- */
|
/* --------------- END CORE SESSION CODE -------------- */
|
||||||
|
|
||||||
|
@ -225,6 +225,7 @@
|
|||||||
(export gnc:*ui-startup-hook*)
|
(export gnc:*ui-startup-hook*)
|
||||||
(export gnc:*ui-shutdown-hook*)
|
(export gnc:*ui-shutdown-hook*)
|
||||||
(export gnc:*book-opened-hook*)
|
(export gnc:*book-opened-hook*)
|
||||||
|
(export gnc:*new-book-hook*)
|
||||||
(export gnc:*book-closed-hook*)
|
(export gnc:*book-closed-hook*)
|
||||||
|
|
||||||
;; utilities
|
;; utilities
|
||||||
|
@ -98,6 +98,11 @@
|
|||||||
'book-opened-hook
|
'book-opened-hook
|
||||||
"Run after book open. Hook args: book URL."))
|
"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*
|
(define gnc:*book-closed-hook*
|
||||||
(gnc:hook-define
|
(gnc:hook-define
|
||||||
'book-closed-hook
|
'book-closed-hook
|
||||||
|
@ -102,9 +102,6 @@ gboolean gnc_get_username_password (gncUIWidget parent,
|
|||||||
char **username,
|
char **username,
|
||||||
char **password);
|
char **password);
|
||||||
|
|
||||||
void gnc_ui_new_user_dialog (void);
|
|
||||||
void gnc_ui_hierarchy_druid (void);
|
|
||||||
|
|
||||||
/* Managing the GUI Windows *****************************************/
|
/* Managing the GUI Windows *****************************************/
|
||||||
|
|
||||||
void gnc_ui_shutdown (void);
|
void gnc_ui_shutdown (void);
|
||||||
|
@ -124,6 +124,5 @@ gnc_ui_new_user_cancel_dialog (void)
|
|||||||
void
|
void
|
||||||
gncp_new_user_finish (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)");
|
gh_eval_str("(gnc:hook-run-danglers gnc:*book-opened-hook* #f)");
|
||||||
}
|
}
|
||||||
|
@ -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
|
static gboolean
|
||||||
gnc_ui_check_events (gpointer not_used)
|
gnc_ui_check_events (gpointer not_used)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,6 @@ gboolean gnucash_ui_open_file(const char * name);
|
|||||||
GNCMainInfo * gnc_ui_get_data(void);
|
GNCMainInfo * gnc_ui_get_data(void);
|
||||||
void gnc_ui_shutdown(void);
|
void gnc_ui_shutdown(void);
|
||||||
void gnc_ui_destroy(void);
|
void gnc_ui_destroy(void);
|
||||||
int gnc_ui_show_main_window(void);
|
|
||||||
int gnc_ui_start_event_loop(void);
|
int gnc_ui_start_event_loop(void);
|
||||||
gboolean gnc_reverse_balance_type(GNCAccountType type);
|
gboolean gnc_reverse_balance_type(GNCAccountType type);
|
||||||
gboolean gnc_reverse_balance(Account *account);
|
gboolean gnc_reverse_balance(Account *account);
|
||||||
|
@ -188,11 +188,3 @@ the account instead of opening a register.") #f))
|
|||||||
gnc:main-window-book-open-handler)
|
gnc:main-window-book-open-handler)
|
||||||
(gnc:hook-add-dangler gnc:*book-closed-hook*
|
(gnc:hook-add-dangler gnc:*book-closed-hook*
|
||||||
gnc:main-window-book-close-handler)
|
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))) )
|
|
||||||
|
@ -168,6 +168,22 @@
|
|||||||
(gnc:depend "price-quotes.scm")
|
(gnc:depend "price-quotes.scm")
|
||||||
(gnc:depend "tip-of-the-day.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))
|
(if (not (gnc:handle-command-line-args))
|
||||||
(gnc:shutdown 1))
|
(gnc:shutdown 1))
|
||||||
|
|
||||||
@ -259,7 +275,6 @@
|
|||||||
(if (null? gnc:*batch-mode-things-to-do*)
|
(if (null? gnc:*batch-mode-things-to-do*)
|
||||||
;; We're not in batch mode; we can go ahead and do the normal thing.
|
;; We're not in batch mode; we can go ahead and do the normal thing.
|
||||||
(begin
|
(begin
|
||||||
;; (gnc:load-account-file)
|
|
||||||
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)
|
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)
|
||||||
(gnc:ui-init)
|
(gnc:ui-init)
|
||||||
(if (and
|
(if (and
|
||||||
@ -267,13 +282,9 @@
|
|||||||
(not (string? (gnc:history-get-last)))
|
(not (string? (gnc:history-get-last)))
|
||||||
(gnc:option-value
|
(gnc:option-value
|
||||||
(gnc:lookup-global-option "__new_user" "first_startup")))
|
(gnc:lookup-global-option "__new_user" "first_startup")))
|
||||||
(begin
|
(gnc:new-user-dialog)
|
||||||
(gnc:new-user-dialog)
|
(gnc:load-account-file))
|
||||||
(gnc:start-ui-event-loop))
|
(gnc:start-ui-event-loop)
|
||||||
(begin
|
|
||||||
(gnc:load-account-file)
|
|
||||||
(gnc:show-main-window)
|
|
||||||
(gnc:start-ui-event-loop)))
|
|
||||||
(gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish))
|
(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
|
;; else: we're in batch mode. Just do what the user said on the
|
||||||
|
Loading…
Reference in New Issue
Block a user