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

Chapter 12. CTree Widget

The CTree widget is derived from the CList widget. It is designed to display hierarchically-organised data. The tree is displayed vertically, and branches of the tree can be clapsed and expanded as required by the user.

This section of the tutorial is under development.

12.1. Creating a CTree

A CTree, being derived from CList, can have multiple columns. These columns optionally have titles that are displayed along the top of the CTree widget. Hence there are two functions for creating a new CTree widget:

GtkWidget *gtk_ctree_new_with_titles( gint   columns, 
                                      gint   tree_column,
                                      gchar *titles[] );

GtkWidget *gtk_ctree_new( gint columns, 
                          gint tree_column );

The columns argument specifies the number of columns that the CTree will contain. The tree_column argumnet specifies which of those columns is to contain the tree. Columns are numbered starting from 0.

With the first funtion above, the titles argument contains an array of strings that contain the captions for the column headings. A typical code fragment using the gtk_ctree_new_with_titles() function would be:

    /* CTree column titles /*
    char *titles[] = { "Location" , "Description" };
    GtkWidget *ctree;

    ctree = gtk_ctree_new_with_titles(2, 0, titles);

This would create a new CTree with two columns entitled "Location" and "Description", with the first column containing the tree.