Forum: Ruby-Gnome 2 TreeView returning a COPY of my renderer?

Posted by Eric C. (eric_c)
on 2012-02-21 22:07
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
Posted by Eric C. (eric_c)
on 2012-02-22 00:07
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
Posted by Eric C. (eric_c)
on 2012-02-22 00:51
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.