Hello,

> As a side question, I'm a little confused about the "text" property in
> gtk_tree_view_insert_column_with_attributes().  What is this the
> "text" property to? 
There is a little misunderstanding in the function
gtk_tree_view_insert_column_with_attributes() here. The explanations
for the ... in the function is given is the
gtk_tree_view_column_new_with_attributes() function (which is called by
the routine you use)
(http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html#gtk-tree-view-column-new-with-attributes).
To sum up, your model use N fields (yours is 11), numbered from 0 to N
- 1. Then, the viewing system (here, the render of the column), need to
know where its properties should be read in the model (i.e. which
field). So here you have to say that the "text" property of your
textRenderer is read from field n in [0;N[. So, syntaxically, writing
>     col=gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(tv),
>     -1, "First Column",
>     renderer,
>     "text", TRUE,
>     NULL);
is correct  but it means that the "text" is read from the second field
of your model (TRUE = 1)...
You should have done something like this:
/* Replace here FOO_n with meaningful names */
enum
{
  ipmsPrice_FOO_0,
  ipmsPrice_FOO_1,
  ...
  ipmsPrice_FOO_10
}
...
/* Create 3 columns with text rendering */
renderer = gtk_cell_renderer_text_new()
gtk_tree_view_insert_column_with_attributes
  (GTK_TREE_VIEW(tv), -1, "First Column", renderer,
   "text", ipmsPrice_FOO_0, NULL);
gtk_tree_view_insert_column_with_attributes
  (GTK_TREE_VIEW(tv), -1, "Second Column", renderer,
   "text", ipmsPrice_FOO_1,
   "color", ipmsPrice_FOO_2, NULL);
gtk_tree_view_insert_column_with_attributes
  (GTK_TREE_VIEW(tv), -1, "Third Column", renderer,
   "text", ipmsPrice_FOO_3, NULL);
...
/* Populate your model (assuming a treestore) */
gtk_tree_store_prepend(GTK_TREE_STORE(tm), &iter, NULL);
gtk_tree_store_set(GTK_TREE_STORE(tm), &iter,
                   ipmsPrice_FOO_0, "captain",
                   ipmsPrice_FOO_1, "age",
                   ipmsPrice_FOO_2, "red",
                   ipmsPrice_FOO_3, 42,
                   NULL);

Of course you can read from your model whatever information you want,
not only the text to be rendered, but also the rendering colour of that
text... To do it, add a string field in your model and when you set the
value using gtk_treemodel_set(), put "red" or whatever in that field.
And "connect" the "color" property to this field when inserting the
column as shown in the example.

Hope this will help your TreeView problem.

Damien.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to