GTK+
The GIMP Toolkit

General
Introduction
Screenshots
Download
Mailing Lists
Language Bindings
Themes
Bug Tracker

Documentation
FAQ
Tutorial
API Reference
Published Books

Projects
Pango
Inti
GNOME
GTK+ for Win32
GtkFB (Framebuffer)
GTK+ on DirectFB
GTK+ for BeOS

Applications
GIMP
Abiword
Dia
Glade
GnuCash
Gnumeric

GNOME Software Map

12.4. 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.