diff --git a/ChangeLog b/ChangeLog index c0cee9d530..ff102505fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-17 David Hampton + + * src/gnome-utils/gnc-file.c: + * src/gnome-utils/gnc-main-window.c: + * src/engine/gnc-hooks.[ch]: Add a "book saved" hook. Use this to + update the window titles after a file is saved. Fixes 334789. + 2006-03-17 Andreas Köhler * src/engine/Split.c: Fix return value of get_corr_account_split diff --git a/src/engine/gnc-hooks.c b/src/engine/gnc-hooks.c index b58977b82d..b1bb85f1f0 100644 --- a/src/engine/gnc-hooks.c +++ b/src/engine/gnc-hooks.c @@ -323,6 +323,8 @@ gnc_hooks_init(void) "Run after book open. Hook args: ."); gnc_hook_create(HOOK_BOOK_CLOSED, 1, "Run before file close. Hook args: "); + gnc_hook_create(HOOK_BOOK_SAVED, 1, + "Run after file saved. Hook args: "); LEAVE(""); } diff --git a/src/engine/gnc-hooks.h b/src/engine/gnc-hooks.h index 618b322db5..9c097de85e 100644 --- a/src/engine/gnc-hooks.h +++ b/src/engine/gnc-hooks.h @@ -70,5 +70,6 @@ void gnc_hooks_init(void); /* Common session hook names */ #define HOOK_BOOK_OPENED "hook_book_opened" #define HOOK_BOOK_CLOSED "hook_book_closed" +#define HOOK_BOOK_SAVED "hook_book_saved" #endif /* GNC_HOOKS_H */ diff --git a/src/gnome-utils/gnc-file.c b/src/gnome-utils/gnc-file.c index ad367f8e65..d9c6dcc7ab 100644 --- a/src/gnome-utils/gnc-file.c +++ b/src/gnome-utils/gnc-file.c @@ -965,6 +965,7 @@ gnc_file_save (void) } gnc_add_history (session); + gnc_hook_run(HOOK_BOOK_SAVED, session); LEAVE (" "); } @@ -1095,6 +1096,7 @@ gnc_file_save_as (void) save_in_progress--; g_free (newfile); + gnc_hook_run(HOOK_BOOK_SAVED, new_session); LEAVE (" "); } diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index 0c74c0b9eb..fd91ec9c0f 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -1166,6 +1166,14 @@ gnc_main_window_update_title (GncMainWindow *window) g_free(title); } +static void +gnc_main_window_update_all_titles (void) +{ + g_list_foreach(active_windows, + (GFunc)gnc_main_window_update_title, + NULL); +} + /** This data structure is used to describe the requested state of a * GtkRadioAction, and us used to pass data among several @@ -1669,6 +1677,8 @@ gnc_main_window_class_init (GncMainWindowClass *klass) gnc_gconf_general_register_cb (KEY_SHOW_CLOSE_BUTTON, gnc_main_window_update_tabs, NULL); + gnc_hook_add_dangler(HOOK_BOOK_SAVED, + (GFunc)gnc_main_window_update_all_titles, NULL); }