Re: How to set the color of a row based on the data in one coloumn Gtk::Treeview
- From: muppet <scott asofyet org>
- To: Ragavendar Swamisai <ragavendar swamisai gmail com>
- Cc: gtk-perl-list gnome org
- Subject: Re: How to set the color of a row based on the data in one coloumn Gtk::Treeview
- Date: Wed, 26 Aug 2009 19:17:46 -0400
On Aug 19, 2009, at 5:05 PM, Ragavendar Swamisai wrote:
Hi,
I am trying to create a TreeView (with SimpleList) and I have a column
where its value is set dynamically, and when the value in the column
is set to a specific string I want to set the complete row to say RED.
I am able to do that for a column using the 'attr' key in the
SimpleList.
Any pointers or code snippet will be helpful.
The easiest way is to have a hidden row in your column that contains
the color you want to use. You'd calculate that when you insert the
data. Then, loop across all the columns in the view, adding an
attribute to control the color, like this:
foreach my $col ($view->get_columns ()) {
# NOTE: in newer gtk+, this is get_cells()
foreach my $cell ($col->get_cell_renderers ()) {
# assuming you're talking about the foreground color, and
that the
# model stores this as a string color name.
$col->add_attribute ($cell, foreground =>
HIDDEN_COLOR_COLUMN_INDEX);
}
}
If you want the background color, you may need to tweak.
If it needs to be more dynamic than that, or not use a column to store
this value, then you will need to use a cell data function, which
replaces your attributes, which means you want to do it by hand
instead of using SimpleList.
--
Applause is an addiction, like heroin or checking your email.
-- Sideshow Mel
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]