[Gnucash-changes] Please port these changes to 1.8.x and g2
branches.
Linas Vepstas
linas at cvs.gnucash.org
Sun May 30 18:24:00 EDT 2004
Log Message:
-----------
Please port these changes to 1.8.x and g2 branches.
This patch adds code to allow combo-boxes to run with
a shared quickfill. The use of a shared quickfill should
dramatically improve register startup performance for
systems with a large number of accounts. See
http://bugzilla.gnome.org/show_bug.cgi?id=120028
for details
Modified Files:
--------------
gnucash/src/register/register-core:
combocell.h
gnucash/src/register/register-gnome:
combocell-gnome.c
Revision Data
-------------
Index: combocell.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-core/combocell.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lsrc/register/register-core/combocell.h -Lsrc/register/register-core/combocell.h -u -r1.4 -r1.5
--- src/register/register-core/combocell.h
+++ src/register/register-core/combocell.h
@@ -20,28 +20,19 @@
* *
\********************************************************************/
-/*
- * FILE:
- * combocell.h
- *
- * FUNCTION:
- * The ComboCell object implements a cell handler with a
- * "combination-box" pull-down menu in it.
+/**
+ * @file combocell.h
+ * @breif The ComboCell object implements a cell handler with a
+ * "combination-box" pull-down menu in it.
*
* On output, the currently selected menu item is displayed.
* On input, the user can select from a list in the pull-down menu,
* or use the keyboard to slect a menu entry by typing the first
* few menu characters.
*
- * METHODS:
- * The xaccAddComboCellMenuItem() method can be used to add a menu
- * item to the list.
- *
- *
- * HISTORY:
- * Created Jan 1998 Linas Vepstas
- * Copyright (c) 1998 Linas Vepstas
- * Copyright (c) 2000 Dave Peticolas
+ * @author Created Jan 1998 Linas Vepstas
+ * @author Copyright (c) 1998 Linas Vepstas <linas at linas.org>
+ * @author Copyright (c) 2000 Dave Peticolas
*/
#ifndef COMBO_CELL_H
@@ -50,7 +41,7 @@
#include <glib.h>
#include "basiccell.h"
-
+#include "QuickFill.h"
typedef struct
{
@@ -64,27 +55,40 @@
void gnc_combo_cell_set_value (ComboCell *cell, const char *value);
void gnc_combo_cell_clear_menu (ComboCell *cell);
+
+/** Add a menu item to the list. */
void gnc_combo_cell_add_menu_item (ComboCell *cell, char * menustr);
-/* Determines whether the cell will accept strings not in the
+/** Determines whether the cell will accept strings not in the
* menu. Defaults to strict, i.e., only menu items are accepted. */
void gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict);
-/* Sets a character used for special completion processing. */
+/** Sets a character used for special completion processing. */
void gnc_combo_cell_set_complete_char (ComboCell *cell,
char complete_char);
-/* Add a string to a list of strings which, if the cell has that value,
+/** Add a string to a list of strings which, if the cell has that value,
* will cause the cell to be uneditable on 'enter'. */
void gnc_combo_cell_add_ignore_string (ComboCell *cell,
const char *ignore_string);
-/* Determines whether the popup list autosizes itself or uses
+/** Determines whether the popup list autosizes itself or uses
* all available space. FALSE by default. */
void gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize);
-/* Determines whether combocells are automatically raised upon typing.
+/** Determines whether combocells are automatically raised upon typing.
* Defaults to false. This is a 'class' method. */
void gnc_combo_cell_set_autopop (gboolean auto_pop_combos);
+/** Tell the combocell to use a shared QuickFill object. Using this routine
+ * can dramatically improve performance when creating combocells with a
+ * large number of entries. For example, users with thousands of accounts
+ * are complaining about 10-second register startup times, of which 98%
+ * of the cpu is spent building the multi-thousand entry quickfill.
+ * When a shared quickfill is specified, the combo-cell will not add to
+ * nor delete the quickfill; it is the users resonsibility to manage the
+ * quickfill object. The combocell will *not* make a copy of teh quickfill.
+ */
+void gnc_combo_cell_use_quickfill_cache (ComboCell *cell, QuickFill *shared_qf);
+
#endif
Index: combocell-gnome.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/combocell-gnome.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lsrc/register/register-gnome/combocell-gnome.c -Lsrc/register/register-gnome/combocell-gnome.c -u -r1.12 -r1.13
--- src/register/register-gnome/combocell-gnome.c
+++ src/register/register-gnome/combocell-gnome.c
@@ -63,6 +63,8 @@
gboolean autosize;
QuickFill *qf;
+ gboolean use_quickfill_cache; /* If TRUE, we don't own the qf */
+
gboolean in_list_select;
gboolean strict;
@@ -127,6 +129,8 @@
cell->cell.gui_private = box;
box->qf = gnc_quickfill_new ();
+ box->use_quickfill_cache = FALSE;
+
box->in_list_select = FALSE;
box->strict = TRUE;
@@ -301,8 +305,12 @@
g_list_free(box->menustrings);
box->menustrings = NULL;
- gnc_quickfill_destroy (box->qf);
- box->qf = NULL;
+ /* Don't destroy the qf if its not ours to destroy */
+ if (FALSE == box->use_quickfill_cache)
+ {
+ gnc_quickfill_destroy (box->qf);
+ box->qf = NULL;
+ }
for (node = box->ignore_strings; node; node = node->next)
{
@@ -339,8 +347,12 @@
g_list_free (box->menustrings);
box->menustrings = NULL;
- gnc_quickfill_destroy (box->qf);
- box->qf = gnc_quickfill_new ();
+ /* Don't destroy the qf if its not ours to destroy */
+ if (FALSE == box->use_quickfill_cache)
+ {
+ gnc_quickfill_destroy (box->qf);
+ box->qf = gnc_quickfill_new ();
+ }
if (box->item_list != NULL)
{
@@ -355,6 +367,21 @@
box->list_sorted = TRUE;
}
+void
+gnc_combo_cell_use_quickfill_cache (ComboCell * cell, QuickFill *shared_qf)
+{
+ PopBox *box;
+
+ if (cell == NULL) return;
+
+ box = cell->cell.gui_private;
+ if (NULL == box) return;
+
+ box->use_quickfill_cache = TRUE;
+ gnc_quickfill_destroy (box->qf);
+ box->qf = shared_qf;
+}
+
static void
gnc_append_string_to_list (gpointer _string, gpointer _item_list)
{
@@ -404,7 +431,7 @@
{
block_list_signals (cell);
- gnc_item_list_append (box->item_list, menustr);
+ gnc_item_list_append (box->item_list, menustr);
if (cell->cell.value &&
(strcmp (menustr, cell->cell.value) == 0))
gnc_item_list_select (box->item_list, menustr);
@@ -414,7 +441,12 @@
else
box->list_in_sync = FALSE;
- gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
+ /* If we're going to be using a pre-fab quickfill,
+ * then don't fill it in here */
+ if (FALSE == box->use_quickfill_cache)
+ {
+ gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
+ }
box->list_sorted = FALSE;
}
More information about the gnucash-changes
mailing list