9.4. Glade and Tree Views

A frequently asked question is how you can add columns to a GtkTreeView in Glade. [1] The answer is basically that you don't, and that you can't. The only thing glade/libglade can do for you is to create the GtkTreeView for you with nothing in it. You will need to look up the tree view widget at the start of your application (after the interface has been created of course), and connect your list store or tree store to it. Then you will need to add GtkTreeViewColumns and cell renderers to display the information from the model as you want it to be displayed. You will need to do all that from within your application.

An alternative approach is to derive your own special widget from GtkTreeView that sets up everything as you want it to, and then use the 'custom widget' function in glade. Of course this still means that you have to write all the code to fill in the columns and cell renderers and to create the model yourself.



Do not use Glade to generate code for you. Use Glade to create the interface. It will save the interface into a .glade file in XML format. You can then use libglade2 to construct your interface (windows etc.) from that .glade file. See this mailing list message for a short discussion about why you should avoid Glade code generation.