From 5fbcc4828efb084344e9c5fd42ebccb288ee492f Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Wed, 2 Aug 2000 16:56:26 +0000 Subject: Add a handler for "model_pre_change" and properly stop editing. 2000-08-02 Christopher James Lahey * e-table-item.c, e-table-item.h: Add a handler for "model_pre_change" and properly stop editing. * e-table-model.c, e-table-model.h: Added a "model_pre_change" signal that gets sent before any row numbers are changed. * e-table-sorted-variable.c, e-table-subset-variable.c: Emit "model_pre_change" signals as appropriate. * e-table-subset.c, e-table-subset.h: Proxy "model_pre_changed" signals. svn path=/trunk/; revision=4472 --- widgets/e-table/e-table-item.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'widgets/e-table/e-table-item.c') diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c index 4eac94ed41..1ecd119133 100644 --- a/widgets/e-table/e-table-item.c +++ b/widgets/e-table/e-table-item.c @@ -302,6 +302,8 @@ eti_remove_table_model (ETableItem *eti) if (!eti->table_model) return; + 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_change_id); gtk_signal_disconnect (GTK_OBJECT (eti->table_model), @@ -316,6 +318,7 @@ eti_remove_table_model (ETableItem *eti) if (eti->source_model) gtk_object_unref (GTK_OBJECT (eti->source_model)); + eti->table_model_pre_change_id = 0; eti->table_model_change_id = 0; eti->table_model_row_change_id = 0; eti->table_model_cell_change_id = 0; @@ -558,6 +561,16 @@ eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1) gnome_canvas_request_redraw (item->canvas, rect.x0, rect.y0, rect.x1, rect.y1); } +/* + * Callback routine: invoked before the ETableModel has suffers a change + */ +static void +eti_table_model_pre_change (ETableModel *table_model, ETableItem *eti) +{ + if (eti_editing (eti)) + e_table_item_leave_edit (eti); +} + /* * Callback routine: invoked when the ETableModel has suffered a change */ @@ -720,7 +733,11 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model) eti->table_model = table_model; gtk_object_ref (GTK_OBJECT (eti->table_model)); - + + eti->table_model_pre_change_id = gtk_signal_connect ( + GTK_OBJECT (table_model), "model_pre_change", + GTK_SIGNAL_FUNC (eti_table_model_pre_change), eti); + eti->table_model_change_id = gtk_signal_connect ( GTK_OBJECT (table_model), "model_changed", GTK_SIGNAL_FUNC (eti_table_model_changed), eti); @@ -841,12 +858,12 @@ eti_destroy (GtkObject *object) if (eti->selection) gtk_object_unref(GTK_OBJECT(eti->selection)); - + if (eti->height_cache_idle_id) g_source_remove(eti->height_cache_idle_id); - + g_free (eti->height_cache); - + if (GTK_OBJECT_CLASS (eti_parent_class)->destroy) (*GTK_OBJECT_CLASS (eti_parent_class)->destroy) (object); } @@ -1033,6 +1050,9 @@ eti_unrealize (GnomeCanvasItem *item) { ETableItem *eti = E_TABLE_ITEM (item); + if (eti_editing (eti)) + e_table_item_leave_edit (eti); + gdk_gc_unref (eti->fill_gc); eti->fill_gc = NULL; gdk_gc_unref (eti->grid_gc); @@ -1844,18 +1864,26 @@ e_table_item_enter_edit (ETableItem *eti, int col, int row) void e_table_item_leave_edit (ETableItem *eti) { + int col, row; + void *edit_ctx; + g_return_if_fail (eti != NULL); g_return_if_fail (E_IS_TABLE_ITEM (eti)); if (!eti_editing (eti)) return; - e_cell_leave_edit (eti->cell_views [eti->editing_col], - view_to_model_col(eti, eti->editing_col), eti->editing_col, eti->editing_row, - eti->edit_ctx); + col = eti->editing_col; + row = eti->editing_row; + edit_ctx = eti->edit_ctx; + eti->editing_col = -1; eti->editing_row = -1; eti->edit_ctx = NULL; + + e_cell_leave_edit (eti->cell_views [col], + view_to_model_col(eti, col), + col, row, edit_ctx); } typedef struct { -- cgit