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 gtkc.gtktypes;
31 public  import std.algorithm;
32 
33 
34 /**
35  * #GtkTreeSortable is an interface to be implemented by tree models which
36  * support sorting. The #GtkTreeView uses the methods provided by this interface
37  * to sort the model.
38  */
39 public template TreeSortableT(TStruct)
40 {
41 	/** Get the main Gtk struct */
42 	public GtkTreeSortable* getTreeSortableStruct(bool transferOwnership = false)
43 	{
44 		if (transferOwnership)
45 			ownedRef = false;
46 		return cast(GtkTreeSortable*)getStruct();
47 	}
48 
49 
50 	/**
51 	 * Fills in @sort_column_id and @order with the current sort column and the
52 	 * order. It returns %TRUE unless the @sort_column_id is
53 	 * %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or
54 	 * %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
55 	 *
56 	 * Params:
57 	 *     sortColumnId = The sort column id to be filled in
58 	 *     order = The #GtkSortType to be filled in
59 	 *
60 	 * Returns: %TRUE if the sort column is not one of the special sort
61 	 *     column ids.
62 	 */
63 	public bool getSortColumnId(out int sortColumnId, out GtkSortType order)
64 	{
65 		return gtk_tree_sortable_get_sort_column_id(getTreeSortableStruct(), &sortColumnId, &order) != 0;
66 	}
67 
68 	/**
69 	 * Returns %TRUE if the model has a default sort function. This is used
70 	 * primarily by GtkTreeViewColumns in order to determine if a model can
71 	 * go back to the default state, or not.
72 	 *
73 	 * Returns: %TRUE, if the model has a default sort function
74 	 */
75 	public bool hasDefaultSortFunc()
76 	{
77 		return gtk_tree_sortable_has_default_sort_func(getTreeSortableStruct()) != 0;
78 	}
79 
80 	/**
81 	 * Sets the default comparison function used when sorting to be @sort_func.
82 	 * If the current sort column id of @sortable is
83 	 * %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using
84 	 * this function.
85 	 *
86 	 * If @sort_func is %NULL, then there will be no default comparison function.
87 	 * This means that once the model  has been sorted, it can’t go back to the
88 	 * default state. In this case, when the current sort column id of @sortable
89 	 * is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
90 	 *
91 	 * Params:
92 	 *     sortFunc = The comparison function
93 	 *     userData = User data to pass to @sort_func, or %NULL
94 	 *     destroy = Destroy notifier of @user_data, or %NULL
95 	 */
96 	public void setDefaultSortFunc(GtkTreeIterCompareFunc sortFunc, void* userData, GDestroyNotify destroy)
97 	{
98 		gtk_tree_sortable_set_default_sort_func(getTreeSortableStruct(), sortFunc, userData, destroy);
99 	}
100 
101 	/**
102 	 * Sets the current sort column to be @sort_column_id. The @sortable will
103 	 * resort itself to reflect this change, after emitting a
104 	 * #GtkTreeSortable::sort-column-changed signal. @sort_column_id may either be
105 	 * a regular column id, or one of the following special values:
106 	 *
107 	 * - %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID: the default sort function
108 	 * will be used, if it is set
109 	 *
110 	 * - %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID: no sorting will occur
111 	 *
112 	 * Params:
113 	 *     sortColumnId = the sort column id to set
114 	 *     order = The sort order of the column
115 	 */
116 	public void setSortColumnId(int sortColumnId, GtkSortType order)
117 	{
118 		gtk_tree_sortable_set_sort_column_id(getTreeSortableStruct(), sortColumnId, order);
119 	}
120 
121 	/**
122 	 * Sets the comparison function used when sorting to be @sort_func. If the
123 	 * current sort column id of @sortable is the same as @sort_column_id, then
124 	 * the model will sort using this function.
125 	 *
126 	 * Params:
127 	 *     sortColumnId = the sort column id to set the function for
128 	 *     sortFunc = The comparison function
129 	 *     userData = User data to pass to @sort_func, or %NULL
130 	 *     destroy = Destroy notifier of @user_data, or %NULL
131 	 */
132 	public void setSortFunc(int sortColumnId, GtkTreeIterCompareFunc sortFunc, void* userData, GDestroyNotify destroy)
133 	{
134 		gtk_tree_sortable_set_sort_func(getTreeSortableStruct(), sortColumnId, sortFunc, userData, destroy);
135 	}
136 
137 	/**
138 	 * Emits a #GtkTreeSortable::sort-column-changed signal on @sortable.
139 	 */
140 	public void sortColumnChanged()
141 	{
142 		gtk_tree_sortable_sort_column_changed(getTreeSortableStruct());
143 	}
144 
145 	/**
146 	 * The ::sort-column-changed signal is emitted when the sort column
147 	 * or sort order of @sortable is changed. The signal is emitted before
148 	 * the contents of @sortable are resorted.
149 	 */
150 	gulong addOnSortColumnChanged(void delegate(TreeSortableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
151 	{
152 		return Signals.connect(this, "sort-column-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
153 	}
154 }