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