2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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:
27 * outFile = TreeRowReference
28 * strct = GtkTreeRowReference
31 * clss = TreeRowReference
39 * - gtk_tree_row_reference_
49 * - GObject* -> ObjectG
50 * - GtkTreeIter* -> TreeIter
51 * - GtkTreeModel* -> TreeModel
52 * - GtkTreePath* -> TreePath
56 module gtk
.TreeRowReference
;
58 private import gtk
.gtktypes
;
60 private import lib
.gtk
;
62 private import gtk
.TreeModel
;
63 private import gtk
.TreePath
;
64 private import gobject
.ObjectG
;
65 private import gtk
.TreeIter
;
69 * The GtkTreeModel interface defines a generic tree interface for use by
70 * the GtkTreeView widget. It is an abstract interface, and is designed
71 * to be usable with any appropriate data structure. The programmer just
72 * has to implement this interface on their own data type for it to be
73 * viewable by a GtkTreeView widget.
74 * The model is represented as a hierarchical tree of strongly-typed,
75 * columned data. In other words, the model can be seen as a tree where
76 * every node has different values depending on which column is being
77 * queried. The type of data found in a column is determined by using the
78 * GType system (ie. G_TYPE_INT, GTK_TYPE_BUTTON, G_TYPE_POINTER, etc.).
79 * The types are homogeneous per column across all nodes. It is important
80 * to note that this interface only provides a way of examining a model and
81 * observing changes. The implementation of each individual model decides
82 * how and if changes are made.
83 * In order to make life simpler for programmers who do not need to write
84 * their own specialized model, two generic models are provided the
85 * GtkTreeStore and the GtkListStore. To use these, the developer simply
86 * pushes data into these models as necessary. These models provide the
87 * data structure as well as all appropriate tree interfaces. As a result,
88 * implementing drag and drop, sorting, and storing data is trivial. For
89 * the vast majority of trees and lists, these two models are sufficient.
90 * Models are accessed on a node/column level of granularity. One can
91 * query for the value of a model at a certain node and a certain column
92 * on that node. There are two structures used to reference a particular
93 * node in a model. They are the GtkTreePath and the GtkTreeIter
95 * Most of the interface consists of operations on a GtkTreeIter.
96 * A path is essentially a potential node. It is a location on a model
97 * that may or may not actually correspond to a node on a specific model.
98 * The GtkTreePath struct can be converted into either an array of
99 * unsigned integers or a string. The string form is a list of numbers
100 * separated by a colon. Each number refers to the offset at that level.
101 * Thus, the path 0 refers to the root node and the path
102 * 2:4 refers to the fifth child of the third node.
103 * By contrast, a GtkTreeIter is a reference to a specific node on a
104 * specific model. It is a generic struct with an integer and three
105 * generic pointers. These are filled in by the model in a model-specific
106 * way. One can convert a path to an iterator by calling
107 * gtk_tree_model_get_iter(). These iterators are the primary way of
108 * accessing a model and are similar to the iterators used by
109 * GtkTextBuffer. They are generally statically allocated on the stack and
110 * only used for a short time. The model interface defines a set of
111 * operations using them for navigating the model.
112 * It is expected that models fill in the iterator with private data. For
113 * example, the GtkListStore model, which is internally a simple linked
114 * list, stores a list node in one of the pointers. The GtkTreeModelSort
115 * stores an array and an offset in two of the pointers. Additionally,
116 * there is an integer field. This field is generally filled with a unique
117 * stamp per model. This stamp is for catching errors resulting from using
118 * invalid iterators with a model.
119 * The lifecycle of an iterator can be a little confusing at first.
120 * Iterators are expected to always be valid for as long as the model is
121 * unchanged (and doesn't emit a signal). The model is considered to own
122 * all outstanding iterators and nothing needs to be done to free them from
123 * the user's point of view. Additionally, some models guarantee that an
124 * iterator is valid for as long as the node it refers to is valid (most
125 * notably the GtkTreeStore and GtkListStore). Although generally
126 * uninteresting, as one always has to allow for the case where iterators
127 * do not persist beyond a signal, some very important performance
128 * enhancements were made in the sort model. As a result, the
129 * GTK_TREE_MODEL_ITERS_PERSIST flag was added to indicate this behavior.
130 * To help show some common operation of a model, some examples are
131 * provided. The first example shows three ways of getting the iter at the
132 * location 3:2:5. While the first method shown is easier,
133 * the second is much more common, as you often get paths from callbacks.
134 * Example1.Acquiring a GtkTreeIter
135 * /+* Three ways of getting the iter pointing to the location
140 * GtkTreeIter parent_iter;
141 * /+* get the iterator from a string +/
142 * gtk_tree_model_get_iter_from_string (model, iter, "3:2:5");
143 * /+* get the iterator from a path +/
144 * path = gtk_tree_path_new_from_string ("3:2:5");
145 * gtk_tree_model_get_iter (model, iter, path);
146 * gtk_tree_path_free (path);
147 * /+* walk the tree to find the iterator +/
148 * gtk_tree_model_iter_nth_child (model, iter, NULL, 3);
149 * parent_iter = iter;
150 * gtk_tree_model_iter_nth_child (model, iter, parent_iter, 2);
151 * parent_iter = iter;
152 * gtk_tree_model_iter_nth_child (model, iter, parent_iter, 5);
154 * This second example shows a quick way of iterating through a list and
155 * getting a string and an integer from each row. The
156 * populate_model function used below is not shown, as
157 * it is specific to the GtkListStore. For information on how to write
158 * such a function, see the GtkListStore documentation.
159 * Example2.Reading data from a GtkTreeModel
167 * GtkTreeModel *list_store;
170 * gint row_count = 0;
171 * /+* make a new list_store +/
172 * list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
173 * /+* Fill the list store with data +/
174 * populate_model (list_store);
175 * /+* Get the first iter in the list +/
176 * valid = gtk_tree_model_get_iter_first (list_store, iter);
179 * /+* Walk through the list, reading each row +/
182 * /+* Make sure you terminate calls to gtk_tree_model_get()
183 * * with a '-1' value
185 * gtk_tree_model_get (list_store, iter,
186 * STRING_COLUMN, str_data,
187 * INT_COLUMN, int_data,
189 * /+* Do something with the data +/
190 * g_print ("Row %d: (%s,%d)\n", row_count, str_data, int_data);
193 * valid = gtk_tree_model_iter_next (list_store, iter);
197 public class TreeRowReference
200 /** the main Gtk struct */
201 protected GtkTreeRowReference
* gtkTreeRowReference
;
204 public GtkTreeRowReference
* getTreeRowReferenceStruct()
206 return gtkTreeRowReference
;
210 /** the main Gtk struct as a void* */
211 protected void* getStruct()
213 return cast(void*)gtkTreeRowReference
;
217 * Sets our main struct and passes it to the parent class
219 public this (GtkTreeRowReference
* gtkTreeRowReference
)
221 this.gtkTreeRowReference
= gtkTreeRowReference
;
227 // imports for the signal processing
228 private import gobject
.Signals
;
229 private import gdk
.gdktypes
;
230 int[char[]] connectedSignals
;
232 void delegate(TreePath
, TreeIter
, TreeRowReference
)[] onRowChangedListeners
;
233 void addOnRowChanged(void delegate(TreePath
, TreeIter
, TreeRowReference
) dlg
)
235 if ( !("row-changed" in connectedSignals
) )
240 cast(GCallback
)&callBackRowChanged
,
243 cast(ConnectFlags
)0);
244 connectedSignals
["row-changed"] = 1;
246 onRowChangedListeners
~= dlg
;
248 extern(C
) static void callBackRowChanged(GtkTreeModel
* treeModelStruct
, GtkTreePath
* path
, GtkTreeIter
* iter
, TreeRowReference treeRowReference
)
250 bit consumed
= false;
252 foreach ( void delegate(TreePath
, TreeIter
, TreeRowReference
) dlg
; treeRowReference
.onRowChangedListeners
)
254 dlg(new TreePath(path
), new TreeIter(iter
), treeRowReference
);
260 void delegate(TreePath
, TreeRowReference
)[] onRowDeletedListeners
;
261 void addOnRowDeleted(void delegate(TreePath
, TreeRowReference
) dlg
)
263 if ( !("row-deleted" in connectedSignals
) )
268 cast(GCallback
)&callBackRowDeleted
,
271 cast(ConnectFlags
)0);
272 connectedSignals
["row-deleted"] = 1;
274 onRowDeletedListeners
~= dlg
;
276 extern(C
) static void callBackRowDeleted(GtkTreeModel
* treeModelStruct
, GtkTreePath
* path
, TreeRowReference treeRowReference
)
278 bit consumed
= false;
280 foreach ( void delegate(TreePath
, TreeRowReference
) dlg
; treeRowReference
.onRowDeletedListeners
)
282 dlg(new TreePath(path
), treeRowReference
);
288 void delegate(TreePath
, TreeIter
, TreeRowReference
)[] onRowHasChildToggledListeners
;
289 void addOnRowHasChildToggled(void delegate(TreePath
, TreeIter
, TreeRowReference
) dlg
)
291 if ( !("row-has-child-toggled" in connectedSignals
) )
295 "row-has-child-toggled",
296 cast(GCallback
)&callBackRowHasChildToggled
,
299 cast(ConnectFlags
)0);
300 connectedSignals
["row-has-child-toggled"] = 1;
302 onRowHasChildToggledListeners
~= dlg
;
304 extern(C
) static void callBackRowHasChildToggled(GtkTreeModel
* treeModelStruct
, GtkTreePath
* path
, GtkTreeIter
* iter
, TreeRowReference treeRowReference
)
306 bit consumed
= false;
308 foreach ( void delegate(TreePath
, TreeIter
, TreeRowReference
) dlg
; treeRowReference
.onRowHasChildToggledListeners
)
310 dlg(new TreePath(path
), new TreeIter(iter
), treeRowReference
);
316 void delegate(TreePath
, TreeIter
, TreeRowReference
)[] onRowInsertedListeners
;
317 void addOnRowInserted(void delegate(TreePath
, TreeIter
, TreeRowReference
) dlg
)
319 if ( !("row-inserted" in connectedSignals
) )
324 cast(GCallback
)&callBackRowInserted
,
327 cast(ConnectFlags
)0);
328 connectedSignals
["row-inserted"] = 1;
330 onRowInsertedListeners
~= dlg
;
332 extern(C
) static void callBackRowInserted(GtkTreeModel
* treeModelStruct
, GtkTreePath
* path
, GtkTreeIter
* iter
, TreeRowReference treeRowReference
)
334 bit consumed
= false;
336 foreach ( void delegate(TreePath
, TreeIter
, TreeRowReference
) dlg
; treeRowReference
.onRowInsertedListeners
)
338 dlg(new TreePath(path
), new TreeIter(iter
), treeRowReference
);
344 void delegate(TreePath
, TreeIter
, gpointer
, TreeRowReference
)[] onRowsReorderedListeners
;
345 void addOnRowsReordered(void delegate(TreePath
, TreeIter
, gpointer
, TreeRowReference
) dlg
)
347 if ( !("rows-reordered" in connectedSignals
) )
352 cast(GCallback
)&callBackRowsReordered
,
355 cast(ConnectFlags
)0);
356 connectedSignals
["rows-reordered"] = 1;
358 onRowsReorderedListeners
~= dlg
;
360 extern(C
) static void callBackRowsReordered(GtkTreeModel
* treeModelStruct
, GtkTreePath
* path
, GtkTreeIter
* iter
, gpointer arg3
, TreeRowReference treeRowReference
)
362 bit consumed
= false;
364 foreach ( void delegate(TreePath
, TreeIter
, gpointer
, TreeRowReference
) dlg
; treeRowReference
.onRowsReorderedListeners
)
366 dlg(new TreePath(path
), new TreeIter(iter
), arg3
, treeRowReference
);
400 * Creates a row reference based on path. This reference will keep pointing
401 * to the node pointed to by path, so long as it exists. It listens to all
402 * signals emitted by model, and updates its path appropriately. If path
403 * isn't a valid path in model, then NULL is returned.
407 * A valid GtkTreePath to monitor
409 * A newly allocated GtkTreeRowReference, or NULL
411 public this (TreeModel model
, TreePath path
)
413 // GtkTreeRowReference* gtk_tree_row_reference_new (GtkTreeModel *model, GtkTreePath *path);
414 this(cast(GtkTreeRowReference
*)gtk_tree_row_reference_new((model
is null) ?
null : model
.getTreeModelStruct(), (path
is null) ?
null : path
.getTreePathStruct()) );
418 * You do not need to use this function. Creates a row reference based on
419 * path. This reference will keep pointing to the node pointed to by path,
420 * so long as it exists. If path isn't a valid path in model, then NULL is
421 * returned. However, unlike references created with
422 * gtk_tree_row_reference_new(), it does not listen to the model for changes.
423 * The creator of the row reference must do this explicitly using
424 * gtk_tree_row_reference_inserted(), gtk_tree_row_reference_deleted(),
425 * gtk_tree_row_reference_reordered().
426 * These functions must be called exactly once per proxy when the
427 * corresponding signal on the model is emitted. This single call
428 * updates all row references for that proxy. Since built-in GTK+
429 * objects like GtkTreeView already use this mechanism internally,
430 * using them as the proxy object will produce unpredictable results.
431 * Further more, passing the same object as model and proxy
432 * doesn't work for reasons of internal implementation.
433 * This type of row reference is primarily meant by structures that need to
434 * carefully monitor exactly when a row reference updates itself, and is not
435 * generally needed by most applications.
441 * A valid GtkTreePath to monitor
443 * A newly allocated GtkTreeRowReference, or NULL
445 public this (ObjectG proxy
, TreeModel model
, TreePath path
)
447 // GtkTreeRowReference* gtk_tree_row_reference_new_proxy (GObject *proxy, GtkTreeModel *model, GtkTreePath *path);
448 this(cast(GtkTreeRowReference
*)gtk_tree_row_reference_new_proxy((proxy
is null) ?
null : proxy
.getObjectGStruct(), (model
is null) ?
null : model
.getTreeModelStruct(), (path
is null) ?
null : path
.getTreePathStruct()) );
452 * Returns the model that the row reference is monitoring.
454 * A GtkTreeRowReference
459 public TreeModel
getModel()
461 // GtkTreeModel* gtk_tree_row_reference_get_model (GtkTreeRowReference *reference);
462 return new TreeModel( gtk_tree_row_reference_get_model(gtkTreeRowReference
) );
466 * Returns a path that the row reference currently points to, or NULL if the
467 * path pointed to is no longer valid.
469 * A GtkTreeRowReference
471 * A current path, or NULL.
473 public TreePath
getPath()
475 // GtkTreePath* gtk_tree_row_reference_get_path (GtkTreeRowReference *reference);
476 return new TreePath( gtk_tree_row_reference_get_path(gtkTreeRowReference
) );
480 * Returns TRUE if the reference is non-NULL and refers to a current valid
483 * A GtkTreeRowReference, or NULL
485 * TRUE if reference points to a valid path.
489 // gboolean gtk_tree_row_reference_valid (GtkTreeRowReference *reference);
490 return gtk_tree_row_reference_valid(gtkTreeRowReference
);
494 * Free's reference. reference may be NULL.
496 * A GtkTreeRowReference, or NULL
500 // void gtk_tree_row_reference_free (GtkTreeRowReference *reference);
501 gtk_tree_row_reference_free(gtkTreeRowReference
);
505 * Copies a GtkTreeRowReference.
507 * a GtkTreeRowReference
509 * a copy of reference.
512 public GtkTreeRowReference
* copy()
514 // GtkTreeRowReference* gtk_tree_row_reference_copy (GtkTreeRowReference *reference);
515 return gtk_tree_row_reference_copy(gtkTreeRowReference
);
519 * Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
520 * know that the model emitted the "row_inserted" signal.
524 * The row position that was inserted
526 public static void inserted(ObjectG proxy
, TreePath path
)
528 // void gtk_tree_row_reference_inserted (GObject *proxy, GtkTreePath *path);
529 gtk_tree_row_reference_inserted((proxy
is null) ?
null : proxy
.getObjectGStruct(), (path
is null) ?
null : path
.getTreePathStruct());
533 * Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
534 * know that the model emitted the "row_deleted" signal.
538 * The path position that was deleted
540 public static void deleted(ObjectG proxy
, TreePath path
)
542 // void gtk_tree_row_reference_deleted (GObject *proxy, GtkTreePath *path);
543 gtk_tree_row_reference_deleted((proxy
is null) ?
null : proxy
.getObjectGStruct(), (path
is null) ?
null : path
.getTreePathStruct());
547 * Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
548 * know that the model emitted the "rows_reordered" signal.
552 * The parent path of the reordered signal
554 * The iter pointing to the parent of the reordered
556 * The new order of rows
558 public static void reordered(ObjectG proxy
, TreePath path
, TreeIter iter
, int* newOrder
)
560 // void gtk_tree_row_reference_reordered (GObject *proxy, GtkTreePath *path, GtkTreeIter *iter, gint *new_order);
561 gtk_tree_row_reference_reordered((proxy
is null) ?
null : proxy
.getObjectGStruct(), (path
is null) ?
null : path
.getTreePathStruct(), (iter
is null) ?
null : iter
.getTreeIterStruct(), newOrder
);