# TreeView returning a COPY of my renderer?

**URL:** <https://www.ruby-forum.com/t/treeview-returning-a-copy-of-my-renderer/217116>\
**Category:** Ruby-Gnome 2\
**Created:** [February 21, 2012, 10:07pm UTC](https://www.ruby-forum.com/t/treeview-returning-a-copy-of-my-renderer/217116 "2012-02-21T22:07:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 21, 2012, 10:07pm UTC](https://www.ruby-forum.com/t/treeview-returning-a-copy-of-my-renderer/217116/1 "2012-02-21T22:07:39Z")

</div>

Hi:

I’m writing an API to handle treeviews, and listviews. I’m having a  
problem with subclassing renderers. I subclassed  
Gtk::CellRendererToggle, and I’m trying to give it “radio” button  
functionality:

class VR\_CellRendererToggle \< Gtk::CellRendererToggle

attr\_accessor :radiox

def initialize  
@radiox = false  
end

end

This works fine. I create an instance of it and append() the column to  
my treeview. The problem occurs when I try to retrieve it, and set the  
“radio” instance variable to true:

@view.columns(CHECK\_BOXES).cellrenderers[0].radiox = true

This has no effect because the renderer in the above statement returns a  
copy of the renderer. I’ve verified this by showing each object’s  
object\_id on the screen. They don’t match.

Is this how its supposed to work? What can I do?

Thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![ericrchr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/8baadc/32.png) [@ericrchr](https://www.ruby-forum.com/u/ericrchr)\
**Post date:** [February 22, 2012, 12:07am UTC](https://www.ruby-forum.com/t/treeview-returning-a-copy-of-my-renderer/217116/2 "2012-02-22T00:07:08Z")

</div>

This might be a clue about what’s going on. When I run my program, I  
get about 18 of these warnings:

GLib-GObject-WARNING \*\*:unable to set property `text' of type`gchararray’ from value of type `VALUE’  
ListViewDemo.rb: line 15

(line 15 is Gtk.main)

I have 6 lines of data, so I think that 3 of my fields are generating  
this warning. Upon googling this, I learned that the “type” of the  
renderer isn’t generating a proper value for the “text” field. Since  
I’m populating my model with various subclasses of objects, It must be  
causing a problem. Is it possible this is messing up the references to  
the renderers?

Does anyone know about this?

thanks,  
Eric

---

<div class="post-metadata">

**Author:** ![ericrchr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/8baadc/32.png) [@ericrchr](https://www.ruby-forum.com/u/ericrchr)\
**Post date:** [February 22, 2012, 12:51am UTC](https://www.ruby-forum.com/t/treeview-returning-a-copy-of-my-renderer/217116/3 "2012-02-22T00:51:48Z")

</div>

Nevermind. I solved it! It turns out that I was adding a  
UserDefinedObject into my model/view and it was making everything go  
haywire. In fact, the IDE that I’m writing started behaving strangely  
too because all the object\_ids were switched around (I think).

So, the moral of this story, is make sure you only add objects that  
properly render a :text field.

E
