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