From 20e7e5d6502063bd4c05ffd35bc1657e6345ab94 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 25 Jul 2000 21:56:06 +0000 Subject: Replaced get_selection_list with foreach. 2000-07-25 Christopher James Lahey * e-table-selection-model.c, e-table-selection-model.h: Replaced get_selection_list with foreach. * e-table.h: Add a ETableSelectionModel. svn path=/trunk/; revision=4334 --- widgets/table/e-table-selection-model.c | 15 ++++++--------- widgets/table/e-table-selection-model.h | 7 +++++-- widgets/table/e-table.h | 3 +++ 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'widgets/table') diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c index 77be6eb2fa..6524dee4d4 100644 --- a/widgets/table/e-table-selection-model.c +++ b/widgets/table/e-table-selection-model.c @@ -196,7 +196,7 @@ e_table_selection_model_new (void) gboolean e_table_selection_model_is_row_selected (ETableSelectionModel *selection, - int n) + guint n) { if (selection->row_count < n) return 0; @@ -204,25 +204,22 @@ e_table_selection_model_is_row_selected (ETableSelectionModel *selection, return ((selection->selection[n / 32]) >> (31 - (n % 32))) & 0x1; } -GList * -e_table_selection_model_get_selection_list (ETableSelectionModel *selection) +void +e_table_selection_model_foreach (ETableSelectionModel *selection, + ETableForeachFunc callback, + gpointer closure) { int i; - GList *list = NULL; - if (selection->row_count < 0) - return NULL; for (i = selection->row_count / 32; i >= 0; i--) { if (selection->selection[i]) { int j; guint32 value = selection->selection[i]; for (j = 31; j >= 0; j--) { if (value & 0x1) { - list = g_list_prepend(list, (void *) (i * 32 + j)); + callback(i * 32 + j, closure); } value >>= 1; } } } - - return NULL; } diff --git a/widgets/table/e-table-selection-model.h b/widgets/table/e-table-selection-model.h index a36f4ca03c..2aaba021f8 100644 --- a/widgets/table/e-table-selection-model.h +++ b/widgets/table/e-table-selection-model.h @@ -4,6 +4,7 @@ #include #include "widgets/e-table/e-table-model.h" +#include "widgets/e-table/e-table-defines.h" #define E_TABLE_SELECTION_MODEL_TYPE (e_table_selection_model_get_type ()) #define E_TABLE_SELECTION_MODEL(o) (GTK_CHECK_CAST ((o), E_TABLE_SELECTION_MODEL_TYPE, ETableSelectionModel)) @@ -45,8 +46,10 @@ typedef struct { GtkType e_table_selection_model_get_type (void); gboolean e_table_selection_model_is_row_selected (ETableSelectionModel *selection, - int n); -GList *e_table_selection_model_get_selection_list (ETableSelectionModel *selection); + guint n); +void e_table_selection_model_foreach (ETableSelectionModel *selection, + ETableForeachFunc callback, + gpointer closure); ETableSelectionModel *e_table_selection_model_new (void); diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index 7612cddebe..06905a3711 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -10,6 +10,7 @@ #include "e-table-group.h" #include "e-table-sort-info.h" #include "e-table-item.h" +#include "e-table-selection-model.h" #include "e-util/e-printable.h" BEGIN_GNOME_DECLS @@ -32,6 +33,8 @@ typedef struct { ETableSortInfo *sort_info; + ETableSelectionModel *selection; + int table_model_change_id; int table_row_change_id; int table_cell_change_id; -- cgit v1.2.3