GTK+ 1.2 Tutorial
Prev | Chapter 11. CList Widget | Next

# Adding rows to the list

We can add rows in three ways. They can be prepended or appended to the list using

    gint gtk_clist_prepend( GtkCList *clist,
                            gchar    *text[] );

    gint gtk_clist_append( GtkCList *clist,
                           gchar    *text[] );

The return value of these two functions indicate the index of the row that was just added. We can insert a row at a given place using

    void gtk_clist_insert( GtkCList *clist,
                           gint      row,
                           gchar    *text[] );

In these calls we have to provide a collection of pointers that are the texts we want to put in the columns. The number of pointers should equal the number of columns in the list. If the text[] argument is NULL, then there will be no text in the columns of the row. This is useful, for example, if we want to add pixmaps instead (something that has to be done manually).

Also, please note that the numbering of both rows and columns start at 0.

To remove an individual row we use

    void gtk_clist_remove( GtkCList *clist,
                           gint      row );

There is also a call that removes all rows in the list. This is a lot faster than calling gtk_clist_remove once for each row, which is the only alternative.

    void gtk_clist_clear( GtkCList *clist );

There are also two convenience functions that should be used when a lot of changes have to be made to the list. This is to prevent the list flickering while being repeatedly updated, which may be highly annoying to the user. So instead it is a good idea to freeze the list, do the updates to it, and finally thaw it which causes the list to be updated on the screen.

    void gtk_clist_freeze( GtkCList * clist );

    void gtk_clist_thaw( GtkCList * clist );

Prev | Home | Next
Manipulating the list itself | Up | Setting text and pixmaps in the cells