1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = gtk
28  * outFile = TreeRowReference
29  * strct   = GtkTreeRowReference
30  * realStrct=
31  * ctorStrct=
32  * clss    = TreeRowReference
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_tree_row_reference_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * 	- row-changed
46  * 	- row-deleted
47  * 	- row-has-child-toggled
48  * 	- row-inserted
49  * 	- rows-reordered
50  * imports:
51  * 	- gtk.TreeModel
52  * 	- gtk.TreeModelIF
53  * 	- gtk.TreePath
54  * 	- gobject.ObjectG
55  * 	- gtk.TreeIter
56  * structWrap:
57  * 	- GObject* -> ObjectG
58  * 	- GtkTreeIter* -> TreeIter
59  * 	- GtkTreeModel* -> TreeModelIF
60  * 	- GtkTreePath* -> TreePath
61  * 	- GtkTreeRowReference* -> TreeRowReference
62  * module aliases:
63  * local aliases:
64  * overrides:
65  */
66 
67 module gtk.TreeRowReference;
68 
69 public  import gtkc.gtktypes;
70 
71 private import gtkc.gtk;
72 private import glib.ConstructionException;
73 private import gobject.ObjectG;
74 
75 private import gobject.Signals;
76 public  import gtkc.gdktypes;
77 
78 private import gtk.TreeModel;
79 private import gtk.TreeModelIF;
80 private import gtk.TreePath;
81 private import gobject.ObjectG;
82 private import gtk.TreeIter;
83 
84 
85 
86 
87 /**
88  * Description
89  * The GtkTreeModel interface defines a generic tree interface for use by
90  * the GtkTreeView widget. It is an abstract interface, and is designed
91  * to be usable with any appropriate data structure. The programmer just
92  * has to implement this interface on their own data type for it to be
93  * viewable by a GtkTreeView widget.
94  * The model is represented as a hierarchical tree of strongly-typed,
95  * columned data. In other words, the model can be seen as a tree where
96  * every node has different values depending on which column is being
97  * queried. The type of data found in a column is determined by using the
98  * GType system (ie. G_TYPE_INT, GTK_TYPE_BUTTON, G_TYPE_POINTER, etc.).
99  * The types are homogeneous per column across all nodes. It is important
100  * to note that this interface only provides a way of examining a model and
101  * observing changes. The implementation of each individual model decides
102  * how and if changes are made.
103  * In order to make life simpler for programmers who do not need to write
104  * their own specialized model, two generic models are provided — the
105  * GtkTreeStore and the GtkListStore. To use these, the developer simply
106  * pushes data into these models as necessary. These models provide the
107  * data structure as well as all appropriate tree interfaces. As a result,
108  * implementing drag and drop, sorting, and storing data is trivial. For
109  * the vast majority of trees and lists, these two models are sufficient.
110  * Models are accessed on a node/column level of granularity. One can
111  * query for the value of a model at a certain node and a certain column
112  * on that node. There are two structures used to reference a particular
113  * node in a model. They are the GtkTreePath and the GtkTreeIter
114  * [4]
115  * Most of the interface consists of operations on a GtkTreeIter.
116  * A path is essentially a potential node. It is a location on a model
117  * that may or may not actually correspond to a node on a specific model.
118  * The GtkTreePath struct can be converted into either an array of
119  * unsigned integers or a string. The string form is a list of numbers
120  * separated by a colon. Each number refers to the offset at that level.
121  * Thus, the path “0” refers to the root node and the path
122  * “2:4” refers to the fifth child of the third node.
123  * By contrast, a GtkTreeIter is a reference to a specific node on a
124  * specific model. It is a generic struct with an integer and three
125  * generic pointers. These are filled in by the model in a model-specific
126  * way. One can convert a path to an iterator by calling
127  * gtk_tree_model_get_iter(). These iterators are the primary way of
128  * accessing a model and are similar to the iterators used by
129  * GtkTextBuffer. They are generally statically allocated on the stack and
130  * only used for a short time. The model interface defines a set of
131  * operations using them for navigating the model.
132  * It is expected that models fill in the iterator with private data. For
133  * example, the GtkListStore model, which is internally a simple linked
134  * list, stores a list node in one of the pointers. The GtkTreeModelSort
135  * stores an array and an offset in two of the pointers. Additionally,
136  * there is an integer field. This field is generally filled with a unique
137  * stamp per model. This stamp is for catching errors resulting from using
138  * invalid iterators with a model.
139  * The lifecycle of an iterator can be a little confusing at first.
140  * Iterators are expected to always be valid for as long as the model is
141  * unchanged (and doesn't emit a signal). The model is considered to own
142  * all outstanding iterators and nothing needs to be done to free them from
143  * the user's point of view. Additionally, some models guarantee that an
144  * iterator is valid for as long as the node it refers to is valid (most
145  * notably the GtkTreeStore and GtkListStore). Although generally
146  * uninteresting, as one always has to allow for the case where iterators
147  * do not persist beyond a signal, some very important performance
148  * enhancements were made in the sort model. As a result, the
149  * GTK_TREE_MODEL_ITERS_PERSIST flag was added to indicate this behavior.
150  * To help show some common operation of a model, some examples are
151  * provided. The first example shows three ways of getting the iter at the
152  * location “3:2:5”. While the first method shown is easier,
153  * the second is much more common, as you often get paths from callbacks.
154  * $(DDOC_COMMENT example)
155  * This second example shows a quick way of iterating through a list and
156  * getting a string and an integer from each row. The
157  * populate_model function used below is not shown, as
158  * it is specific to the GtkListStore. For information on how to write
159  * such a function, see the GtkListStore documentation.
160  * $(DDOC_COMMENT example)
161  */
162 public class TreeRowReference
163 {
164 	
165 	/** the main Gtk struct */
166 	protected GtkTreeRowReference* gtkTreeRowReference;
167 	
168 	
169 	public GtkTreeRowReference* getTreeRowReferenceStruct()
170 	{
171 		return gtkTreeRowReference;
172 	}
173 	
174 	
175 	/** the main Gtk struct as a void* */
176 	protected void* getStruct()
177 	{
178 		return cast(void*)gtkTreeRowReference;
179 	}
180 	
181 	/**
182 	 * Sets our main struct and passes it to the parent class
183 	 */
184 	public this (GtkTreeRowReference* gtkTreeRowReference)
185 	{
186 		this.gtkTreeRowReference = gtkTreeRowReference;
187 	}
188 	
189 	/**
190 	 */
191 	
192 	/**
193 	 * Creates a row reference based on path. This reference will keep pointing
194 	 * to the node pointed to by path, so long as it exists. It listens to all
195 	 * signals emitted by model, and updates its path appropriately. If path
196 	 * isn't a valid path in model, then NULL is returned.
197 	 * Params:
198 	 * model = A GtkTreeModel
199 	 * path = A valid GtkTreePath to monitor
200 	 * Throws: ConstructionException GTK+ fails to create the object.
201 	 */
202 	public this (TreeModelIF model, TreePath path)
203 	{
204 		// GtkTreeRowReference * gtk_tree_row_reference_new (GtkTreeModel *model,  GtkTreePath *path);
205 		auto p = gtk_tree_row_reference_new((model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct());
206 		if(p is null)
207 		{
208 			throw new ConstructionException("null returned by gtk_tree_row_reference_new((model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct())");
209 		}
210 		this(cast(GtkTreeRowReference*) p);
211 	}
212 	
213 	/**
214 	 * You do not need to use this function. Creates a row reference based on
215 	 * path. This reference will keep pointing to the node pointed to by path,
216 	 * so long as it exists. If path isn't a valid path in model, then NULL is
217 	 * returned. However, unlike references created with
218 	 * gtk_tree_row_reference_new(), it does not listen to the model for changes.
219 	 * The creator of the row reference must do this explicitly using
220 	 * gtk_tree_row_reference_inserted(), gtk_tree_row_reference_deleted(),
221 	 * gtk_tree_row_reference_reordered().
222 	 * These functions must be called exactly once per proxy when the
223 	 * corresponding signal on the model is emitted. This single call
224 	 * updates all row references for that proxy. Since built-in GTK+
225 	 * objects like GtkTreeView already use this mechanism internally,
226 	 * using them as the proxy object will produce unpredictable results.
227 	 * Further more, passing the same object as model and proxy
228 	 * doesn't work for reasons of internal implementation.
229 	 * This type of row reference is primarily meant by structures that need to
230 	 * carefully monitor exactly when a row reference updates itself, and is not
231 	 * generally needed by most applications.
232 	 * Params:
233 	 * proxy = A proxy GObject
234 	 * model = A GtkTreeModel
235 	 * path = A valid GtkTreePath to monitor
236 	 * Throws: ConstructionException GTK+ fails to create the object.
237 	 */
238 	public this (ObjectG proxy, TreeModelIF model, TreePath path)
239 	{
240 		// GtkTreeRowReference * gtk_tree_row_reference_new_proxy (GObject *proxy,  GtkTreeModel *model,  GtkTreePath *path);
241 		auto p = gtk_tree_row_reference_new_proxy((proxy is null) ? null : proxy.getObjectGStruct(), (model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct());
242 		if(p is null)
243 		{
244 			throw new ConstructionException("null returned by gtk_tree_row_reference_new_proxy((proxy is null) ? null : proxy.getObjectGStruct(), (model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct())");
245 		}
246 		this(cast(GtkTreeRowReference*) p);
247 	}
248 	
249 	/**
250 	 * Returns the model that the row reference is monitoring.
251 	 * Since 2.8
252 	 * Returns: the model. [transfer none]
253 	 */
254 	public TreeModelIF getModel()
255 	{
256 		// GtkTreeModel * gtk_tree_row_reference_get_model (GtkTreeRowReference *reference);
257 		auto p = gtk_tree_row_reference_get_model(gtkTreeRowReference);
258 		
259 		if(p is null)
260 		{
261 			return null;
262 		}
263 		
264 		return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p);
265 	}
266 	
267 	/**
268 	 * Returns a path that the row reference currently points to, or NULL if the
269 	 * path pointed to is no longer valid.
270 	 * Returns: A current path, or NULL.
271 	 */
272 	public TreePath getPath()
273 	{
274 		// GtkTreePath * gtk_tree_row_reference_get_path (GtkTreeRowReference *reference);
275 		auto p = gtk_tree_row_reference_get_path(gtkTreeRowReference);
276 		
277 		if(p is null)
278 		{
279 			return null;
280 		}
281 		
282 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
283 	}
284 	
285 	/**
286 	 * Returns TRUE if the reference is non-NULL and refers to a current valid
287 	 * path.
288 	 * Returns: TRUE if reference points to a valid path.
289 	 */
290 	public int valid()
291 	{
292 		// gboolean gtk_tree_row_reference_valid (GtkTreeRowReference *reference);
293 		return gtk_tree_row_reference_valid(gtkTreeRowReference);
294 	}
295 	
296 	/**
297 	 * Free's reference. reference may be NULL.
298 	 */
299 	public void free()
300 	{
301 		// void gtk_tree_row_reference_free (GtkTreeRowReference *reference);
302 		gtk_tree_row_reference_free(gtkTreeRowReference);
303 	}
304 	
305 	/**
306 	 * Copies a GtkTreeRowReference.
307 	 * Since 2.2
308 	 * Returns: a copy of reference.
309 	 */
310 	public TreeRowReference copy()
311 	{
312 		// GtkTreeRowReference * gtk_tree_row_reference_copy (GtkTreeRowReference *reference);
313 		auto p = gtk_tree_row_reference_copy(gtkTreeRowReference);
314 		
315 		if(p is null)
316 		{
317 			return null;
318 		}
319 		
320 		return ObjectG.getDObject!(TreeRowReference)(cast(GtkTreeRowReference*) p);
321 	}
322 	
323 	/**
324 	 * Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
325 	 * know that the model emitted the "row_inserted" signal.
326 	 * Params:
327 	 * proxy = A GObject
328 	 * path = The row position that was inserted
329 	 */
330 	public static void inserted(ObjectG proxy, TreePath path)
331 	{
332 		// void gtk_tree_row_reference_inserted (GObject *proxy,  GtkTreePath *path);
333 		gtk_tree_row_reference_inserted((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct());
334 	}
335 	
336 	/**
337 	 * Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
338 	 * know that the model emitted the "row_deleted" signal.
339 	 * Params:
340 	 * proxy = A GObject
341 	 * path = The path position that was deleted
342 	 */
343 	public static void deleted(ObjectG proxy, TreePath path)
344 	{
345 		// void gtk_tree_row_reference_deleted (GObject *proxy,  GtkTreePath *path);
346 		gtk_tree_row_reference_deleted((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct());
347 	}
348 	
349 	/**
350 	 * Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
351 	 * know that the model emitted the "rows_reordered" signal.
352 	 * Params:
353 	 * proxy = A GObject
354 	 * path = The parent path of the reordered signal
355 	 * iter = The iter pointing to the parent of the reordered
356 	 * newOrder = The new order of rows
357 	 */
358 	public static void reordered(ObjectG proxy, TreePath path, TreeIter iter, int[] newOrder)
359 	{
360 		// void gtk_tree_row_reference_reordered (GObject *proxy,  GtkTreePath *path,  GtkTreeIter *iter,  gint *new_order);
361 		gtk_tree_row_reference_reordered((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder.ptr);
362 	}
363 }