Colorizing rows in SimpleList revisited
- From: John McDermott <jjm jkintl com>
- To: gtk-perl-list gnome org
- Subject: Colorizing rows in SimpleList revisited
- Date: Fri, 02 Jan 2004 17:52:47 -0700
I asked earlier about colorizing rows in a Gtk2::SimpleList. Here is the
solution I came up with:
1) add a column or columns to the data to hold the attributes of the rows
(e.g. column number 8 for background color). Use the SimpleList
attribute of 'hidden'.
2) declare this method
sub Gtk2::SimpleList::set_attr {
my ($self, $attr, $col_no) = @_;
for(my $i = 0 ; $i < $self->get_model->get_n_columns ; $i++){
# how to avoid warnings on non-existant attributes???
my $col = $self->get_column($i);
$col->add_attribute($col->get_cell_renderers,
$attr=>$col_no)
if defined $col and defined $col->get_cell_renderers;
}
}
3) after creating the list, configure the columns connecting the
appropriate column and the attribute it holds.. e.g.
$slist->set_attr( "cell-background",8); #col 8 is fg
$slist->set_attr( "foreground",9); #col 9 is bg
$slist->{data}[4][8] = "green"; #change fg on row 4
The only problem is that this gives runtime warnings for cells not having
a given attribute -- e.g. cells using the boolean renderer don't have a
foreground color. My question is, how do I determine whether or not a
given renderer supports a particular attribute?
Thanks,
--john
--
John McDermott
Writer, Educator, Consultant
jjm jkintl com http://www.jkintl.com
V +1 505/377-6293 F +1 505/377-6313
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]