[Gnucash-changes] r13532 - gnucash/trunk - The account quickfill has multiple components to it, only one of which

David Hampton hampton at cvs.gnucash.org
Tue Mar 7 22:06:52 EST 2006


Author: hampton
Date: 2006-03-07 22:06:51 -0500 (Tue, 07 Mar 2006)
New Revision: 13532
Trac: http://svn.gnucash.org/trac/changeset/13532

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/gnome-utils/account-quickfill.c
   gnucash/trunk/src/gnome-utils/account-quickfill.h
   gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c
   gnucash/trunk/src/register/ledger-core/split-register-load.c
   gnucash/trunk/src/register/ledger-core/split-register.h
   gnucash/trunk/src/register/register-core/combocell.h
   gnucash/trunk/src/register/register-gnome/combocell-gnome.c
   gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
   gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h
   gnucash/trunk/src/register/register-gnome/gnucash-item-list.c
   gnucash/trunk/src/register/register-gnome/gnucash-item-list.h
Log:
The account quickfill has multiple components to it, only one of which
was shared. Build and use a shared list store used by the
gnucash_item_edit widget (which is updated by signals sent when
accounts are added/deleted/modified.)  With this in place, its not
necessary to rebuild two account quickfills for each open register
window when a gnc_gui_resume_refresh is called which eliminates an
O(2n) slowdown.  This seems sufficient to close 120028.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/ChangeLog	2006-03-08 03:06:51 UTC (rev 13532)
@@ -1,17 +1,34 @@
 2006-03-07  David Hampton  <hampton at employees.org>
 
-	* src/gnome-utils/gnc-file.c:
+	* src/register/register-gnome/combocell-gnome.c:
+	* src/register/register-gnome/gnucash-item-list.[ch]:
+	* src/register/register-gnome/gnucash-item-edit.[ch]:
+	* src/register/ledger-core/gnc-ledger-display.c:
+	* src/register/ledger-core/split-register.h:
+	* src/register/ledger-core/split-register-load.c:
+	* src/register/register-core/combocell.h:
+	* src/gnome-utils/account-quickfill.[ch]: The account quickfill
+	has multiple components to it, only one of which was shared. Build
+	and use a shared list store used by the gnucash_item_edit
+	widget (which is updated by signals sent when accounts are
+	added/deleted/modified.)  With this in place, its not necessary to
+	rebuild two account quickfills for each open register window when
+	a gnc_gui_resume_refresh is called which eliminates an O(2n)
+	slowdown.  This seems sufficient to close 120028.
+
 	* src/gnome/dialog-price-editor.c:
 	* src/gnome/top-level.c:
 	* src/gnome/dialog-commodities.c:
 	* src/gnome/dialog-price-edit-db.c:
-
 	* src/gnc-ui.h: Remove all usage of gnc_get_current_session / book
 	/ whatever except at the very top level when the dialog is
 	originally created. Tell the component manager to delete the
 	dialog when the session is destroyed. Remove support for an old
 	url-that-generates-a-price-edit-window trick.
 
+	* src/gnome-utils/gnc-file.c: Add a couple of calls to the
+	component manager when closing the current session.
+
 	* src/engine/gnc-pricedb.c: Use the pointer to the commodity as a
 	hash key instead of looking up the commodity string and then
 	hashing that.  Fixes 332678.

Modified: gnucash/trunk/src/gnome-utils/account-quickfill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/account-quickfill.c	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/gnome-utils/account-quickfill.c	2006-03-08 03:06:51 UTC (rev 13532)
@@ -44,6 +44,7 @@
 
 typedef struct {
   QuickFill *qf;
+  GtkListStore *list_store;
   QofBook *book;
   AccountGroup *group;
   gint  listener;
@@ -59,6 +60,7 @@
 			      shared_quickfill_gconf_changed,
 			      qfb);
   gnc_quickfill_destroy (qfb->qf);
+  g_object_unref(qfb->list_store);
   gnc_engine_unregister_event_handler (qfb->listener);
   g_free (qfb);
 }
