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