From ca1df83585c912a91d37a51b1ea046b872dfdfe3 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Tue, 21 Oct 2008 22:08:47 +0000 Subject: [PATCH] 2008-10-21 Mike Kestner * gtkhtml/HTML.custom: copy in previously generated signal marshaler from 2-16 branch since url-requested signal exposes a G_TYPE_POINTER parameter that can't be marshaled automatically by SignalClosure. [Fixes #436298] svn path=/trunk/gnome-desktop-sharp/; revision=116682 --- ChangeLog | 7 ++++ gtkhtml/HTML.custom | 72 ++++++++++++++++++++++++++++++++++ gtkhtml/Makefile.am | 3 +- gtkhtml/UrlRequestedHandler.cs | 24 ++++++++++++ gtkhtml/metadata | 1 + 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 gtkhtml/UrlRequestedHandler.cs diff --git a/ChangeLog b/ChangeLog index 9e2f685..e034066 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-10-21 Mike Kestner + + * gtkhtml/HTML.custom: copy in previously generated signal marshaler + from 2-16 branch since url-requested signal exposes a G_TYPE_POINTER + parameter that can't be marshaled automatically by SignalClosure. + [Fixes #436298] + 2008-09-08 Mike Kestner * configure.in: make gnome-sharp-2.0 an unconditional dependency. diff --git a/gtkhtml/HTML.custom b/gtkhtml/HTML.custom index 11d6b7a..7ffa550 100644 --- a/gtkhtml/HTML.custom +++ b/gtkhtml/HTML.custom @@ -55,3 +55,75 @@ Write (handle, buffer, (ulong) size); } + [GLib.CDeclCallback] + delegate void UrlRequestedSignalDelegate (IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr gch); + + static void UrlRequestedSignalCallback (IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr gch) + { + Gtk.UrlRequestedArgs args = new Gtk.UrlRequestedArgs (); + try { + GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal; + if (sig == null) + throw new Exception("Unknown signal GC handle received " + gch); + + args.Args = new object[2]; + args.Args[0] = GLib.Marshaller.Utf8PtrToString (arg1); + args.Args[1] = arg2 == IntPtr.Zero ? null : (Gtk.HTMLStream) GLib.Opaque.GetOpaque (arg2, typeof (Gtk.HTMLStream), false); + Gtk.UrlRequestedHandler handler = (Gtk.UrlRequestedHandler) sig.Handler; + handler (GLib.Object.GetObject (arg0), args); + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + } + } + + [GLib.CDeclCallback] + delegate void UrlRequestedVMDelegate (IntPtr html, IntPtr url, IntPtr handle); + + static UrlRequestedVMDelegate UrlRequestedVMCallback; + + static void urlrequested_cb (IntPtr html, IntPtr url, IntPtr handle) + { + try { + HTML html_managed = GLib.Object.GetObject (html, false) as HTML; + html_managed.OnUrlRequested (GLib.Marshaller.Utf8PtrToString (url), handle == IntPtr.Zero ? null : (Gtk.HTMLStream) GLib.Opaque.GetOpaque (handle, typeof (Gtk.HTMLStream), false)); + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + } + } + + private static void OverrideUrlRequested (GLib.GType gtype) + { + if (UrlRequestedVMCallback == null) + UrlRequestedVMCallback = new UrlRequestedVMDelegate (urlrequested_cb); + OverrideVirtualMethod (gtype, "url_requested", UrlRequestedVMCallback); + } + + [GLib.DefaultSignalHandler(Type=typeof(Gtk.HTML), ConnectionMethod="OverrideUrlRequested")] + protected virtual void OnUrlRequested (string url, Gtk.HTMLStream handle) + { + GLib.Value ret = GLib.Value.Empty; + GLib.ValueArray inst_and_params = new GLib.ValueArray (3); + GLib.Value[] vals = new GLib.Value [3]; + vals [0] = new GLib.Value (this); + inst_and_params.Append (vals [0]); + vals [1] = new GLib.Value (url); + inst_and_params.Append (vals [1]); + vals [2] = new GLib.Value (handle); + inst_and_params.Append (vals [2]); + g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret); + foreach (GLib.Value v in vals) + v.Dispose (); + } + + [GLib.Signal("url_requested")] + public event Gtk.UrlRequestedHandler UrlRequested { + add { + GLib.Signal sig = GLib.Signal.Lookup (this, "url_requested", new UrlRequestedSignalDelegate(UrlRequestedSignalCallback)); + sig.AddDelegate (value); + } + remove { + GLib.Signal sig = GLib.Signal.Lookup (this, "url_requested", new UrlRequestedSignalDelegate(UrlRequestedSignalCallback)); + sig.RemoveDelegate (value); + } + } + diff --git a/gtkhtml/Makefile.am b/gtkhtml/Makefile.am index 7714e68..51867a0 100644 --- a/gtkhtml/Makefile.am +++ b/gtkhtml/Makefile.am @@ -16,7 +16,8 @@ METADATA = metadata references = glue_args = --glue-includes=gtkhtml/gtkhtml.h,gtkhtml/gtkhtml-embedded.h --gluelib-name=gtkhtmlsharpglue-2 --glue-filename=glue/generated.c -sources = +sources = \ + UrlRequestedHandler.cs customs = \ HTML.custom \ diff --git a/gtkhtml/UrlRequestedHandler.cs b/gtkhtml/UrlRequestedHandler.cs new file mode 100644 index 0000000..2cda6c6 --- /dev/null +++ b/gtkhtml/UrlRequestedHandler.cs @@ -0,0 +1,24 @@ +// This file was generated by the Gtk# code generator. +// Any changes made will be lost if regenerated. + +namespace Gtk { + + using System; + + public delegate void UrlRequestedHandler(object o, UrlRequestedArgs args); + + public class UrlRequestedArgs : GLib.SignalArgs { + public string Url{ + get { + return (string) Args[0]; + } + } + + public Gtk.HTMLStream Handle{ + get { + return (Gtk.HTMLStream) Args[1]; + } + } + + } +} diff --git a/gtkhtml/metadata b/gtkhtml/metadata index 856ecab..fa364d9 100644 --- a/gtkhtml/metadata +++ b/gtkhtml/metadata @@ -4,6 +4,7 @@ 1 1 OnCommand + 1 Begin Begin Search