@@ -79,6 +81,7 @@
   const char *match_str;
   QofCollection *col;
   Account *account;
+  GtkTreeIter iter;
 
   if (! (event_type & GNC_EVENT_MODIFY)) return;
   if (QSTRCMP (type, GNC_ID_ACCOUNT)) return;
@@ -108,6 +111,8 @@
 add_string:
   PINFO ("insert new account %s into qf=%p\n", name, qf);
   gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
+  gtk_list_store_append (qfb->list_store, &iter);
+  gtk_list_store_set (qfb->list_store, &iter, 0, name, -1);
 done:
   g_free(name);
 }
@@ -118,6 +123,7 @@
 {
   QFB *qfb = data;
   char *name;
+  GtkTreeIter iter;
 
   if (qfb->dont_add_cb)
   {
@@ -128,6 +134,8 @@
   name = xaccAccountGetFullName (account);
   if (NULL == name) return NULL;
   gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA);
+  gtk_list_store_append (qfb->list_store, &iter);
+  gtk_list_store_set (qfb->list_store, &iter, 0, name, -1);
   g_free(name);
 
   return NULL;
@@ -147,7 +155,7 @@
 /* Build the quickfill list out of account names. 
  * Essentially same loop as in gnc_load_xfer_cell() above.
  */
-static QuickFill *
+static QFB *
 build_shared_quickfill (QofBook *book, AccountGroup *group, const char * key,
                         AccountBoolCB cb, gpointer data)
 {
@@ -160,6 +168,7 @@
   qfb->listener = 0;
   qfb->dont_add_cb = cb;
   qfb->dont_add_data = data;
+  qfb->list_store = gtk_list_store_new (1, G_TYPE_STRING);
 
   gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
 				shared_quickfill_gconf_changed,
@@ -172,7 +181,7 @@
 
   qof_book_set_data_fin (book, key, qfb, shared_quickfill_destroy);
 
-  return qfb->qf;
+  return qfb;
 }
 
 QuickFill *
@@ -188,7 +197,25 @@
 
   if (qfb) return qfb->qf;
 
-  return build_shared_quickfill (book, group, key, cb, cb_data);
+  qfb = build_shared_quickfill (book, group, key, cb, cb_data);
+  return qfb->qf;
 }
 
+GtkListStore *
+gnc_get_shared_account_name_list_store (AccountGroup *group, 
+					const char * key, 
+					AccountBoolCB cb, gpointer cb_data)
+{
+  QFB *qfb;
+  QofBook *book;
+
+  book = xaccGroupGetBook (group);
+  qfb = qof_book_get_data (book, key);
+
+  if (qfb) return qfb->list_store;
+
+  qfb = build_shared_quickfill (book, group, key, cb, cb_data);
+  return qfb->list_store;
+}
+
 /* ====================== END OF FILE ================================== */

Modified: gnucash/trunk/src/gnome-utils/account-quickfill.h
===================================================================
--- gnucash/trunk/src/gnome-utils/account-quickfill.h	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/gnome-utils/account-quickfill.h	2006-03-08 03:06:51 UTC (rev 13532)
@@ -40,7 +40,7 @@
 #ifndef QUICKFILL_ACCOUNT_H
 #define QUICKFILL_ACCOUNT_H
 
-#include <glib.h>
+#include <gtk/gtk.h>
 
 #include "Account.h"
 #include "Group.h"
@@ -73,6 +73,10 @@
                                                    const char * key,
                                                    AccountBoolCB skip_cb, 
                                                    gpointer cb_data);
+GtkListStore *
+gnc_get_shared_account_name_list_store (AccountGroup *group, 
+					const char * key, 
+					AccountBoolCB cb, gpointer cb_data);
 
 #endif
 

Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c	2006-03-08 03:06:51 UTC (rev 13532)
@@ -800,9 +800,6 @@
   if (!ld || ld->loading)
     return;
 
