From 4404cde3fc7f27f9dc348d388a4cad22af302ea0 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 22 Jan 2001 01:48:54 +0000 Subject: Made the cursor move when rows are inserted or deleted. If in single mode 2001-01-21 Christopher James Lahey * e-table-selection-model.c: Made the cursor move when rows are inserted or deleted. If in single mode and the selected row gets removed, move it up. svn path=/trunk/; revision=7691 --- widgets/table/e-table-selection-model.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'widgets') diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c index 7c39648f55..85a22fd638 100644 --- a/widgets/table/e-table-selection-model.c +++ b/widgets/table/e-table-selection-model.c @@ -27,6 +27,8 @@ static GtkObjectClass *e_table_selection_model_parent_class; +static void etsm_select_single_row (ETableSelectionModel *selection, int row); + enum { CURSOR_CHANGED, SELECTION_CHANGED, @@ -74,6 +76,8 @@ model_row_inserted(ETableModel *etm, int row, ETableSelectionModel *etsm) etsm->selection[box] = (etsm->selection[box] & BITMASK_LEFT(row)) | ((etsm->selection[box] & BITMASK_RIGHT(row)) >> 1); etsm->row_count ++; } + if (etsm->cursor_row >= row) + etsm->cursor_row ++; } static void @@ -82,6 +86,7 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm) int box; int i; int last; + int selected = FALSE; if(etsm->row_count >= 0) { guint32 bitmask; box = row >> 5; @@ -89,6 +94,7 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm) /* Build bitmasks for the left and right half of the box */ bitmask = BITMASK_RIGHT(row) >> 1; + selected = e_table_selection_model_is_row_selected(etsm, row); /* Shift right half of box one bit to the left. */ etsm->selection[box] = (etsm->selection[box] & BITMASK_LEFT(row))| ((etsm->selection[box] & bitmask) << 1); @@ -106,7 +112,12 @@ model_row_deleted(ETableModel *etm, int row, ETableSelectionModel *etsm) if ((etsm->row_count & 0x1f) == 0) { etsm->selection = g_renew(gint, etsm->selection, etsm->row_count >> 5); } + if (selected && etsm->mode == GTK_SELECTION_SINGLE) { + etsm_select_single_row (etsm, row > 0 ? row - 1 : 0); + } } + if (etsm->cursor_row >= row && etsm->cursor_row > 0) + etsm->cursor_row --; } #else -- cgit