From ad5ed0d603b0b915865bef3c4edc996378696187 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 28 Jun 2013 10:11:21 -0400 Subject: ETableSortInfo: Rework API to avoid exposing ETableSortColumn. Replace ETableSortColumn with separate ETableColumnSpecification and GtkSortType parameters in the "get_nth" and "set_nth" functions. Makes some other parts of the code simpler since it no longer has to translate a column number to a column specification. --- e-util/e-table-sorter.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'e-util/e-table-sorter.c') diff --git a/e-util/e-table-sorter.c b/e-util/e-table-sorter.c index 1342326c8f..d8e50db13d 100644 --- a/e-util/e-table-sorter.c +++ b/e-util/e-table-sorter.c @@ -136,24 +136,36 @@ table_sorter_sort (ETableSorter *table_sorter) qd.cmp_cache = e_table_sorting_utils_create_cmp_cache (); for (j = 0; j < cols; j++) { - ETableSortColumn column; + ETableColumnSpecification *spec; ETableCol *col; + GtkSortType sort_type; if (j < group_cols) - column = e_table_sort_info_grouping_get_nth (table_sorter->sort_info, j); + spec = e_table_sort_info_grouping_get_nth ( + table_sorter->sort_info, + j, &sort_type); else - column = e_table_sort_info_sorting_get_nth (table_sorter->sort_info, j - group_cols); - - col = e_table_header_get_column_by_col_idx (table_sorter->full_header, column.column); - if (col == NULL) - col = e_table_header_get_column (table_sorter->full_header, e_table_header_count (table_sorter->full_header) - 1); + spec = e_table_sort_info_sorting_get_nth ( + table_sorter->sort_info, + j - group_cols, &sort_type); + + col = e_table_header_get_column_by_spec ( + table_sorter->full_header, spec); + if (col == NULL) { + gint last = e_table_header_count ( + table_sorter->full_header) - 1; + col = e_table_header_get_column ( + table_sorter->full_header, last); + } for (i = 0; i < rows; i++) { - qd.vals[i * cols + j] = e_table_model_value_at (table_sorter->source, col->spec->model_col, i); + qd.vals[i * cols + j] = e_table_model_value_at ( + table_sorter->source, + col->spec->model_col, i); } qd.compare[j] = col->compare; - qd.ascending[j] = column.ascending; + qd.ascending[j] = (sort_type == GTK_SORT_ASCENDING); } g_qsort_with_data (table_sorter->sorted, rows, sizeof (gint), qsort_callback, &qd); -- cgit v1.2.3