Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GNode

[15:7] extends: object

The #GNode struct represents one node in a n-ary tree.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GNode (Handle = null)

    Creates a new Node by wrapping a native handle or another wrapper.

    • @p 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 exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • child_index (data)

    Gets the position of the first child of a #GNode which contains the given data.

    • @p data is the data to find.
    • @r 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.

    • @p child is a child of @node.
    • @r 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.

    • @p flags is which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.
    • @p func is the function to call for each visited node.
    • @p data is user data to pass to the function.
    • @r 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).

    • @r a new #GNode containing the same data pointers.
  • copy_deep (data)

    Recursively copies a #GNode and its data.

    • @p copy_func is the function which is called to copy the data inside each node, or %NULL to use the original data..
    • @p data is data to pass to @copy_func.
    • @r 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.

    • @r the depth of the #GNode.
  • destroy ()

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

    • @r None.
  • find (string order, string flags, data)

    Finds a #GNode in a tree.

    • @p order is the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
    • @p flags is which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.
    • @p data is the data to find.
    • @r 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.

    • @p flags is which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.
    • @p data is the data to find.
    • @r 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.

    • @r the first sibling of @node.
  • get_root ()

    Gets the root of a tree.

    • @r the root of the tree.
  • insert (int position, object node)

    Inserts a #GNode beneath the parent at the given position.

    • @p position is the position to place @node at, with respect to its siblings If position is -1, @node is inserted as the last child of
    • @parent. ``
    • @p node is the #GNode to insert.
    • @r the inserted #GNode.
  • insert_after (object sibling, object node)

    Inserts a #GNode beneath the parent after the given sibling.

    • @p sibling is the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent..
    • @p node is the #GNode to insert.
    • @r the inserted #GNode.
  • insert_before (object sibling, object node)

    Inserts a #GNode beneath the parent before the given sibling.

    • @p sibling is the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent..
    • @p node is the #GNode to insert.
    • @r 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

    • @descendant etc.
    • @p descendant is a #GNode.
    • @r %TRUE if @node is an ancestor of @descendant.
  • last_child ()

    Gets the last child of a #GNode.

    • @r 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.

    • @r 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.

    • @r the maximum height of the tree beneath @root.
  • n_children ()

    Gets the number of children of a #GNode.

    • @r the number of children of @node.
  • n_nodes (string flags)

    Gets the number of nodes in a tree.

    • @p flags is which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.
    • @r 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.

    • @p n is the index of the desired child.
    • @r the child of @node at index @n.
  • prepend (object node)

    Inserts a #GNode as the first child of the given parent.

    • @p node is the #GNode to insert.
    • @r the inserted #GNode.
  • reverse_children ()

    Reverses the order of the children of a #GNode. (It doesn't change the order of the grandchildren.)

    • @r 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.

    • @p order is the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER..
    • @p flags is which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES.
    • @p 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..
    • @p func is the function to call for each visited #GNode.
    • @p data is user data to pass to the function.
    • @r None.
  • unlink ()

    Unlinks a #GNode from a tree, resulting in two separate trees.

    • @r None.