/usr/include/d/gtkd-3/glib/Node.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module glib.Node;
private import glib.ConstructionException;
private import glib.c.functions;
public import glib.c.types;
public import gtkc.glibtypes;
private import gtkd.Loader;
/**
* The #GNode struct represents one node in a [n-ary tree][glib-N-ary-Trees].
*/
public final class Node
{
/** the main Gtk struct */
protected GNode* gNode;
protected bool ownedRef;
/** Get the main Gtk struct */
public GNode* getNodeStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gNode;
}
/** the main Gtk struct as a void* */
protected void* getStruct()
{
return cast(void*)gNode;
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GNode* gNode, bool ownedRef = false)
{
this.gNode = gNode;
this.ownedRef = ownedRef;
}
~this ()
{
if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef )
g_free(gNode);
}
/**
* contains the actual data of the node.
*/
public @property void* data()
{
return gNode.data;
}
/** Ditto */
public @property void data(void* value)
{
gNode.data = value;
}
/**
* points to the node's next sibling (a sibling is another
* #GNode with the same parent).
*/
public @property Node next()
{
return new Node(gNode.next, false);
}
/** Ditto */
public @property void next(Node value)
{
gNode.next = value.getNodeStruct();
}
/**
* points to the node's previous sibling.
*/
public @property Node prev()
{
return new Node(gNode.prev, false);
}
/** Ditto */
public @property void prev(Node value)
{
gNode.prev = value.getNodeStruct();
}
/**
* points to the parent of the #GNode, or is %NULL if the
* #GNode is the root of the tree.
*/
public @property Node parent()
{
return new Node(gNode.parent, false);
}
/** Ditto */
public @property void parent(Node value)
{
gNode.parent = value.getNodeStruct();
}
/**
* points to the first child of the #GNode. The other
* children are accessed by using the @next pointer of each
* child.
*/
public @property Node children()
{
return new Node(gNode.children, false);
}
/** Ditto */
public @property void children(Node value)
{
gNode.children = value.getNodeStruct();
}
/**
* Gets the position of the first child of a #GNode
* which contains the given data.
*
* Params:
* data = the data to find
*
* Returns: the index of the child of @node which contains
* @data, or -1 if the data is not found
*/
public int childIndex(void* data)
{
return g_node_child_index(gNode, data);
}
/**
* Gets the position of a #GNode with respect to its siblings.
* @child must be a child of @node. The first child is numbered 0,
* the second 1, and so on.
*
* Params:
* child = a child of @node
*
* Returns: the position of @child with respect to its siblings
*/
public int childPosition(Node child)
{
return g_node_child_position(gNode, (child is null) ? null : child.getNodeStruct());
}
/**
* Calls a function for each of the children of a #GNode.
* Note that it doesn't descend beneath the child nodes.
*
* Params:
* flags = which types of children are to be visited, one of
* %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
* func = the function to call for each visited node
* data = user data to pass to the function
*/
public void childrenForeach(GTraverseFlags flags, GNodeForeachFunc func, void* data)
{
g_node_children_foreach(gNode, flags, func, data);
}
/**
* Recursively copies a #GNode (but does not deep-copy the data inside the
* nodes, see g_node_copy_deep() if you need that).
*
* Returns: a new #GNode containing the same data pointers
*/
public Node copy()
{
auto p = g_node_copy(gNode);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Recursively copies a #GNode and its data.
*
* Params:
* copyFunc = the function which is called to copy the data inside each node,
* or %NULL to use the original data.
* data = data to pass to @copy_func
*
* Returns: a new #GNode containing copies of the data in @node.
*
* Since: 2.4
*/
public Node copyDeep(GCopyFunc copyFunc, void* data)
{
auto p = g_node_copy_deep(gNode, copyFunc, data);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Gets the depth of a #GNode.
*
* If @node is %NULL the depth is 0. The root node has a depth of 1.
* For the children of the root node the depth is 2. And so on.
*
* Returns: the depth of the #GNode
*/
public uint depth()
{
return g_node_depth(gNode);
}
/**
* Removes @root and its children from the tree, freeing any memory
* allocated.
*/
public void destroy()
{
g_node_destroy(gNode);
}
/**
* Finds a #GNode in a tree.
*
* Params:
* order = the order in which nodes are visited - %G_IN_ORDER,
* %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
* flags = which types of children are to be searched, one of
* %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
* data = the data to find
*
* Returns: the found #GNode, or %NULL if the data is not found
*/
public Node find(GTraverseType order, GTraverseFlags flags, void* data)
{
auto p = g_node_find(gNode, order, flags, data);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Finds the first child of a #GNode with the given data.
*
* Params:
* flags = which types of children are to be searched, one of
* %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
* data = the data to find
*
* Returns: the found child #GNode, or %NULL if the data is not found
*/
public Node findChild(GTraverseFlags flags, void* data)
{
auto p = g_node_find_child(gNode, flags, data);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Gets the first sibling of a #GNode.
* This could possibly be the node itself.
*
* Returns: the first sibling of @node
*/
public Node firstSibling()
{
auto p = g_node_first_sibling(gNode);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Gets the root of a tree.
*
* Returns: the root of the tree
*/
public Node getRoot()
{
auto p = g_node_get_root(gNode);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Inserts a #GNode beneath the parent at the given position.
*
* Params:
* position = the position to place @node at, with respect to its siblings
* If position is -1, @node is inserted as the last child of @parent
* node = the #GNode to insert
*
* Returns: the inserted #GNode
*/
public Node insert(int position, Node node)
{
auto p = g_node_insert(gNode, position, (node is null) ? null : node.getNodeStruct());
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Inserts a #GNode beneath the parent after the given sibling.
*
* Params:
* sibling = the sibling #GNode to place @node after.
* If sibling is %NULL, the node is inserted as the first child of @parent.
* node = the #GNode to insert
*
* Returns: the inserted #GNode
*/
public Node insertAfter(Node sibling, Node node)
{
auto p = g_node_insert_after(gNode, (sibling is null) ? null : sibling.getNodeStruct(), (node is null) ? null : node.getNodeStruct());
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Inserts a #GNode beneath the parent before the given sibling.
*
* Params:
* sibling = the sibling #GNode to place @node before.
* If sibling is %NULL, the node is inserted as the last child of @parent.
* node = the #GNode to insert
*
* Returns: the inserted #GNode
*/
public Node insertBefore(Node sibling, Node node)
{
auto p = g_node_insert_before(gNode, (sibling is null) ? null : sibling.getNodeStruct(), (node is null) ? null : node.getNodeStruct());
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Returns %TRUE if @node is an ancestor of @descendant.
* This is true if node is the parent of @descendant,
* or if node is the grandparent of @descendant etc.
*
* Params:
* descendant = a #GNode
*
* Returns: %TRUE if @node is an ancestor of @descendant
*/
public bool isAncestor(Node descendant)
{
return g_node_is_ancestor(gNode, (descendant is null) ? null : descendant.getNodeStruct()) != 0;
}
/**
* Gets the last child of a #GNode.
*
* Returns: the last child of @node, or %NULL if @node has no children
*/
public Node lastChild()
{
auto p = g_node_last_child(gNode);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Gets the last sibling of a #GNode.
* This could possibly be the node itself.
*
* Returns: the last sibling of @node
*/
public Node lastSibling()
{
auto p = g_node_last_sibling(gNode);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Gets the maximum height of all branches beneath a #GNode.
* This is the maximum distance from the #GNode to all leaf nodes.
*
* If @root is %NULL, 0 is returned. If @root has no children,
* 1 is returned. If @root has children, 2 is returned. And so on.
*
* Returns: the maximum height of the tree beneath @root
*/
public uint maxHeight()
{
return g_node_max_height(gNode);
}
/**
* Gets the number of children of a #GNode.
*
* Returns: the number of children of @node
*/
public uint nChildren()
{
return g_node_n_children(gNode);
}
/**
* Gets the number of nodes in a tree.
*
* Params:
* flags = which types of children are to be counted, one of
* %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
*
* Returns: the number of nodes in the tree
*/
public uint nNodes(GTraverseFlags flags)
{
return g_node_n_nodes(gNode, flags);
}
/**
* Gets a child of a #GNode, using the given index.
* The first child is at index 0. If the index is
* too big, %NULL is returned.
*
* Params:
* n = the index of the desired child
*
* Returns: the child of @node at index @n
*/
public Node nthChild(uint n)
{
auto p = g_node_nth_child(gNode, n);
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Inserts a #GNode as the first child of the given parent.
*
* Params:
* node = the #GNode to insert
*
* Returns: the inserted #GNode
*/
public Node prepend(Node node)
{
auto p = g_node_prepend(gNode, (node is null) ? null : node.getNodeStruct());
if(p is null)
{
return null;
}
return new Node(cast(GNode*) p);
}
/**
* Reverses the order of the children of a #GNode.
* (It doesn't change the order of the grandchildren.)
*/
public void reverseChildren()
{
g_node_reverse_children(gNode);
}
/**
* Traverses a tree starting at the given root #GNode.
* It calls the given function for each node visited.
* The traversal can be halted at any point by returning %TRUE from @func.
*
* Params:
* order = the order in which nodes are visited - %G_IN_ORDER,
* %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
* flags = which types of children are to be visited, one of
* %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
* maxDepth = the maximum depth of the traversal. Nodes below this
* depth will not be visited. If max_depth is -1 all nodes in
* the tree are visited. If depth is 1, only the root is visited.
* If depth is 2, the root and its children are visited. And so on.
* func = the function to call for each visited #GNode
* data = user data to pass to the function
*/
public void traverse(GTraverseType order, GTraverseFlags flags, int maxDepth, GNodeTraverseFunc func, void* data)
{
g_node_traverse(gNode, order, flags, maxDepth, func, data);
}
/**
* Unlinks a #GNode from a tree, resulting in two separate trees.
*/
public void unlink()
{
g_node_unlink(gNode);
}
/**
* Creates a new #GNode containing the given data.
* Used to create the first node in a tree.
*
* Params:
* data = the data of the new node
*
* Returns: a new #GNode
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(void* data)
{
auto p = g_node_new(data);
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GNode*) p);
}
}
|