From 1d68f8289f5686820da5ed0cecec586bc50e445c Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 15 Jan 2002 22:33:13 +0000 Subject: New functions for saving selection state and such. 2002-01-15 Christopher James Lahey * e-cell.c, e-cell.h (e_cell_save_state, e_cell_load_state, e_cell_free_state): New functions for saving selection state and such. * e-cell-text.c (ect_save_state): Implemented the new state functions. * e-table-item.c, e-table-item.h: Use the new cell state functions when focusing in or out. Fixes Ximian bug #14968. svn path=/trunk/; revision=15335 --- widgets/table/e-cell-text.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'widgets/table/e-cell-text.c') diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 9f57710d81..63a78a5a98 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -1093,6 +1093,50 @@ ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, voi } } +/* + * ECellView::save_state method + */ +static void * +ect_save_state (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context) +{ + ECellTextView *text_view = (ECellTextView *) ecell_view; + CellEdit *edit = text_view->edit; + + int *save_state = g_new (int, 2); + + save_state[0] = edit->selection_start; + save_state[1] = edit->selection_end; + return save_state; +} + +/* + * ECellView::load_state method + */ +static void +ect_load_state (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context, void *save_state) +{ + ECellTextView *text_view = (ECellTextView *) ecell_view; + CellEdit *edit = text_view->edit; + int length; + int *selection = save_state; + + length = strlen (edit->cell.text); + + edit->selection_start = MIN (selection[0], length); + edit->selection_end = MIN (selection[1], length); + + ect_queue_redraw (text_view, view_col, row); +} + +/* + * ECellView::free_state method + */ +static void +ect_free_state (ECellView *ecell_view, int model_col, int view_col, int row, void *save_state) +{ + g_free (save_state); +} + static void ect_print (ECellView *ecell_view, GnomePrintContext *context, int model_col, int view_col, int row, @@ -1455,6 +1499,9 @@ e_cell_text_class_init (GtkObjectClass *object_class) ecc->height = ect_height; ecc->enter_edit = ect_enter_edit; ecc->leave_edit = ect_leave_edit; + ecc->save_state = ect_save_state; + ecc->load_state = ect_load_state; + ecc->free_state = ect_free_state; ecc->print = ect_print; ecc->print_height = ect_print_height; ecc->max_width = ect_max_width; -- cgit