[Gnucash-changes] r13661 - gnucash/trunk - Enhance the quickfill event handler to detect changes in whether an

David Hampton hampton at cvs.gnucash.org
Fri Mar 17 18:26:13 EST 2006


Author: hampton
Date: 2006-03-17 18:26:13 -0500 (Fri, 17 Mar 2006)
New Revision: 13661
Trac: http://svn.gnucash.org/trac/changeset/13661

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


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-17 22:59:28 UTC (rev 13660)
+++ gnucash/trunk/ChangeLog	2006-03-17 23:26:13 UTC (rev 13661)
@@ -1,5 +1,9 @@
 2006-03-17  David Hampton  <hampton at 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

Modified: gnucash/trunk/src/gnome-utils/account-quickfill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/account-quickfill.c	2006-03-17 22:59:28 UTC (rev 13660)
+++ gnucash/trunk/src/gnome-utils/account-quickfill.c	2006-03-17 23:26:13 UTC (rev 13661)
@@ -225,6 +225,7 @@
   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 @@
   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,9 +248,31 @@
     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:
       DEBUG("modify %s", name);
@@ -269,8 +282,6 @@
       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 @@
       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)) {



More information about the gnucash-changes mailing list