Chapter 11. CList Widget

Table of Contents
11.1. Creating a CList widget
11.2. Modes of operation
11.3. Working with titles
11.4. Manipulating the list itself
11.5. Adding rows to the list
11.6. Setting text and pixmaps in the cells
11.7. Storing data pointers
11.8. Working with selections
11.9. The signals that bring it together
11.10. A CList example
The CList widget has replaced the List widget (which is still available).

The CList widget is a multi-column list widget that is capable of handling literally thousands of rows of information. Each column can optionally have a title, which itself is optionally active, allowing us to bind a callback to its selection.

11.1. Creating a CList widget

Creating a CList is quite straightforward, once you have learned about widgets in general. It provides the almost standard two ways, that is the hard way, and the easy way. But before we create it, there is one thing we should figure out beforehand: how many columns should it have?

Not all columns have to be visible and can be used to store data that is related to a certain cell in the list.
clist = GtkCList(columns)

clist = GtkCList(columns, titles)

The first form is very straightforward, the second might require some explanation. Each column can have a title associated with it, and this title can be a label or a button that reacts when we click on it. If we use the second form, we must provide a list of title texts, and the number of list items should equal the number of columns specified. Of course we can always use the first form, and manually add titles later.

Note: The CList widget does not have its own scrollbars and should be placed within a ScrolledWindow widget if you require this functionality.