aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/table/e-table-selection-model.c42
-rw-r--r--widgets/table/e-table-selection-model.h3
-rw-r--r--widgets/table/e-table.c18
-rw-r--r--widgets/table/e-table.h4
4 files changed, 67 insertions, 0 deletions
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];
+ }
+}
diff --git a/widgets/table/e-table-selection-model.h b/widgets/table/e-table-selection-model.h
index cc8b721049..2646189e2c 100644
--- a/widgets/table/e-table-selection-model.h
+++ b/widgets/table/e-table-selection-model.h
@@ -65,6 +65,9 @@ void e_table_selection_model_maybe_do_something (ETableSelectionM
void e_table_selection_model_clear (ETableSelectionModel *selection);
gint e_table_selection_model_selected_count (ETableSelectionModel *selection);
+void e_table_selection_model_select_all (ETableSelectionModel *selection);
+void e_table_selection_model_invert_selection (ETableSelectionModel *selection);
+
ETableSelectionModel *e_table_selection_model_new (void);
#endif /* _E_TABLE_SELECTION_MODEL_H_ */
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 5c59723b6c..294cfa9968 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -951,6 +951,24 @@ e_table_selected_row_foreach (ETable *e_table,
closure);
}
+void
+e_table_select_all (ETable *table)
+{
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (E_IS_TABLE (table));
+
+ e_table_selection_model_select_all (table->selection);
+}
+
+void
+e_table_invert_selection (ETable *table)
+{
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (E_IS_TABLE (table));
+
+ e_table_selection_model_invert_selection (table->selection);
+}
+
EPrintable *
e_table_get_printable (ETable *e_table)
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index b3a2805fed..5b71fa82c2 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -247,6 +247,10 @@ GdkDragContext *e_table_drag_begin (ETable *table,
gint button,
GdkEvent *event);
+/* selection stuff */
+void e_table_select_all (ETable *table);
+void e_table_invert_selection (ETable *table);
+
END_GNOME_DECLS
#endif /* _E_TABLE_H_ */