Skip to content

Commit

Permalink
Add a "book saved" hook. Use this to update the window titles after a
Browse files Browse the repository at this point in the history
file is saved.  Fixes 334789.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13660 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
David Hampton committed Mar 17, 2006
1 parent 199281f commit 2cd27a1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2006-03-17 David Hampton <hampton@employees.org>

* 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 <andi5.py@gmx.net>

* src/engine/Split.c: Fix return value of get_corr_account_split
Expand Down
2 changes: 2 additions & 0 deletions src/engine/gnc-hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ gnc_hooks_init(void)
"Run after book open. Hook args: <gnc:Session*>.");
gnc_hook_create(HOOK_BOOK_CLOSED, 1,
"Run before file close. Hook args: <gnc:Session*>");
gnc_hook_create(HOOK_BOOK_SAVED, 1,
"Run after file saved. Hook args: <gnc:Session*>");

LEAVE("");
}
1 change: 1 addition & 0 deletions src/engine/gnc-hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions src/gnome-utils/gnc-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ gnc_file_save (void)
}

gnc_add_history (session);
gnc_hook_run(HOOK_BOOK_SAVED, session);
LEAVE (" ");
}

Expand Down Expand Up @@ -1095,6 +1096,7 @@ gnc_file_save_as (void)
save_in_progress--;

g_free (newfile);
gnc_hook_run(HOOK_BOOK_SAVED, new_session);
LEAVE (" ");
}

Expand Down
10 changes: 10 additions & 0 deletions src/gnome-utils/gnc-main-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 2cd27a1

Please sign in to comment.