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