GTK+ 1.2 Tutorial
Prev | Chapter 13. Tree Widget | Next

# Adding a Subtree

A subtree is created like any other Tree widget. A subtree is added to another tree beneath a tree item, using:

    void gtk_tree_item_set_subtree( GtkTreeItem *tree_item,
                                    GtkWidget   *subtree );

You do not need to call gtk_widget_show() on a subtree before or after adding it to a TreeItem. However, you must have added the TreeItem in question to a parent tree before calling gtk_tree_item_set_subtree(). This is because, technically, the parent of the subtree is not the GtkTreeItem which "owns" it, but rather the GtkTree which holds that GtkTreeItem.

When you add a subtree to a TreeItem, a plus or minus sign appears beside it, which the user can click on to "expand" or "collapse" it, meaning, to show or hide its subtree. TreeItems are collapsed by default. Note that when you collapse a TreeItem, any selected items in its subtree remain selected, which may not be what the user expects.

Prev | Home | Next
Tree Widget | Up | Handling the Selection List