Re: Subclassing Gtk2::TreeModel



On Sunday, September 21, 2003, at 04:56 PM, Dan Lyke wrote:

The thing I want right now is a node that reports itself as having
children, but that I don't have to fill in children for until it's
actually clicked on, and I could do this by entering dummy data and
then deleting and reinserting when I actually have to expand it, but
fooling Gtk2::TreeStore that way seems like an awful lot of work.
i believe the nautilus guys have done something to figure out how to 
populate a tree on demand.  you might check their irc channels and 
mailing lists.  but in fact, what you describe sounds rather a bit like 
what i seem to recall hearing from them.

So, in my heat coma yesterday evening, I slapped together a little
class that had Gtk2::TreeModel in its @ISA, had all the appropriate
interface functions, and...
a normal perl object isn't enough to have signals called on it, because 
signals, virtual overrides, and all of that sort of mess require you to 
fiddle with a GObjectClass.  for that, you need to *register* a GObject 
subclass with g_type_register(); perl's front-end to that is the 
Glib::Object::Subclass module.
now the fact of the matter is, GtkTreeModel is a GInterface, not a 
GObject.  GtkTreeStore is a GObject which implements the GtkTreeModel 
interface.  this mumbo jumbo actually refers to the fact that the 
GObjectClass for GtkTreeStore contains a pointer to a GtkTreeModel 
vtable filled in with the right functions for GtkTreeStore.
frankly, i didn't really understand this GInterface stuff until a few 
days ago (and i'm still far from an expert on it), so you may not be 
surprised that there's currently no way to implement a GInterface from 
perl.  i mean, you could try it, but i don't think it would work.  what 
a downer.
now, if you're not afraid of C and/or XS, you could implement the 
crucial portions of your custom model in C and bind it to perl with 
very little extra effort, and things should work fine.

And if not, then I'll go back to fooling Gtk2::TreeStore into showing
what I want by playing silly games with its data.
let us know what you find ...

--
muppet <scott at asofyet dot org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]