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 * Conversion parameters: 26 * inFile = 27 * outPack = gtk 28 * outFile = TreeRowReference 29 * strct = GtkTreeRowReference 30 * realStrct= 31 * ctorStrct= 32 * clss = TreeRowReference 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_tree_row_reference_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * - row-changed 46 * - row-deleted 47 * - row-has-child-toggled 48 * - row-inserted 49 * - rows-reordered 50 * imports: 51 * - gobject.ObjectG 52 * - gtk.TreeIter 53 * - gtk.TreeModel 54 * - gtk.TreeModelIF 55 * - gtk.TreePath 56 * structWrap: 57 * - GObject* -> ObjectG 58 * - GtkTreeIter* -> TreeIter 59 * - GtkTreeModel* -> TreeModelIF 60 * - GtkTreePath* -> TreePath 61 * - GtkTreeRowReference* -> TreeRowReference 62 * module aliases: 63 * local aliases: 64 * overrides: 65 */ 66 67 module gtk.TreeRowReference; 68 69 public import gtkc.gtktypes; 70 71 private import gtkc.gtk; 72 private import glib.ConstructionException; 73 private import gobject.ObjectG; 74 75 private import gobject.Signals; 76 public import gtkc.gdktypes; 77 78 private import gobject.ObjectG; 79 private import gtk.TreeIter; 80 private import gtk.TreeModel; 81 private import gtk.TreeModelIF; 82 private import gtk.TreePath; 83 84 85 86 87 /** 88 * The GtkTreeModel interface defines a generic tree interface for 89 * use by the GtkTreeView widget. It is an abstract interface, and 90 * is designed to be usable with any appropriate data structure. The 91 * programmer just has to implement this interface on their own data 92 * type for it to be viewable by a GtkTreeView widget. 93 * 94 * The model is represented as a hierarchical tree of strongly-typed, 95 * columned data. In other words, the model can be seen as a tree where 96 * every node has different values depending on which column is being 97 * queried. The type of data found in a column is determined by using 98 * the GType system (ie. G_TYPE_INT, GTK_TYPE_BUTTON, G_TYPE_POINTER, 99 * etc). The types are homogeneous per column across all nodes. It is 100 * important to note that this interface only provides a way of examining 101 * a model and observing changes. The implementation of each individual 102 * model decides how and if changes are made. 103 * 104 * In order to make life simpler for programmers who do not need to 105 * write their own specialized model, two generic models are provided 106 * — the GtkTreeStore and the GtkListStore. To use these, the 107 * developer simply pushes data into these models as necessary. These 108 * models provide the data structure as well as all appropriate tree 109 * interfaces. As a result, implementing drag and drop, sorting, and 110 * storing data is trivial. For the vast majority of trees and lists, 111 * these two models are sufficient. 112 * 113 * Models are accessed on a node/column level of granularity. One can 114 * query for the value of a model at a certain node and a certain 115 * column on that node. There are two structures used to reference 116 * a particular node in a model. They are the GtkTreePath and the 117 * GtkTreeIter[4]. Most of the interface 118 * consists of operations on a GtkTreeIter. 119 * 120 * A path is essentially a potential node. It is a location on a model 121 * that may or may not actually correspond to a node on a specific 122 * model. The GtkTreePath struct can be converted into either an 123 * array of unsigned integers or a string. The string form is a list 124 * of numbers separated by a colon. Each number refers to the offset 125 * at that level. Thus, the path “0” refers to the root 126 * node and the path “2:4” refers to the fifth child of 127 * the third node. 128 * 129 * By contrast, a GtkTreeIter is a reference to a specific node on 130 * a specific model. It is a generic struct with an integer and three 131 * generic pointers. These are filled in by the model in a model-specific 132 * way. One can convert a path to an iterator by calling 133 * gtk_tree_model_get_iter(). These iterators are the primary way 134 * of accessing a model and are similar to the iterators used by 135 * GtkTextBuffer. They are generally statically allocated on the 136 * stack and only used for a short time. The model interface defines 137 * a set of operations using them for navigating the model. 138 * 139 * It is expected that models fill in the iterator with private data. 140 * For example, the GtkListStore model, which is internally a simple 141 * linked list, stores a list node in one of the pointers. The 142 * GtkTreeModelSort stores an array and an offset in two of the 143 * pointers. Additionally, there is an integer field. This field is 144 * generally filled with a unique stamp per model. This stamp is for 145 * catching errors resulting from using invalid iterators with a model. 146 * 147 * The lifecycle of an iterator can be a little confusing at first. 148 * Iterators are expected to always be valid for as long as the model 149 * is unchanged (and doesn't emit a signal). The model is considered 150 * to own all outstanding iterators and nothing needs to be done to 151 * free them from the user's point of view. Additionally, some models 152 * guarantee that an iterator is valid for as long as the node it refers 153 * to is valid (most notably the GtkTreeStore and GtkListStore). 154 * Although generally uninteresting, as one always has to allow for 155 * the case where iterators do not persist beyond a signal, some very 156 * important performance enhancements were made in the sort model. 157 * As a result, the GTK_TREE_MODEL_ITERS_PERSIST flag was added to 158 * indicate this behavior. 159 * 160 * To help show some common operation of a model, some examples are 161 * provided. The first example shows three ways of getting the iter at 162 * the location “3:2:5”. While the first method shown is 163 * easier, the second is much more common, as you often get paths from 164 * callbacks. 165 * 166 * $(DDOC_COMMENT example) 167 * 168 * This second example shows a quick way of iterating through a list 169 * and getting a string and an integer from each row. The 170 * populate_model function used below is not 171 * shown, as it is specific to the GtkListStore. For information on 172 * how to write such a function, see the GtkListStore documentation. 173 * 174 * $(DDOC_COMMENT example) 175 * 176 * The GtkTreeModel interface contains two methods for reference 177 * counting: gtk_tree_model_ref_node() and gtk_tree_model_unref_node(). 178 * These two methods are optional to implement. The reference counting 179 * is meant as a way for views to let models know when nodes are being 180 * displayed. GtkTreeView will take a reference on a node when it is 181 * visible, which means the node is either in the toplevel or expanded. 182 * Being displayed does not mean that the node is currently directly 183 * visible to the user in the viewport. Based on this reference counting 184 * scheme a caching model, for example, can decide whether or not to cache 185 * a node based on the reference count. A file-system based model would 186 * not want to keep the entire file hierarchy in memory, but just the 187 * folders that are currently expanded in every current view. 188 * 189 * When working with reference counting, the following rules must be taken 190 * into account: 191 * 192 * Never take a reference on a node without owning a 193 * reference on its parent. This means that all parent nodes of a referenced 194 * node must be referenced as well. 195 * 196 * Outstanding references on a deleted node are not released. 197 * This is not possible because the node has already been deleted by the 198 * time the row-deleted signal is received. 199 * 200 * Models are not obligated to emit a signal on rows of 201 * which none of its siblings are referenced. To phrase this differently, 202 * signals are only required for levels in which nodes are referenced. For 203 * the root level however, signals must be emitted at all times (however the 204 * root level is always referenced when any view is attached). 205 */ 206 public class TreeRowReference 207 { 208 209 /** the main Gtk struct */ 210 protected GtkTreeRowReference* gtkTreeRowReference; 211 212 213 public GtkTreeRowReference* getTreeRowReferenceStruct() 214 { 215 return gtkTreeRowReference; 216 } 217 218 219 /** the main Gtk struct as a void* */ 220 protected void* getStruct() 221 { 222 return cast(void*)gtkTreeRowReference; 223 } 224 225 /** 226 * Sets our main struct and passes it to the parent class 227 */ 228 public this (GtkTreeRowReference* gtkTreeRowReference) 229 { 230 this.gtkTreeRowReference = gtkTreeRowReference; 231 } 232 233 /** 234 */ 235 236 /** 237 * Creates a row reference based on path. 238 * This reference will keep pointing to the node pointed to 239 * by path, so long as it exists. Any changes that occur on model are 240 * propagated, and the path is updated appropriately. If 241 * path isn't a valid path in model, then NULL is returned. 242 * Params: 243 * model = a GtkTreeModel 244 * path = a valid GtkTreePath to monitor 245 * Throws: ConstructionException GTK+ fails to create the object. 246 */ 247 public this (TreeModelIF model, TreePath path) 248 { 249 // GtkTreeRowReference * gtk_tree_row_reference_new (GtkTreeModel *model, GtkTreePath *path); 250 auto p = gtk_tree_row_reference_new((model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct()); 251 if(p is null) 252 { 253 throw new ConstructionException("null returned by gtk_tree_row_reference_new((model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct())"); 254 } 255 this(cast(GtkTreeRowReference*) p); 256 } 257 258 /** 259 * You do not need to use this function. 260 * Creates a row reference based on path. 261 * This reference will keep pointing to the node pointed to 262 * by path, so long as it exists. If path isn't a valid 263 * path in model, then NULL is returned. However, unlike 264 * references created with gtk_tree_row_reference_new(), it 265 * does not listen to the model for changes. The creator of 266 * the row reference must do this explicitly using 267 * gtk_tree_row_reference_inserted(), gtk_tree_row_reference_deleted(), 268 * gtk_tree_row_reference_reordered(). 269 * These functions must be called exactly once per proxy when the 270 * corresponding signal on the model is emitted. This single call 271 * updates all row references for that proxy. Since built-in GTK+ 272 * objects like GtkTreeView already use this mechanism internally, 273 * using them as the proxy object will produce unpredictable results. 274 * Further more, passing the same object as model and proxy 275 * doesn't work for reasons of internal implementation. 276 * This type of row reference is primarily meant by structures that 277 * need to carefully monitor exactly when a row reference updates 278 * itself, and is not generally needed by most applications. 279 * Params: 280 * proxy = a proxy GObject 281 * model = a GtkTreeModel 282 * path = a valid GtkTreePath to monitor 283 * Throws: ConstructionException GTK+ fails to create the object. 284 */ 285 public this (ObjectG proxy, TreeModelIF model, TreePath path) 286 { 287 // GtkTreeRowReference * gtk_tree_row_reference_new_proxy (GObject *proxy, GtkTreeModel *model, GtkTreePath *path); 288 auto p = gtk_tree_row_reference_new_proxy((proxy is null) ? null : proxy.getObjectGStruct(), (model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct()); 289 if(p is null) 290 { 291 throw new ConstructionException("null returned by gtk_tree_row_reference_new_proxy((proxy is null) ? null : proxy.getObjectGStruct(), (model is null) ? null : model.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct())"); 292 } 293 this(cast(GtkTreeRowReference*) p); 294 } 295 296 /** 297 * Returns the model that the row reference is monitoring. 298 * Since 2.8 299 * Returns: the model. [transfer none] 300 */ 301 public TreeModelIF getModel() 302 { 303 // GtkTreeModel * gtk_tree_row_reference_get_model (GtkTreeRowReference *reference); 304 auto p = gtk_tree_row_reference_get_model(gtkTreeRowReference); 305 306 if(p is null) 307 { 308 return null; 309 } 310 311 return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p); 312 } 313 314 /** 315 * Returns a path that the row reference currently points to, 316 * or NULL if the path pointed to is no longer valid. 317 * Returns: a current path, or NULL 318 */ 319 public TreePath getPath() 320 { 321 // GtkTreePath * gtk_tree_row_reference_get_path (GtkTreeRowReference *reference); 322 auto p = gtk_tree_row_reference_get_path(gtkTreeRowReference); 323 324 if(p is null) 325 { 326 return null; 327 } 328 329 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p); 330 } 331 332 /** 333 * Returns TRUE if the reference is non-NULL and refers to 334 * a current valid path. 335 * Returns: TRUE if reference points to a valid path 336 */ 337 public int valid() 338 { 339 // gboolean gtk_tree_row_reference_valid (GtkTreeRowReference *reference); 340 return gtk_tree_row_reference_valid(gtkTreeRowReference); 341 } 342 343 /** 344 * Free's reference. reference may be NULL 345 */ 346 public void free() 347 { 348 // void gtk_tree_row_reference_free (GtkTreeRowReference *reference); 349 gtk_tree_row_reference_free(gtkTreeRowReference); 350 } 351 352 /** 353 * Copies a GtkTreeRowReference. 354 * Since 2.2 355 * Returns: a copy of reference 356 */ 357 public TreeRowReference copy() 358 { 359 // GtkTreeRowReference * gtk_tree_row_reference_copy (GtkTreeRowReference *reference); 360 auto p = gtk_tree_row_reference_copy(gtkTreeRowReference); 361 362 if(p is null) 363 { 364 return null; 365 } 366 367 return ObjectG.getDObject!(TreeRowReference)(cast(GtkTreeRowReference*) p); 368 } 369 370 /** 371 * Lets a set of row reference created by 372 * gtk_tree_row_reference_new_proxy() know that the 373 * model emitted the "row-inserted" signal. 374 * Params: 375 * proxy = a GObject 376 * path = the row position that was inserted 377 */ 378 public static void inserted(ObjectG proxy, TreePath path) 379 { 380 // void gtk_tree_row_reference_inserted (GObject *proxy, GtkTreePath *path); 381 gtk_tree_row_reference_inserted((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct()); 382 } 383 384 /** 385 * Lets a set of row reference created by 386 * gtk_tree_row_reference_new_proxy() know that the 387 * model emitted the "row-deleted" signal. 388 * Params: 389 * proxy = a GObject 390 * path = the path position that was deleted 391 */ 392 public static void deleted(ObjectG proxy, TreePath path) 393 { 394 // void gtk_tree_row_reference_deleted (GObject *proxy, GtkTreePath *path); 395 gtk_tree_row_reference_deleted((proxy is null) ? null : proxy.getObjectGStruct(), (path is null) ? null : path.getTreePathStruct()); 396 } 397 398 /** 399 * Lets a set of row reference created by 400 * gtk_tree_row_reference_new_proxy() know that the 401 * model emitted the "rows-reordered" signal. 402 * Params: 403 * proxy = a GObject 404 * path = the parent path of the reordered signal 405 * iter = the iter pointing to the parent of the reordered 406 * newOrder = the new order of rows 407 */ 408 public static void reordered(ObjectG proxy, TreePath path, TreeIter iter, int[] newOrder) 409 { 410 // void gtk_tree_row_reference_reordered (GObject *proxy, GtkTreePath *path, GtkTreeIter *iter, gint *new_order); 411 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); 412 } 413 }