mail-archives/gtk-sharp-list/2004-February/003422.html

87 строки
3.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] connect_after issues
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mkestner%40ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="003419.html">
<LINK REL="Next" HREF="003420.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] connect_after issues
</H1>
<B>Mike Kestner
</B>
<A HREF="mailto:mkestner%40ximian.com"
TITLE="[Gtk-sharp-list] connect_after issues">mkestner@ximian.com
</A><BR>
<I>Wed, 18 Feb 2004 17:30:04 -0600</I>
<P><UL>
<LI> Previous message: <A HREF="003419.html">[Gtk-sharp-list] connect_after issues
</A></li>
<LI> Next message: <A HREF="003420.html">[Gtk-sharp-list] [PATCH] GLib.Value as a struct
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#3422">[ date ]</a>
<a href="thread.html#3422">[ thread ]</a>
<a href="subject.html#3422">[ subject ]</a>
<a href="author.html#3422">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>On Wed, 2004-02-18 at 16:15, Thiago Milczarek Sayão wrote:
&gt;<i> I still wonder why people would want to connect_after things ??
</I>&gt;<i> As a gtk binding, gtk# should follow what is standard in gtk which is
</I>&gt;<i> connect_before. (see g_signal_connect ()).
</I>
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.
&gt;<i> I was told at #mono that i could connect_before extending the class and
</I>&gt;<i> overriding the event method. That doesn't work. See the example
</I>&gt;<i> attached.
</I>
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 &quot;protected&quot; 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
RegisterGType.
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 &lt;<A HREF="mailto:mkestner@ximian.com">mkestner@ximian.com</A>&gt;
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="003419.html">[Gtk-sharp-list] connect_after issues
</A></li>
<LI> Next message: <A HREF="003420.html">[Gtk-sharp-list] [PATCH] GLib.Value as a struct
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#3422">[ date ]</a>
<a href="thread.html#3422">[ thread ]</a>
<a href="subject.html#3422">[ subject ]</a>
<a href="author.html#3422">[ author ]</a>
</LI>
</UL>
</body></html>