--- tree_mark_cell_orig.pl 2005-02-17 19:18:37.770007480 +0100 +++ tree_mark_cell.pl 2005-02-17 19:28:38.726648184 +0100 @@ -22,18 +22,8 @@ Glib::String Glib::String / ); -# Ouch ! We need to give a home to that unwanted row-highlight. my $iter = $model->append (undef); $model->set ($iter, - 0, undef, 1, undef, - 2, undef, 3, undef, - 4, undef, 5, undef, - 5, undef, 7, undef, - 8, undef, 9, undef, -); - -$iter = $model->append (undef); -$model->set ($iter, 0, 'foo', 1, undef, 2, undef, 3, undef, 4, undef, 5, undef, @@ -66,6 +56,7 @@ $tree_view->append_column($col); push @tree_columns, $col; } +$tree_view->get_selection->set_mode ('none'); $tree_view->expand_all; my $clicked_cache; @@ -113,17 +104,33 @@ if ($path) { my $model = $tree_view->get_model; my $i = $column->{column_number}; - return 0 unless $i; # If the first column is clicked, - # the user actually wants to higlight the whole row - return 0 if ($path->to_string eq "0"); # If the dummy row is clicked - return 0 if ($i>3); # If the hidden row is clicked + + my $iter = $model->get_iter ($path); + + # Change the background of all cells in the clicked row + if ($i == 0) { + my $color = undef; + + foreach (1 .. $#columns - 1) { + unless (defined $model->get($iter, $_*2+1)) { + $color = 'green'; + last; + } + } + + foreach (1 .. $#columns - 1) { + $model->set($iter, $_*2+1, $color); + } + + return 1; + } # Change the background of the cell that was clicked - $model->set($model->get_iter ($path), $i*2+1, 'green'); + $model->set($iter, $i*2+1, defined $model->get($iter, $i*2+1) ? undef : 'green'); - my $name = $model->get($model->get_iter ($path), 0); + my $name = $model->get($iter, 0); my $col = $columns[$i]; - my $text = $model->get($model->get_iter ($path), $i*2); + my $text = $model->get($iter, $i*2); push @$clicked_cache, { path => $path->to_string, name => $name, @@ -131,10 +138,6 @@ column_number => $i, text => $text }; - - # Send the cursor to the dummy row. Else the color change won't be seen - # The color change will be hidden under the row-higlight - $tree_view->set_cursor (Gtk2::TreePath->new_from_string("0"), undef, TRUE); return 1; }