Re: Subclassing Gtk2::CellRenderer



Thanks a lot, muppet. You're confirming my most pessimistic suspicions. I took at quick look at the xs code (and even some gtk+ code) and I'm now starting to get a glimmer of understanding (and appreciation) of the magic that goes on to make the perl interface work so well as it does.

Still, wouldn't it be nice to be able to do anything you can do in C in perl as well? Not necessarily making it simple to do in perl, but at least possible? Some additional magic during code generation, maybe? Exposing in special-purpose perl classes what you're doing your best to hide in the normal case?

muppet wrote:


On Wednesday, October 1, 2003, at 10:50 AM, Bjarne Steinsbø wrote:

A method invocation in GObject is just a signal, right? So I should override the proper signal name in order to let my own routine handle this method.


i wish it was just that simple.

Yepp, that's where I went wrong, allright. Reality is never as simple as you think it is after just a few days exposure to a new system/job/API/whatever...

now to be perfectly honest, the render method would be called a *lot*, so they probably assume that you'd have to be insane to want to implement that in a non-c or c++ language. given that i can't see a way to attach a widget to the treeview and you'll probably wind up rendering something that looks like an optionmenu by hand, i can't say that i really fault them for that assumption.

An optionmenu shouldn't really be that hard to render in the normal case, it's just a string and a pixmap. It's the editing phase that's complicated. But I see your point. The elegant way to extend the treeview would be to allow widgets in the cells, much like a gnome canvas or (just saw this in the docs, really neat!) in a Combo. And yes, it would hurt performance, which is probably one of the reasons they didn't put it in.

if you don't mind having a little bit of extra XS for your custom cellrenderer, i think you can pull it off a little more easily by mixing C and perl.

Since it's not simple to do, I'll probably implement the functionality some other way, at least initially. Probably a popup when the user clicks in a column of a certain type. I'll probably sub-class the widget and hide it down there, so that I can come back and change the implementation at a later stage, if and when I want to do it properly.

Bjarne

P.S. I think I stumbled across a typo in the xs documentation for Glib. Please see attached diff.
*** /usr/src/Gtk2-perl/Glib-1.00rc3/GType.xs    Fri Sep 26 01:26:32 2003
--- GType.xs    Thu Oct  2 12:55:29 2003
***************
*** 453,455 ****
  
! =item GType gperl_type_from_package (GType gtype)
  
--- 453,455 ----
  
! =item GType gperl_package_from_type (GType gtype)
  


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