[l10n] Updated German help translation screen-shots
[evolution.git] / e-util / e-sorter.c
blob9e255e89f28da9a6df8404dba3c28a0f9ea071e6
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2 of the License, or (at your option) version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with the program; if not, see <http://www.gnu.org/licenses/>
16 * Authors:
17 * Chris Lahey <clahey@ximian.com>
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
27 #include <stdlib.h>
28 #include <string.h>
30 #include "e-sorter.h"
31 #include "e-util.h"
33 #define d(x)
35 #define PARENT_TYPE G_TYPE_OBJECT
37 G_DEFINE_TYPE (
38 ESorter,
39 e_sorter,
40 G_TYPE_OBJECT)
42 static gint es_model_to_sorted (ESorter *es, gint row);
43 static gint es_sorted_to_model (ESorter *es, gint row);
44 static void es_get_model_to_sorted_array (ESorter *es, gint **array, gint *count);
45 static void es_get_sorted_to_model_array (ESorter *es, gint **array, gint *count);
46 static gboolean es_needs_sorting (ESorter *es);
48 static void
49 e_sorter_class_init (ESorterClass *klass)
51 klass->model_to_sorted = es_model_to_sorted;
52 klass->sorted_to_model = es_sorted_to_model;
53 klass->get_model_to_sorted_array = es_get_model_to_sorted_array;
54 klass->get_sorted_to_model_array = es_get_sorted_to_model_array;
55 klass->needs_sorting = es_needs_sorting;
58 static void
59 e_sorter_init (ESorter *es)
63 ESorter *
64 e_sorter_new (void)
66 ESorter *es = g_object_new (E_SORTER_TYPE, NULL);
68 return es;
71 static gint
72 es_model_to_sorted (ESorter *es, gint row)
74 return row;
77 static gint
78 es_sorted_to_model (ESorter *es, gint row)
80 return row;
83 static void
84 es_get_model_to_sorted_array (ESorter *es, gint **array, gint *count)
88 static void
89 es_get_sorted_to_model_array (ESorter *es, gint **array, gint *count)
93 static gboolean
94 es_needs_sorting (ESorter *es)
96 return FALSE;
99 gint
100 e_sorter_model_to_sorted (ESorter *es, gint row)
102 g_return_val_if_fail (es != NULL, -1);
103 g_return_val_if_fail (row >= 0, -1);
105 if (E_SORTER_GET_CLASS (es)->model_to_sorted)
106 return E_SORTER_GET_CLASS (es)->model_to_sorted (es, row);
107 else
108 return -1;
111 gint
112 e_sorter_sorted_to_model (ESorter *es, gint row)
114 g_return_val_if_fail (es != NULL, -1);
115 g_return_val_if_fail (row >= 0, -1);
117 if (E_SORTER_GET_CLASS (es)->sorted_to_model)
118 return E_SORTER_GET_CLASS (es)->sorted_to_model (es, row);
119 else
120 return -1;
123 void
124 e_sorter_get_model_to_sorted_array (ESorter *es, gint **array, gint *count)
126 g_return_if_fail (es != NULL);
128 if (E_SORTER_GET_CLASS (es)->get_model_to_sorted_array)
129 E_SORTER_GET_CLASS (es)->get_model_to_sorted_array (es, array, count);
132 void
133 e_sorter_get_sorted_to_model_array (ESorter *es, gint **array, gint *count)
135 g_return_if_fail (es != NULL);
137 if (E_SORTER_GET_CLASS (es)->get_sorted_to_model_array)
138 E_SORTER_GET_CLASS (es)->get_sorted_to_model_array (es, array, count);
141 gboolean
142 e_sorter_needs_sorting (ESorter *es)
144 g_return_val_if_fail (es != NULL, FALSE);
146 if (E_SORTER_GET_CLASS (es)->needs_sorting)
147 return E_SORTER_GET_CLASS (es)->needs_sorting (es);
148 else
149 return FALSE;