aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-table-sort-info.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-02-25 18:09:34 +0800
committerMilan Crha <mcrha@redhat.com>2014-02-25 18:09:34 +0800
commit3a91092b4af34c9429adf92dc3af73cc3d85ddb4 (patch)
tree8c86825d59a76d0e4a2d26927af0b55467d4008b /e-util/e-table-sort-info.c
parentc0c420014922e0fb64d63130a9a0b82458e790dc (diff)
downloadgsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.tar
gsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.tar.gz
gsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.tar.bz2
gsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.tar.lz
gsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.tar.xz
gsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.tar.zst
gsoc2013-evolution-3a91092b4af34c9429adf92dc3af73cc3d85ddb4.zip
ETree/ETable: Allow easier adding of columns for sorting
This extends behaviour of left-clicking column header which is not used for sorting yet in an ETree/ETable in a way: a) alone left-click behaves like before, all current sorting is dropped and the ETree/ETable is sorted only by that column b) left-click with pressed Ctrl key adds the column as the first to sort by c) left-click with pressed Ctrl+Shift adds the column as the last to sort by
Diffstat (limited to 'e-util/e-table-sort-info.c')
-rw-r--r--e-util/e-table-sort-info.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/e-util/e-table-sort-info.c b/e-util/e-table-sort-info.c
index 815897b11d..caf571f811 100644
--- a/e-util/e-table-sort-info.c
+++ b/e-util/e-table-sort-info.c
@@ -693,6 +693,55 @@ e_table_sort_info_sorting_set_nth (ETableSortInfo *sort_info,
}
/**
+ * @sort_info: an #ETableSortInfo
+ * @n: Index to insert to.
+ * @spec: an #ETableColumnSpecification
+ * @sort_type: a #GtkSortType
+ *
+ * Inserts the sorting criteria for index @n to @spec and @sort_type.
+ *
+ * Since: 3.12
+ **/
+void
+e_table_sort_info_sorting_insert (ETableSortInfo *sort_info,
+ guint n,
+ ETableColumnSpecification *spec,
+ GtkSortType sort_type)
+{
+ GArray *array;
+ ColumnData *column_data, tmp;
+
+ g_return_if_fail (E_IS_TABLE_SORT_INFO (sort_info));
+ g_return_if_fail (E_IS_TABLE_COLUMN_SPECIFICATION (spec));
+
+ array = sort_info->priv->sortings;
+ if (array->len == 0) {
+ e_table_sort_info_sorting_set_nth (sort_info, 0, spec, sort_type);
+ return;
+ }
+
+ if ((gint) n == -1)
+ n = 0;
+ else if (n > array->len)
+ n = array->len;
+
+ tmp.column_spec = NULL;
+ tmp.sort_type = sort_type;
+ column_data = &tmp;
+
+ if (n == array->len)
+ g_array_append_val (array, column_data);
+ else
+ g_array_insert_val (array, n, column_data);
+
+ column_data = &g_array_index (array, ColumnData, n);
+ column_data->column_spec = g_object_ref (spec);
+ column_data->sort_type = sort_type;
+
+ g_signal_emit (sort_info, signals[SORT_INFO_CHANGED], 0);
+}
+
+/**
* e_table_sort_info_load_from_node:
* @sort_info: an #ETableSortInfo
* @node: pointer to the xmlNode that describes the sorting and grouping information