Re: Row color in GtkTreeView

From: Date: Mon, 13 Mar 2006 19:54:56 +0000
Subject: Re: Row color in GtkTreeView
References: 1 2 3 4 5  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6787@lists.php.net to get a copy of this message
Eduardo RBS wrote:
Thanks for the help... I get it working.. but.. all the TreeView is in one color I want each row (depending of the value) to be in one color... like ... if age > 18 the row in blue.. but if the age<=18 the row is red.. ok? with $cell_renderer->set_property I can only set the color of the all the TreeView, but I want to set color of one row each time..
You have to use a callback to set the cell properties for each row. Take a look at: http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html#gtk-tree-view-column-set-cell-data-func You pass a function like this: function setBackgroundColor($tree, $cell, $model, $iter, $userData = array()) {
    $value = ... // Get the value from the model and iter.
    if ($value > 18) {
        $cell->set_property('cell_background', '#0000ff');
    } else {
        ....
    }
} -- Scott Mattocks http://www.crisscott.com

« previous php.gtk.general (#6787) next »