# How to change the rendering in a cell of a treeview in gtk2

**URL:** <https://www.ruby-forum.com/t/how-to-change-the-rendering-in-a-cell-of-a-treeview-in-gtk2/225699>\
**Category:** Ruby-Gnome 2\
**Created:** [January 24, 2013, 12:19pm UTC](https://www.ruby-forum.com/t/how-to-change-the-rendering-in-a-cell-of-a-treeview-in-gtk2/225699 "2013-01-24T12:19:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 24, 2013, 12:19pm UTC](https://www.ruby-forum.com/t/how-to-change-the-rendering-in-a-cell-of-a-treeview-in-gtk2/225699/1 "2013-01-24T12:19:11Z")

</div>

Hi, I am just starting to use gtk2 library. I have a problem which I  
think should be a simple one but I cannot find an answer with google or  
checking the doc. What I want is change the rendering (like making it  
insensitive) of certain cells or rows in an established treeview with a  
check button. The button sits beside the treeview.

what I tried is adding some extra lines into the  
“col.set\_cell\_data\_func(renderer)” function which run at the treeview  
initialization. I want to make certain cells insensitive. What I got is  
that certain cells will only become insensitive when the cursor was  
moved onto the cell. This is not what I want. The effect I want is  
certain rows or cells become insensitive immediately when I click on the  
check button.

I guess I am doing it the wrong way. Any suggestions?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![peng\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e480ec/32.png) [@peng\_h](https://www.ruby-forum.com/u/peng_h)\
**Post date:** [January 27, 2013, 8:14am UTC](https://www.ruby-forum.com/t/how-to-change-the-rendering-in-a-cell-of-a-treeview-in-gtk2/225699/2 "2013-01-27T08:14:44Z")

</div>

Hi:

If I understand your question, you have a single checkbox (not a column  
in the treeview) that when you check it you want the treeview to repaint  
so that certain cells are insensitive?

The way to do this is you write a handler for the checkboxes “toggled”  
method that repaints the treeview:

In visualruby:

def checkbox\_\_toggled(\*args)

# make cells insensitive here

@builder[“scrolledwindow1”].hide # repaint treeview  
@builder[“window1”].show\_all  
end

If you’re using gtk directly:

checkbox.signal\_connect(“toggled”) { |x,y| checkbox\_\_toggled(x,y) }

(something like that?!?!?)

Hope it helps,  
Eric  
[visualruby.net](http://visualruby.net)

---

<div class="post-metadata">

**Author:** ![peng\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e480ec/32.png) [@peng\_h](https://www.ruby-forum.com/u/peng_h)\
**Post date:** [February 2, 2013, 3:37pm UTC](https://www.ruby-forum.com/t/how-to-change-the-rendering-in-a-cell-of-a-treeview-in-gtk2/225699/3 "2013-02-02T15:37:09Z")

</div>

Hi Eric,

thanks a lot for your explanation.

I am using gtk2. And I has been using the

checkbox.signal\_connect(“toggled”){}

method as you explained. But I do not know how to repaint the tree view.  
To be specific, I already have this @treeview object. How do I render  
again certain rows? Is it possible to get the handle of renderers of  
certain rows or columns from the @treeview object so that I can set  
renderer.sensitive to false?

Or should I create a new renderer and couple it with the @treeview?

Peng
