[Gtk-sharp-list] connect_after issues

Mike Kestner mkestner@ximian.com
Wed, 18 Feb 2004 17:30:04 -0600

On Wed, 2004-02-18 at 16:15, Thiago Milczarek SayĆ£o wrote:

> I still wonder why people would want to connect_after things ??
> As a gtk binding, gtk# should follow what is standard in gtk which is
> connect_before. (see g_signal_connect ()).

This is already in the FAQ, but just because the convention in C
programming is to pierce encapsulation and change object behavior
without subclassing doesn't mean that a C# binding should do it. 

> I was told at #mono that i could connect_before extending the class and
> overriding the event method. That doesn't work. See the example
> attached.

No, subclassing and overriding the default handler does *not* use
g_signal_connect at all.  It uses the more object-oriented approach of
overriding the object's "protected" default handler to change the
object's behavior.

Your example doesn't work because it has a bug.  You need to use
RegisterGType to register your subclass with the native type system.
RegisterGType automagically hooks up all overridden default handlers.
Take a look at sample/Subclass.cs for an example usage of

Oh and before anyone mentions that native type registration should be
done automatically, they should go through the exercise of figuring out
how and posting a patch for it, because if I knew how to do that, it
would be done already.  :)

Mike Kestner <mkestner@ximian.com>