aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-table-sorter.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-28 22:11:21 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-02 22:34:10 +0800
commitad5ed0d603b0b915865bef3c4edc996378696187 (patch)
tree828eca186260e34b8f9c106b46519981437bdbd4 /e-util/e-table-sorter.c
parentce3e2091c2ff7a581bfa959d71050a059d48ee94 (diff)
downloadgsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.tar
gsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.tar.gz
gsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.tar.bz2
gsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.tar.lz
gsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.tar.xz
gsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.tar.zst
gsoc2013-evolution-ad5ed0d603b0b915865bef3c4edc996378696187.zip
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.
Diffstat (limited to 'e-util/e-table-sorter.c')
-rw-r--r--e-util/e-table-sorter.c30
1 files changed, 21 insertions, 9 deletions
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);