Disable highlighting current row in treeview



I’m wondering is there is a setting to disable the automatic highlight
of the current row.

I’m using backgrounds colors in each cell to help the user know if the
cell is ok or need to be edited, but it does not appear for the current
row, where all the cells have a default background, from theme I guess,
which overrides whatever background I have set.

I tried to google it to no avail, and I don’t see anything in the docs.

Anyone has an idea ?





You might be able to do something similar to what evolution does.
There’s some color scheme “mucking” in mail/em-format-html-display.c
that computes “complimentary” colors. There’s also some algorithms that
I have somewhere that do some similar stuff, but I haven’t thought about
them for quite a while.

I think you can just alter the selection color to be something along the
lines of what you want. Shutting it off completely wouldn’t be good
from a usability perspective.



On Sat, 2008-10-11 at 19:49 +0200, Simon A. wrote:

I tried to google it to no avail, and I don’t see anything in the docs.

Anyone has an idea ?



Andrew S. Townley removed_email_address@domain.invalid


Thanks, your answer directed me in the right direction.

There might be others solution, but I’m happy with what I’ve found.

Basically, by default, and from theme, the current row is highlighted.
Mainly setting a background color so you can easyly see which row you

You can change this color with Gtk::Widget#modify_base (seeGtk::Widget
doc), but it will still change the whole row.

I then went with disabling the selection, which did work just as I
wanted except you could not double clic a cell to edit it. So I added
this functionnality back. See below.

tw = Gtk::TreeView.new tw.selection.mode = Gtk::SELECTION_NONE tw.signal_connect("row-activated") do |me, path, column| me.set_cursor(path, column, true) end

It would have been nice to be able to modify style for each cell, but
I’m not sure it’s feasible, and I don’t want to spend more time on this,
as I have a solution which works exactly as I want it to.

Hope it can help



You can change the rendering on a cell by cell basis in the
TreeViewColumn. Something like this which just sets the text bold or
normal depending on the output of the mythical foobar() method:

col = Gtk::TreeViewColumn.new(column_title)
col.set_cell_data_func(renderer) do |col, rend, model, iter|
if model_column == MAP_TITLE[:COLUMN]
highlight = foobar(col, rend, model, iter)
weight = highlight ? Pango::WEIGHT_BOLD : Pango::WEIGHT_NORMAL)
rend.set_property(‘weight’, weight)
rend.set_property(‘weight-set’, 1)