Re: ListStore/TreeView with row based settings for columns



Hello,

Le 24/07/2008, "Robert G." <cryptococa gmail com> a Ãcrit :
Hello, I was wondering if there's any way to have a ListStore/TreeView
have rows xalign'd to different sides of a column.
Yes, it is possible. To do things on a per row basis, use the model.
Reserve some entries in your model to tune the properties of your
renderer. Here is an example:

This is a complex set method that sets a name and a value in a treeview.
The value (a potential) can be editable or not, depending on the type
variable and its colour can also be changed. Here its visibility is
always TRUE:

gtk_tree_store_set(isosurfaces_data_list, &childIter,
 NAME_COLUMN, current_surface,
 POTENTIAL_COLUMN, potentialData[pos],
 EDIT_POTENTIAL_COLUMN, (type == SURFACE_TYPE_FILE_DENPOT),
 COLOR_POTENTIAL_COLUMN, color,
 USE_POTENTIAL_COLUMN, TRUE,
 -1);

The corresponding column for the potential has been declared like
this, where renderer is a text one:
  column = gtk_tree_view_column_new_with_attributes
            (_("Value"), renderer,
             "text", POTENTIAL_COLUMN,
             "editable", EDIT_POTENTIAL_COLUMN,
             "foreground", COLOR_POTENTIAL_COLUMN,
             "visible", USE_POTENTIAL_COLUMN, NULL);
So in that case, the model can tune per row the editable, colour and
visible properties.

The model has the following description (it has many more things than
just the potential one):
isosurfaces_data_list =
    gtk_tree_store_new(N_COLUMNS, G_TYPE_INT, G_TYPE_BOOLEAN,
                       G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING,
                       G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT,
                       G_TYPE_FLOAT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
                       G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT,
                       G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER,
                       G_TYPE_STRING);

Damien.

PS: questions about the usage of GTK+ should be sent to
gtk-app-devel-list gnome org not the other one that is for the
development of GTK+ itself.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]