diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 7b0148e95..ff08499dc 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +Mon Mar 25 11:31:41 2002 Jonathan Blandford + + * gtk/tree_widget.sgml: fix bugs in the code. + 2002-03-20 Cody Russell * gtk/tree_widget.sgml: Much expanded overview of the tree. diff --git a/docs/reference/gtk/tree_widget.sgml b/docs/reference/gtk/tree_widget.sgml index f95525019..3e33dd50b 100644 --- a/docs/reference/gtk/tree_widget.sgml +++ b/docs/reference/gtk/tree_widget.sgml @@ -102,11 +102,12 @@ gtk_tree_store_append (store, &iter, NULL); /* Acquire an iterator */ gtk_tree_store_set (store, &iter, TITLE_COLUMN, "The Principle of Reason", AUTHOR_COLUMN, "Martin Heidegger", - CHECKED_COLUMN, FALSE); + CHECKED_COLUMN, FALSE + -1); ]]> - Notice that the last argument is FALSE. This is always done because + Notice that the last argument is -1. This is always done because this is a variable-argument function and it needs to know when to stop processing arguments. It can be used to set the data in any or all columns in a given row. @@ -126,33 +127,35 @@ gtk_tree_store_set (store, &iter1, TITLE_COLUMN, "The Art of Computer Programming", AUTHOR_COLUMN, "Donald E. Knuth", CHECKED_COLUMN, FALSE, - NULL); + -1); gtk_tree_store_append (store, &iter2, &iter1); /* Acquire a child iterator */ gtk_tree_store_set (store, &iter2, TITLE_COLUMN, "Volume 1: Fundamental Algorithms", - NULL); + -1); gtk_tree_store_append (store, &iter2, &iter1); gtk_tree_store_set (store, &iter2, TITLE_COLUMN, "Volume 2: Seminumerical Algorithms", - NULL); + -1); gtk_tree_store_append (store, &iter2, &iter1); gtk_tree_store_set (store, &iter2, TITLE_COLUMN, "Volume 3: Sorting and Searching", - NULL); + -1); ]]> Creating the view component - While there are two different models to choose from, there is only one - view widget to deal with. It works with either the list or the tree store. - Setting up a GtkTreeView is not a - difficult matter. It needs a GtkTreeModel - to know where to retrieve its data from. + While there are several different models to choose from, there is + only one view widget to deal with. It works with either the list + or the tree store. Setting up a GtkTreeView is not a difficult + matter. It needs a GtkTreeModel to know where to + retrieve its data from. Columns and cell renderers - Cell renderers are used to draw the data in the tree model in a certain way. - There are three cell renderers to choose from with GTK+ 2.0, but the - adventuresome hacker may write more. + Once the GtkTreeView widget + has a model, it will need to know how to display the model. It + does this with columns and cell renderers. + + + Cell renderers are used to draw the data in the tree model in a + way. There are three cell renderers that come with GTK+ 2.0. + They are the GtkCellRendererText, GtkCellRendererPixbuf and + the GtkCellRendererToggle. + It is relatively easy to write a custom renderer. + + + A GtkTreeViewColumn is the + object that GtkTreeView uses to organize the vertical columns in + the tree view. It needs to know the name of the column to label + for the user, what type of cell renderer to use, and which piece of + data to retrieve from the model for a given row. - - A GtkTreeViewColumn is the - object that GtkTreeView uses to organize the vertical columns in - the tree view. It needs to know the name of the column to label - for the user, what type of cell renderer to use, and which piece of - data to retrieve from the model for a given row. - At this point, all the steps in creating a displayable tree have been covered. The model is created, data is stored in it, a tree view is @@ -283,12 +296,13 @@ setup_tree (void) /* Create a cell render and arbitrarily make it red for demonstration * purposes */ renderer = gtk_cell_renderer_text_new (); - g_object_set (G_OBJECT (renderer), "foreground", "red", NULL); + g_object_set (G_OBJECT (renderer), + "foreground", "red", + NULL); /* Create a column, associating the "text" attribute of the * cell_renderer to the first column of the model */ - column = gtk_tree_view_column_new_with_attributes ("Author", - renderer, + column = gtk_tree_view_column_new_with_attributes ("Author", renderer, "text", AUTHOR_COLUMN, NULL);