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  = GtkTreeModelSort.html
27  * outPack = gtk
28  * outFile = TreeModelSort
29  * strct   = GtkTreeModelSort
30  * realStrct=
31  * ctorStrct=GtkTreeModel
32  * clss    = TreeModelSort
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- TreeModelIF
40  * 	- TreeDragSourceIF
41  * 	- TreeSortableIF
42  * prefixes:
43  * 	- gtk_tree_model_sort_
44  * omit structs:
45  * omit prefixes:
46  * omit code:
47  * omit signals:
48  * imports:
49  * 	- gtk.TreeIter
50  * 	- gtk.TreeModel
51  * 	- gtk.TreeModelIF
52  * 	- gtk.TreePath
53  * 	- gtk.TreeModelT
54  * 	- gtk.TreeDragSourceT
55  * 	- gtk.TreeDragSourceIF
56  * 	- gtk.TreeSortableT
57  * 	- gtk.TreeSortableIF
58  * structWrap:
59  * 	- GtkTreeIter* -> TreeIter
60  * 	- GtkTreeModel* -> TreeModelIF
61  * 	- GtkTreePath* -> TreePath
62  * module aliases:
63  * local aliases:
64  * overrides:
65  */
66 
67 module gtk.TreeModelSort;
68 
69 public  import gtkc.gtktypes;
70 
71 private import gtkc.gtk;
72 private import glib.ConstructionException;
73 private import gobject.ObjectG;
74 
75 private import gtk.TreeIter;
76 private import gtk.TreeModel;
77 private import gtk.TreeModelIF;
78 private import gtk.TreePath;
79 private import gtk.TreeModelT;
80 private import gtk.TreeDragSourceT;
81 private import gtk.TreeDragSourceIF;
82 private import gtk.TreeSortableT;
83 private import gtk.TreeSortableIF;
84 
85 
86 private import gobject.ObjectG;
87 
88 /**
89  * The GtkTreeModelSort is a model which implements the GtkTreeSortable
90  * interface. It does not hold any data itself, but rather is created with
91  * a child model and proxies its data. It has identical column types to
92  * this child model, and the changes in the child are propagated. The
93  * primary purpose of this model is to provide a way to sort a different
94  * model without modifying it. Note that the sort function used by
95  * GtkTreeModelSort is not guaranteed to be stable.
96  *
97  * The use of this is best demonstrated through an example. In the
98  * following sample code we create two GtkTreeView widgets each with a
99  * view of the same data. As the model is wrapped here by a
100  * GtkTreeModelSort, the two GtkTreeViews can each sort their
101  * view of the data without affecting the other. By contrast, if we
102  * simply put the same model in each widget, then sorting the first would
103  * sort the second.
104  *
105  * $(DDOC_COMMENT example)
106  *
107  * To demonstrate how to access the underlying child model from the sort
108  * model, the next example will be a callback for the GtkTreeSelection
109  * "changed" signal. In this callback, we get a string
110  * from COLUMN_1 of the model. We then modify the string, find the same
111  * selected row on the child model, and change the row there.
112  *
113  * $(DDOC_COMMENT example)
114  */
115 public class TreeModelSort : ObjectG, TreeModelIF, TreeDragSourceIF, TreeSortableIF
116 {
117 	
118 	/** the main Gtk struct */
119 	protected GtkTreeModelSort* gtkTreeModelSort;
120 	
121 	
122 	/** Get the main Gtk struct */
123 	public GtkTreeModelSort* getTreeModelSortStruct()
124 	{
125 		return gtkTreeModelSort;
126 	}
127 	
128 	
129 	/** the main Gtk struct as a void* */
130 	protected override void* getStruct()
131 	{
132 		return cast(void*)gtkTreeModelSort;
133 	}
134 	
135 	/**
136 	 * Sets our main struct and passes it to the parent class
137 	 */
138 	public this (GtkTreeModelSort* gtkTreeModelSort)
139 	{
140 		super(cast(GObject*)gtkTreeModelSort);
141 		this.gtkTreeModelSort = gtkTreeModelSort;
142 	}
143 	
144 	protected override void setStruct(GObject* obj)
145 	{
146 		super.setStruct(obj);
147 		gtkTreeModelSort = cast(GtkTreeModelSort*)obj;
148 	}
149 	
150 	// add the TreeModel capabilities
151 	mixin TreeModelT!(GtkTreeModelSort);
152 	
153 	// add the TreeDragSource capabilities
154 	mixin TreeDragSourceT!(GtkTreeModelSort);
155 	
156 	// add the TreeSortable capabilities
157 	mixin TreeSortableT!(GtkTreeModelSort);
158 	
159 	/**
160 	 */
161 	
162 	/**
163 	 * Creates a new GtkTreeModel, with child_model as the child model.
164 	 * Params:
165 	 * childModel = A GtkTreeModel
166 	 * Throws: ConstructionException GTK+ fails to create the object.
167 	 */
168 	public this (TreeModelIF childModel)
169 	{
170 		// GtkTreeModel * gtk_tree_model_sort_new_with_model (GtkTreeModel *child_model);
171 		auto p = gtk_tree_model_sort_new_with_model((childModel is null) ? null : childModel.getTreeModelTStruct());
172 		if(p is null)
173 		{
174 			throw new ConstructionException("null returned by gtk_tree_model_sort_new_with_model((childModel is null) ? null : childModel.getTreeModelTStruct())");
175 		}
176 		this(cast(GtkTreeModelSort*) p);
177 	}
178 	
179 	/**
180 	 * Returns the model the GtkTreeModelSort is sorting.
181 	 * Returns: the "child model" being sorted. [transfer none]
182 	 */
183 	public TreeModelIF getModel()
184 	{
185 		// GtkTreeModel * gtk_tree_model_sort_get_model (GtkTreeModelSort *tree_model);
186 		auto p = gtk_tree_model_sort_get_model(gtkTreeModelSort);
187 		
188 		if(p is null)
189 		{
190 			return null;
191 		}
192 		
193 		return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p);
194 	}
195 	
196 	/**
197 	 * Converts child_path to a path relative to tree_model_sort. That is,
198 	 * child_path points to a path in the child model. The returned path will
199 	 * point to the same row in the sorted model. If child_path isn't a valid
200 	 * path on the child model, then NULL is returned.
201 	 * Params:
202 	 * childPath = A GtkTreePath to convert
203 	 * Returns: A newly allocated GtkTreePath, or NULL
204 	 */
205 	public TreePath convertChildPathToPath(TreePath childPath)
206 	{
207 		// GtkTreePath * gtk_tree_model_sort_convert_child_path_to_path  (GtkTreeModelSort *tree_model_sort,  GtkTreePath *child_path);
208 		auto p = gtk_tree_model_sort_convert_child_path_to_path(gtkTreeModelSort, (childPath is null) ? null : childPath.getTreePathStruct());
209 		
210 		if(p is null)
211 		{
212 			return null;
213 		}
214 		
215 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
216 	}
217 	
218 	/**
219 	 * Sets sort_iter to point to the row in tree_model_sort that corresponds to
220 	 * the row pointed at by child_iter. If sort_iter was not set, FALSE
221 	 * is returned. Note: a boolean is only returned since 2.14.
222 	 * Params:
223 	 * sortIter = An uninitialized GtkTreeIter. [out]
224 	 * childIter = A valid GtkTreeIter pointing to a row on the child model
225 	 * Returns: TRUE, if sort_iter was set, i.e. if sort_iter is a valid iterator pointer to a visible row in the child model.
226 	 */
227 	public int convertChildIterToIter(TreeIter sortIter, TreeIter childIter)
228 	{
229 		// gboolean gtk_tree_model_sort_convert_child_iter_to_iter  (GtkTreeModelSort *tree_model_sort,  GtkTreeIter *sort_iter,  GtkTreeIter *child_iter);
230 		return gtk_tree_model_sort_convert_child_iter_to_iter(gtkTreeModelSort, (sortIter is null) ? null : sortIter.getTreeIterStruct(), (childIter is null) ? null : childIter.getTreeIterStruct());
231 	}
232 	
233 	/**
234 	 * Converts sorted_path to a path on the child model of tree_model_sort.
235 	 * That is, sorted_path points to a location in tree_model_sort. The
236 	 * returned path will point to the same location in the model not being
237 	 * sorted. If sorted_path does not point to a location in the child model,
238 	 * NULL is returned.
239 	 * Params:
240 	 * sortedPath = A GtkTreePath to convert
241 	 * Returns: A newly allocated GtkTreePath, or NULL
242 	 */
243 	public TreePath convertPathToChildPath(TreePath sortedPath)
244 	{
245 		// GtkTreePath * gtk_tree_model_sort_convert_path_to_child_path  (GtkTreeModelSort *tree_model_sort,  GtkTreePath *sorted_path);
246 		auto p = gtk_tree_model_sort_convert_path_to_child_path(gtkTreeModelSort, (sortedPath is null) ? null : sortedPath.getTreePathStruct());
247 		
248 		if(p is null)
249 		{
250 			return null;
251 		}
252 		
253 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
254 	}
255 	
256 	/**
257 	 * Sets child_iter to point to the row pointed to by sorted_iter.
258 	 * Params:
259 	 * childIter = An uninitialized GtkTreeIter. [out]
260 	 * sortedIter = A valid GtkTreeIter pointing to a row on tree_model_sort.
261 	 */
262 	public void convertIterToChildIter(TreeIter childIter, TreeIter sortedIter)
263 	{
264 		// void gtk_tree_model_sort_convert_iter_to_child_iter  (GtkTreeModelSort *tree_model_sort,  GtkTreeIter *child_iter,  GtkTreeIter *sorted_iter);
265 		gtk_tree_model_sort_convert_iter_to_child_iter(gtkTreeModelSort, (childIter is null) ? null : childIter.getTreeIterStruct(), (sortedIter is null) ? null : sortedIter.getTreeIterStruct());
266 	}
267 	
268 	/**
269 	 * This resets the default sort function to be in the 'unsorted' state. That
270 	 * is, it is in the same order as the child model. It will re-sort the model
271 	 * to be in the same order as the child model only if the GtkTreeModelSort
272 	 * is in 'unsorted' state.
273 	 */
274 	public void resetDefaultSortFunc()
275 	{
276 		// void gtk_tree_model_sort_reset_default_sort_func  (GtkTreeModelSort *tree_model_sort);
277 		gtk_tree_model_sort_reset_default_sort_func(gtkTreeModelSort);
278 	}
279 	
280 	/**
281 	 * This function should almost never be called. It clears the tree_model_sort
282 	 * of any cached iterators that haven't been reffed with
283 	 * gtk_tree_model_ref_node(). This might be useful if the child model being
284 	 * sorted is static (and doesn't change often) and there has been a lot of
285 	 * unreffed access to nodes. As a side effect of this function, all unreffed
286 	 * iters will be invalid.
287 	 */
288 	public void clearCache()
289 	{
290 		// void gtk_tree_model_sort_clear_cache (GtkTreeModelSort *tree_model_sort);
291 		gtk_tree_model_sort_clear_cache(gtkTreeModelSort);
292 	}
293 	
294 	/**
295 	 * Warning
296 	 * This function is slow. Only use it for debugging and/or testing purposes.
297 	 * Checks if the given iter is a valid iter for this GtkTreeModelSort.
298 	 * Since 2.2
299 	 * Params:
300 	 * iter = A GtkTreeIter.
301 	 * Returns: TRUE if the iter is valid, FALSE if the iter is invalid.
302 	 */
303 	public int iterIsValid(TreeIter iter)
304 	{
305 		// gboolean gtk_tree_model_sort_iter_is_valid (GtkTreeModelSort *tree_model_sort,  GtkTreeIter *iter);
306 		return gtk_tree_model_sort_iter_is_valid(gtkTreeModelSort, (iter is null) ? null : iter.getTreeIterStruct());
307 	}
308 }