-    gnc_split_register_load_xfer_cells (ld->reg,
-                                        gnc_ledger_display_leader (ld));
-
   if (!gnc_split_register_full_refresh_ok (ld->reg))
     return;
 

Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-03-08 03:06:51 UTC (rev 13532)
@@ -40,6 +40,9 @@
 /* This static indicates the debugging module that this .o belongs to. */
 /* static short module = MOD_LEDGER; */
 
+static void gnc_split_register_load_xfer_cells (SplitRegister *reg,
+						Account *base_account);
+
 static void
 gnc_split_register_load_recn_cells (SplitRegister *reg)
 {
@@ -551,26 +554,7 @@
 }
 
 /* ===================================================================== */
-/* Splat the account name into the transfer cell combobox menu */
 
-static gpointer
-load_xfer_cell_cb (Account *account, gpointer data)
-{
-  ComboCell *cell = data;
-  char *name;
-
-  if (xaccAccountGetPlaceholder (account)) return NULL;
-
-  name = xaccAccountGetFullName (account);
-  if (NULL == name) return NULL;
-  gnc_combo_cell_add_account_menu_item (cell, name);
-  g_free(name);
-
-  return NULL;
-}
-
-/* ===================================================================== */
-
 #define QKEY  "split_reg_shared_quickfill"
 
 static gboolean 
@@ -579,12 +563,13 @@
   return xaccAccountGetPlaceholder (account);
 }
 
-void
+static void
 gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
 {
   AccountGroup *group;
   QuickFill *qf;
   ComboCell *cell;
+  GtkListStore *store;
 
   group = xaccAccountGetRoot(base_account);
   if (group == NULL)
@@ -594,22 +579,17 @@
     return;
 
   qf = gnc_get_shared_account_name_quickfill (group, QKEY, skip_cb, NULL);
+  store = gnc_get_shared_account_name_list_store (group, QKEY, skip_cb, NULL);
 
   cell = (ComboCell *)
     gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
-  gnc_combo_cell_set_sort_enabled (cell, FALSE);
-  gnc_combo_cell_clear_menu (cell);
   gnc_combo_cell_use_quickfill_cache (cell, qf);
-  xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE);
-  gnc_combo_cell_set_sort_enabled (cell, TRUE);
+  gnc_combo_cell_use_list_store_cache (cell, store);
 
   cell = (ComboCell *)
     gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
-  gnc_combo_cell_set_sort_enabled (cell, FALSE);
-  gnc_combo_cell_clear_menu (cell);
   gnc_combo_cell_use_quickfill_cache (cell, qf);
-  xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE);
-  gnc_combo_cell_set_sort_enabled (cell, TRUE);
+  gnc_combo_cell_use_list_store_cache (cell, store);
 }
 
 /* ====================== END OF FILE ================================== */

Modified: gnucash/trunk/src/register/ledger-core/split-register.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.h	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/ledger-core/split-register.h	2006-03-08 03:06:51 UTC (rev 13532)
@@ -447,10 +447,6 @@
 gboolean gnc_split_register_full_refresh_ok (SplitRegister *reg);
 
 /** Private function -- outsiders must not use this */
-void     gnc_split_register_load_xfer_cells (SplitRegister *reg,
-                                             Account *base_account);
-
-/** Private function -- outsiders must not use this */
 void gnc_copy_trans_onto_trans (Transaction *from, Transaction *to,
                                 gboolean use_cut_semantics,
                                 gboolean do_commit);

Modified: gnucash/trunk/src/register/register-core/combocell.h
===================================================================
--- gnucash/trunk/src/register/register-core/combocell.h	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/register-core/combocell.h	2006-03-08 03:06:51 UTC (rev 13532)
@@ -46,6 +46,7 @@
 typedef struct
 {
   BasicCell cell;
+  gpointer shared_store;
 } ComboCell;
 
 
@@ -96,4 +97,6 @@
  */
 void gnc_combo_cell_use_quickfill_cache (ComboCell *cell, QuickFill *shared_qf);
 
+void gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data);
+
 #endif

