1 /*
2 * e-sorter.h
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 #include "e-sorter.h"
19
G_DEFINE_INTERFACE(ESorter,e_sorter,G_TYPE_OBJECT)20 G_DEFINE_INTERFACE (ESorter, e_sorter, G_TYPE_OBJECT)
21
22 static void
23 e_sorter_default_init (ESorterInterface *iface)
24 {
25 }
26
27 gint
e_sorter_model_to_sorted(ESorter * sorter,gint row)28 e_sorter_model_to_sorted (ESorter *sorter,
29 gint row)
30 {
31 ESorterInterface *iface;
32
33 g_return_val_if_fail (E_IS_SORTER (sorter), -1);
34 g_return_val_if_fail (row >= 0, -1);
35
36 iface = E_SORTER_GET_INTERFACE (sorter);
37 g_return_val_if_fail (iface->model_to_sorted != NULL, -1);
38
39 return iface->model_to_sorted (sorter, row);
40 }
41
42 gint
e_sorter_sorted_to_model(ESorter * sorter,gint row)43 e_sorter_sorted_to_model (ESorter *sorter,
44 gint row)
45 {
46 ESorterInterface *iface;
47
48 g_return_val_if_fail (E_IS_SORTER (sorter), -1);
49 g_return_val_if_fail (row >= 0, -1);
50
51 iface = E_SORTER_GET_INTERFACE (sorter);
52 g_return_val_if_fail (iface->sorted_to_model != NULL, -1);
53
54 return iface->sorted_to_model (sorter, row);
55 }
56
57 void
e_sorter_get_model_to_sorted_array(ESorter * sorter,gint ** array,gint * count)58 e_sorter_get_model_to_sorted_array (ESorter *sorter,
59 gint **array,
60 gint *count)
61 {
62 ESorterInterface *iface;
63
64 g_return_if_fail (E_IS_SORTER (sorter));
65
66 iface = E_SORTER_GET_INTERFACE (sorter);
67 g_return_if_fail (iface->get_model_to_sorted_array != NULL);
68
69 iface->get_model_to_sorted_array (sorter, array, count);
70 }
71
72 void
e_sorter_get_sorted_to_model_array(ESorter * sorter,gint ** array,gint * count)73 e_sorter_get_sorted_to_model_array (ESorter *sorter,
74 gint **array,
75 gint *count)
76 {
77 ESorterInterface *iface;
78
79 g_return_if_fail (E_IS_SORTER (sorter));
80
81 iface = E_SORTER_GET_INTERFACE (sorter);
82 g_return_if_fail (iface->get_sorted_to_model_array != NULL);
83
84 iface->get_sorted_to_model_array (sorter, array, count);
85 }
86
87 gboolean
e_sorter_needs_sorting(ESorter * sorter)88 e_sorter_needs_sorting (ESorter *sorter)
89 {
90 ESorterInterface *iface;
91
92 g_return_val_if_fail (E_IS_SORTER (sorter), FALSE);
93
94 iface = E_SORTER_GET_INTERFACE (sorter);
95 g_return_val_if_fail (iface->needs_sorting != NULL, FALSE);
96
97 return iface->needs_sorting (sorter);
98 }
99
100