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  * Conversion parameters:
26  * inFile  = GtkTreeSortable.html
27  * outPack = gtk
28  * outFile = TreeSortableT
29  * strct   = GtkTreeSortable
30  * realStrct=
31  * ctorStrct=
32  * clss    = TreeSortableT
33  * interf  = TreeSortableIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- gtk_tree_sortable_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.TreeSortableT;
54 
55 public  import gtkc.gtktypes;
56 
57 public import gtkc.gtk;
58 public import glib.ConstructionException;
59 public import gobject.ObjectG;
60 
61 public import gobject.Signals;
62 public  import gtkc.gdktypes;
63 
64 
65 
66 
67 
68 /**
69  * GtkTreeSortable is an interface to be implemented by tree models which
70  * support sorting. The GtkTreeView uses the methods provided by this interface
71  * to sort the model.
72  */
73 public template TreeSortableT(TStruct)
74 {
75 	
76 	/** the main Gtk struct */
77 	protected GtkTreeSortable* gtkTreeSortable;
78 	
79 	
80 	public GtkTreeSortable* getTreeSortableTStruct()
81 	{
82 		return cast(GtkTreeSortable*)getStruct();
83 	}
84 	
85 	
86 	/**
87 	 */
88 	int[string] connectedSignals;
89 	
90 	void delegate(TreeSortableIF)[] _onSortColumnChangedListeners;
91 	@property void delegate(TreeSortableIF)[] onSortColumnChangedListeners()
92 	{
93 		return  _onSortColumnChangedListeners;
94 	}
95 	/**
96 	 * The ::sort-column-changed signal is emitted when the sort column
97 	 * or sort order of sortable is changed. The signal is emitted before
98 	 * the contents of sortable are resorted.
99 	 * See Also
100 	 * GtkTreeModel, GtkTreeView
101 	 */
102 	void addOnSortColumnChanged(void delegate(TreeSortableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
103 	{
104 		if ( !("sort-column-changed" in connectedSignals) )
105 		{
106 			Signals.connectData(
107 			getStruct(),
108 			"sort-column-changed",
109 			cast(GCallback)&callBackSortColumnChanged,
110 			cast(void*)cast(TreeSortableIF)this,
111 			null,
112 			connectFlags);
113 			connectedSignals["sort-column-changed"] = 1;
114 		}
115 		_onSortColumnChangedListeners ~= dlg;
116 	}
117 	extern(C) static void callBackSortColumnChanged(GtkTreeSortable* sortableStruct, TreeSortableIF _treeSortableIF)
118 	{
119 		foreach ( void delegate(TreeSortableIF) dlg ; _treeSortableIF.onSortColumnChangedListeners )
120 		{
121 			dlg(_treeSortableIF);
122 		}
123 	}
124 	
125 	
126 	/**
127 	 * Emits a "sort-column-changed" signal on sortable.
128 	 */
129 	public void sortColumnChanged()
130 	{
131 		// void gtk_tree_sortable_sort_column_changed  (GtkTreeSortable *sortable);
132 		gtk_tree_sortable_sort_column_changed(getTreeSortableTStruct());
133 	}
134 	
135 	/**
136 	 * Fills in sort_column_id and order with the current sort column and the
137 	 * order. It returns TRUE unless the sort_column_id is
138 	 * GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or
139 	 * GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
140 	 * Params:
141 	 * sortColumnId = The sort column id to be filled in. [out]
142 	 * order = The GtkSortType to be filled in. [out]
143 	 * Returns: TRUE if the sort column is not one of the special sort column ids.
144 	 */
145 	public int getSortColumnId(out int sortColumnId, out GtkSortType order)
146 	{
147 		// gboolean gtk_tree_sortable_get_sort_column_id  (GtkTreeSortable *sortable,  gint *sort_column_id,  GtkSortType *order);
148 		return gtk_tree_sortable_get_sort_column_id(getTreeSortableTStruct(), &sortColumnId, &order);
149 	}
150 	
151 	/**
152 	 * Sets the current sort column to be sort_column_id. The sortable will
153 	 * resort itself to reflect this change, after emitting a
154 	 * "sort-column-changed" signal. sort_column_id may either be
155 	 * Params:
156 	 * sortColumnId = the sort column id to set
157 	 * order = The sort order of the column
158 	 */
159 	public void setSortColumnId(int sortColumnId, GtkSortType order)
160 	{
161 		// void gtk_tree_sortable_set_sort_column_id  (GtkTreeSortable *sortable,  gint sort_column_id,  GtkSortType order);
162 		gtk_tree_sortable_set_sort_column_id(getTreeSortableTStruct(), sortColumnId, order);
163 	}
164 	
165 	/**
166 	 * Sets the comparison function used when sorting to be sort_func. If the
167 	 * current sort column id of sortable is the same as sort_column_id, then
168 	 * the model will sort using this function.
169 	 * Params:
170 	 * sortColumnId = the sort column id to set the function for
171 	 * sortFunc = The comparison function
172 	 * userData = User data to pass to sort_func, or NULL. [allow-none]
173 	 * destroy = Destroy notifier of user_data, or NULL. [allow-none]
174 	 */
175 	public void setSortFunc(int sortColumnId, GtkTreeIterCompareFunc sortFunc, void* userData, GDestroyNotify destroy)
176 	{
177 		// void gtk_tree_sortable_set_sort_func (GtkTreeSortable *sortable,  gint sort_column_id,  GtkTreeIterCompareFunc sort_func,  gpointer user_data,  GDestroyNotify destroy);
178 		gtk_tree_sortable_set_sort_func(getTreeSortableTStruct(), sortColumnId, sortFunc, userData, destroy);
179 	}
180 	
181 	/**
182 	 * Sets the default comparison function used when sorting to be sort_func.
183 	 * If the current sort column id of sortable is
184 	 * GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using
185 	 * this function.
186 	 * If sort_func is NULL, then there will be no default comparison function.
187 	 * This means that once the model has been sorted, it can't go back to the
188 	 * default state. In this case, when the current sort column id of sortable
189 	 * is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
190 	 * Params:
191 	 * sortFunc = The comparison function
192 	 * userData = User data to pass to sort_func, or NULL. [allow-none]
193 	 * destroy = Destroy notifier of user_data, or NULL. [allow-none]
194 	 */
195 	public void setDefaultSortFunc(GtkTreeIterCompareFunc sortFunc, void* userData, GDestroyNotify destroy)
196 	{
197 		// void gtk_tree_sortable_set_default_sort_func  (GtkTreeSortable *sortable,  GtkTreeIterCompareFunc sort_func,  gpointer user_data,  GDestroyNotify destroy);
198 		gtk_tree_sortable_set_default_sort_func(getTreeSortableTStruct(), sortFunc, userData, destroy);
199 	}
200 	
201 	/**
202 	 * Returns TRUE if the model has a default sort function. This is used
203 	 * primarily by GtkTreeViewColumns in order to determine if a model can
204 	 * go back to the default state, or not.
205 	 * Returns: TRUE, if the model has a default sort function Signal Details The "sort-column-changed" signal void user_function (GtkTreeSortable *sortable, gpointer user_data) : Run Last The ::sort-column-changed signal is emitted when the sort column or sort order of sortable is changed. The signal is emitted before the contents of sortable are resorted.
206 	 */
207 	public int hasDefaultSortFunc()
208 	{
209 		// gboolean gtk_tree_sortable_has_default_sort_func  (GtkTreeSortable *sortable);
210 		return gtk_tree_sortable_has_default_sort_func(getTreeSortableTStruct());
211 	}
212 }