[Gtk-sharp-list] unused g_signal_connect_data parameters

Petr Danecek danecek@ucl.cas.cz
26 Feb 2003 14:03:16 +0100


--=-a6FMhdg8u2UuqqQ4q+rK
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello everybody,
I'd like to discuss the following problem concerning signal handlers in 
gtk#. 

So far the autogenerated handlers (such as
voidObjectTextIterstringintSignal) use for the argument "flags" to
g_signal_connect_data a default value 0. I think that it would be
helpful to pass other values as well - G_CONNECT_AFTER, for instance.

Now, how to do this? Bellow is my patch to generator/Signal.cs,
generator/SignalHandler.cs and api/gtk-api.xml. Obviously, the thing
needs to be done differently, because 1) gtk-api.xml is autogenerated
and 2) my solution takes advantage of xml attribute "when", which seems
to be unused, but which purpose I do not know.

What do you think?
Petr



--=-a6FMhdg8u2UuqqQ4q+rK
Content-Disposition: attachment; filename=file.diff
Content-Type: text/x-patch; name=file.diff; charset=ISO-8859-2
Content-Transfer-Encoding: 7bit

Index: api/gtk-api.xml
===================================================================
RCS file: /cvs/public/gtk-sharp/api/gtk-api.xml,v
retrieving revision 1.26
diff -u -U2 -r1.26 gtk-api.xml
--- api/gtk-api.xml	22 Feb 2003 04:34:55 -0000	1.26
+++ api/gtk-api.xml	26 Feb 2003 12:56:09 -0000
@@ -6233,4 +6233,13 @@
         </parameters>
       </signal>
+      <signal name="InsertTextAfter" cname="insert_text" when="AFTER">
+        <return-type type="void"/>
+        <parameters>
+          <parameter type="GtkTextBuffer*" name="buffer"/>
+          <parameter type="GtkTextIter*" name="pos"/>
+          <parameter type="const-gchar*" name="text"/>
+          <parameter type="gint" name="length"/>
+        </parameters>
+      </signal>
       <signal name="PixbufInserted" cname="insert_pixbuf" when="LAST">
         <return-type type="void"/>
Index: generator/Signal.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/Signal.cs,v
retrieving revision 1.13
diff -u -U2 -r1.13 Signal.cs
--- generator/Signal.cs	26 Feb 2003 02:16:38 -0000	1.13
+++ generator/Signal.cs	26 Feb 2003 12:56:09 -0000
@@ -164,5 +164,8 @@
 			if (argsname != "System.EventArgs")
 				sw.Write("," + container_type.NS.ToLower() + "-sharp");
-			sw.WriteLine("\"));\n\t\t\t\telse");
+			sw.Write("\")");
+			if ( this.elem.GetAttribute("when") == "AFTER" )
+				sw.Write(", 1");
+			sw.WriteLine(");\n\t\t\t\telse");
 			sw.WriteLine("\t\t\t\t\t((GtkSharp.SignalCallback) Signals [{0}]).AddDelegate (value);", cname);
 			sw.WriteLine("\t\t\t\tEventList.AddHandler(" + cname + ", value);");
Index: generator/SignalHandler.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/generator/SignalHandler.cs,v
retrieving revision 1.21
diff -u -U2 -r1.21 SignalHandler.cs
--- generator/SignalHandler.cs	26 Feb 2003 02:16:38 -0000	1.21
+++ generator/SignalHandler.cs	26 Feb 2003 12:56:09 -0000
@@ -182,4 +182,15 @@
 			sw.WriteLine("\t\t}");
 			sw.WriteLine();
+			sw.Write("\t\tpublic " + sname + "(GLib.Object obj, IntPtr raw, ");
+			sw.WriteLine("String name, Delegate eh, Type argstype, int flags) : base(obj, eh, argstype)");
+			sw.WriteLine("\t\t{");
+			sw.WriteLine("\t\t\tif (_Delegate == null) {");
+			sw.WriteLine("\t\t\t\t_Delegate = new " + dname + "(" + cbname + ");");
+			sw.WriteLine("\t\t\t}");
+			sw.WriteLine("\t\t\t_raw = raw;");
+			sw.Write("\t\t\t_HandlerID = g_signal_connect_data(raw, name, ");
+			sw.WriteLine("_Delegate, _key, new IntPtr(0), flags);");
+			sw.WriteLine("\t\t}");
+			sw.WriteLine();
 			sw.WriteLine("\t\t[DllImport(\"libgobject-2.0-0.dll\")]");
 			sw.WriteLine("\t\tstatic extern void g_signal_handler_disconnect (IntPtr instance, uint handler);");

--=-a6FMhdg8u2UuqqQ4q+rK--