From 75a1cb19cdba3774d8d76ac9bf238254545b018f Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 4 Jun 2002 21:24:19 +0000 Subject: Added this function. 2002-06-04 Christopher James Lahey * e-table-header.c, e-table-header.h (e_table_header_prioritized_column_selected): Added this function. * e-table-utils.c, e-table-utils.h (e_table_util_calculate_current_search_col): Added this function. * e-table.c, e-table.h, e-tree.c: Added a "always_search" argument. If this is off, then searches only occur if there's sort. If it's on, sort takes precendence in doing searches, followed by the highest priority column shown. svn path=/trunk/; revision=17109 --- widgets/table/e-table-utils.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'widgets/table/e-table-utils.c') diff --git a/widgets/table/e-table-utils.c b/widgets/table/e-table-utils.c index 8ae460681f..eb36323d70 100644 --- a/widgets/table/e-table-utils.c +++ b/widgets/table/e-table-utils.c @@ -137,3 +137,48 @@ e_table_spec_to_full_header (ETableSpecification *spec, return nh; } + +static gboolean +check_col (ETableCol *col, gpointer user_data) +{ + return col->search ? TRUE : FALSE; +} + +ETableCol * +e_table_util_calculate_current_search_col (ETableHeader *header, ETableHeader *full_header, ETableSortInfo *sort_info, gboolean always_search) +{ + int i; + int count; + ETableCol *col = NULL; + count = e_table_sort_info_grouping_get_count (sort_info); + for (i = 0; i < count; i++) { + ETableSortColumn column = e_table_sort_info_grouping_get_nth(sort_info, i); + + col = e_table_header_get_column (full_header, column.column); + + if (col && col->search) + break; + + col = NULL; + } + + if (col == NULL) { + count = e_table_sort_info_sorting_get_count (sort_info); + for (i = 0; i < count; i++) { + ETableSortColumn column = e_table_sort_info_sorting_get_nth(sort_info, i); + + col = e_table_header_get_column (full_header, column.column); + + if (col && col->search) + break; + + col = NULL; + } + } + + if (col == NULL && always_search) { + col = e_table_header_prioritized_column_selected (header, check_col, NULL); + } + + return col; +} -- cgit v1.2.3