From 60b04c2ac577a4139bd388f38c6c335bf262de61 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 4 Oct 2000 21:40:08 +0000 Subject: Select all elements of the etable. 2000-10-04 Jeffrey Stedfast * e-table-selection-model.c (e_table_selection_model_select_all): Select all elements of the etable. (e_table_selection_model_invert_selection): Invert the current selection. * e-table.c (e_table_select_all): New convenience function to select all elements in an e-table. (e_table_invert_selection): New convenience function to invert the current selection in an e-table. svn path=/trunk/; revision=5719 --- widgets/table/e-table-selection-model.c | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'widgets/table/e-table-selection-model.c') diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c index 024ef2abc1..552d632fc9 100644 --- a/widgets/table/e-table-selection-model.c +++ b/widgets/table/e-table-selection-model.c @@ -501,3 +501,45 @@ e_table_selection_model_selected_count (ETableSelectionModel *selection) return count; } + +void +e_table_selection_model_select_all (ETableSelectionModel *selection) +{ + int i; + + if (selection->row_count < 0) { + if (selection->model) { + selection->row_count = e_table_model_row_count (selection->model); + g_free (selection->selection); + selection->selection = g_new0 (gint, (selection->row_count + 31) / 32); + } + } + + if (!selection->selection) + selection->selection = g_new0 (gint, (selection->row_count + 31) / 32); + + for (i = 0; i < (selection->row_count + 31) / 32; i ++) { + selection->selection[i] = ONES; + } +} + +void +e_table_selection_model_invert_selection (ETableSelectionModel *selection) +{ + int i; + + if (selection->row_count < 0) { + if (selection->model) { + selection->row_count = e_table_model_row_count (selection->model); + g_free (selection->selection); + selection->selection = g_new0 (gint, (selection->row_count + 31) / 32); + } + } + + if (!selection->selection) + selection->selection = g_new0 (gint, (selection->row_count + 31) / 32); + + for (i = 0; i < (selection->row_count + 31) / 32; i ++) { + selection->selection[i] = ~selection->selection[i]; + } +} -- cgit v1.2.3