From 6a8d4951dc284e0f3d3e1645d258d3a9968025c8 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Wed, 28 Feb 2001 03:36:29 +0000 Subject: Changed e_table_selection_model_clear to e_selection_model_clear. 2001-02-27 Christopher James Lahey * gal/e-text/e-completion-view.c: Changed e_table_selection_model_clear to e_selection_model_clear. * tests/test-tree-3.c: Changed E_TABLE_CURSOR_LINE to E_CURSOR_LINE. From gal/e-table/ChangeLog: 2001-02-27 Christopher James Lahey * e-table-click-to-add.c, e-table-group-container.c, e-table-group-container.h, e-table-group-leaf.c, e-table-group-leaf.h, e-table-item.c, e-table-item.h, e-table-specification.c, e-table-specification.h, e-table.c, e-table.h: Changed a lot of the ETableSelectionModels to ESelectionModels, a lot of the ETableSorters to ESorters, all the ETableCursorModes to ECursorModes, and all of the ETableForeachFuncs into EForeachFuncs. * e-table-defines.h: Moved ETableForeachFunc and ETableCursorMode to e-selection-model.h. * e-table-selection-model.c, e-table-selection-model.h: Made this a subclass of ESelectionModel which simple connects to an ETableModel. * e-table-sorter.c, e-table-sorter.h: Made this a subclass of ESorter so that implements the same semantics it used to. svn path=/trunk/; revision=8422 --- widgets/table/e-table-sorter.c | 117 ++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 49 deletions(-) (limited to 'widgets/table/e-table-sorter.c') diff --git a/widgets/table/e-table-sorter.c b/widgets/table/e-table-sorter.c index 08c7c1b120..2dbbddf366 100644 --- a/widgets/table/e-table-sorter.c +++ b/widgets/table/e-table-sorter.c @@ -22,19 +22,25 @@ enum { ARG_SORT_INFO }; -#define PARENT_TYPE gtk_object_get_type() +#define PARENT_TYPE e_sorter_get_type() #define INCREMENT_AMOUNT 100 -static GtkObjectClass *parent_class; +static ESorterClass *parent_class; -static void ets_model_changed (ETableModel *etm, ETableSorter *ets); -static void ets_model_row_changed (ETableModel *etm, int row, ETableSorter *ets); -static void ets_model_cell_changed (ETableModel *etm, int col, int row, ETableSorter *ets); -static void ets_sort_info_changed (ETableSortInfo *info, ETableSorter *ets); -static void ets_clean (ETableSorter *ets); -static void ets_sort (ETableSorter *ets); -static void ets_backsort (ETableSorter *ets); +static void ets_model_changed (ETableModel *etm, ETableSorter *ets); +static void ets_model_row_changed (ETableModel *etm, int row, ETableSorter *ets); +static void ets_model_cell_changed (ETableModel *etm, int col, int row, ETableSorter *ets); +static void ets_sort_info_changed (ETableSortInfo *info, ETableSorter *ets); +static void ets_clean (ETableSorter *ets); +static void ets_sort (ETableSorter *ets); +static void ets_backsort (ETableSorter *ets); + +static gint ets_model_to_sorted (ESorter *sorter, int row); +static gint ets_sorted_to_model (ESorter *sorter, int row); +static void ets_get_model_to_sorted_array (ESorter *sorter, int **array, int *count); +static void ets_get_sorted_to_model_array (ESorter *sorter, int **array, int *count); +static gboolean ets_needs_sorting (ESorter *ets); static void ets_destroy (GtkObject *object) @@ -105,12 +111,19 @@ static void ets_class_init (ETableSorterClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass); + ESorterClass *sorter_class = E_SORTER_CLASS(klass); + + parent_class = gtk_type_class (PARENT_TYPE); - parent_class = gtk_type_class (PARENT_TYPE); + object_class->destroy = ets_destroy; + object_class->set_arg = ets_set_arg; + object_class->get_arg = ets_get_arg; - object_class->destroy = ets_destroy; - object_class->set_arg = ets_set_arg; - object_class->get_arg = ets_get_arg; + sorter_class->model_to_sorted = ets_model_to_sorted ; + sorter_class->sorted_to_model = ets_sorted_to_model ; + sorter_class->get_model_to_sorted_array = ets_get_model_to_sorted_array ; + sorter_class->get_sorted_to_model_array = ets_get_sorted_to_model_array ; + sorter_class->needs_sorting = ets_needs_sorting ; gtk_object_add_arg_type ("ETableSorter::sort_info", GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SORT_INFO); @@ -478,75 +491,81 @@ ets_backsort(ETableSorter *ets) } } -gboolean -e_table_sorter_needs_sorting(ETableSorter *ets) -{ - if (ets->needs_sorting < 0) { - if (e_table_sort_info_sorting_get_count(ets->sort_info) + e_table_sort_info_grouping_get_count(ets->sort_info)) - ets->needs_sorting = 1; - else - ets->needs_sorting = 0; - } - return ets->needs_sorting; -} - -gint -e_table_sorter_model_to_sorted (ETableSorter *sorter, int row) +static gint +ets_model_to_sorted (ESorter *es, int row) { - int rows = e_table_model_row_count(sorter->source); + ETableSorter *ets = E_TABLE_SORTER(es); + int rows = e_table_model_row_count(ets->source); g_return_val_if_fail(row >= 0, -1); g_return_val_if_fail(row < rows, -1); - if (e_table_sorter_needs_sorting(sorter)) - ets_backsort(sorter); + if (ets_needs_sorting(es)) + ets_backsort(ets); - if (sorter->backsorted) - return sorter->backsorted[row]; + if (ets->backsorted) + return ets->backsorted[row]; else return row; } -gint -e_table_sorter_sorted_to_model (ETableSorter *sorter, int row) +static gint +ets_sorted_to_model (ESorter *es, int row) { - int rows = e_table_model_row_count(sorter->source); + ETableSorter *ets = E_TABLE_SORTER(es); + int rows = e_table_model_row_count(ets->source); g_return_val_if_fail(row >= 0, -1); g_return_val_if_fail(row < rows, -1); - if (e_table_sorter_needs_sorting(sorter)) - ets_sort(sorter); + if (ets_needs_sorting(es)) + ets_sort(ets); - if (sorter->sorted) - return sorter->sorted[row]; + if (ets->sorted) + return ets->sorted[row]; else return row; } -void -e_table_sorter_get_model_to_sorted_array (ETableSorter *sorter, int **array, int *count) +static void +ets_get_model_to_sorted_array (ESorter *es, int **array, int *count) { + ETableSorter *ets = E_TABLE_SORTER(es); if (array || count) { - ets_backsort(sorter); + ets_backsort(ets); if (array) - *array = sorter->backsorted; + *array = ets->backsorted; if (count) - *count = e_table_model_row_count(sorter->source); + *count = e_table_model_row_count(ets->source); } } -void -e_table_sorter_get_sorted_to_model_array (ETableSorter *sorter, int **array, int *count) +static void +ets_get_sorted_to_model_array (ESorter *es, int **array, int *count) { + ETableSorter *ets = E_TABLE_SORTER(es); if (array || count) { - ets_sort(sorter); + ets_sort(ets); if (array) - *array = sorter->sorted; + *array = ets->sorted; if (count) - *count = e_table_model_row_count(sorter->source); + *count = e_table_model_row_count(ets->source); } } + + +static gboolean +ets_needs_sorting(ESorter *es) +{ + ETableSorter *ets = E_TABLE_SORTER(es); + if (ets->needs_sorting < 0) { + if (e_table_sort_info_sorting_get_count(ets->sort_info) + e_table_sort_info_grouping_get_count(ets->sort_info)) + ets->needs_sorting = 1; + else + ets->needs_sorting = 0; + } + return ets->needs_sorting; +} -- cgit v1.2.3