File: WebKitHtmlRender.cs

package info (click to toggle)
mono-tools 4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 13,868 kB
  • sloc: cs: 100,909; sh: 3,845; makefile: 2,040; xml: 126
file content (91 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (8)
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
//
// WebKitHtmlRender.cs: Implementation of IHtmlRender that uses WebKit
//
// Author: Alp Toker <alp@nuanti.com>
//

using System;
using System.IO;
using Gtk;
using WebKit;

namespace Monodoc {
public class WebKitHtmlRender : IHtmlRender {

	WebView web_view;
	public Widget HtmlPanel {
		get { return (Widget) web_view; }
	}

	string url;
	public string Url {
		get { return url; }
	}

	RootTree help_tree;
	public event EventHandler OnUrl;
	public event EventHandler UrlClicked;

	public WebKitHtmlRender (RootTree help_tree) 
	{
		web_view = new WebView ();
		web_view.Show (); 
		web_view.NavigationRequested += delegate (object sender, NavigationRequestedArgs e) {
			if (e.Request.Uri == "about:blank")
				return;
			url = e.Request.Uri;
			if (UrlClicked != null)
				UrlClicked (this, new EventArgs());
			e.RetVal = NavigationResponse.Ignore;
		};
		web_view.HoveringOverLink += delegate (object sender, HoveringOverLinkArgs e) {
			url = e.Link;
			if (OnUrl != null)
			  OnUrl (this, new EventArgs ());
		};
		this.help_tree = help_tree;
	}

	public void JumpToAnchor (string anchor)
	{
		web_view.Open ("#" + anchor);
	}

	public void Copy () 
	{
		web_view.CopyClipboard ();
	}

	public void SelectAll () 
	{
		web_view.SelectAll ();	
	}

	public void Render (string html) 
	{
		web_view.LoadHtmlString (html, null);
	}

	public void Print (string html)
	{
		web_view.ExecuteScript ("print();");
	}

	public bool Initialize ()
	{
		return true;
	}

	public Capabilities Capabilities
	{
		get { return Capabilities.Css | Capabilities.Fonts; }
	}

	public string Name
	{
		get { return "WebKit"; }
	}


}
}