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