GTK+ 1.2 Tutorial
Prev | Chapter 12. CTree Widget | Next

# Utilizing row data

The CTree widget allows you to associate data with each node of the tree. This is most often used in callback functions, such as when a row is selected.

Although only a single data element can be stored for each row, this data element can be any variable or data structure, which indirectly allows a set of data to be referenced.

There are two functions for setting row data:

    void gtk_ctree_node_set_row_data( GtkCTree     *ctree,
                                      GtkCTreeNode *node,
                                      gpointer      data );

    void gtk_ctree_node_set_row_data_full( GtkCTree         *ctree,
    				       GtkCTreeNode     *node,
                                           gpointer          data,
                                           GtkDestroyNotify  destroy );

The function `gtk_ctree_node_set_row_data()` simply takes as arguments pointers to the CTree, node and data.

The function `gtk_ctree_node_set_row_data_full()` takes an additional parameter, `destroy`. This parameter is a pointer to a function that will be called when the row is destroyed. Typically, this function would take responsibility for freeing the memory used by the row data. This function should take the form:

    void destroy_func( gpointer data );

The paramter passed to this function will be the row data.

Prev | Home | Next
Setting CTree Attributes | Up | Tree Widget