diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-04 16:52:04 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-04 16:52:04 +0800 |
commit | 55b79db1f4a1d26892fa6a57663dcf2b1715091e (patch) | |
tree | 1800a23735b9019c63fb91c7bfa6f2cdf2c3f91e | |
parent | cb7c636a65f9fe7f1ba301af8e1f31d69c112d3c (diff) | |
download | gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.tar gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.tar.gz gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.tar.bz2 gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.tar.lz gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.tar.xz gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.tar.zst gsoc2013-evolution-55b79db1f4a1d26892fa6a57663dcf2b1715091e.zip |
Added a height_cache idle loop so that the height_cache will be validated
2000-05-04 Christopher James Lahey <clahey@helixcode.com>
* e-table-item.c, e-table-item.h: Added a height_cache idle loop
so that the height_cache will be validated in the idle loop.
svn path=/trunk/; revision=2794
-rw-r--r-- | widgets/e-table/ChangeLog | 5 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.c | 40 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.h | 2 | ||||
-rw-r--r-- | widgets/table/e-table-item.c | 40 | ||||
-rw-r--r-- | widgets/table/e-table-item.h | 2 |
5 files changed, 85 insertions, 4 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index 0a5adcf0ac..9d367ae392 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,5 +1,10 @@ 2000-05-04 Christopher James Lahey <clahey@helixcode.com> + * e-table-item.c, e-table-item.h: Added a height_cache idle loop + so that the height_cache will be validated in the idle loop. + +2000-05-04 Christopher James Lahey <clahey@helixcode.com> + * e-table-sorted-variable.c: Load all the data to be sorted by before actually doing the sort. diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c index ccc1eba5d8..cae22ec081 100644 --- a/widgets/e-table/e-table-item.c +++ b/widgets/e-table/e-table-item.c @@ -48,6 +48,7 @@ enum { }; static int eti_get_height (ETableItem *eti); +static int eti_row_height (ETableItem *eti, int row); static gboolean eti_editing (ETableItem *eti) @@ -298,12 +299,40 @@ eti_row_height_real (ETableItem *eti, int row) return max_h; } +static gboolean +height_cache_idle(ETableItem *eti) +{ + int changed = 0; + int i; + if (!eti->height_cache) { + eti->height_cache = g_new(int, eti->rows); + } + for (i = eti->height_cache_idle_count; i < eti->rows; i++) { + if (eti->height_cache[i] == -1) { + eti_row_height(eti, i); + changed ++; + if (changed >= 20) + break; + } + } + if (changed >= 20) { + eti->height_cache_idle_count = i; + return TRUE; + } + eti->height_cache_idle_id = 0; + return FALSE; +} + static void free_height_cache (ETableItem *eti) { if (eti->height_cache) g_free (eti->height_cache); eti->height_cache = NULL; + eti->height_cache_idle_count = 0; + + if (eti->height_cache_idle_id == 0) + eti->height_cache_idle_id = g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) height_cache_idle, eti, NULL); } static void @@ -375,8 +404,10 @@ eti_get_height (ETableItem *eti) if (eti->height_cache) { height = 0; for (row = 0; row < rows; row++) { - if (eti->height_cache[row] == -1) - height += row_height + 1; + if (eti->height_cache[row] == -1) { + height += (row_height + 1) * (rows - row); + break; + } else height += eti->height_cache[row] + 1; } @@ -628,6 +659,9 @@ eti_destroy (GtkObject *object) g_slist_free (eti->selection); + if (eti->height_cache_idle_id) + g_source_remove(eti->height_cache_idle_id); + if (GTK_OBJECT_CLASS (eti_parent_class)->destroy) (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object); } @@ -706,6 +740,8 @@ eti_init (GnomeCanvasItem *item) eti->height = 0; eti->height_cache = NULL; + eti->height_cache_idle_id = 0; + eti->height_cache_idle_count = 0; eti->length_threshold = -1; eti->renderers_can_change_size = 1; diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h index 1e451e64fe..696bf465e6 100644 --- a/widgets/e-table/e-table-item.h +++ b/widgets/e-table/e-table-item.h @@ -51,6 +51,8 @@ typedef struct { int n_cells; int *height_cache; + int height_cache_idle_id; + int height_cache_idle_count; /* * Lengh Threshold: above this, we stop computing correctly diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index ccc1eba5d8..cae22ec081 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -48,6 +48,7 @@ enum { }; static int eti_get_height (ETableItem *eti); +static int eti_row_height (ETableItem *eti, int row); static gboolean eti_editing (ETableItem *eti) @@ -298,12 +299,40 @@ eti_row_height_real (ETableItem *eti, int row) return max_h; } +static gboolean +height_cache_idle(ETableItem *eti) +{ + int changed = 0; + int i; + if (!eti->height_cache) { + eti->height_cache = g_new(int, eti->rows); + } + for (i = eti->height_cache_idle_count; i < eti->rows; i++) { + if (eti->height_cache[i] == -1) { + eti_row_height(eti, i); + changed ++; + if (changed >= 20) + break; + } + } + if (changed >= 20) { + eti->height_cache_idle_count = i; + return TRUE; + } + eti->height_cache_idle_id = 0; + return FALSE; +} + static void free_height_cache (ETableItem *eti) { if (eti->height_cache) g_free (eti->height_cache); eti->height_cache = NULL; + eti->height_cache_idle_count = 0; + + if (eti->height_cache_idle_id == 0) + eti->height_cache_idle_id = g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) height_cache_idle, eti, NULL); } static void @@ -375,8 +404,10 @@ eti_get_height (ETableItem *eti) if (eti->height_cache) { height = 0; for (row = 0; row < rows; row++) { - if (eti->height_cache[row] == -1) - height += row_height + 1; + if (eti->height_cache[row] == -1) { + height += (row_height + 1) * (rows - row); + break; + } else height += eti->height_cache[row] + 1; } @@ -628,6 +659,9 @@ eti_destroy (GtkObject *object) g_slist_free (eti->selection); + if (eti->height_cache_idle_id) + g_source_remove(eti->height_cache_idle_id); + if (GTK_OBJECT_CLASS (eti_parent_class)->destroy) (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object); } @@ -706,6 +740,8 @@ eti_init (GnomeCanvasItem *item) eti->height = 0; eti->height_cache = NULL; + eti->height_cache_idle_id = 0; + eti->height_cache_idle_count = 0; eti->length_threshold = -1; eti->renderers_can_change_size = 1; diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h index 1e451e64fe..696bf465e6 100644 --- a/widgets/table/e-table-item.h +++ b/widgets/table/e-table-item.h @@ -51,6 +51,8 @@ typedef struct { int n_cells; int *height_cache; + int height_cache_idle_id; + int height_cache_idle_count; /* * Lengh Threshold: above this, we stop computing correctly |