aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog5
-rw-r--r--widgets/e-table/e-table-item.c40
-rw-r--r--widgets/e-table/e-table-item.h2
3 files changed, 45 insertions, 2 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