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