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/>
17 * Chris Lahey <clahey@ximian.com>
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
35 #define PARENT_TYPE 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
);
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
;
59 e_sorter_init (ESorter
*es
)
66 ESorter
*es
= g_object_new (E_SORTER_TYPE
, NULL
);
72 es_model_to_sorted (ESorter
*es
, gint row
)
78 es_sorted_to_model (ESorter
*es
, gint row
)
84 es_get_model_to_sorted_array (ESorter
*es
, gint
**array
, gint
*count
)
89 es_get_sorted_to_model_array (ESorter
*es
, gint
**array
, gint
*count
)
94 es_needs_sorting (ESorter
*es
)
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
);
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
);
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
);
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
);
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
);