From 79e7cdff57d341114bd5b05135471470876074f0 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Fri, 17 Mar 2006 23:26:13 +0000 Subject: [PATCH] Enhance the quickfill event handler to detect changes in whether an 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 --- ChangeLog | 4 ++++ src/gnome-utils/account-quickfill.c | 37 ++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff102505fab..65898a11f1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-03-17 David Hampton + * 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 diff --git a/src/gnome-utils/account-quickfill.c b/src/gnome-utils/account-quickfill.c index 5179a965ca7..3be212d3513 100644 --- a/src/gnome-utils/account-quickfill.c +++ b/src/gnome-utils/account-quickfill.c @@ -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; @@ -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; @@ -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: @@ -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)) { @@ -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)) {