Re: inheriting from containers

Espen S Johnsen <[email protected]> 06 Mar 2008 18:12:46 +0100
Newsgroups gmane.lisp.clg.devel
Message-ID <[email protected]>
"Walter C. Pelissero" <[email protected]> writes:

> I've noticed that although I'm allowed to do things like:
> 
>   (defclass my-box (v-box)
>     ()
>     (:metaclass glib:gobject-class))
> 
>   (container-add (make-instance 'my-box) some-widget)
> 
> I'm not allowed to do:
> 
>   (container-add (make-instance 'my-box) some-widget :expand nil)
> 
> In fact INIT-CHILD-SLOTS is not able to find the right child container
> to instantiate.
> 
> Did I totally fail to understand how to inherit from a CLG class?
> When I define a new container do I also have to define its children
> type? (How?)

Let me try to explain how this works, or at least how I understand it...

Gtk container classes have something called child properties, which are
properties that a child object would take on when added to a
container. Instances of child classes (named so due to lack of better
ideas) in clg are proxy objects used to access these properties.

So when you subclass a container you would also have to subclass the
child class, even if you're not adding any child properties (which isn't
possible to do currently). For the example above, the child class
definition would be:

(defclass my-box-child (v-box-child) 
  ()
  (:metaclass container-child-class) (:container my-box))

This is a bit awkward, the reason being that I created this mechanism
before I made subclassing possible, so I'll probably use this
opportunity to fix it (hopefully without breaking too much existing
code).

-- 
Espen

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/