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.TreeRowReference;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.TreeIter;
30 private import gtk.TreeModel;
31 private import gtk.TreeModelIF;
32 private import gtk.TreePath;
33 private import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * A GtkTreeRowReference tracks model changes so that it always refers to the
39  * same row (a #GtkTreePath refers to a position, not a fixed row). Create a
40  * new GtkTreeRowReference with gtk_tree_row_reference_new().
41  */
42 public class TreeRowReference
43 {
44 	/** the main Gtk struct */
45 	protected GtkTreeRowReference* gtkTreeRowReference;
46 
47 	/** Get the main Gtk struct */
48 	public GtkTreeRowReference* getTreeRowReferenceStruct()
49 	{
50 		return gtkTreeRowReference;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected void* getStruct()
55 	{
56 		return cast(void*)gtkTreeRowReference;
57 	}
58 
59 	/**
60 	 * Sets our main struct and passes it to the parent class.
61 	 */
62 	public this (GtkTreeRowReference* gtkTreeRowReference)
63 	{
64 		this.gtkTreeRowReference = gtkTreeRowReference;
65 	}
66 
67 	/**
68 	 */
69 
70 	public static GType getType()
71 	{
72 		return gtk_tree_row_reference_get_type();
73 	}
74 
75 	/**
76 	 * Creates a row reference based on @path.
77 	 *
78 	 * This reference will keep pointing to the node pointed to
79 	 * by @path, so long as it exists. Any changes that occur on @model are
80 	 * propagated, and the path is updated appropriately. If
81 	 * @path isn’t a valid path in @model, then %NULL is returned.
82 	 *
83 	 * Params:
84 	 *     model = a #GtkTreeModel
85 	 *     path = a valid #GtkTreePath-struct to monitor
86 	 *
87 	 * Return: a newly allocated #GtkTreeRowReference, or %NULL
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this(TreeModelIF model, TreePath path)
92 	{
93 		auto p = gtk_tree_row_reference_new((model is null) ? null : model.getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct());
94 		
95 		if(p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 		
100 		this(cast(GtkTreeRowReference*) p);
101 	}
102 
103 	/**
104 	 * You do not need to use this function.
105 	 *
106 	 * Creates a row reference based on @path.
107 	 *
108 	 * This reference will keep pointing to the node pointed to
109 	 * by @path, so long as it exists. If @path isn’t a valid
110 	 * path in @model, then %NULL is returned. However, unlike
111 	 * references created with gtk_tree_row_reference_new(), it
112 	 * does not listen to the model for changes. The creator of
113 	 * the row reference must do this explicitly using
114 	 * gtk_tree_row_reference_inserted(), gtk_tree_row_reference_deleted(),
115 	 * gtk_tree_row_reference_reordered().
116 	 *
117 	 * These functions must be called exactly once per proxy when the
118 	 * corresponding signal on the model is emitted. This single call
119 	 * updates all row references for that proxy. Since built-in GTK+
120 	 * objects like #GtkTreeView already use this mechanism internally,
121 	 * using them as the proxy object will produce unpredictable results.
122 	 * Further more, passing the same object as @model and @proxy
123 	 * doesn’t work for reasons of internal implementation.
124 	 *
125 	 * This type of row reference is primarily meant by structures that
126 	 * need to carefully monitor exactly when a row reference updates
127 	 * itself, and is not generally needed by most applications.
128 	 *
129 	 * Params:
130 	 *     proxy = a proxy #GObject
131 	 *     model = a #GtkTreeModel
132 	 *     path = a valid #GtkTreePath-struct to monitor
133 	 *
134 	 * Return: a newly allocated #GtkTreeRowReference, or %NULL
135 	 *
136 	 * Throws: ConstructionException GTK+ fails to create the object.
137 	 */
138 	public this(ObjectG proxy, TreeModelIF model, TreePath path)
139 	{
140 		auto p = gtk_tree_row_reference_new_proxy((proxy is null) ? null : proxy.getObjectGStruct(), (model is null) ? null : model.getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct());
141 		
142 		if(p is null)
143 		{
144 			throw new ConstructionException("null returned by new_proxy");
145 		}
146 		
147 		this(cast(GtkTreeRowReference*) p);
148 	}
149 
150 	/**
151 	 * Copies a #GtkTreeRowReference.
152 	 *
153 	 * Return: a copy of @reference
154 	 *
155 	 * Since: 2.2
156 	 */
157 	public TreeRowReference copy()
158 	{
159 		auto p = gtk_tree_row_reference_copy(gtkTreeRowReference);
160 		
161 		if(p is null)
162 		{
163 			return null;
164 		}
165 		
166 		return ObjectG.getDObject!(TreeRowReference)(cast(GtkTreeRowReference*) p);
167 	}
168 
169 	/**
170 	 * Free’s @reference. @reference may be %NULL
171 	 */
172 	public void free()
173 	{
174 		gtk_tree_row_reference_free(gtkTreeRowReference);
175 	}
176 
177 	/**
178 	 * Returns the model that the row reference is monitoring.
179 	 *
180 	 * Return: the model
181 	 *
182 	 * Since: 2.8
183 	 */
184 	public TreeModelIF getModel()
185 	{
186 		auto p = gtk_tree_row_reference_get_model(gtkTreeRowReference);
187 		
188 		if(p is null)
189 		{
190 			return null;
191 		}
192 		
193 		return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p);
194 	}
195 
196 	/**
197 	 * Returns a path that the row reference currently points to,
198 	 * or %NULL if the path pointed to is no longer valid.
199 	 *
200 	 * Return: a current path, or %NULL
201 	 */
202 	public TreePath getPath()
203 	{
204 		auto p = gtk_tree_row_reference_get_path(gtkTreeRowReference);
205 		
206 		if(p is null)
207 		{
208 			return null;
209 		}
210 		
211 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
212 	}
213 
214 	/**
215 	 * Returns %TRUE if the @reference is non-%NULL and refers to
216 	 * a current valid path.
217 	 *
218 	 * Return: %TRUE if @reference points to a valid path
219 	 */
220 	public bool valid()
221 	{
222 		return gtk_tree_row_reference_valid(gtkTreeRowReference) != 0;
223 	}
224 
225 	/**
226 	 * Lets a set of row reference created by
227 	 * gtk_tree_row_reference_new_proxy() know that the
228 	 * model emitted the #GtkTreeModel::row-deleted signal.
229 	 *
230 	 * Params:
231 	 *     proxy = a #GObject
232 	 *     path = the path position that was deleted
233 	 */
234 	public static void deleted(ObjectG proxy, TreePath path)
235 	{
236 		gtk_tree_row_reference_deleted((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct());
237 	}
238 
239 	/**
240 	 * Lets a set of row reference created by
241 	 * gtk_tree_row_reference_new_proxy() know that the
242 	 * model emitted the #GtkTreeModel::row-inserted signal.
243 	 *
244 	 * Params:
245 	 *     proxy = a #GObject
246 	 *     path = the row position that was inserted
247 	 */
248 	public static void inserted(ObjectG proxy, TreePath path)
249 	{
250 		gtk_tree_row_reference_inserted((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct());
251 	}
252 
253 	/**
254 	 * Lets a set of row reference created by
255 	 * gtk_tree_row_reference_new_proxy() know that the
256 	 * model emitted the #GtkTreeModel::rows-reordered signal.
257 	 *
258 	 * Params:
259 	 *     proxy = a #GObject
260 	 *     path = the parent path of the reordered signal
261 	 *     iter = the iter pointing to the parent of the reordered
262 	 *     newOrder = the new order of rows
263 	 */
264 	public static void reordered(ObjectG proxy, TreePath path, TreeIter iter, int[] newOrder)
265 	{
266 		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);
267 	}
268 }