TreeView returning a COPY of my renderer?

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

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 typegchararray’ 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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs