2 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "gtktreesortable.h"
22 #include "gtksignal.h"
24 static void gtk_tree_sortable_base_init (gpointer g_class);
27 gtk_tree_sortable_get_type (void)
29 static GtkType tree_sortable_type = 0;
31 if (! tree_sortable_type)
33 static const GTypeInfo tree_sortable_info =
35 sizeof (GtkTreeSortableIface), /* class_size */
36 gtk_tree_sortable_base_init, /* base_init */
37 NULL, /* base_finalize */
39 NULL, /* class_finalize */
40 NULL, /* class_data */
45 tree_sortable_type = g_type_register_static (G_TYPE_INTERFACE, "GtkTreeSortable", &tree_sortable_info, 0);
46 g_type_interface_add_prerequisite (tree_sortable_type, G_TYPE_OBJECT);
49 return tree_sortable_type;
53 gtk_tree_sortable_base_init (gpointer g_class)
55 static gboolean initialized = FALSE;
59 g_signal_new ("sort_column_changed",
60 GTK_TYPE_TREE_SORTABLE,
62 G_STRUCT_OFFSET (GtkTreeSortableIface, sort_column_changed),
64 gtk_marshal_VOID__VOID,
71 gtk_tree_sortable_sort_column_changed (GtkTreeSortable *sortable)
73 g_return_if_fail (GTK_IS_TREE_SORTABLE (sortable));
75 g_signal_emit_by_name (G_OBJECT (sortable),
76 "sort_column_changed");
80 gtk_tree_sortable_get_sort_column_id (GtkTreeSortable *sortable,
82 GtkTreeSortOrder *order)
84 GtkTreeSortableIface *iface;
86 g_return_val_if_fail (GTK_IS_TREE_SORTABLE (sortable), FALSE);
88 iface = GTK_TREE_SORTABLE_GET_IFACE (sortable);
90 g_return_val_if_fail (iface != NULL, FALSE);
91 g_return_val_if_fail (iface->get_sort_column_id != NULL, FALSE);
93 return (* iface->get_sort_column_id) (sortable, sort_column_id, order);
97 gtk_tree_sortable_set_sort_column_id (GtkTreeSortable *sortable,
99 GtkTreeSortOrder order)
101 GtkTreeSortableIface *iface;
103 g_return_if_fail (GTK_IS_TREE_SORTABLE (sortable));
105 iface = GTK_TREE_SORTABLE_GET_IFACE (sortable);
107 g_return_if_fail (iface != NULL);
108 g_return_if_fail (iface->set_sort_column_id != NULL);
110 (* iface->set_sort_column_id) (sortable, sort_column_id, order);
115 gtk_tree_sortable_set_sort_func (GtkTreeSortable *sortable,
117 GtkTreeIterCompareFunc func,
119 GtkDestroyNotify destroy)
121 GtkTreeSortableIface *iface;
123 g_return_if_fail (GTK_IS_TREE_SORTABLE (sortable));
125 iface = GTK_TREE_SORTABLE_GET_IFACE (sortable);
127 g_return_if_fail (iface != NULL);
128 g_return_if_fail (iface->set_sort_func != NULL);
130 (* iface->set_sort_func) (sortable, sort_column_id, func, data, destroy);