Re: Gtk2 and inheritance



Jörn Reder <joern zyn de> writes:

Jörn Reder wrote:

With Gtk this works. Gtk2 stores the objects internally as scalar refs 
(I suppose it's is the corresponding C pointer), while Gtk uses hash 
refs, which could be reblessed without problems

Ok - I crawled the source again and now I know a little more.

The "modification of a read-only value" thing is easy to fix. We just 
have to remove

  SvREADONLY_on(obj);

from _Helpers.c, unless it's not just for safeness. I checked this with
"make test" - it runs without problems, so removing it should be Ok.

Goran was the decider for that. I'll let him answer on it.

To my eyes, it seems that it's for safeness because there is no
known necessity for re-blessing gtk2 objects from perl code.
 
(also it was easy to 
attach user data to arbitrary widget objects - but that's not that 
important here... ;)

But here I was mistaken (probably I should get more sleep ;). In fact 
inheritance without the ability of attaching additional attributes to an
object, is useless.

Use `$object->set_data' and `$object->get_data'.

So we agree, re-blessing gtk2 objects from perl code is useless :).


-- 
Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/



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