File: HTML.custom

package info (click to toggle)
gnome-desktop-sharp2 2.26.0-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,768 kB
  • ctags: 73
  • sloc: sh: 9,300; makefile: 397; xml: 196; cs: 143; perl: 32; ansic: 24
file content (129 lines) | stat: -rw-r--r-- 4,592 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Gtk.HTML.custom - Gtk HTML class customizations
//
// Author: Mike Kestner <mkestner@ximian.com> 
//
// Copyright (C) 2004 Novell, Inc.
//
// This code is inserted after the automatically generated code.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General 
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
		
		[DllImport("gtkhtml-3.0")]
		static extern IntPtr gtk_html_new();

		public HTML () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (HTML)) {
				CreateNativeObject (new string [0], new GLib.Value[0]);
				Construct ();
				return;
			}
			Raw = gtk_html_new();
		}

		[DllImport("gtkhtml-3.0")]
		static extern IntPtr gtk_html_new_from_string(IntPtr Astr, int len);

		public HTML (string Astr) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (HTML)) {
				CreateNativeObject (new string [0], new GLib.Value[0]);
				Construct ();
				LoadFromString (Astr);
				return;
			}

			IntPtr native = GLib.Marshaller.StringToPtrGStrdup (Astr);
			Raw = gtk_html_new_from_string (native, -1);
			GLib.Marshaller.Free (native);
		}

		public void Write (HTMLStream handle, string buffer, int size)
		{
			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);
			}
		}