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 = TreeModelT 29 * strct = GtkTreeModel 30 * realStrct= 31 * ctorStrct= 32 * clss = TreeModelT 33 * interf = TreeModelIF 34 * class Code: Yes 35 * interface Code: Yes 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - gtk_tree_model_ 42 * omit structs: 43 * omit prefixes: 44 * - gtk_tree_row_reference_ 45 * - gtk_tree_path_ 46 * - gtk_tree_iter_ 47 * omit code: 48 * - gtk_tree_model_get_value 49 * - gtk_tree_model_get_iter 50 * omit signals: 51 * imports: 52 * - glib.Str 53 * - gtk.TreeIter 54 * - gtk.TreePath 55 * - gobject.Value 56 * structWrap: 57 * - GValue* -> Value 58 * - GtkTreeIter* -> TreeIter 59 * - GtkTreePath* -> TreePath 60 * module aliases: 61 * local aliases: 62 * overrides: 63 */ 64 65 module gtk.TreeModelT; 66 67 public import gtkc.gtktypes; 68 69 public import gtkc.gtk; 70 public import glib.ConstructionException; 71 public import gobject.ObjectG; 72 73 public import gobject.Signals; 74 public import gtkc.gdktypes; 75 76 public import glib.Str; 77 public import gtk.TreeIter; 78 public import gtk.TreePath; 79 public import gobject.Value; 80 81 82 83 84 /** 85 * Description 86 * The GtkTreeModel interface defines a generic tree interface for use by 87 * the GtkTreeView widget. It is an abstract interface, and is designed 88 * to be usable with any appropriate data structure. The programmer just 89 * has to implement this interface on their own data type for it to be 90 * viewable by a GtkTreeView widget. 91 * The model is represented as a hierarchical tree of strongly-typed, 92 * columned data. In other words, the model can be seen as a tree where 93 * every node has different values depending on which column is being 94 * queried. The type of data found in a column is determined by using the 95 * GType system (ie. G_TYPE_INT, GTK_TYPE_BUTTON, G_TYPE_POINTER, etc.). 96 * The types are homogeneous per column across all nodes. It is important 97 * to note that this interface only provides a way of examining a model and 98 * observing changes. The implementation of each individual model decides 99 * how and if changes are made. 100 * In order to make life simpler for programmers who do not need to write 101 * their own specialized model, two generic models are provided — the 102 * GtkTreeStore and the GtkListStore. To use these, the developer simply 103 * pushes data into these models as necessary. These models provide the 104 * data structure as well as all appropriate tree interfaces. As a result, 105 * implementing drag and drop, sorting, and storing data is trivial. For 106 * the vast majority of trees and lists, these two models are sufficient. 107 * Models are accessed on a node/column level of granularity. One can 108 * query for the value of a model at a certain node and a certain column 109 * on that node. There are two structures used to reference a particular 110 * node in a model. They are the GtkTreePath and the GtkTreeIter 111 * [4] 112 * Most of the interface consists of operations on a GtkTreeIter. 113 * A path is essentially a potential node. It is a location on a model 114 * that may or may not actually correspond to a node on a specific model. 115 * The GtkTreePath struct can be converted into either an array of 116 * unsigned integers or a string. The string form is a list of numbers 117 * separated by a colon. Each number refers to the offset at that level. 118 * Thus, the path “0” refers to the root node and the path 119 * “2:4” refers to the fifth child of the third node. 120 * By contrast, a GtkTreeIter is a reference to a specific node on a 121 * specific model. It is a generic struct with an integer and three 122 * generic pointers. These are filled in by the model in a model-specific 123 * way. One can convert a path to an iterator by calling 124 * gtk_tree_model_get_iter(). These iterators are the primary way of 125 * accessing a model and are similar to the iterators used by 126 * GtkTextBuffer. They are generally statically allocated on the stack and 127 * only used for a short time. The model interface defines a set of 128 * operations using them for navigating the model. 129 * It is expected that models fill in the iterator with private data. For 130 * example, the GtkListStore model, which is internally a simple linked 131 * list, stores a list node in one of the pointers. The GtkTreeModelSort 132 * stores an array and an offset in two of the pointers. Additionally, 133 * there is an integer field. This field is generally filled with a unique 134 * stamp per model. This stamp is for catching errors resulting from using 135 * invalid iterators with a model. 136 * The lifecycle of an iterator can be a little confusing at first. 137 * Iterators are expected to always be valid for as long as the model is 138 * unchanged (and doesn't emit a signal). The model is considered to own 139 * all outstanding iterators and nothing needs to be done to free them from 140 * the user's point of view. Additionally, some models guarantee that an 141 * iterator is valid for as long as the node it refers to is valid (most 142 * notably the GtkTreeStore and GtkListStore). Although generally 143 * uninteresting, as one always has to allow for the case where iterators 144 * do not persist beyond a signal, some very important performance 145 * enhancements were made in the sort model. As a result, the 146 * GTK_TREE_MODEL_ITERS_PERSIST flag was added to indicate this behavior. 147 * To help show some common operation of a model, some examples are 148 * provided. The first example shows three ways of getting the iter at the 149 * location “3:2:5”. While the first method shown is easier, 150 * the second is much more common, as you often get paths from callbacks. 151 * $(DDOC_COMMENT example) 152 * This second example shows a quick way of iterating through a list and 153 * getting a string and an integer from each row. The 154 * populate_model function used below is not shown, as 155 * it is specific to the GtkListStore. For information on how to write 156 * such a function, see the GtkListStore documentation. 157 * $(DDOC_COMMENT example) 158 */ 159 public template TreeModelT(TStruct) 160 { 161 162 /** the main Gtk struct */ 163 protected GtkTreeModel* gtkTreeModel; 164 165 166 public GtkTreeModel* getTreeModelTStruct() 167 { 168 return cast(GtkTreeModel*)getStruct(); 169 } 170 171 172 /** 173 * Get the value of a column as a char array. 174 * this is the same calling getValue and get the string from the value object 175 */ 176 string getValueString(TreeIter iter, int column) 177 { 178 Value value = new Value(); 179 getValue(iter, column, value); 180 return value.getString(); 181 } 182 183 /** 184 * Get the value of a column as a char array. 185 * this is the same calling getValue and get the int from the value object 186 */ 187 int getValueInt(TreeIter iter, int column) 188 { 189 Value value = new Value(); 190 getValue(iter, column, value); 191 return value.getInt(); 192 } 193 194 /** 195 * Sets iter to a valid iterator pointing to path. 196 * Params: 197 * iter = The uninitialized GtkTreeIter. 198 * path = The GtkTreePath. 199 * Returns: 200 * TRUE, if iter was set. 201 */ 202 public int getIter(TreeIter iter, TreePath path) 203 { 204 // gboolean gtk_tree_model_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path); 205 iter.setModel(this); 206 return gtk_tree_model_get_iter( 207 getTreeModelTStruct(), 208 (iter is null) ? null : iter.getTreeIterStruct(), 209 (path is null) ? null : path.getTreePathStruct()); 210 } 211 212 /** 213 * Initializes and sets value to that at column. 214 * When done with value, g_value_unset() needs to be called 215 * to free any allocated memory. 216 * Params: 217 * iter = The GtkTreeIter. 218 * column = The column to lookup the value at. 219 * value = (inout) (transfer none) An empty GValue to set. 220 */ 221 public Value getValue(TreeIter iter, int column, Value value = null) 222 { 223 if ( value is null ) 224 value = new Value(); 225 226 // void gtk_tree_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value); 227 gtk_tree_model_get_value(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct(), column, (value is null) ? null : value.getValueStruct()); 228 229 return value; 230 } 231 232 /** 233 */ 234 int[string] connectedSignals; 235 236 void delegate(TreePath, TreeIter, TreeModelIF)[] _onRowChangedListeners; 237 void delegate(TreePath, TreeIter, TreeModelIF)[] onRowChangedListeners() 238 { 239 return _onRowChangedListeners; 240 } 241 /** 242 * This signal is emitted when a row in the model has changed. 243 */ 244 void addOnRowChanged(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 245 { 246 if ( !("row-changed" in connectedSignals) ) 247 { 248 Signals.connectData( 249 getStruct(), 250 "row-changed", 251 cast(GCallback)&callBackRowChanged, 252 cast(void*)cast(TreeModelIF)this, 253 null, 254 connectFlags); 255 connectedSignals["row-changed"] = 1; 256 } 257 _onRowChangedListeners ~= dlg; 258 } 259 extern(C) static void callBackRowChanged(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, TreeModelIF _treeModelIF) 260 { 261 foreach ( void delegate(TreePath, TreeIter, TreeModelIF) dlg ; _treeModelIF.onRowChangedListeners ) 262 { 263 dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), _treeModelIF); 264 } 265 } 266 267 void delegate(TreePath, TreeModelIF)[] _onRowDeletedListeners; 268 void delegate(TreePath, TreeModelIF)[] onRowDeletedListeners() 269 { 270 return _onRowDeletedListeners; 271 } 272 /** 273 * This signal is emitted when a row has been deleted. 274 * Note that no iterator is passed to the signal handler, 275 * since the row is already deleted. 276 * This should be called by models after a row has been removed. 277 * The location pointed to by path should be the location that 278 * the row previously was at. It may not be a valid location anymore. 279 */ 280 void addOnRowDeleted(void delegate(TreePath, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 281 { 282 if ( !("row-deleted" in connectedSignals) ) 283 { 284 Signals.connectData( 285 getStruct(), 286 "row-deleted", 287 cast(GCallback)&callBackRowDeleted, 288 cast(void*)cast(TreeModelIF)this, 289 null, 290 connectFlags); 291 connectedSignals["row-deleted"] = 1; 292 } 293 _onRowDeletedListeners ~= dlg; 294 } 295 extern(C) static void callBackRowDeleted(GtkTreeModel* treeModelStruct, GtkTreePath* path, TreeModelIF _treeModelIF) 296 { 297 foreach ( void delegate(TreePath, TreeModelIF) dlg ; _treeModelIF.onRowDeletedListeners ) 298 { 299 dlg(ObjectG.getDObject!(TreePath)(path), _treeModelIF); 300 } 301 } 302 303 void delegate(TreePath, TreeIter, TreeModelIF)[] _onRowHasChildToggledListeners; 304 void delegate(TreePath, TreeIter, TreeModelIF)[] onRowHasChildToggledListeners() 305 { 306 return _onRowHasChildToggledListeners; 307 } 308 /** 309 * This signal is emitted when a row has gotten the first child row or lost 310 * its last child row. 311 */ 312 void addOnRowHasChildToggled(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 313 { 314 if ( !("row-has-child-toggled" in connectedSignals) ) 315 { 316 Signals.connectData( 317 getStruct(), 318 "row-has-child-toggled", 319 cast(GCallback)&callBackRowHasChildToggled, 320 cast(void*)cast(TreeModelIF)this, 321 null, 322 connectFlags); 323 connectedSignals["row-has-child-toggled"] = 1; 324 } 325 _onRowHasChildToggledListeners ~= dlg; 326 } 327 extern(C) static void callBackRowHasChildToggled(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, TreeModelIF _treeModelIF) 328 { 329 foreach ( void delegate(TreePath, TreeIter, TreeModelIF) dlg ; _treeModelIF.onRowHasChildToggledListeners ) 330 { 331 dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), _treeModelIF); 332 } 333 } 334 335 void delegate(TreePath, TreeIter, TreeModelIF)[] _onRowInsertedListeners; 336 void delegate(TreePath, TreeIter, TreeModelIF)[] onRowInsertedListeners() 337 { 338 return _onRowInsertedListeners; 339 } 340 /** 341 * This signal is emitted when a new row has been inserted in the model. 342 * Note that the row may still be empty at this point, since 343 * it is a common pattern to first insert an empty row, and 344 * then fill it with the desired values. 345 */ 346 void addOnRowInserted(void delegate(TreePath, TreeIter, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 347 { 348 if ( !("row-inserted" in connectedSignals) ) 349 { 350 Signals.connectData( 351 getStruct(), 352 "row-inserted", 353 cast(GCallback)&callBackRowInserted, 354 cast(void*)cast(TreeModelIF)this, 355 null, 356 connectFlags); 357 connectedSignals["row-inserted"] = 1; 358 } 359 _onRowInsertedListeners ~= dlg; 360 } 361 extern(C) static void callBackRowInserted(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, TreeModelIF _treeModelIF) 362 { 363 foreach ( void delegate(TreePath, TreeIter, TreeModelIF) dlg ; _treeModelIF.onRowInsertedListeners ) 364 { 365 dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), _treeModelIF); 366 } 367 } 368 369 void delegate(TreePath, TreeIter, void*, TreeModelIF)[] _onRowsReorderedListeners; 370 void delegate(TreePath, TreeIter, void*, TreeModelIF)[] onRowsReorderedListeners() 371 { 372 return _onRowsReorderedListeners; 373 } 374 /** 375 * This signal is emitted when the children of a node in the GtkTreeModel 376 * have been reordered. 377 * Note that this signal is not emitted 378 * when rows are reordered by DND, since this is implemented 379 * by removing and then reinserting the row. 380 * See Also 381 * GtkTreeView, GtkTreeStore, GtkListStore, GtkTreeDnd, GtkTreeSortable 382 * [4] 383 * Here, iter is short for “iterator” 384 */ 385 void addOnRowsReordered(void delegate(TreePath, TreeIter, void*, TreeModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 386 { 387 if ( !("rows-reordered" in connectedSignals) ) 388 { 389 Signals.connectData( 390 getStruct(), 391 "rows-reordered", 392 cast(GCallback)&callBackRowsReordered, 393 cast(void*)cast(TreeModelIF)this, 394 null, 395 connectFlags); 396 connectedSignals["rows-reordered"] = 1; 397 } 398 _onRowsReorderedListeners ~= dlg; 399 } 400 extern(C) static void callBackRowsReordered(GtkTreeModel* treeModelStruct, GtkTreePath* path, GtkTreeIter* iter, void* newOrder, TreeModelIF _treeModelIF) 401 { 402 foreach ( void delegate(TreePath, TreeIter, void*, TreeModelIF) dlg ; _treeModelIF.onRowsReorderedListeners ) 403 { 404 dlg(ObjectG.getDObject!(TreePath)(path), ObjectG.getDObject!(TreeIter)(iter), newOrder, _treeModelIF); 405 } 406 } 407 408 409 /** 410 * Returns a set of flags supported by this interface. The flags are a bitwise 411 * combination of GtkTreeModelFlags. The flags supported should not change 412 * during the lifecycle of the tree_model. 413 * Returns: The flags supported by this interface. 414 */ 415 public GtkTreeModelFlags getFlags() 416 { 417 // GtkTreeModelFlags gtk_tree_model_get_flags (GtkTreeModel *tree_model); 418 return gtk_tree_model_get_flags(getTreeModelTStruct()); 419 } 420 421 /** 422 * Returns the number of columns supported by tree_model. 423 * Returns: The number of columns. 424 */ 425 public int getNColumns() 426 { 427 // gint gtk_tree_model_get_n_columns (GtkTreeModel *tree_model); 428 return gtk_tree_model_get_n_columns(getTreeModelTStruct()); 429 } 430 431 /** 432 * Returns the type of the column. 433 * Params: 434 * index = The column index. 435 * Returns: The type of the column. [transfer none] 436 */ 437 public GType getColumnType(int index) 438 { 439 // GType gtk_tree_model_get_column_type (GtkTreeModel *tree_model, gint index_); 440 return gtk_tree_model_get_column_type(getTreeModelTStruct(), index); 441 } 442 443 /** 444 * Sets iter to a valid iterator pointing to path_string, if it 445 * exists. Otherwise, iter is left invalid and FALSE is returned. 446 * Params: 447 * iter = An uninitialized GtkTreeIter. [out] 448 * pathString = A string representation of a GtkTreePath. 449 * Returns: TRUE, if iter was set. 450 */ 451 public int getIterFromString(TreeIter iter, string pathString) 452 { 453 // gboolean gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model, GtkTreeIter *iter, const gchar *path_string); 454 return gtk_tree_model_get_iter_from_string(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct(), Str.toStringz(pathString)); 455 } 456 457 /** 458 * Initializes iter with the first iterator in the tree (the one at the path 459 * "0") and returns TRUE. Returns FALSE if the tree is empty. 460 * Params: 461 * iter = The uninitialized GtkTreeIter. [out] 462 * Returns: TRUE, if iter was set. 463 */ 464 public int getIterFirst(TreeIter iter) 465 { 466 // gboolean gtk_tree_model_get_iter_first (GtkTreeModel *tree_model, GtkTreeIter *iter); 467 return gtk_tree_model_get_iter_first(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 468 } 469 470 /** 471 * Returns a newly-created GtkTreePath referenced by iter. This path should 472 * be freed with gtk_tree_path_free(). 473 * Params: 474 * iter = The GtkTreeIter. 475 * Returns: a newly-created GtkTreePath. 476 */ 477 public TreePath getPath(TreeIter iter) 478 { 479 // GtkTreePath * gtk_tree_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter); 480 auto p = gtk_tree_model_get_path(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 481 482 if(p is null) 483 { 484 return null; 485 } 486 487 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p); 488 } 489 490 /** 491 * Sets iter to point to the node following it at the current level. If there 492 * is no next iter, FALSE is returned and iter is set to be invalid. 493 * Params: 494 * iter = The GtkTreeIter. [in] 495 * Returns: TRUE if iter has been changed to the next node. 496 */ 497 public int iterNext(TreeIter iter) 498 { 499 // gboolean gtk_tree_model_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter); 500 return gtk_tree_model_iter_next(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 501 } 502 503 /** 504 * Sets iter to point to the first child of parent. If parent has no 505 * children, FALSE is returned and iter is set to be invalid. parent 506 * will remain a valid node after this function has been called. 507 * If parent is NULL returns the first node, equivalent to 508 * gtk_tree_model_get_iter_first (tree_model, iter); 509 * Params: 510 * iter = The new GtkTreeIter to be set to the child. [out] 511 * parent = The GtkTreeIter, or NULL. [allow-none] 512 * Returns: TRUE, if child has been set to the first child. 513 */ 514 public int iterChildren(TreeIter iter, TreeIter parent) 515 { 516 // gboolean gtk_tree_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent); 517 return gtk_tree_model_iter_children(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct(), (parent is null) ? null : parent.getTreeIterStruct()); 518 } 519 520 /** 521 * Returns TRUE if iter has children, FALSE otherwise. 522 * Params: 523 * iter = The GtkTreeIter to test for children. 524 * Returns: TRUE if iter has children. 525 */ 526 public int iterHasChild(TreeIter iter) 527 { 528 // gboolean gtk_tree_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter); 529 return gtk_tree_model_iter_has_child(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 530 } 531 532 /** 533 * Returns the number of children that iter has. As a special case, if iter 534 * is NULL, then the number of toplevel nodes is returned. 535 * Params: 536 * iter = The GtkTreeIter, or NULL. [allow-none] 537 * Returns: The number of children of iter. 538 */ 539 public int iterNChildren(TreeIter iter) 540 { 541 // gint gtk_tree_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter); 542 return gtk_tree_model_iter_n_children(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 543 } 544 545 /** 546 * Sets iter to be the child of parent, using the given index. The first 547 * index is 0. If n is too big, or parent has no children, iter is set 548 * to an invalid iterator and FALSE is returned. parent will remain a valid 549 * node after this function has been called. As a special case, if parent is 550 * NULL, then the nth root node is set. 551 * Params: 552 * iter = The GtkTreeIter to set to the nth child. [out] 553 * parent = The GtkTreeIter to get the child from, or NULL. [allow-none] 554 * n = Then index of the desired child. 555 * Returns: TRUE, if parent has an nth child. 556 */ 557 public int iterNthChild(TreeIter iter, TreeIter parent, int n) 558 { 559 // gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n); 560 return gtk_tree_model_iter_nth_child(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct(), (parent is null) ? null : parent.getTreeIterStruct(), n); 561 } 562 563 /** 564 * Sets iter to be the parent of child. If child is at the toplevel, and 565 * doesn't have a parent, then iter is set to an invalid iterator and FALSE 566 * is returned. child will remain a valid node after this function has been 567 * called. 568 * Params: 569 * iter = The new GtkTreeIter to set to the parent. [out] 570 * child = The GtkTreeIter. 571 * Returns: TRUE, if iter is set to the parent of child. 572 */ 573 public int iterParent(TreeIter iter, TreeIter child) 574 { 575 // gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child); 576 return gtk_tree_model_iter_parent(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct(), (child is null) ? null : child.getTreeIterStruct()); 577 } 578 579 /** 580 * Generates a string representation of the iter. This string is a ':' 581 * separated list of numbers. For example, "4:10:0:3" would be an 582 * acceptable return value for this string. 583 * Since 2.2 584 * Params: 585 * iter = An GtkTreeIter. 586 * Returns: A newly-allocated string. Must be freed with g_free(). 587 */ 588 public string getStringFromIter(TreeIter iter) 589 { 590 // gchar * gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model, GtkTreeIter *iter); 591 return Str.toString(gtk_tree_model_get_string_from_iter(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct())); 592 } 593 594 /** 595 * Lets the tree ref the node. This is an optional method for models to 596 * implement. To be more specific, models may ignore this call as it exists 597 * primarily for performance reasons. 598 * This function is primarily meant as a way for views to let caching model 599 * know when nodes are being displayed (and hence, whether or not to cache that 600 * node.) For example, a file-system based model would not want to keep the 601 * entire file-hierarchy in memory, just the sections that are currently being 602 * displayed by every current view. 603 * A model should be expected to be able to get an iter independent of its 604 * reffed state. 605 * Params: 606 * iter = The GtkTreeIter. 607 */ 608 public void refNode(TreeIter iter) 609 { 610 // void gtk_tree_model_ref_node (GtkTreeModel *tree_model, GtkTreeIter *iter); 611 gtk_tree_model_ref_node(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 612 } 613 614 /** 615 * Lets the tree unref the node. This is an optional method for models to 616 * implement. To be more specific, models may ignore this call as it exists 617 * primarily for performance reasons. 618 * For more information on what this means, see gtk_tree_model_ref_node(). 619 * Please note that nodes that are deleted are not unreffed. 620 * Params: 621 * iter = The GtkTreeIter. 622 */ 623 public void unrefNode(TreeIter iter) 624 { 625 // void gtk_tree_model_unref_node (GtkTreeModel *tree_model, GtkTreeIter *iter); 626 gtk_tree_model_unref_node(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 627 } 628 629 /** 630 * See gtk_tree_model_get(), this version takes a va_list 631 * for language bindings to use. 632 * Params: 633 * iter = a row in tree_model 634 * varArgs = va_list of column/return location pairs 635 */ 636 public void getValist(TreeIter iter, void* varArgs) 637 { 638 // void gtk_tree_model_get_valist (GtkTreeModel *tree_model, GtkTreeIter *iter, va_list var_args); 639 gtk_tree_model_get_valist(getTreeModelTStruct(), (iter is null) ? null : iter.getTreeIterStruct(), varArgs); 640 } 641 642 /** 643 * Calls func on each node in model in a depth-first fashion. 644 * If func returns TRUE, then the tree ceases to be walked, and 645 * gtk_tree_model_foreach() returns. 646 * Params: 647 * func = A function to be called on each row. [scope call] 648 * userData = User data to passed to func. 649 */ 650 public void foreac(GtkTreeModelForeachFunc func, void* userData) 651 { 652 // void gtk_tree_model_foreach (GtkTreeModel *model, GtkTreeModelForeachFunc func, gpointer user_data); 653 gtk_tree_model_foreach(getTreeModelTStruct(), func, userData); 654 } 655 656 /** 657 * Emits the "row-changed" signal on tree_model. 658 * Params: 659 * path = A GtkTreePath pointing to the changed row 660 * iter = A valid GtkTreeIter pointing to the changed row 661 */ 662 public void rowChanged(TreePath path, TreeIter iter) 663 { 664 // void gtk_tree_model_row_changed (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter); 665 gtk_tree_model_row_changed(getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 666 } 667 668 /** 669 * Emits the "row-inserted" signal on tree_model 670 * Params: 671 * path = A GtkTreePath pointing to the inserted row 672 * iter = A valid GtkTreeIter pointing to the inserted row 673 */ 674 public void rowInserted(TreePath path, TreeIter iter) 675 { 676 // void gtk_tree_model_row_inserted (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter); 677 gtk_tree_model_row_inserted(getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 678 } 679 680 /** 681 * Emits the "row-has-child-toggled" signal on tree_model. This should be 682 * called by models after the child state of a node changes. 683 * Params: 684 * path = A GtkTreePath pointing to the changed row 685 * iter = A valid GtkTreeIter pointing to the changed row 686 */ 687 public void rowHasChildToggled(TreePath path, TreeIter iter) 688 { 689 // void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter); 690 gtk_tree_model_row_has_child_toggled(getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct()); 691 } 692 693 /** 694 * Emits the "row-deleted" signal on tree_model. This should be called by 695 * models after a row has been removed. The location pointed to by path 696 * should be the location that the row previously was at. It may not be a 697 * valid location anymore. 698 * Params: 699 * path = A GtkTreePath pointing to the previous location of the deleted row. 700 */ 701 public void rowDeleted(TreePath path) 702 { 703 // void gtk_tree_model_row_deleted (GtkTreeModel *tree_model, GtkTreePath *path); 704 gtk_tree_model_row_deleted(getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct()); 705 } 706 707 /** 708 * Emits the "rows-reordered" signal on tree_model. This should be called by 709 * models when their rows have been reordered. 710 * Params: 711 * path = A GtkTreePath pointing to the tree node whose children have been 712 * reordered 713 * iter = A valid GtkTreeIter pointing to the node whose children have been 714 * reordered, or NULL if the depth of path is 0. 715 * newOrder = an array of integers mapping the current position of each child 716 * to its old position before the re-ordering, 717 * i.e. new_order[newpos] = oldpos. 718 * Signal Details 719 * The "row-changed" signal 720 * void user_function (GtkTreeModel *tree_model, 721 * GtkTreePath *path, 722 * GtkTreeIter *iter, 723 * gpointer user_data) : Run Last 724 * This signal is emitted when a row in the model has changed. 725 * path = a GtkTreePath identifying the changed row 726 * iter = a valid GtkTreeIter pointing to the changed row 727 */ 728 public void rowsReordered(TreePath path, TreeIter iter, int[] newOrder) 729 { 730 // void gtk_tree_model_rows_reordered (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gint *new_order); 731 gtk_tree_model_rows_reordered(getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct(), (iter is null) ? null : iter.getTreeIterStruct(), newOrder.ptr); 732 } 733 }