Node

The glib.Node struct represents one node in a [n-ary tree][glib-N-ary-Trees].

Constructors

this
this(GNode* gNode, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(void* data)

Creates a new glib.Node containing the given data. Used to create the first node in a tree.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

childIndex
int childIndex(void* data)

Gets the position of the first child of a glib.Node which contains the given data.

childPosition
int childPosition(Node child)

Gets the position of a glib.Node with respect to its siblings. child must be a child of node. The first child is numbered 0, the second 1, and so on.

childrenForeach
void childrenForeach(GTraverseFlags flags, GNodeForeachFunc func, void* data)

Calls a function for each of the children of a glib.Node Note that it doesn't descend beneath the child nodes. func must not do anything that would modify the structure of the tree.

copy
Node copy()

Recursively copies a glib.Node (but does not deep-copy the data inside the nodes, see Node.copyDeep if you need that).

copyDeep
Node copyDeep(GCopyFunc copyFunc, void* data)

Recursively copies a glib.Node and its data.

depth
uint depth()

Gets the depth of a glib.Node

destroy
void destroy()

Removes root and its children from the tree, freeing any memory allocated.

find
Node find(GTraverseType order, GTraverseFlags flags, void* data)

Finds a glib.Node in a tree.

findChild
Node findChild(GTraverseFlags flags, void* data)

Finds the first child of a glib.Node with the given data.

firstSibling
Node firstSibling()

Gets the first sibling of a glib.Node This could possibly be the node itself.

getNodeStruct
GNode* getNodeStruct(bool transferOwnership)

Get the main Gtk struct

getRoot
Node getRoot()

Gets the root of a tree.

getStruct
void* getStruct()

the main Gtk struct as a void*

insert
Node insert(int position, Node node)

Inserts a glib.Node beneath the parent at the given position.

insertAfter
Node insertAfter(Node sibling, Node node)

Inserts a glib.Node beneath the parent after the given sibling.

insertBefore
Node insertBefore(Node sibling, Node node)

Inserts a glib.Node beneath the parent before the given sibling.

isAncestor
bool isAncestor(Node descendant)

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.

lastChild
Node lastChild()

Gets the last child of a glib.Node

lastSibling
Node lastSibling()

Gets the last sibling of a glib.Node This could possibly be the node itself.

maxHeight
uint maxHeight()

Gets the maximum height of all branches beneath a glib.Node This is the maximum distance from the glib.Node to all leaf nodes.

nChildren
uint nChildren()

Gets the number of children of a glib.Node

nNodes
uint nNodes(GTraverseFlags flags)

Gets the number of nodes in a tree.

nthChild
Node nthChild(uint n)

Gets a child of a glib.Node, using the given index. The first child is at index 0. If the index is too big, NULL is returned.

prepend
Node prepend(Node node)

Inserts a glib.Node as the first child of the given parent.

reverseChildren
void reverseChildren()

Reverses the order of the children of a glib.Node (It doesn't change the order of the grandchildren.)

traverse
void traverse(GTraverseType order, GTraverseFlags flags, int maxDepth, GNodeTraverseFunc func, void* data)

Traverses a tree starting at the given root glib.Node It calls the given function for each node visited. The traversal can be halted at any point by returning TRUE from func. func must not do anything that would modify the structure of the tree.

unlink
void unlink()

Unlinks a glib.Node from a tree, resulting in two separate trees.

Properties

children
Node children [@property getter]
Node children [@property setter]

points to the first child of the glib.Node The other children are accessed by using the next pointer of each child.

data
void* data [@property getter]
void* data [@property setter]

contains the actual data of the node.

next
Node next [@property getter]
Node next [@property setter]

points to the node's next sibling (a sibling is another glib.Node with the same parent).

parent
Node parent [@property getter]
Node parent [@property setter]

points to the parent of the glib.Node, or is NULL if the glib.Node is the root of the tree.

prev
Node prev [@property getter]
Node prev [@property setter]

points to the node's previous sibling.

Variables

gNode
GNode* gNode;

the main Gtk struct