diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-10-31 18:33:51 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-10-31 18:33:51 +0800 |
commit | 23587bebe83c772d08ab2ae7faa31dffa45b0987 (patch) | |
tree | 610958e3503f902d708b7facdbc381315b62f317 /widgets/table/e-table-item.c | |
parent | a06c0a0d1265e81e0672c859742474c623f3d2d8 (diff) | |
download | gsoc2013-evolution-23587bebe83c772d08ab2ae7faa31dffa45b0987.tar.gz gsoc2013-evolution-23587bebe83c772d08ab2ae7faa31dffa45b0987.tar.zst gsoc2013-evolution-23587bebe83c772d08ab2ae7faa31dffa45b0987.zip |
Added frozen_count variable to know not to show the cursor while a change
2001-10-31 Christopher James Lahey <clahey@ximian.com>
* e-table-item.c, e-table-item.h: Added frozen_count variable to
know not to show the cursor while a change is going on.
* e-table-model.c, e-table-model.h, e-tree-model.c,
e-tree-model.h: Added a model_no_change signal to pair with a
pre_change if there's no change.
* e-table-selection-model.h: Removed an unused frozen field here.
* e-table-sorted.c, e-table-subset.c, e-table-subset.h,
e-table-without.c, e-tree-memory.c, e-tree-sorted.c,
e-tree-table-adapter.c: Made sure pre_changes were all matched by
some change. Proxy no_change signal where appropriate.
* e-tree-selection-model.c: Keep track of the frozen_count
variable to know whether a change is going on.
svn path=/trunk/; revision=14523
Diffstat (limited to 'widgets/table/e-table-item.c')
-rw-r--r-- | widgets/table/e-table-item.c | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 69b866e910..d090aa9b43 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -458,6 +458,8 @@ eti_remove_table_model (ETableItem *eti) gtk_signal_disconnect (GTK_OBJECT (eti->table_model), eti->table_model_pre_change_id); gtk_signal_disconnect (GTK_OBJECT (eti->table_model), + eti->table_model_no_change_id); + gtk_signal_disconnect (GTK_OBJECT (eti->table_model), eti->table_model_change_id); gtk_signal_disconnect (GTK_OBJECT (eti->table_model), eti->table_model_row_change_id); @@ -472,6 +474,7 @@ eti_remove_table_model (ETableItem *eti) gtk_object_unref (GTK_OBJECT (eti->source_model)); eti->table_model_pre_change_id = 0; + eti->table_model_no_change_id = 0; eti->table_model_change_id = 0; eti->table_model_row_change_id = 0; eti->table_model_cell_change_id = 0; @@ -840,6 +843,11 @@ eti_show_cursor (ETableItem *eti, int delay) if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) return; + + if (eti->frozen_count > 0) { + eti->queue_show_cursor = TRUE; + return; + } gtk_object_get(GTK_OBJECT(eti->selection), "cursor_row", &cursor_row, @@ -881,6 +889,10 @@ eti_check_cursor_bounds (ETableItem *eti) if (!((GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED) && eti->cell_views_realized)) return; + + if (eti->frozen_count > 0) { + return; + } gtk_object_get(GTK_OBJECT(eti->selection), "cursor_row", &cursor_row, @@ -957,8 +969,25 @@ eti_cancel_drag_due_to_model_change (ETableItem *eti) } } +static void +eti_freeze (ETableItem *eti) +{ + eti->frozen_count ++; +} + +static void +eti_unfreeze (ETableItem *eti) +{ + eti->frozen_count --; + if (eti->frozen_count == 0 && eti->queue_show_cursor) { + eti_show_cursor (eti, 0); + eti_check_cursor_bounds (eti); + eti->queue_show_cursor = FALSE; + } +} + /* - * Callback routine: invoked before the ETableModel has suffers a change + * Callback routine: invoked before the ETableModel suffers a change */ static void eti_table_model_pre_change (ETableModel *table_model, ETableItem *eti) @@ -967,6 +996,16 @@ eti_table_model_pre_change (ETableModel *table_model, ETableItem *eti) eti_check_cursor_bounds (eti); if (eti_editing (eti)) e_table_item_leave_edit_(eti); + eti_freeze (eti); +} + +/* + * Callback routine: invoked when the ETableModel has not suffered a change + */ +static void +eti_table_model_no_change (ETableModel *table_model, ETableItem *eti) +{ + eti_unfreeze (eti); } /* @@ -976,13 +1015,17 @@ eti_table_model_pre_change (ETableModel *table_model, ETableItem *eti) static void eti_table_model_changed (ETableModel *table_model, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + eti_unfreeze (eti); return; + } eti->rows = e_table_model_row_count (eti->table_model); free_height_cache(eti); + eti_unfreeze (eti); + eti->needs_compute_height = 1; e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti)); eti->needs_redraw = 1; @@ -994,36 +1037,46 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti) static void eti_table_model_row_changed (ETableModel *table_model, int row, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + eti_unfreeze (eti); return; + } if ((!eti->uniform_row_height) && eti->height_cache && eti->height_cache[row] != -1 && eti_row_height_real(eti, row) != eti->height_cache[row]) { eti_table_model_changed (table_model, eti); return; } + eti_unfreeze (eti); + eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0); } static void eti_table_model_cell_changed (ETableModel *table_model, int col, int row, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + eti_unfreeze (eti); return; + } if ((!eti->uniform_row_height) && eti->height_cache && eti->height_cache[row] != -1 && eti_row_height_real(eti, row) != eti->height_cache[row]) { eti_table_model_changed (table_model, eti); return; } + eti_unfreeze (eti); + eti_request_region_redraw (eti, 0, row, eti->cols - 1, row, 0); } static void eti_table_model_rows_inserted (ETableModel *table_model, int row, int count, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + eti_unfreeze (eti); return; + } eti->rows = e_table_model_row_count (eti->table_model); if (eti->height_cache) { @@ -1034,6 +1087,8 @@ eti_table_model_rows_inserted (ETableModel *table_model, int row, int count, ETa eti->height_cache[i] = -1; } + eti_unfreeze (eti); + eti_idle_maybe_show_cursor(eti); eti->needs_compute_height = 1; @@ -1045,8 +1100,10 @@ eti_table_model_rows_inserted (ETableModel *table_model, int row, int count, ETa static void eti_table_model_rows_deleted (ETableModel *table_model, int row, int count, ETableItem *eti) { - if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) + if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED)) { + eti_unfreeze (eti); return; + } g_assert (eti->rows == -1 || row + count <= eti->rows); @@ -1058,6 +1115,8 @@ eti_table_model_rows_deleted (ETableModel *table_model, int row, int count, ETab memmove(eti->height_cache + row, eti->height_cache + row + count, (eti->rows - row) * sizeof(int)); } + eti_unfreeze (eti); + eti_idle_maybe_show_cursor(eti); eti->needs_compute_height = 1; @@ -1116,6 +1175,10 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model) GTK_OBJECT (table_model), "model_pre_change", GTK_SIGNAL_FUNC (eti_table_model_pre_change), eti); + eti->table_model_no_change_id = gtk_signal_connect ( + GTK_OBJECT (table_model), "model_no_change", + GTK_SIGNAL_FUNC (eti_table_model_no_change), eti); + eti->table_model_change_id = gtk_signal_connect ( GTK_OBJECT (table_model), "model_changed", GTK_SIGNAL_FUNC (eti_table_model_changed), eti); @@ -1464,6 +1527,9 @@ eti_init (GnomeCanvasItem *item) eti->rows = -1; + eti->frozen_count = 0; + eti->queue_show_cursor = FALSE; + e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM (eti), eti_reflow); } @@ -2834,6 +2900,7 @@ eti_cursor_activated (ESelectionModel *selection, int row, int col, ETableItem * } else { eti_show_cursor(eti, 0); } + eti_check_cursor_bounds (eti); } } |