Modified: gnucash/trunk/src/register/register-gnome/combocell-gnome.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/combocell-gnome.c	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/register-gnome/combocell-gnome.c	2006-03-08 03:06:51 UTC (rev 13532)
@@ -423,6 +423,14 @@
 	box->qf = shared_qf;
 }
 
+void
+gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data)
+{
+	if (cell == NULL) return;
+
+	cell->shared_store = data;
+}
+
 static void
 gnc_append_string_to_list (gpointer _string, gpointer _item_list)
 {
@@ -789,7 +797,7 @@
 	/* initialize gui-specific, private data */
 	box->sheet = sheet;
 	box->item_edit = item_edit;
-	box->item_list = gnc_item_edit_new_list(box->item_edit);
+	box->item_list = gnc_item_edit_new_list(box->item_edit, cell->shared_store);
 	g_object_ref (box->item_list);
 	gtk_object_sink (GTK_OBJECT(box->item_list));
 

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c	2006-03-08 03:06:51 UTC (rev 13532)
@@ -1326,13 +1326,14 @@
 
 
 GncItemList *
-gnc_item_edit_new_list (GncItemEdit *item_edit)
+gnc_item_edit_new_list (GncItemEdit *item_edit, GtkListStore *shared_store)
 {
         GncItemList *item_list;
 
 	g_return_val_if_fail (GNC_IS_ITEM_EDIT(item_edit), NULL);
 
-        item_list = GNC_ITEM_LIST (gnc_item_list_new (item_edit->parent));
+        item_list = GNC_ITEM_LIST (gnc_item_list_new (item_edit->parent,
+						      shared_store));
 
 	return item_list;
 }

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h	2006-03-08 03:06:51 UTC (rev 13532)
@@ -127,7 +127,7 @@
 GnomeCanvasItem *gnc_item_edit_new (GnomeCanvasGroup *parent,
 				    GnucashSheet *sheet, GtkWidget *entry);
 
-GncItemList * gnc_item_edit_new_list (GncItemEdit *item_edit);
+GncItemList * gnc_item_edit_new_list (GncItemEdit *item_edit, GtkListStore *shared_store);
 GNCDatePicker * gnc_item_edit_new_date_picker (GncItemEdit *item_edit);
 
 void gnc_item_edit_set_popup (GncItemEdit     *item_edit,

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-list.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-list.c	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-list.c	2006-03-08 03:06:51 UTC (rev 13532)
@@ -404,12 +404,11 @@
 }
 
 GnomeCanvasItem *
-gnc_item_list_new(GnomeCanvasGroup *parent)
+gnc_item_list_new(GnomeCanvasGroup *parent, GtkListStore *list_store)
 {
         GtkWidget *frame;
 	GtkWidget *tree_view;
         GtkWidget *scrollwin;
-	GtkListStore *list_store;
 	GtkCellRenderer *renderer;
 	GtkTreeViewColumn *column;
         GnomeCanvasItem *item;
@@ -424,7 +423,8 @@
                                         GTK_POLICY_AUTOMATIC,
                                         GTK_POLICY_AUTOMATIC);
 
-	list_store = gtk_list_store_new (1, G_TYPE_STRING);
+	if (NULL == list_store)
+		list_store = gtk_list_store_new (1, G_TYPE_STRING);
 	tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
 	/* Removed code to enable sorting. Enable it after the list is
 	 * fully populated by calling gnc_item_list_finished_loading(). */

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-list.h
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-list.h	2006-03-08 02:26:53 UTC (rev 13531)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-list.h	2006-03-08 03:06:51 UTC (rev 13532)
@@ -59,7 +59,7 @@
 
 GType gnc_item_list_get_type (void);
 
-GnomeCanvasItem *gnc_item_list_new (GnomeCanvasGroup *parent);
+GnomeCanvasItem *gnc_item_list_new (GnomeCanvasGroup *parent, GtkListStore *shared_store);
 
 void gnc_item_list_clear (GncItemList *item_list);
 



More information about the gnucash-changes mailing list