Skip to content

Commit

Permalink
Enhance the quickfill event handler to detect changes in whether an
Browse files Browse the repository at this point in the history
account should appear in the quickfill.  Fixes 334787.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13661 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
David Hampton committed Mar 17, 2006
1 parent 2cd27a1 commit 79e7cdf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,5 +1,9 @@
2006-03-17 David Hampton <hampton@employees.org>

* src/gnome-utils/account-quickfill.c: Enhance the quickfill event
handler to detect changes in whether an account should appear in
the quickfill. Fixes 334787.

* 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
Expand Down
37 changes: 23 additions & 14 deletions src/gnome-utils/account-quickfill.c
Expand Up @@ -225,6 +225,7 @@ listen_for_account_events (QofEntity *entity, QofEventId event_type,
Account *account;
GtkTreeIter iter;
find_data data;
gboolean skip;

if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_ADD | QOF_EVENT_REMOVE)))
return;
Expand All @@ -236,16 +237,6 @@ listen_for_account_events (QofEntity *entity, QofEventId event_type,
ENTER("entity %p, event type %x, user data %p, ecent data %p",
entity, event_type, user_data, event_data);

/* Not every new account is eligable for the menu */
if (qfb->dont_add_cb)
{
gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
if (skip) {
LEAVE("skip function matched");
return;
}
}

if (xaccAccountGetRoot(account) != qfb->group) {
LEAVE("root group mismatch");
return;
Expand All @@ -257,8 +248,30 @@ listen_for_account_events (QofEntity *entity, QofEventId event_type,
return;
}

/* Does the account exist in the model? */
data.account = account;
data.found = NULL;
gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
shared_quickfill_find_account, &data);

/* Should the account exist in the model? */
if (qfb->dont_add_cb) {
skip = (qfb->dont_add_cb) (account, qfb->dont_add_data);
} else {
skip = FALSE;
}

/* Synthesize new events to make the following case statement
* simpler. */
if (event_type == QOF_EVENT_MODIFY) {
if (skip && data.found) {
DEBUG("existing account now filtered");
event_type = QOF_EVENT_REMOVE;
} else if (!skip && !data.found) {
DEBUG("existing account no longer filtered");
event_type = QOF_EVENT_ADD;
}
}

switch (event_type) {
case QOF_EVENT_MODIFY:
Expand All @@ -269,8 +282,6 @@ listen_for_account_events (QofEntity *entity, QofEventId event_type,
xaccGroupForEachAccount (qfb->group, load_shared_qf_cb, qfb, TRUE);

/* Update list store */
gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
shared_quickfill_find_account, &data);
if (data.found) {
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
&iter, data.found)) {
Expand All @@ -290,8 +301,6 @@ listen_for_account_events (QofEntity *entity, QofEventId event_type,
xaccGroupForEachAccount (qfb->group, load_shared_qf_cb, qfb, TRUE);

/* Remove from list store */
gtk_tree_model_foreach(GTK_TREE_MODEL(qfb->list_store),
shared_quickfill_find_account, &data);
if (data.found) {
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(qfb->list_store),
&iter, data.found)) {
Expand Down

0 comments on commit 79e7cdf

Please sign in to comment.