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  = GtkTreeModelFilter.html
27  * outPack = gtk
28  * outFile = TreeModelFilter
29  * strct   = GtkTreeModelFilter
30  * realStrct=
31  * ctorStrct=GtkTreeModel
32  * clss    = TreeModelFilter
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- TreeModelIF
40  * 	- TreeDragSourceIF
41  * prefixes:
42  * 	- gtk_tree_model_filter_
43  * 	- gtk_
44  * omit structs:
45  * omit prefixes:
46  * omit code:
47  * omit signals:
48  * imports:
49  * 	- gtk.TreeModel
50  * 	- gtk.TreeModelIF
51  * 	- gtk.TreePath
52  * 	- gtk.TreeIter
53  * 	- gtk.TreeModelT
54  * 	- gtk.TreeDragSourceT
55  * 	- gtk.TreeDragSourceIF
56  * structWrap:
57  * 	- GtkTreeIter* -> TreeIter
58  * 	- GtkTreeModel* -> TreeModelIF
59  * 	- GtkTreePath* -> TreePath
60  * module aliases:
61  * local aliases:
62  * overrides:
63  */
64 
65 module gtk.TreeModelFilter;
66 
67 public  import gtkc.gtktypes;
68 
69 private import gtkc.gtk;
70 private import glib.ConstructionException;
71 private import gobject.ObjectG;
72 
73 
74 private import gtk.TreeModel;
75 private import gtk.TreeModelIF;
76 private import gtk.TreePath;
77 private import gtk.TreeIter;
78 private import gtk.TreeModelT;
79 private import gtk.TreeDragSourceT;
80 private import gtk.TreeDragSourceIF;
81 
82 
83 
84 private import gobject.ObjectG;
85 
86 /**
87  * Description
88  * A GtkTreeModelFilter is a tree model which wraps another tree model,
89  * and can do the following things:
90  * Filter specific rows, based on data from a "visible column", a column
91  * storing booleans indicating whether the row should be filtered or not,
92  * or based on the return value of a "visible function", which gets a
93  * model, iter and user_data and returns a boolean indicating whether the
94  * row should be filtered or not.
95  * Modify the "appearance" of the model, using a modify function.
96  * This is extremely powerful and allows for just changing
97  * some values and also for creating a completely different model based on
98  * the given child model.
99  * Set a different root node, also known as a "virtual root". You can pass in
100  * a GtkTreePath indicating the root node for the filter at construction time.
101  */
102 public class TreeModelFilter : ObjectG, TreeModelIF, TreeDragSourceIF
103 {
104 	
105 	/** the main Gtk struct */
106 	protected GtkTreeModelFilter* gtkTreeModelFilter;
107 	
108 	
109 	public GtkTreeModelFilter* getTreeModelFilterStruct()
110 	{
111 		return gtkTreeModelFilter;
112 	}
113 	
114 	
115 	/** the main Gtk struct as a void* */
116 	protected override void* getStruct()
117 	{
118 		return cast(void*)gtkTreeModelFilter;
119 	}
120 	
121 	/**
122 	 * Sets our main struct and passes it to the parent class
123 	 */
124 	public this (GtkTreeModelFilter* gtkTreeModelFilter)
125 	{
126 		super(cast(GObject*)gtkTreeModelFilter);
127 		this.gtkTreeModelFilter = gtkTreeModelFilter;
128 	}
129 	
130 	protected override void setStruct(GObject* obj)
131 	{
132 		super.setStruct(obj);
133 		gtkTreeModelFilter = cast(GtkTreeModelFilter*)obj;
134 	}
135 	
136 	// add the TreeModel capabilities
137 	mixin TreeModelT!(GtkTreeModelFilter);
138 	
139 	// add the TreeDragSource capabilities
140 	mixin TreeDragSourceT!(GtkTreeModelFilter);
141 	
142 	/**
143 	 */
144 	
145 	/**
146 	 * Creates a new GtkTreeModel, with child_model as the child_model
147 	 * and root as the virtual root.
148 	 * Since 2.4
149 	 * Params:
150 	 * childModel = A GtkTreeModel.
151 	 * root = A GtkTreePath or NULL. [allow-none]
152 	 * Throws: ConstructionException GTK+ fails to create the object.
153 	 */
154 	public this (TreeModelIF childModel, TreePath root)
155 	{
156 		// GtkTreeModel * gtk_tree_model_filter_new (GtkTreeModel *child_model,  GtkTreePath *root);
157 		auto p = gtk_tree_model_filter_new((childModel is null) ? null : childModel.getTreeModelTStruct(), (root is null) ? null : root.getTreePathStruct());
158 		if(p is null)
159 		{
160 			throw new ConstructionException("null returned by gtk_tree_model_filter_new((childModel is null) ? null : childModel.getTreeModelTStruct(), (root is null) ? null : root.getTreePathStruct())");
161 		}
162 		this(cast(GtkTreeModelFilter*) p);
163 	}
164 	
165 	/**
166 	 * Sets the visible function used when filtering the filter to be func. The
167 	 * function should return TRUE if the given row should be visible and
168 	 * FALSE otherwise.
169 	 * If the condition calculated by the function changes over time (e.g. because
170 	 * it depends on some global parameters), you must call
171 	 * gtk_tree_model_filter_refilter() to keep the visibility information of
172 	 * the model uptodate.
173 	 * Note that func is called whenever a row is inserted, when it may still be
174 	 * empty. The visible function should therefore take special care of empty
175 	 * rows, like in the example below.
176 	 * $(DDOC_COMMENT example)
177 	 * Since 2.4
178 	 * Params:
179 	 * func = A GtkTreeModelFilterVisibleFunc, the visible function.
180 	 * data = User data to pass to the visible function, or NULL. [allow-none]
181 	 * destroy = Destroy notifier of data, or NULL. [allow-none]
182 	 */
183 	public void setVisibleFunc(GtkTreeModelFilterVisibleFunc func, void* data, GDestroyNotify destroy)
184 	{
185 		// void gtk_tree_model_filter_set_visible_func  (GtkTreeModelFilter *filter,  GtkTreeModelFilterVisibleFunc func,  gpointer data,  GDestroyNotify destroy);
186 		gtk_tree_model_filter_set_visible_func(gtkTreeModelFilter, func, data, destroy);
187 	}
188 	
189 	/**
190 	 * With the n_columns and types parameters, you give an array of column
191 	 * types for this model (which will be exposed to the parent model/view).
192 	 * The func, data and destroy parameters are for specifying the modify
193 	 * function. The modify function will get called for each
194 	 * data access, the goal of the modify function is to return the data which
195 	 * should be displayed at the location specified using the parameters of the
196 	 * modify function.
197 	 * Since 2.4
198 	 * Params:
199 	 * types = The GTypes of the columns. [array length=n_columns]
200 	 * func = A GtkTreeModelFilterModifyFunc
201 	 * data = User data to pass to the modify function, or NULL. [allow-none]
202 	 * destroy = Destroy notifier of data, or NULL. [allow-none]
203 	 */
204 	public void setModifyFunc(GType[] types, GtkTreeModelFilterModifyFunc func, void* data, GDestroyNotify destroy)
205 	{
206 		// void gtk_tree_model_filter_set_modify_func  (GtkTreeModelFilter *filter,  gint n_columns,  GType *types,  GtkTreeModelFilterModifyFunc func,  gpointer data,  GDestroyNotify destroy);
207 		gtk_tree_model_filter_set_modify_func(gtkTreeModelFilter, cast(int) types.length, types.ptr, func, data, destroy);
208 	}
209 	
210 	/**
211 	 * Sets column of the child_model to be the column where filter should
212 	 * look for visibility information. columns should be a column of type
213 	 * G_TYPE_BOOLEAN, where TRUE means that a row is visible, and FALSE
214 	 * if not.
215 	 * Since 2.4
216 	 * Params:
217 	 * column = A gint which is the column containing the visible information.
218 	 */
219 	public void setVisibleColumn(int column)
220 	{
221 		// void gtk_tree_model_filter_set_visible_column  (GtkTreeModelFilter *filter,  gint column);
222 		gtk_tree_model_filter_set_visible_column(gtkTreeModelFilter, column);
223 	}
224 	
225 	/**
226 	 * Returns a pointer to the child model of filter.
227 	 * Since 2.4
228 	 * Returns: A pointer to a GtkTreeModel. [transfer none]
229 	 */
230 	public TreeModelIF getModel()
231 	{
232 		// GtkTreeModel * gtk_tree_model_filter_get_model (GtkTreeModelFilter *filter);
233 		auto p = gtk_tree_model_filter_get_model(gtkTreeModelFilter);
234 		
235 		if(p is null)
236 		{
237 			return null;
238 		}
239 		
240 		return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p);
241 	}
242 	
243 	/**
244 	 * Sets filter_iter to point to the row in filter that corresponds to the
245 	 * row pointed at by child_iter. If filter_iter was not set, FALSE is
246 	 * returned.
247 	 * Since 2.4
248 	 * Params:
249 	 * filter = A GtkTreeModelFilter.
250 	 * filterIter = An uninitialized GtkTreeIter. [out]
251 	 * childIter = A valid GtkTreeIter pointing to a row on the child model.
252 	 * Returns: TRUE, if filter_iter was set, i.e. if child_iter is a valid iterator pointing to a visible row in child model.
253 	 */
254 	public int convertChildIterToIter(TreeIter filterIter, TreeIter childIter)
255 	{
256 		// gboolean gtk_tree_model_filter_convert_child_iter_to_iter  (GtkTreeModelFilter *filter,  GtkTreeIter *filter_iter,  GtkTreeIter *child_iter);
257 		return gtk_tree_model_filter_convert_child_iter_to_iter(gtkTreeModelFilter, (filterIter is null) ? null : filterIter.getTreeIterStruct(), (childIter is null) ? null : childIter.getTreeIterStruct());
258 	}
259 	
260 	/**
261 	 * Sets child_iter to point to the row pointed to by filter_iter.
262 	 * Since 2.4
263 	 * Params:
264 	 * filter = A GtkTreeModelFilter.
265 	 * childIter = An uninitialized GtkTreeIter. [out]
266 	 * filterIter = A valid GtkTreeIter pointing to a row on filter.
267 	 */
268 	public void convertIterToChildIter(TreeIter childIter, TreeIter filterIter)
269 	{
270 		// void gtk_tree_model_filter_convert_iter_to_child_iter  (GtkTreeModelFilter *filter,  GtkTreeIter *child_iter,  GtkTreeIter *filter_iter);
271 		gtk_tree_model_filter_convert_iter_to_child_iter(gtkTreeModelFilter, (childIter is null) ? null : childIter.getTreeIterStruct(), (filterIter is null) ? null : filterIter.getTreeIterStruct());
272 	}
273 	
274 	/**
275 	 * Converts child_path to a path relative to filter. That is, child_path
276 	 * points to a path in the child model. The rerturned path will point to the
277 	 * same row in the filtered model. If child_path isn't a valid path on the
278 	 * child model or points to a row which is not visible in filter, then NULL
279 	 * is returned.
280 	 * Since 2.4
281 	 * Params:
282 	 * childPath = A GtkTreePath to convert.
283 	 * Returns: A newly allocated GtkTreePath, or NULL.
284 	 */
285 	public TreePath convertChildPathToPath(TreePath childPath)
286 	{
287 		// GtkTreePath * gtk_tree_model_filter_convert_child_path_to_path  (GtkTreeModelFilter *filter,  GtkTreePath *child_path);
288 		auto p = gtk_tree_model_filter_convert_child_path_to_path(gtkTreeModelFilter, (childPath is null) ? null : childPath.getTreePathStruct());
289 		
290 		if(p is null)
291 		{
292 			return null;
293 		}
294 		
295 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
296 	}
297 	
298 	/**
299 	 * Converts filter_path to a path on the child model of filter. That is,
300 	 * filter_path points to a location in filter. The returned path will
301 	 * point to the same location in the model not being filtered. If filter_path
302 	 * does not point to a location in the child model, NULL is returned.
303 	 * Since 2.4
304 	 * Params:
305 	 * filter = A GtkTreeModelFilter.
306 	 * filterPath = A GtkTreePath to convert.
307 	 * Returns: A newly allocated GtkTreePath, or NULL.
308 	 */
309 	public TreePath convertPathToChildPath(TreePath filterPath)
310 	{
311 		// GtkTreePath * gtk_tree_model_filter_convert_path_to_child_path  (GtkTreeModelFilter *filter,  GtkTreePath *filter_path);
312 		auto p = gtk_tree_model_filter_convert_path_to_child_path(gtkTreeModelFilter, (filterPath is null) ? null : filterPath.getTreePathStruct());
313 		
314 		if(p is null)
315 		{
316 			return null;
317 		}
318 		
319 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
320 	}
321 	
322 	/**
323 	 * Emits ::row_changed for each row in the child model, which causes
324 	 * the filter to re-evaluate whether a row is visible or not.
325 	 * Since 2.4
326 	 * Params:
327 	 * filter = A GtkTreeModelFilter.
328 	 */
329 	public void refilter()
330 	{
331 		// void gtk_tree_model_filter_refilter (GtkTreeModelFilter *filter);
332 		gtk_tree_model_filter_refilter(gtkTreeModelFilter);
333 	}
334 	
335 	/**
336 	 * This function should almost never be called. It clears the filter
337 	 * of any cached iterators that haven't been reffed with
338 	 * gtk_tree_model_ref_node(). This might be useful if the child model
339 	 * being filtered is static (and doesn't change often) and there has been
340 	 * a lot of unreffed access to nodes. As a side effect of this function,
341 	 * all unreffed iters will be invalid.
342 	 * Since 2.4
343 	 */
344 	public void clearCache()
345 	{
346 		// void gtk_tree_model_filter_clear_cache (GtkTreeModelFilter *filter);
347 		gtk_tree_model_filter_clear_cache(gtkTreeModelFilter);
348 	}
349 }