Basics
Guides
API Reference
Basics
Guides
API Reference
[15:7] extends: object
The #GNode struct represents one node in a n-ary tree.
GNode (Handle = null)
Creates a new
Nodeby wrapping a native handle or another wrapper.
Handle is the native handle or another wrapper whose handle to adopt.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.child_index (data)
Gets the position of the first child of a #GNode which contains the given data.
data is the data to find.the index of the child of @node which contains @data, or -1 if the data is not found.child_position (object child)
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.
child is a child of @node.the position of @child with respect to its siblings.children_foreach (string flags, data)
Calls a function for each of the children of a #GNode. Note that it doesn't descend beneath the child nodes. @func must not do anything that would modify the structure of the tree.
flags is which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.func is the function to call for each visited node.data is user data to pass to the function.None.copy ()
Recursively copies a #GNode (but does not deep-copy the data inside the nodes, see g_node_copy_deep() if you need that).
a new #GNode containing the same data pointers.copy_deep (data)
Recursively copies a #GNode and its data.
copy_func is the function which is called to copy the data inside each node, or %NULL to use the original data..data is data to pass to @copy_func.a new #GNode containing copies of the data in @node..depth ()
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.
the depth of the #GNode.destroy ()
Removes @root and its children from the tree, freeing any memory allocated.
None.find (string order, string flags, data)
Finds a #GNode in a tree.
order is the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.flags is which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.data is the data to find.the found #GNode, or %NULL if the data is not found.find_child (string flags, data)
Finds the first child of a #GNode with the given data.
flags is which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.data is the data to find.the found child #GNode, or %NULL if the data is not found.first_sibling ()
Gets the first sibling of a #GNode. This could possibly be the node itself.
the first sibling of @node.get_root ()
Gets the root of a tree.
the root of the tree.insert (int position, object node)
Inserts a #GNode beneath the parent at the given position.
position is the position to place @node at, with respect to its siblings If position is -1, @node is inserted as the last child ofnode is the #GNode to insert.the inserted #GNode.insert_after (object sibling, object node)
Inserts a #GNode beneath the parent after the given sibling.
sibling is the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent..node is the #GNode to insert.the inserted #GNode.insert_before (object sibling, object node)
Inserts a #GNode beneath the parent before the given sibling.
sibling is the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent..node is the #GNode to insert.the inserted #GNode.is_ancestor (object 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
etc.descendant is a #GNode.%TRUE if @node is an ancestor of @descendant.last_child ()
Gets the last child of a #GNode.
the last child of @node, or %NULL if @node has no children.last_sibling ()
Gets the last sibling of a #GNode. This could possibly be the node itself.
the last sibling of @node.max_height ()
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.
the maximum height of the tree beneath @root.n_children ()
Gets the number of children of a #GNode.
the number of children of @node.n_nodes (string flags)
Gets the number of nodes in a tree.
flags is which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.the number of nodes in the tree.nth_child (int n)
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.
n is the index of the desired child.the child of @node at index @n.prepend (object node)
Inserts a #GNode as the first child of the given parent.
node is the #GNode to insert.the inserted #GNode.reverse_children ()
Reverses the order of the children of a #GNode. (It doesn't change the order of the grandchildren.)
None.traverse (string order, string flags, int max_depth, data)
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. @func must not do anything that would modify the structure of the tree.
order is the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER..flags is which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.max_depth is 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 is the function to call for each visited #GNode.data is user data to pass to the function.None.unlink ()
Unlinks a #GNode from a tree, resulting in two separate trees.
None.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.