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.TreeModelT;
26 
27 public  import glib.Str;
28 public  import gobject.ObjectG;
29 public  import gobject.Signals;
30 public  import gobject.Value;
31 public  import gtk.TreeIter;
32 public  import gtk.TreePath;
33 public  import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 public  import std.algorithm;
36 
37 
38 /**
39  * The #GtkTreeModel interface defines a generic tree interface for
40  * use by the #GtkTreeView widget. It is an abstract interface, and
41  * is designed to be usable with any appropriate data structure. The
42  * programmer just has to implement this interface on their own data
43  * type for it to be viewable by a #GtkTreeView widget.
44  * 
45  * The model is represented as a hierarchical tree of strongly-typed,
46  * columned data. In other words, the model can be seen as a tree where
47  * every node has different values depending on which column is being
48  * queried. The type of data found in a column is determined by using
49  * the GType system (ie. #G_TYPE_INT, #GTK_TYPE_BUTTON, #G_TYPE_POINTER,
50  * etc). The types are homogeneous per column across all nodes. It is
51  * important to note that this interface only provides a way of examining
52  * a model and observing changes. The implementation of each individual
53  * model decides how and if changes are made.
54  * 
55  * In order to make life simpler for programmers who do not need to
56  * write their own specialized model, two generic models are provided
57  * — the #GtkTreeStore and the #GtkListStore. To use these, the
58  * developer simply pushes data into these models as necessary. These
59  * models provide the data structure as well as all appropriate tree
60  * interfaces. As a result, implementing drag and drop, sorting, and
61  * storing data is trivial. For the vast majority of trees and lists,
62  * these two models are sufficient.
63  * 
64  * Models are accessed on a node/column level of granularity. One can
65  * query for the value of a model at a certain node and a certain
66  * column on that node. There are two structures used to reference a
67  * particular node in a model. They are the #GtkTreePath-struct and
68  * the #GtkTreeIter-struct (“iter” is short for iterator). Most of the
69  * interface consists of operations on a #GtkTreeIter-struct.
70  * 
71  * A path is essentially a potential node. It is a location on a model
72  * that may or may not actually correspond to a node on a specific
73  * model. The #GtkTreePath-struct can be converted into either an
74  * array of unsigned integers or a string. The string form is a list
75  * of numbers separated by a colon. Each number refers to the offset
76  * at that level. Thus, the path `0` refers to the root
77  * node and the path `2:4` refers to the fifth child of
78  * the third node.
79  * 
80  * By contrast, a #GtkTreeIter-struct is a reference to a specific node on
81  * a specific model. It is a generic struct with an integer and three
82  * generic pointers. These are filled in by the model in a model-specific
83  * way. One can convert a path to an iterator by calling
84  * gtk_tree_model_get_iter(). These iterators are the primary way
85  * of accessing a model and are similar to the iterators used by
86  * #GtkTextBuffer. They are generally statically allocated on the
87  * stack and only used for a short time. The model interface defines
88  * a set of operations using them for navigating the model.
89  * 
90  * It is expected that models fill in the iterator with private data.
91  * For example, the #GtkListStore model, which is internally a simple
92  * linked list, stores a list node in one of the pointers. The
93  * #GtkTreeModelSort stores an array and an offset in two of the
94  * pointers. Additionally, there is an integer field. This field is
95  * generally filled with a unique stamp per model. This stamp is for
96  * catching errors resulting from using invalid iterators with a model.
97  * 
98  * The lifecycle of an iterator can be a little confusing at first.
99  * Iterators are expected to always be valid for as long as the model
100  * is unchanged (and doesn’t emit a signal). The model is considered
101  * to own all outstanding iterators and nothing needs to be done to
102  * free them from the user’s point of view. Additionally, some models
103  * guarantee that an iterator is valid for as long as the node it refers
104  * to is valid (most notably the #GtkTreeStore and #GtkListStore).
105  * Although generally uninteresting, as one always has to allow for
106  * the case where iterators do not persist beyond a signal, some very
107  * important performance enhancements were made in the sort model.
108  * As a result, the #GTK_TREE_MODEL_ITERS_PERSIST flag was added to
109  * indicate this behavior.
110  * 
111  * To help show some common operation of a model, some examples are
112  * provided. The first example shows three ways of getting the iter at
113  * the location `3:2:5`. While the first method shown is
114  * easier, the second is much more common, as you often get paths from
115  * callbacks.
116  * 
117  * ## Acquiring a #GtkTreeIter-struct
118  * 
119  * |[<!-- language="C" -->
120  * // Three ways of getting the iter pointing to the location
121  * GtkTreePath *path;
122  * GtkTreeIter iter;
123  * GtkTreeIter parent_iter;
124  * 
125  * // get the iterator from a string
126  * gtk_tree_model_get_iter_from_string (model,
127  * &iter,
128  * "3:2:5");
129  * 
130  * // get the iterator from a path
131  * path = gtk_tree_path_new_from_string ("3:2:5");
132  * gtk_tree_model_get_iter (model, &iter, path);
133  * gtk_tree_path_free (path);
134  * 
135  * // walk the tree to find the iterator
136  * gtk_tree_model_iter_nth_child (model, &iter,
137  * NULL, 3);
138  * parent_iter = iter;
139  * gtk_tree_model_iter_nth_child (model, &iter,
140  * &parent_iter, 2);
141  * parent_iter = iter;
142  * gtk_tree_model_iter_nth_child (model, &iter,
143  * &parent_iter, 5);
144  * ]|
145  * 
146  * This second example shows a quick way of iterating through a list
147  * and getting a string and an integer from each row. The
148  * populate_model() function used below is not
149  * shown, as it is specific to the #GtkListStore. For information on
150  * how to write such a function, see the #GtkListStore documentation.
151  * 
152  * ## Reading data from a #GtkTreeModel
153  * 
154  * |[<!-- language="C" -->
155  * enum
156  * {
157  * STRING_COLUMN,
158  * INT_COLUMN,
159  * N_COLUMNS
160  * };
161  * 
162  * ...
163  * 
164  * GtkTreeModel *list_store;
165  * GtkTreeIter iter;
166  * gboolean valid;
167  * gint row_count = 0;
168  * 
169  * // make a new list_store
170  * list_store = gtk_list_store_new (N_COLUMNS,
171  * G_TYPE_STRING,
172  * G_TYPE_INT);
173  * 
174  * // Fill the list store with data
175  * populate_model (list_store);
176  * 
177  * // Get the first iter in the list, check it is valid and walk
178  * // through the list, reading each row.
179  * 
180  * valid = gtk_tree_model_get_iter_first (list_store,
181  * &iter);
182  * while (valid)
183  * {
184  * gchar *str_data;
185  * gint   int_data;
186  * 
187  * // Make sure you terminate calls to gtk_tree_model_get() with a “-1” value
188  * gtk_tree_model_get (list_store, &iter,
189  * STRING_COLUMN, &str_data,
190  * INT_COLUMN, &int_data,
191  * -1);
192  * 
193  * // Do something with the data
194  * g_print ("Row %d: (%s,%d)\n",
195  * row_count, str_data, int_data);
196  * g_free (str_data);
197  * 
198  * valid = gtk_tree_model_iter_next (list_store,
199  * &iter);
200  * row_count++;
201  * }
202  * ]|
203  * 
204  * The #GtkTreeModel interface contains two methods for reference
205  * counting: gtk_tree_model_ref_node() and gtk_tree_model_unref_node().
206  * These two methods are optional to implement. The reference counting
207  * is meant as a way for views to let models know when nodes are being
208  * displayed. #GtkTreeView will take a reference on a node when it is
209  * visible, which means the node is either in the toplevel or expanded.
210  * Being displayed does not mean that the node is currently directly
211  * visible to the user in the viewport. Based on this reference counting
212  * scheme a caching model, for example, can decide whether or not to cache
213  * a node based on the reference count. A file-system based model would
214  * not want to keep the entire file hierarchy in memory, but just the
215  * folders that are currently expanded in every current view.
216  * 
217  * When working with reference counting, the following rules must be taken
218  * into account:
219  * 
220  * - Never take a reference on a node without owning a reference on its parent.
221  * This means that all parent nodes of a referenced node must be referenced
222  * as well.
223  * 
224  * - Outstanding references on a deleted node are not released. This is not
225  * possible because the node has already been deleted by the time the
226  * row-deleted signal is received.
227  * 
228  * - Models are not obligated to emit a signal on rows of which none of its
229  * siblings are referenced. To phrase this differently, signals are only
230  * required for levels in which nodes are referenced. For the root level
231  * however, signals must be emitted at all times (however the root level
232  * is always referenced when any view is attached).
233  */
234 public template TreeModelT(TStruct)
235 {
236 	/** Get the main Gtk struct */
237 	public GtkTreeModel* getTreeModelStruct(bool transferOwnership = false)
238 	{
239 		if (transferOwnership)
240 			ownedRef = false;
241 		return cast(GtkTreeModel*)getStruct();
242 	}
243 
244 	/**
245 	 * Get the value of a column as a char array.
246 	 * this is the same calling getValue and get the string from the value object
247 	 */
248 	string getValueString(TreeIter iter, int column)
249 	{
250 		Value value = getValue(iter, column);
251 		return value.getString();
252 	}
253 	
254 	/**
255 	 * Get the value of a column as a char array.
256 	 * this is the same calling getValue and get the int from the value object
257 	 */
258 	int getValueInt(TreeIter iter, int column)
259 	{
260 		Value value = getValue(iter, column);
261 		return value.getInt();
262 	}
263 	
264 	/**
265 	 * Sets iter to a valid iterator pointing to path.
266 	 * Params:
267 	 *  iter = The uninitialized GtkTreeIter.
268 	 *  path = The GtkTreePath.
269 	 * Returns:
270 	 *  TRUE, if iter was set.
271 	 */
272 	public int getIter(TreeIter iter, TreePath path)
273 	{
274 		iter.setModel(this);
275 		return gtk_tree_model_get_iter(
276 			getTreeModelStruct(),
277 			(iter is null) ? null : iter.getTreeIterStruct(),
278 		(path is null) ? null : path.getTreePathStruct());
279 	}
280 	
281 	/**
282 	 * Initializes and sets value to that at column.
283 	 * When done with value, g_value_unset() needs to be called
284 	 * to free any allocated memory.
285 	 * Params:
286 	 * iter = The GtkTreeIter.
287 	 * column = The column to lookup the value at.
288 	 * value = (inout) (transfer none) An empty GValue to set.
289 	 */
290 	public Value getValue(TreeIter iter, int column, Value value = null)
291 	{
292 		if ( value is null )
293 			value = new Value();
294 		
295 		gtk_tree_model_get_value(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct(), column, (value is null) ? null : value.getValueStruct());
296 		
297 		return value;
298 	}
299 
300 	/**
301 	 */
302 
303 	/**
304 	 * Calls func on each node in model in a depth-first fashion.
305 	 *
306 	 * If @func returns %TRUE, then the tree ceases to be walked,
307 	 * and gtk_tree_model_foreach() returns.
308 	 *
309 	 * Params:
310 	 *     func = a function to be called on each row
311 	 *     userData = user data to passed to @func
312 	 */
313 	public void foreac(GtkTreeModelForeachFunc func, void* userData)
314 	{
315 		gtk_tree_model_foreach(getTreeModelStruct(), func, userData);
316 	}
317 
318 	/**
319 	 * Returns the type of the column.
320 	 *
321 	 * Params:
322 	 *     index = the column index
323 	 *
324 	 * Returns: the type of the column
325 	 */
326 	public GType getColumnType(int index)
327 	{
328 		return gtk_tree_model_get_column_type(getTreeModelStruct(), index);
329 	}
330 
331 	/**
332 	 * Returns a set of flags supported by this interface.
333 	 *
334 	 * The flags are a bitwise combination of #GtkTreeModelFlags.
335 	 * The flags supported should not change during the lifetime
336 	 * of the @tree_model.
337 	 *
338 	 * Returns: the flags supported by this interface
339 	 */
340 	public GtkTreeModelFlags getFlags()
341 	{
342 		return gtk_tree_model_get_flags(getTreeModelStruct());
343 	}
344 
345 	/**
346 	 * Initializes @iter with the first iterator in the tree
347 	 * (the one at the path "0") and returns %TRUE. Returns
348 	 * %FALSE if the tree is empty.
349 	 *
350 	 * Params:
351 	 *     iter = the uninitialized #GtkTreeIter-struct
352 	 *
353 	 * Returns: %TRUE, if @iter was set
354 	 */
355 	public bool getIterFirst(out TreeIter iter)
356 	{
357 		GtkTreeIter* outiter = gMalloc!GtkTreeIter();
358 		
359 		auto p = gtk_tree_model_get_iter_first(getTreeModelStruct(), outiter) != 0;
360 		
361 		iter = ObjectG.getDObject!(TreeIter)(outiter, true);
362 		
363 		return p;
364 	}
365 
366 	/**
367 	 * Sets @iter to a valid iterator pointing to @path_string, if it
368 	 * exists. Otherwise, @iter is left invalid and %FALSE is returned.
369 	 *
370 	 * Params:
371 	 *     iter = an uninitialized #GtkTreeIter-struct
372 	 *     pathString = a string representation of a #GtkTreePath-struct
373 	 *
374 	 * Returns: %TRUE, if @iter was set
375 	 */
376 	public bool getIterFromString(out TreeIter iter, string pathString)
377 	{
378 		GtkTreeIter* outiter = gMalloc!GtkTreeIter();
379 		
380 		auto p = gtk_tree_model_get_iter_from_string(getTreeModelStruct(), outiter, Str.toStringz(pathString)) != 0;
381 		
382 		iter = ObjectG.getDObject!(TreeIter)(outiter, true);
383 		
384 		return p;
385 	}
386 
387 	/**
388 	 * Returns the number of columns supported by @tree_model.
389 	 *
390 	 * Returns: the number of columns
391 	 */
392 	public int getNColumns()
393 	{
394 		return gtk_tree_model_get_n_columns(getTreeModelStruct());
395 	}
396 
397 	/**
398 	 * Returns a newly-created #GtkTreePath-struct referenced by @iter.
399 	 *
400 	 * This path should be freed with gtk_tree_path_free().
401 	 *
402 	 * Params:
403 	 *     iter = the #GtkTreeIter-struct
404 	 *
405 	 * Returns: a newly-created #GtkTreePath-struct
406 	 */
407 	public TreePath getPath(TreeIter iter)
408 	{
409 		auto p = gtk_tree_model_get_path(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct());
410 		
411 		if(p is null)
412 		{
413 			return null;
414 		}
415 		
416 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p, true);
417 	}
418 
419 	/**
420 	 * Generates a string representation of the iter.
421 	 *
422 	 * This string is a “:” separated list of numbers.
423 	 * For example, “4:10:0:3” would be an acceptable
424 	 * return value for this string.
425 	 *
426 	 * Params:
427 	 *     iter = a #GtkTreeIter-struct
428 	 *
429 	 * Returns: a newly-allocated string.
430 	 *     Must be freed with g_free().
431 	 *
432 	 * Since: 2.2
433 	 */
434 	public string getStringFromIter(TreeIter iter)
435 	{
436 		auto retStr = gtk_tree_model_get_string_from_iter(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct());
437 		
438 		scope(exit) Str.freeString(retStr);
439 		return Str.toString(retStr);
440 	}
441 
442 	/**
443 	 * See gtk_tree_model_get(), this version takes a va_list
444 	 * for language bindings to use.
445 	 *
446 	 * Params:
447 	 *     iter = a row in @tree_model
448 	 *     varArgs = va_list of column/return location pairs
449 	 */
450 	public void getValist(TreeIter iter, void* varArgs)
451 	{
452 		gtk_tree_model_get_valist(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct(), varArgs);
453 	}
454 
455 	/**
456 	 * Sets @iter to point to the first child of @parent.
457 	 *
458 	 * If @parent has no children, %FALSE is returned and @iter is
459 	 * set to be invalid. @parent will remain a valid node after this
460 	 * function has been called.
461 	 *
462 	 * If @parent is %NULL returns the first node, equivalent to
463 	 * `gtk_tree_model_get_iter_first (tree_model, iter);`
464 	 *
465 	 * Params:
466 	 *     iter = the new #GtkTreeIter-struct to be set to the child
467 	 *     parent = the #GtkTreeIter-struct, or %NULL
468 	 *
469 	 * Returns: %TRUE, if @iter has been set to the first child
470 	 */
471 	public bool iterChildren(out TreeIter iter, TreeIter parent)
472 	{
473 		GtkTreeIter* outiter = gMalloc!GtkTreeIter();
474 		
475 		auto p = gtk_tree_model_iter_children(getTreeModelStruct(), outiter, (parent is null) ? null : parent.getTreeIterStruct()) != 0;
476 		
477 		iter = ObjectG.getDObject!(TreeIter)(outiter, true);
478 		
479 		return p;
480 	}
481 
482 	/**
483 	 * Returns %TRUE if @iter has children, %FALSE otherwise.
484 	 *
485 	 * Params:
486 	 *     iter = the #GtkTreeIter-struct to test for children
487 	 *
488 	 * Returns: %TRUE if @iter has children
489 	 */
490 	public bool iterHasChild(TreeIter iter)
491 	{
492 		return gtk_tree_model_iter_has_child(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()) != 0;
493 	}
494 
495 	/**
496 	 * Returns the number of children that @iter has.
497 	 *
498 	 * As a special case, if @iter is %NULL, then the number
499 	 * of toplevel nodes is returned.
500 	 *
501 	 * Params:
502 	 *     iter = the #GtkTreeIter-struct, or %NULL
503 	 *
504 	 * Returns: the number of children of @iter
505 	 */
506 	public int iterNChildren(TreeIter iter)
507 	{
508 		return gtk_tree_model_iter_n_children(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct());
509 	}
510 
511 	/**
512 	 * Sets @iter to point to the node following it at the current level.
513 	 *
514 	 * If there is no next @iter, %FALSE is returned and @iter is set
515 	 * to be invalid.
516 	 *
517 	 * Params:
518 	 *     iter = the #GtkTreeIter-struct
519 	 *
520 	 * Returns: %TRUE if @iter has been changed to the next node
521 	 */
522 	public bool iterNext(TreeIter iter)
523 	{
524 		return gtk_tree_model_iter_next(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()) != 0;
525 	}
526 
527 	/**
528 	 * Sets @iter to be the child of @parent, using the given index.
529 	 *
530 	 * The first index is 0. If @n is too big, or @parent has no children,
531 	 * @iter is set to an invalid iterator and %FALSE is returned. @parent
532 	 * will remain a valid node after this function has been called. As a
533 	 * special case, if @parent is %NULL, then the @n-th root node
534 	 * is set.
535 	 *
536 	 * Params:
537 	 *     iter = the #GtkTreeIter-struct to set to the nth child
538 	 *     parent = the #GtkTreeIter-struct to get the child from, or %NULL.
539 	 *     n = the index of the desired child
540 	 *
541 	 * Returns: %TRUE, if @parent has an @n-th child
542 	 */
543 	public bool iterNthChild(out TreeIter iter, TreeIter parent, int n)
544 	{
545 		GtkTreeIter* outiter = gMalloc!GtkTreeIter();
546 		
547 		auto p = gtk_tree_model_iter_nth_child(getTreeModelStruct(), outiter, (parent is null) ? null : parent.getTreeIterStruct(), n) != 0;
548 		
549 		iter = ObjectG.getDObject!(TreeIter)(outiter, true);
550 		
551 		return p;
552 	}
553 
554 	/**
555 	 * Sets @iter to be the parent of @child.
556 	 *
557 	 * If @child is at the toplevel, and doesn’t have a parent, then
558 	 * @iter is set to an invalid iterator and %FALSE is returned.
559 	 * @child will remain a valid node after this function has been
560 	 * called.
561 	 *
562 	 * @iter will be initialized before the lookup is performed, so @child
563 	 * and @iter cannot point to the same memory location.
564 	 *
565 	 * Params:
566 	 *     iter = the new #GtkTreeIter-struct to set to the parent
567 	 *     child = the #GtkTreeIter-struct
568 	 *
569 	 * Returns: %TRUE, if @iter is set to the parent of @child
570 	 */
571 	public bool iterParent(out TreeIter iter, TreeIter child)
572 	{
573 		GtkTreeIter* outiter = gMalloc!GtkTreeIter();
574 		
575 		auto p = gtk_tree_model_iter_parent(getTreeModelStruct(), outiter, (child is null) ? null : child.getTreeIterStruct()) != 0;
576 		
577 		iter = ObjectG.getDObject!(TreeIter)(outiter, true);
578 		
579 		return p;
580 	}
581 
582 	/**
583 	 * Sets @iter to point to the previous node at the current level.
584 	 *
585 	 * If there is no previous @iter, %FALSE is returned and @iter is
586 	 * set to be invalid.
587 	 *
588 	 * Params:
589 	 *     iter = the #GtkTreeIter-struct
590 	 *
591 	 * Returns: %TRUE if @iter has been changed to the previous node
592 	 *
593 	 * Since: 3.0
594 	 */
595 	public bool iterPrevious(TreeIter iter)
596 	{
597 		return gtk_tree_model_iter_previous(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct()) != 0;
598 	}
599 
600 	/**
601 	 * Lets the tree ref the node.
602 	 *
603 	 * This is an optional method for models to implement.
604 	 * To be more specific, models may ignore this call as it exists
605 	 * primarily for performance reasons.
606 	 *
607 	 * This function is primarily meant as a way for views to let
608 	 * caching models know when nodes are being displayed (and hence,
609 	 * whether or not to cache that node). Being displayed means a node
610 	 * is in an expanded branch, regardless of whether the node is currently
611 	 * visible in the viewport. For example, a file-system based model
612 	 * would not want to keep the entire file-hierarchy in memory,
613 	 * just the sections that are currently being displayed by
614 	 * every current view.
615 	 *
616 	 * A model should be expected to be able to get an iter independent
617 	 * of its reffed state.
618 	 *
619 	 * Params:
620 	 *     iter = the #GtkTreeIter-struct
621 	 */
622 	public void refNode(TreeIter iter)
623 	{
624 		gtk_tree_model_ref_node(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct());
625 	}
626 
627 	/**
628 	 * Emits the #GtkTreeModel::row-changed signal on @tree_model.
629 	 *
630 	 * Params:
631 	 *     path = a #GtkTreePath-struct pointing to the changed row
632 	 *     iter = a valid #GtkTreeIter-struct pointing to the changed row
633 	 */
634 	public void rowChanged(TreePath path, TreeIter iter)
635 	{
636 		gtk_tree_model_row_changed(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct());
637 	}
638 
639 	/**
640 	 * Emits the #GtkTreeModel::row-deleted signal on @tree_model.
641 	 *
642 	 * This should be called by models after a row has been removed.
643 	 * The location pointed to by @path should be the location that
644 	 * the row previously was at. It may not be a valid location anymore.
645 	 *
646 	 * Nodes that are deleted are not unreffed, this means that any
647 	 * outstanding references on the deleted node should not be released.
648 	 *
649 	 * Params:
650 	 *     path = a #GtkTreePath-struct pointing to the previous location of
651 	 *         the deleted row
652 	 */
653 	public void rowDeleted(TreePath path)
654 	{
655 		gtk_tree_model_row_deleted(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct());
656 	}
657 
658 	/**
659 	 * Emits the #GtkTreeModel::row-has-child-toggled signal on
660 	 * @tree_model. This should be called by models after the child
661 	 * state of a node changes.
662 	 *
663 	 * Params:
664 	 *     path = a #GtkTreePath-struct pointing to the changed row
665 	 *     iter = a valid #GtkTreeIter-struct pointing to the changed row
666 	 */
667 	public void rowHasChildToggled(TreePath path, TreeIter iter)
668 	{
669 		gtk_tree_model_row_has_child_toggled(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct());
670 	}
671 
672 	/**
673 	 * Emits the #GtkTreeModel::row-inserted signal on @tree_model.
674 	 *
675 	 * Params:
676 	 *     path = a #GtkTreePath-struct pointing to the inserted row
677 	 *     iter = a valid #GtkTreeIter-struct pointing to the inserted row
678 	 */
679 	public void rowInserted(TreePath path, TreeIter iter)
680 	{
681 		gtk_tree_model_row_inserted(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct());
682 	}
683 
684 	/**
685 	 * Emits the #GtkTreeModel::rows-reordered signal on @tree_model.
686 	 *
687 	 * This should be called by models when their rows have been
688 	 * reordered.
689 	 *
690 	 * Params:
691 	 *     path = a #GtkTreePath-struct pointing to the tree node whose children
692 	 *         have been reordered
693 	 *     iter = a valid #GtkTreeIter-struct pointing to the node whose children
694 	 *         have been reordered, or %NULL if the depth of @path is 0
695 	 *     newOrder = an array of integers mapping the current position of
696 	 *         each child to its old position before the re-ordering,
697 	 *         i.e. @new_order`[newpos] = oldpos`
698 	 */
699 	public void rowsReordered(TreePath path, TreeIter iter, int* newOrder)
700 	{
701 		gtk_tree_model_rows_reordered(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder);
702 	}
703 
704 	/**
705 	 * Emits the #GtkTreeModel::rows-reordered signal on @tree_model.
706 	 *
707 	 * This should be called by models when their rows have been
708 	 * reordered.
709 	 *
710 	 * Params:
711 	 *     path = a #GtkTreePath-struct pointing to the tree node whose children
712 	 *         have been reordered
713 	 *     iter = a valid #GtkTreeIter-struct pointing to the node
714 	 *         whose children have been reordered, or %NULL if the depth
715 	 *         of @path is 0
716 	 *     newOrder = an array of integers
717 	 *         mapping the current position of each child to its old
718 	 *         position before the re-ordering,
719 	 *         i.e. @new_order`[newpos] = oldpos`
720 	 *     length = length of @new_order array
721 	 *
722 	 * Since: 3.10
723 	 */
724 	public void rowsReorderedWithLength(TreePath path, TreeIter iter, int[] newOrder)
725 	{
726 		gtk_tree_model_rows_reordered_with_length(getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder.ptr, cast(int)newOrder.length);
727 	}
728 
729 	/**
730 	 * Lets the tree unref the node.
731 	 *
732 	 * This is an optional method for models to implement.
733 	 * To be more specific, models may ignore this call as it exists
734 	 * primarily for performance reasons. For more information on what
735 	 * this means, see gtk_tree_model_ref_node().
736 	 *
737 	 * Please note that nodes that are deleted are not unreffed.
738 	 *
739 	 * Params:
740 	 *     iter = the #GtkTreeIter-struct
741 	 */
742 	public void unrefNode(TreeIter iter)
743 	{
744 		gtk_tree_model_unref_node(getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct());
745 	}
746 
747 	protected class OnRowChangedDelegateWrapper
748 	{
749 		static OnRowChangedDelegateWrapper[] listeners;
750 		void delegate(TreePath, TreeIter, TreeModelIF) dlg;
751 		gulong handlerId;
752 		
753 		this(void delegate(TreePath, TreeIter, TreeModelIF) dlg)
754 		{
755 			this.dlg = dlg;
756 			this.listeners ~= this;
757 		}
758 		
759 		void remove(OnRowChangedDelegateWrapper source)
760 		{
761 			foreach(index, wrapper; listeners)
762 			{
763 				if (wrapper.handlerId == source.handlerId)
764 				{
765 					listeners[index] = null;
766 					listeners = std.algorithm.remove(listeners, index);
767 					break;
768 				}
769 			}
770 		}
771 	}
772 
773 	/**
774 	 * This signal is emitted when a row in the model has changed.
775 	 *
776 	 * Params:
777 	 *     path = a #GtkTreePath-struct identifying the changed row
778 	 *     iter = a valid #GtkTreeIter-struct pointing to the changed row
779 	 */
780 	gulong addOnRowChanged(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
781 	{
782 		auto wrapper = new OnRowChangedDelegateWrapper(dlg);
783 		wrapper.handlerId = Signals.connectData(
784 			this,
785 			"row-changed",
786 			cast(GCallback)&callBackRowChanged,
787 			cast(void*)wrapper,
788 			cast(GClosureNotify)&callBackRowChangedDestroy,
789 			connectFlags);
790 		return wrapper.handlerId;
791 	}
792 	
793 	extern(C) static void callBackRowChanged(GtkTreeModel* treemodelStruct, GtkTreePath* path, GtkTreeIter* iter, OnRowChangedDelegateWrapper wrapper)
794 	{
795 		wrapper.dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), wrapper.outer);
796 	}
797 	
798 	extern(C) static void callBackRowChangedDestroy(OnRowChangedDelegateWrapper wrapper, GClosure* closure)
799 	{
800 		wrapper.remove(wrapper);
801 	}
802 
803 	protected class OnRowDeletedDelegateWrapper
804 	{
805 		static OnRowDeletedDelegateWrapper[] listeners;
806 		void delegate(TreePath, TreeModelIF) dlg;
807 		gulong handlerId;
808 		
809 		this(void delegate(TreePath, TreeModelIF) dlg)
810 		{
811 			this.dlg = dlg;
812 			this.listeners ~= this;
813 		}
814 		
815 		void remove(OnRowDeletedDelegateWrapper source)
816 		{
817 			foreach(index, wrapper; listeners)
818 			{
819 				if (wrapper.handlerId == source.handlerId)
820 				{
821 					listeners[index] = null;
822 					listeners = std.algorithm.remove(listeners, index);
823 					break;
824 				}
825 			}
826 		}
827 	}
828 
829 	/**
830 	 * This signal is emitted when a row has been deleted.
831 	 *
832 	 * Note that no iterator is passed to the signal handler,
833 	 * since the row is already deleted.
834 	 *
835 	 * This should be called by models after a row has been removed.
836 	 * The location pointed to by @path should be the location that
837 	 * the row previously was at. It may not be a valid location anymore.
838 	 *
839 	 * Params:
840 	 *     path = a #GtkTreePath-struct identifying the row
841 	 */
842 	gulong addOnRowDeleted(void delegate(TreePath, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
843 	{
844 		auto wrapper = new OnRowDeletedDelegateWrapper(dlg);
845 		wrapper.handlerId = Signals.connectData(
846 			this,
847 			"row-deleted",
848 			cast(GCallback)&callBackRowDeleted,
849 			cast(void*)wrapper,
850 			cast(GClosureNotify)&callBackRowDeletedDestroy,
851 			connectFlags);
852 		return wrapper.handlerId;
853 	}
854 	
855 	extern(C) static void callBackRowDeleted(GtkTreeModel* treemodelStruct, GtkTreePath* path, OnRowDeletedDelegateWrapper wrapper)
856 	{
857 		wrapper.dlg(ObjectG.getDObject!(TreePath)(path), wrapper.outer);
858 	}
859 	
860 	extern(C) static void callBackRowDeletedDestroy(OnRowDeletedDelegateWrapper wrapper, GClosure* closure)
861 	{
862 		wrapper.remove(wrapper);
863 	}
864 
865 	protected class OnRowHasChildToggledDelegateWrapper
866 	{
867 		static OnRowHasChildToggledDelegateWrapper[] listeners;
868 		void delegate(TreePath, TreeIter, TreeModelIF) dlg;
869 		gulong handlerId;
870 		
871 		this(void delegate(TreePath, TreeIter, TreeModelIF) dlg)
872 		{
873 			this.dlg = dlg;
874 			this.listeners ~= this;
875 		}
876 		
877 		void remove(OnRowHasChildToggledDelegateWrapper source)
878 		{
879 			foreach(index, wrapper; listeners)
880 			{
881 				if (wrapper.handlerId == source.handlerId)
882 				{
883 					listeners[index] = null;
884 					listeners = std.algorithm.remove(listeners, index);
885 					break;
886 				}
887 			}
888 		}
889 	}
890 
891 	/**
892 	 * This signal is emitted when a row has gotten the first child
893 	 * row or lost its last child row.
894 	 *
895 	 * Params:
896 	 *     path = a #GtkTreePath-struct identifying the row
897 	 *     iter = a valid #GtkTreeIter-struct pointing to the row
898 	 */
899 	gulong addOnRowHasChildToggled(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
900 	{
901 		auto wrapper = new OnRowHasChildToggledDelegateWrapper(dlg);
902 		wrapper.handlerId = Signals.connectData(
903 			this,
904 			"row-has-child-toggled",
905 			cast(GCallback)&callBackRowHasChildToggled,
906 			cast(void*)wrapper,
907 			cast(GClosureNotify)&callBackRowHasChildToggledDestroy,
908 			connectFlags);
909 		return wrapper.handlerId;
910 	}
911 	
912 	extern(C) static void callBackRowHasChildToggled(GtkTreeModel* treemodelStruct, GtkTreePath* path, GtkTreeIter* iter, OnRowHasChildToggledDelegateWrapper wrapper)
913 	{
914 		wrapper.dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), wrapper.outer);
915 	}
916 	
917 	extern(C) static void callBackRowHasChildToggledDestroy(OnRowHasChildToggledDelegateWrapper wrapper, GClosure* closure)
918 	{
919 		wrapper.remove(wrapper);
920 	}
921 
922 	protected class OnRowInsertedDelegateWrapper
923 	{
924 		static OnRowInsertedDelegateWrapper[] listeners;
925 		void delegate(TreePath, TreeIter, TreeModelIF) dlg;
926 		gulong handlerId;
927 		
928 		this(void delegate(TreePath, TreeIter, TreeModelIF) dlg)
929 		{
930 			this.dlg = dlg;
931 			this.listeners ~= this;
932 		}
933 		
934 		void remove(OnRowInsertedDelegateWrapper source)
935 		{
936 			foreach(index, wrapper; listeners)
937 			{
938 				if (wrapper.handlerId == source.handlerId)
939 				{
940 					listeners[index] = null;
941 					listeners = std.algorithm.remove(listeners, index);
942 					break;
943 				}
944 			}
945 		}
946 	}
947 
948 	/**
949 	 * This signal is emitted when a new row has been inserted in
950 	 * the model.
951 	 *
952 	 * Note that the row may still be empty at this point, since
953 	 * it is a common pattern to first insert an empty row, and
954 	 * then fill it with the desired values.
955 	 *
956 	 * Params:
957 	 *     path = a #GtkTreePath-struct identifying the new row
958 	 *     iter = a valid #GtkTreeIter-struct pointing to the new row
959 	 */
960 	gulong addOnRowInserted(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
961 	{
962 		auto wrapper = new OnRowInsertedDelegateWrapper(dlg);
963 		wrapper.handlerId = Signals.connectData(
964 			this,
965 			"row-inserted",
966 			cast(GCallback)&callBackRowInserted,
967 			cast(void*)wrapper,
968 			cast(GClosureNotify)&callBackRowInsertedDestroy,
969 			connectFlags);
970 		return wrapper.handlerId;
971 	}
972 	
973 	extern(C) static void callBackRowInserted(GtkTreeModel* treemodelStruct, GtkTreePath* path, GtkTreeIter* iter, OnRowInsertedDelegateWrapper wrapper)
974 	{
975 		wrapper.dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), wrapper.outer);
976 	}
977 	
978 	extern(C) static void callBackRowInsertedDestroy(OnRowInsertedDelegateWrapper wrapper, GClosure* closure)
979 	{
980 		wrapper.remove(wrapper);
981 	}
982 
983 	protected class OnRowsReorderedDelegateWrapper
984 	{
985 		static OnRowsReorderedDelegateWrapper[] listeners;
986 		void delegate(TreePath, TreeIter, void*, TreeModelIF) dlg;
987 		gulong handlerId;
988 		
989 		this(void delegate(TreePath, TreeIter, void*, TreeModelIF) dlg)
990 		{
991 			this.dlg = dlg;
992 			this.listeners ~= this;
993 		}
994 		
995 		void remove(OnRowsReorderedDelegateWrapper source)
996 		{
997 			foreach(index, wrapper; listeners)
998 			{
999 				if (wrapper.handlerId == source.handlerId)
1000 				{
1001 					listeners[index] = null;
1002 					listeners = std.algorithm.remove(listeners, index);
1003 					break;
1004 				}
1005 			}
1006 		}
1007 	}
1008 
1009 	/**
1010 	 * This signal is emitted when the children of a node in the
1011 	 * #GtkTreeModel have been reordered.
1012 	 *
1013 	 * Note that this signal is not emitted
1014 	 * when rows are reordered by DND, since this is implemented
1015 	 * by removing and then reinserting the row.
1016 	 *
1017 	 * Params:
1018 	 *     path = a #GtkTreePath-struct identifying the tree node whose children
1019 	 *         have been reordered
1020 	 *     iter = a valid #GtkTreeIter-struct pointing to the node whose children
1021 	 *         have been reordered, or %NULL if the depth of @path is 0
1022 	 *     newOrder = an array of integers mapping the current position
1023 	 *         of each child to its old position before the re-ordering,
1024 	 *         i.e. @new_order`[newpos] = oldpos`
1025 	 */
1026 	gulong addOnRowsReordered(void delegate(TreePath, TreeIter, void*, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1027 	{
1028 		auto wrapper = new OnRowsReorderedDelegateWrapper(dlg);
1029 		wrapper.handlerId = Signals.connectData(
1030 			this,
1031 			"rows-reordered",
1032 			cast(GCallback)&callBackRowsReordered,
1033 			cast(void*)wrapper,
1034 			cast(GClosureNotify)&callBackRowsReorderedDestroy,
1035 			connectFlags);
1036 		return wrapper.handlerId;
1037 	}
1038 	
1039 	extern(C) static void callBackRowsReordered(GtkTreeModel* treemodelStruct, GtkTreePath* path, GtkTreeIter* iter, void* newOrder, OnRowsReorderedDelegateWrapper wrapper)
1040 	{
1041 		wrapper.dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), newOrder, wrapper.outer);
1042 	}
1043 	
1044 	extern(C) static void callBackRowsReorderedDestroy(OnRowsReorderedDelegateWrapper wrapper, GClosure* closure)
1045 	{
1046 		wrapper.remove(wrapper);
1047 	}
1048 }