alternative to assert
[gtkD.git] / gtkD / src / gtk / TreeModel.d
blobf5a3f35974197f287cf2f58f3de02fc133dea246
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkTreeModel.html
26 * outPack = gtk
27 * outFile = TreeModel
28 * strct = GtkTreeModel
29 * realStrct=
30 * ctorStrct=
31 * clss = TreeModel
32 * interf =
33 * class Code: Yes
34 * interface Code: Yes
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_tree_model_
40 * omit structs:
41 * omit prefixes:
42 * - gtk_tree_row_reference_
43 * - gtk_tree_path_
44 * - gtk_tree_iter_
45 * omit code:
46 * - gtk_tree_model_get_iter
47 * imports:
48 * - glib.Str
49 * - gtk.TreeIter
50 * - gtk.TreePath
51 * - gobject.Value
52 * structWrap:
53 * - GValue* -> Value
54 * - GtkTreeIter* -> TreeIter
55 * - GtkTreePath* -> TreePath
56 * module aliases:
57 * local aliases:
60 module gtk.TreeModel;
62 version(noAssert)
64 version(Tango)
66 import tango.io.Stdout; // use the tango loging?
70 private import gtkc.gtktypes;
72 private import gtkc.gtk;
75 private import glib.Str;
76 private import gtk.TreeIter;
77 private import gtk.TreePath;
78 private import gobject.Value;
83 /**
84 * Description
85 * The GtkTreeModel interface defines a generic tree interface for use by
86 * the GtkTreeView widget. It is an abstract interface, and is designed
87 * to be usable with any appropriate data structure. The programmer just
88 * has to implement this interface on their own data type for it to be
89 * viewable by a GtkTreeView widget.
90 * The model is represented as a hierarchical tree of strongly-typed,
91 * columned data. In other words, the model can be seen as a tree where
92 * every node has different values depending on which column is being
93 * queried. The type of data found in a column is determined by using the
94 * GType system (ie. G_TYPE_INT, GTK_TYPE_BUTTON, G_TYPE_POINTER, etc.).
95 * The types are homogeneous per column across all nodes. It is important
96 * to note that this interface only provides a way of examining a model and
97 * observing changes. The implementation of each individual model decides
98 * how and if changes are made.
99 * In order to make life simpler for programmers who do not need to write
100 * their own specialized model, two generic models are provided the
101 * GtkTreeStore and the GtkListStore. To use these, the developer simply
102 * pushes data into these models as necessary. These models provide the
103 * data structure as well as all appropriate tree interfaces. As a result,
104 * implementing drag and drop, sorting, and storing data is trivial. For
105 * the vast majority of trees and lists, these two models are sufficient.
106 * Models are accessed on a node/column level of granularity. One can
107 * query for the value of a model at a certain node and a certain column
108 * on that node. There are two structures used to reference a particular
109 * node in a model. They are the GtkTreePath and the GtkTreeIter
110 * [4]
111 * Most of the interface consists of operations on a GtkTreeIter.
112 * A path is essentially a potential node. It is a location on a model
113 * that may or may not actually correspond to a node on a specific model.
114 * The GtkTreePath struct can be converted into either an array of
115 * unsigned integers or a string. The string form is a list of numbers
116 * separated by a colon. Each number refers to the offset at that level.
117 * Thus, the path 0 refers to the root node and the path
118 * 2:4 refers to the fifth child of the third node.
119 * By contrast, a GtkTreeIter is a reference to a specific node on a
120 * specific model. It is a generic struct with an integer and three
121 * generic pointers. These are filled in by the model in a model-specific
122 * way. One can convert a path to an iterator by calling
123 * gtk_tree_model_get_iter(). These iterators are the primary way of
124 * accessing a model and are similar to the iterators used by
125 * GtkTextBuffer. They are generally statically allocated on the stack and
126 * only used for a short time. The model interface defines a set of
127 * operations using them for navigating the model.
128 * It is expected that models fill in the iterator with private data. For
129 * example, the GtkListStore model, which is internally a simple linked
130 * list, stores a list node in one of the pointers. The GtkTreeModelSort
131 * stores an array and an offset in two of the pointers. Additionally,
132 * there is an integer field. This field is generally filled with a unique
133 * stamp per model. This stamp is for catching errors resulting from using
134 * invalid iterators with a model.
135 * The lifecycle of an iterator can be a little confusing at first.
136 * Iterators are expected to always be valid for as long as the model is
137 * unchanged (and doesn't emit a signal). The model is considered to own
138 * all outstanding iterators and nothing needs to be done to free them from
139 * the user's point of view. Additionally, some models guarantee that an
140 * iterator is valid for as long as the node it refers to is valid (most
141 * notably the GtkTreeStore and GtkListStore). Although generally
142 * uninteresting, as one always has to allow for the case where iterators
143 * do not persist beyond a signal, some very important performance
144 * enhancements were made in the sort model. As a result, the
145 * GTK_TREE_MODEL_ITERS_PERSIST flag was added to indicate this behavior.
146 * To help show some common operation of a model, some examples are
147 * provided. The first example shows three ways of getting the iter at the
148 * location 3:2:5. While the first method shown is easier,
149 * the second is much more common, as you often get paths from callbacks.
150 * Example1.Acquiring a GtkTreeIter
151 * /+* Three ways of getting the iter pointing to the location
152 * +/
154 * GtkTreePath *path;
155 * GtkTreeIter iter;
156 * GtkTreeIter parent_iter;
157 * /+* get the iterator from a string +/
158 * gtk_tree_model_get_iter_from_string (model, iter, "3:2:5");
159 * /+* get the iterator from a path +/
160 * path = gtk_tree_path_new_from_string ("3:2:5");
161 * gtk_tree_model_get_iter (model, iter, path);
162 * gtk_tree_path_free (path);
163 * /+* walk the tree to find the iterator +/
164 * gtk_tree_model_iter_nth_child (model, iter, NULL, 3);
165 * parent_iter = iter;
166 * gtk_tree_model_iter_nth_child (model, iter, parent_iter, 2);
167 * parent_iter = iter;
168 * gtk_tree_model_iter_nth_child (model, iter, parent_iter, 5);
170 * This second example shows a quick way of iterating through a list and
171 * getting a string and an integer from each row. The
172 * populate_model function used below is not shown, as
173 * it is specific to the GtkListStore. For information on how to write
174 * such a function, see the GtkListStore documentation.
175 * Example2.Reading data from a GtkTreeModel
176 * enum
178 * STRING_COLUMN,
179 * INT_COLUMN,
180 * N_COLUMNS
181 * };
183 * GtkTreeModel *list_store;
184 * GtkTreeIter iter;
185 * gboolean valid;
186 * gint row_count = 0;
187 * /+* make a new list_store +/
188 * list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
189 * /+* Fill the list store with data +/
190 * populate_model (list_store);
191 * /+* Get the first iter in the list +/
192 * valid = gtk_tree_model_get_iter_first (list_store, iter);
193 * while (valid)
195 * /+* Walk through the list, reading each row +/
196 * gchar *str_data;
197 * gint int_data;
198 * /+* Make sure you terminate calls to gtk_tree_model_get()
199 * * with a '-1' value
200 * +/
201 * gtk_tree_model_get (list_store, iter,
202 * STRING_COLUMN, str_data,
203 * INT_COLUMN, int_data,
204 * -1);
205 * /+* Do something with the data +/
206 * g_print ("Row %d: (%s,%d)\n", row_count, str_data, int_data);
207 * g_free (str_data);
208 * row_count ++;
209 * valid = gtk_tree_model_iter_next (list_store, iter);
213 public class TreeModel
216 /** the main Gtk struct */
217 protected GtkTreeModel* gtkTreeModel;
220 public GtkTreeModel* getTreeModelStruct()
222 return gtkTreeModel;
226 /** the main Gtk struct as a void* */
227 protected void* getStruct()
229 return cast(void*)gtkTreeModel;
233 * Sets our main struct and passes it to the parent class
235 public this (GtkTreeModel* gtkTreeModel)
237 version(noAssert)
239 if ( gtkTreeModel is null )
241 int zero = 0;
242 version(Tango)
244 Stdout("struct gtkTreeModel is null on constructor").newline;
246 else
248 printf("struct gtkTreeModel is null on constructor");
250 zero = zero / zero;
253 else
255 assert(gtkTreeModel !is null, "struct gtkTreeModel is null on constructor");
257 this.gtkTreeModel = gtkTreeModel;
261 * Get the value of a column as a char array.
262 * this is the same calling getValue and get the string from the value object
264 char[] getValueString(TreeIter iter, int column)
266 Value value = new Value();
267 getValue(iter, column, value);
268 return value.getString();
272 * Get the value of a column as a char array.
273 * this is the same calling getValue and get the int from the value object
275 int getValueInt(TreeIter iter, int column)
277 Value value = new Value();
278 getValue(iter, column, value);
279 return value.getInt();
283 * Sets iter to a valid iterator pointing to path.
284 * tree_model:
285 * A GtkTreeModel.
286 * iter:
287 * The uninitialized GtkTreeIter.
288 * path:
289 * The GtkTreePath.
290 * Returns:
291 * TRUE, if iter was set.
293 public int getIter(TreeIter iter, TreePath path)
295 // gboolean gtk_tree_model_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path);
296 iter.setModel(this);
297 return gtk_tree_model_get_iter(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), (path is null) ? null : path.getTreePathStruct());
303 // imports for the signal processing
304 private import gobject.Signals;
305 private import gtkc.gdktypes;
306 int[char[]] connectedSignals;
308 void delegate(TreePath, TreeIter, TreeModel)[] onRowChangedListeners;
309 void addOnRowChanged(void delegate(TreePath, TreeIter, TreeModel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
311 if ( !("row-changed" in connectedSignals) )
313 Signals.connectData(
314 getStruct(),
315 "row-changed",
316 cast(GCallback)&callBackRowChanged,
317 cast(void*)this,
318 null,
319 connectFlags);
320 connectedSignals["row-changed"] = 1;
322 onRowChangedListeners ~= dlg;
324 extern(C) static void callBackRowChanged(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, TreeModel treeModel)
326 bool consumed = false;
328 foreach ( void delegate(TreePath, TreeIter, TreeModel) dlg ; treeModel.onRowChangedListeners )
330 dlg(new TreePath(path), new TreeIter(iter), treeModel);
333 return consumed;
336 void delegate(TreePath, TreeModel)[] onRowDeletedListeners;
337 void addOnRowDeleted(void delegate(TreePath, TreeModel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
339 if ( !("row-deleted" in connectedSignals) )
341 Signals.connectData(
342 getStruct(),
343 "row-deleted",
344 cast(GCallback)&callBackRowDeleted,
345 cast(void*)this,
346 null,
347 connectFlags);
348 connectedSignals["row-deleted"] = 1;
350 onRowDeletedListeners ~= dlg;
352 extern(C) static void callBackRowDeleted(GtkTreeModel* treeModelStruct, GtkTreePath* path, TreeModel treeModel)
354 bool consumed = false;
356 foreach ( void delegate(TreePath, TreeModel) dlg ; treeModel.onRowDeletedListeners )
358 dlg(new TreePath(path), treeModel);
361 return consumed;
364 void delegate(TreePath, TreeIter, TreeModel)[] onRowHasChildToggledListeners;
365 void addOnRowHasChildToggled(void delegate(TreePath, TreeIter, TreeModel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
367 if ( !("row-has-child-toggled" in connectedSignals) )
369 Signals.connectData(
370 getStruct(),
371 "row-has-child-toggled",
372 cast(GCallback)&callBackRowHasChildToggled,
373 cast(void*)this,
374 null,
375 connectFlags);
376 connectedSignals["row-has-child-toggled"] = 1;
378 onRowHasChildToggledListeners ~= dlg;
380 extern(C) static void callBackRowHasChildToggled(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, TreeModel treeModel)
382 bool consumed = false;
384 foreach ( void delegate(TreePath, TreeIter, TreeModel) dlg ; treeModel.onRowHasChildToggledListeners )
386 dlg(new TreePath(path), new TreeIter(iter), treeModel);
389 return consumed;
392 void delegate(TreePath, TreeIter, TreeModel)[] onRowInsertedListeners;
393 void addOnRowInserted(void delegate(TreePath, TreeIter, TreeModel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
395 if ( !("row-inserted" in connectedSignals) )
397 Signals.connectData(
398 getStruct(),
399 "row-inserted",
400 cast(GCallback)&callBackRowInserted,
401 cast(void*)this,
402 null,
403 connectFlags);
404 connectedSignals["row-inserted"] = 1;
406 onRowInsertedListeners ~= dlg;
408 extern(C) static void callBackRowInserted(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, TreeModel treeModel)
410 bool consumed = false;
412 foreach ( void delegate(TreePath, TreeIter, TreeModel) dlg ; treeModel.onRowInsertedListeners )
414 dlg(new TreePath(path), new TreeIter(iter), treeModel);
417 return consumed;
420 void delegate(TreePath, TreeIter, gpointer, TreeModel)[] onRowsReorderedListeners;
421 void addOnRowsReordered(void delegate(TreePath, TreeIter, gpointer, TreeModel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
423 if ( !("rows-reordered" in connectedSignals) )
425 Signals.connectData(
426 getStruct(),
427 "rows-reordered",
428 cast(GCallback)&callBackRowsReordered,
429 cast(void*)this,
430 null,
431 connectFlags);
432 connectedSignals["rows-reordered"] = 1;
434 onRowsReorderedListeners ~= dlg;
436 extern(C) static void callBackRowsReordered(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, gpointer arg3, TreeModel treeModel)
438 bool consumed = false;
440 foreach ( void delegate(TreePath, TreeIter, gpointer, TreeModel) dlg ; treeModel.onRowsReorderedListeners )
442 dlg(new TreePath(path), new TreeIter(iter), arg3, treeModel);
445 return consumed;
488 * Returns a set of flags supported by this interface. The flags are a bitwise
489 * combination of GtkTreeModelFlags. The flags supported should not change
490 * during the lifecycle of the tree_model.
491 * tree_model:
492 * A GtkTreeModel.
493 * Returns:
494 * The flags supported by this interface.
496 public GtkTreeModelFlags getFlags()
498 // GtkTreeModelFlags gtk_tree_model_get_flags (GtkTreeModel *tree_model);
499 return gtk_tree_model_get_flags(gtkTreeModel);
503 * Returns the number of columns supported by tree_model.
504 * tree_model:
505 * A GtkTreeModel.
506 * Returns:
507 * The number of columns.
509 public int getNColumns()
511 // gint gtk_tree_model_get_n_columns (GtkTreeModel *tree_model);
512 return gtk_tree_model_get_n_columns(gtkTreeModel);
516 * Returns the type of the column.
517 * tree_model:
518 * A GtkTreeModel.
519 * index_:
520 * The column index.
521 * Returns:
522 * The type of the column.
524 public GType getColumnType(int index)
526 // GType gtk_tree_model_get_column_type (GtkTreeModel *tree_model, gint index_);
527 return gtk_tree_model_get_column_type(gtkTreeModel, index);
532 * Sets iter to a valid iterator pointing to path_string, if it
533 * exists. Otherwise, iter is left invalid and FALSE is returned.
534 * tree_model:
535 * A GtkTreeModel.
536 * iter:
537 * An uninitialized GtkTreeIter.
538 * path_string:
539 * A string representation of a GtkTreePath.
540 * Returns:
541 * TRUE, if iter was set.
543 public int getIterFromString(TreeIter iter, char[] pathString)
545 // gboolean gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model, GtkTreeIter *iter, const gchar *path_string);
546 return gtk_tree_model_get_iter_from_string(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), Str.toStringz(pathString));
550 * Initializes iter with the first iterator in the tree (the one at the path
551 * "0") and returns TRUE. Returns FALSE if the tree is empty.
552 * tree_model:
553 * A GtkTreeModel.
554 * iter:
555 * The uninitialized GtkTreeIter.
556 * Returns:
557 * TRUE, if iter was set.
559 public int getIterFirst(TreeIter iter)
561 // gboolean gtk_tree_model_get_iter_first (GtkTreeModel *tree_model, GtkTreeIter *iter);
562 return gtk_tree_model_get_iter_first(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
567 * Returns a newly-created GtkTreePath referenced by iter. This path should
568 * be freed with gtk_tree_path_free().
569 * tree_model:
570 * A GtkTreeModel.
571 * iter:
572 * The GtkTreeIter.
573 * Returns:
574 * a newly-created GtkTreePath.
576 public TreePath getPath(TreeIter iter)
578 // GtkTreePath* gtk_tree_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter);
579 return new TreePath( gtk_tree_model_get_path(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct()) );
583 * Sets initializes and sets value to that at column. When done with value,
584 * g_value_unset() needs to be called to free any allocated memory.
585 * tree_model:
586 * A GtkTreeModel.
587 * iter:
588 * The GtkTreeIter.
589 * column:
590 * The column to lookup the value at.
591 * value:
592 * An empty GValue to set.
594 public void getValue(TreeIter iter, int column, Value value)
596 // void gtk_tree_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value);
597 gtk_tree_model_get_value(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), column, (value is null) ? null : value.getValueStruct());
601 * Sets iter to point to the node following it at the current level. If there
602 * is no next iter, FALSE is returned and iter is set to be invalid.
603 * tree_model:
604 * A GtkTreeModel.
605 * iter:
606 * The GtkTreeIter.
607 * Returns:
608 * TRUE if iter has been changed to the next node.
610 public int iterNext(TreeIter iter)
612 // gboolean gtk_tree_model_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter);
613 return gtk_tree_model_iter_next(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
617 * Sets iter to point to the first child of parent. If parent has no
618 * children, FALSE is returned and iter is set to be invalid. parent
619 * will remain a valid node after this function has been called.
620 * If parent is NULL returns the first node, equivalent to
621 * gtk_tree_model_get_iter_first (tree_model, iter);
622 * tree_model:
623 * A GtkTreeModel.
624 * iter:
625 * The new GtkTreeIter to be set to the child.
626 * parent:
627 * The GtkTreeIter, or NULL
628 * Returns:
629 * TRUE, if child has been set to the first child.
631 public int iterChildren(TreeIter iter, TreeIter parent)
633 // gboolean gtk_tree_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent);
634 return gtk_tree_model_iter_children(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), (parent is null) ? null : parent.getTreeIterStruct());
638 * Returns TRUE if iter has children, FALSE otherwise.
639 * tree_model:
640 * A GtkTreeModel.
641 * iter:
642 * The GtkTreeIter to test for children.
643 * Returns:
644 * TRUE if iter has children.
646 public int iterHasChild(TreeIter iter)
648 // gboolean gtk_tree_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter);
649 return gtk_tree_model_iter_has_child(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
653 * Returns the number of children that iter has. As a special case, if iter
654 * is NULL, then the number of toplevel nodes is returned.
655 * tree_model:
656 * A GtkTreeModel.
657 * iter:
658 * The GtkTreeIter, or NULL.
659 * Returns:
660 * The number of children of iter.
662 public int iterNChildren(TreeIter iter)
664 // gint gtk_tree_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter);
665 return gtk_tree_model_iter_n_children(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
669 * Sets iter to be the child of parent, using the given index. The first
670 * index is 0. If n is too big, or parent has no children, iter is set
671 * to an invalid iterator and FALSE is returned. parent will remain a valid
672 * node after this function has been called. As a special case, if parent is
673 * NULL, then the nth root node is set.
674 * tree_model:
675 * A GtkTreeModel.
676 * iter:
677 * The GtkTreeIter to set to the nth child.
678 * parent:
679 * The GtkTreeIter to get the child from, or NULL.
680 * n:
681 * Then index of the desired child.
682 * Returns:
683 * TRUE, if parent has an nth child.
685 public int iterNthChild(TreeIter iter, TreeIter parent, int n)
687 // gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n);
688 return gtk_tree_model_iter_nth_child(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), (parent is null) ? null : parent.getTreeIterStruct(), n);
692 * Sets iter to be the parent of child. If child is at the toplevel, and
693 * doesn't have a parent, then iter is set to an invalid iterator and FALSE
694 * is returned. child will remain a valid node after this function has been
695 * called.
696 * tree_model:
697 * A GtkTreeModel
698 * iter:
699 * The new GtkTreeIter to set to the parent.
700 * child:
701 * The GtkTreeIter.
702 * Returns:
703 * TRUE, if iter is set to the parent of child.
705 public int iterParent(TreeIter iter, TreeIter child)
707 // gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child);
708 return gtk_tree_model_iter_parent(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), (child is null) ? null : child.getTreeIterStruct());
712 * Generates a string representation of the iter. This string is a ':'
713 * separated list of numbers. For example, "4:10:0:3" would be an
714 * acceptable return value for this string.
715 * tree_model:
716 * A GtkTreeModel.
717 * iter:
718 * An GtkTreeIter.
719 * Returns:
720 * A newly-allocated string. Must be freed with g_free().
721 * Since 2.2
723 public char[] getStringFromIter(TreeIter iter)
725 // gchar* gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model, GtkTreeIter *iter);
726 return Str.toString(gtk_tree_model_get_string_from_iter(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct()) );
730 * Lets the tree ref the node. This is an optional method for models to
731 * implement. To be more specific, models may ignore this call as it exists
732 * primarily for performance reasons.
733 * This function is primarily meant as a way for views to let caching model
734 * know when nodes are being displayed (and hence, whether or not to cache that
735 * node.) For example, a file-system based model would not want to keep the
736 * entire file-hierarchy in memory, just the sections that are currently being
737 * displayed by every current view.
738 * A model should be expected to be able to get an iter independent of its
739 * reffed state.
740 * tree_model:
741 * A GtkTreeModel.
742 * iter:
743 * The GtkTreeIter.
745 public void refNode(TreeIter iter)
747 // void gtk_tree_model_ref_node (GtkTreeModel *tree_model, GtkTreeIter *iter);
748 gtk_tree_model_ref_node(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
752 * Lets the tree unref the node. This is an optional method for models to
753 * implement. To be more specific, models may ignore this call as it exists
754 * primarily for performance reasons.
755 * For more information on what this means, see gtk_tree_model_ref_node().
756 * Please note that nodes that are deleted are not unreffed.
757 * tree_model:
758 * A GtkTreeModel.
759 * iter:
760 * The GtkTreeIter.
762 public void unrefNode(TreeIter iter)
764 // void gtk_tree_model_unref_node (GtkTreeModel *tree_model, GtkTreeIter *iter);
765 gtk_tree_model_unref_node(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
769 * Gets the value of one or more cells in the row referenced by iter.
770 * The variable argument list should contain integer column numbers,
771 * each column number followed by a place to store the value being
772 * retrieved. The list is terminated by a -1. For example, to get a
773 * value from column 0 with type G_TYPE_STRING, you would
774 * write: gtk_tree_model_get (model, iter, 0, place_string_here, -1),
775 * where place_string_here is a gchar* to be
776 * filled with the string.
777 * If appropriate, the returned values have to be freed or unreferenced.
778 * tree_model:
779 * a GtkTreeModel
780 * iter:
781 * a row in tree_model
782 * ...:
783 * pairs of column number and value return locations, terminated by -1
785 public void get(TreeIter iter, ... )
787 // void gtk_tree_model_get (GtkTreeModel *tree_model, GtkTreeIter *iter, ...);
788 gtk_tree_model_get(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct());
792 * See gtk_tree_model_get(), this version takes a va_list
793 * for language bindings to use.
794 * tree_model:
795 * a GtkTreeModel
796 * iter:
797 * a row in tree_model
798 * var_args:
799 * va_list of column/return location pairs
801 public void getValist(TreeIter iter, void* varArgs)
803 // void gtk_tree_model_get_valist (GtkTreeModel *tree_model, GtkTreeIter *iter, va_list var_args);
804 gtk_tree_model_get_valist(gtkTreeModel, (iter is null) ? null : iter.getTreeIterStruct(), varArgs);
808 * Calls func on each node in model in a depth-first fashion.
809 * If func returns TRUE, then the tree ceases to be walked, and
810 * gtk_tree_model_foreach() returns.
811 * model:
812 * A GtkTreeModel
813 * func:
814 * A function to be called on each row
815 * user_data:
816 * User data to passed to func.
818 public void foreac(GtkTreeModelForeachFunc func, void* userData)
820 // void gtk_tree_model_foreach (GtkTreeModel *model, GtkTreeModelForeachFunc func, gpointer user_data);
821 gtk_tree_model_foreach(gtkTreeModel, func, userData);
825 * Emits the "row_changed" signal on tree_model.
826 * tree_model:
827 * A GtkTreeModel
828 * path:
829 * A GtkTreePath pointing to the changed row
830 * iter:
831 * A valid GtkTreeIter pointing to the changed row
833 public void rowChanged(TreePath path, TreeIter iter)
835 // void gtk_tree_model_row_changed (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter);
836 gtk_tree_model_row_changed(gtkTreeModel, (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct());
840 * Emits the "row_inserted" signal on tree_model
841 * tree_model:
842 * A GtkTreeModel
843 * path:
844 * A GtkTreePath pointing to the inserted row
845 * iter:
846 * A valid GtkTreeIter pointing to the inserted row
848 public void rowInserted(TreePath path, TreeIter iter)
850 // void gtk_tree_model_row_inserted (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter);
851 gtk_tree_model_row_inserted(gtkTreeModel, (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct());
855 * Emits the "row_has_child_toggled" signal on tree_model. This should be
856 * called by models after the child state of a node changes.
857 * tree_model:
858 * A GtkTreeModel
859 * path:
860 * A GtkTreePath pointing to the changed row
861 * iter:
862 * A valid GtkTreeIter pointing to the changed row
864 public void rowHasChildToggled(TreePath path, TreeIter iter)
866 // void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter);
867 gtk_tree_model_row_has_child_toggled(gtkTreeModel, (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct());
871 * Emits the "row_deleted" signal on tree_model. This should be called by
872 * models after a row has been removed. The location pointed to by path
873 * should be the location that the row previously was at. It may not be a
874 * valid location anymore.
875 * tree_model:
876 * A GtkTreeModel
877 * path:
878 * A GtkTreePath pointing to the previous location of the deleted row.
880 public void rowDeleted(TreePath path)
882 // void gtk_tree_model_row_deleted (GtkTreeModel *tree_model, GtkTreePath *path);
883 gtk_tree_model_row_deleted(gtkTreeModel, (path is null) ? null : path.getTreePathStruct());
887 * Emits the "rows_reordered" signal on tree_model. This should be called by
888 * models when their rows have been reordered.
889 * tree_model:
890 * A GtkTreeModel
891 * path:
892 * A GtkTreePath pointing to the tree node whose children have been
893 * reordered
894 * iter:
895 * A valid GtkTreeIter pointing to the node whose children have been
896 * reordered, or NULL if the depth of path is 0.
897 * new_order:
898 * an array of integers mapping the current position of each child
899 * to its old position before the re-ordering,
900 * i.e. new_order[newpos] = oldpos.
901 * Signal Details
902 * The "row-changed" signal
903 * void user_function (GtkTreeModel *tree_model,
904 * GtkTreePath *path,
905 * GtkTreeIter *iter,
906 * gpointer user_data) : Run Last
907 * This signal is emitted when a row in the model has changed.
908 * tree_model:
909 * the GtkTreeModel on which the signal is emitted
910 * path:
911 * a GtkTreePath identifying the changed row
912 * iter:
913 * a valid GtkTreeIter pointing to the changed row
914 * user_data:
915 * user data set when the signal handler was connected.
917 public void rowsReordered(TreePath path, TreeIter iter, int* newOrder)
919 // void gtk_tree_model_rows_reordered (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gint *new_order);
920 gtk_tree_model_rows_reordered(gtkTreeModel, (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder);