1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.TreeSortableT;
26 
27 public  import gobject.Signals;
28 public  import gtk.c.functions;
29 public  import gtk.c.types;
30 public  import std.algorithm;
31 
32 
33 /**
34  * The interface for sortable models used by GtkTreeView
35  * 
36  * #GtkTreeSortable is an interface to be implemented by tree models which
37  * support sorting. The #GtkTreeView uses the methods provided by this interface
38  * to sort the model.
39  */
40 public template TreeSortableT(TStruct)
41 {
42 	/** Get the main Gtk struct */
43 	public GtkTreeSortable* getTreeSortableStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return cast(GtkTreeSortable*)getStruct();
48 	}
49 
50 
51 	/**
52 	 * Fills in @sort_column_id and @order with the current sort column and the
53 	 * order. It returns %TRUE unless the @sort_column_id is
54 	 * %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or
55 	 * %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
56 	 *
57 	 * Params:
58 	 *     sortColumnId = The sort column id to be filled in
59 	 *     order = The #GtkSortType to be filled in
60 	 *
61 	 * Returns: %TRUE if the sort column is not one of the special sort
62 	 *     column ids.
63 	 */
64 	public bool getSortColumnId(out int sortColumnId, out GtkSortType order)
65 	{
66 		return gtk_tree_sortable_get_sort_column_id(getTreeSortableStruct(), &sortColumnId, &order) != 0;
67 	}
68 
69 	/**
70 	 * Returns %TRUE if the model has a default sort function. This is used
71 	 * primarily by GtkTreeViewColumns in order to determine if a model can
72 	 * go back to the default state, or not.
73 	 *
74 	 * Returns: %TRUE, if the model has a default sort function
75 	 */
76 	public bool hasDefaultSortFunc()
77 	{
78 		return gtk_tree_sortable_has_default_sort_func(getTreeSortableStruct()) != 0;
79 	}
80 
81 	/**
82 	 * Sets the default comparison function used when sorting to be @sort_func.
83 	 * If the current sort column id of @sortable is
84 	 * %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using
85 	 * this function.
86 	 *
87 	 * If @sort_func is %NULL, then there will be no default comparison function.
88 	 * This means that once the model  has been sorted, it can’t go back to the
89 	 * default state. In this case, when the current sort column id of @sortable
90 	 * is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
91 	 *
92 	 * Params:
93 	 *     sortFunc = The comparison function
94 	 *     userData = User data to pass to @sort_func, or %NULL
95 	 *     destroy = Destroy notifier of @user_data, or %NULL
96 	 */
97 	public void setDefaultSortFunc(GtkTreeIterCompareFunc sortFunc, void* userData, GDestroyNotify destroy)
98 	{
99 		gtk_tree_sortable_set_default_sort_func(getTreeSortableStruct(), sortFunc, userData, destroy);
100 	}
101 
102 	/**
103 	 * Sets the current sort column to be @sort_column_id. The @sortable will
104 	 * resort itself to reflect this change, after emitting a
105 	 * #GtkTreeSortable::sort-column-changed signal. @sort_column_id may either be
106 	 * a regular column id, or one of the following special values:
107 	 *
108 	 * - %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID: the default sort function
109 	 * will be used, if it is set
110 	 *
111 	 * - %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID: no sorting will occur
112 	 *
113 	 * Params:
114 	 *     sortColumnId = the sort column id to set
115 	 *     order = The sort order of the column
116 	 */
117 	public void setSortColumnId(int sortColumnId, GtkSortType order)
118 	{
119 		gtk_tree_sortable_set_sort_column_id(getTreeSortableStruct(), sortColumnId, order);
120 	}
121 
122 	/**
123 	 * Sets the comparison function used when sorting to be @sort_func. If the
124 	 * current sort column id of @sortable is the same as @sort_column_id, then
125 	 * the model will sort using this function.
126 	 *
127 	 * Params:
128 	 *     sortColumnId = the sort column id to set the function for
129 	 *     sortFunc = The comparison function
130 	 *     userData = User data to pass to @sort_func, or %NULL
131 	 *     destroy = Destroy notifier of @user_data, or %NULL
132 	 */
133 	public void setSortFunc(int sortColumnId, GtkTreeIterCompareFunc sortFunc, void* userData, GDestroyNotify destroy)
134 	{
135 		gtk_tree_sortable_set_sort_func(getTreeSortableStruct(), sortColumnId, sortFunc, userData, destroy);
136 	}
137 
138 	/**
139 	 * Emits a #GtkTreeSortable::sort-column-changed signal on @sortable.
140 	 */
141 	public void sortColumnChanged()
142 	{
143 		gtk_tree_sortable_sort_column_changed(getTreeSortableStruct());
144 	}
145 
146 	/**
147 	 * The ::sort-column-changed signal is emitted when the sort column
148 	 * or sort order of @sortable is changed. The signal is emitted before
149 	 * the contents of @sortable are resorted.
150 	 */
151 	gulong addOnSortColumnChanged(void delegate(TreeSortableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
152 	{
153 		return Signals.connect(this, "sort-column-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
154 	}
155 }