segunda-feira, 25 de abril de 2011

Mono WebBrowser with WebKit [Gtk# not WinForms] « configuration: debug

Mono WebBrowser with WebKit [Gtk# not WinForms] « configuration: debug: "– Enviado usando a Barra de Ferramentas Google"

For long time I have looking for displayin web pages on Mono by using Gtk#…And thanks to this post I came across with WebKit solution!

monologo

WebKit is as they define in their page:

WebKit is an open source web browser engine. WebKit is also the name of the Mac OS X system framework version of the engine that’s used by Safari, Dashboard, Mail, and many other OS X applications. WebKit’s HTML and JavaScript code began as a branch of the KHTML and KJS libraries from KDE. This website is also the home of S60‘s S60 WebKit development.

Well after looking to the simple solution that is made in shana.worldofcoding.com, I give a try to my solution and here it is:

01
using System;
02using Gtk;
03using WebKit;
04
05namespace browserapp {
06 class browser {
07
08 public static void Main () {
09 Application.Init ();
10 Window window = new Window ("BROWSER");
11 window.SetSizeRequest(240,300)
12
13<div id=":h0">
14
;
15 window.Destroyed += delegate (object sender, EventArgs e) {
16 Application.Quit ();
17 };
18 ScrolledWindow scrollWindow = new ScrolledWindow ();
19 WebView webView = new WebView ();
20 webView.SetSizeRequest(240,250);
21 webView.Open ("mono-project.com");
22 scrollWindow.Add (webView);
23
24 Label name=new Label();
25 name.Text="BrowserExample:";
26
27 Fixed fixed1=new Fixed();
28 fixed1.SetSizeRequest(240,300);
29
30 fixed1.Put(name,0,0);
31 fixed1.Put(scrollWindow,0,50);
32
33 window.Add (fixed1);
34 window.ShowAll ();
35 Application.Run ();
36 }
37 }
38}
39
40

In my Debian Lenny:

“apt-get install mono-2.0-devel gtk-sharp2 libwebkit1.0-cil”

“gmcs -pkg:gtk-sharp-2.0 -pkg:webkit-sharp-1.0 web.cs”

“mono web.exe”

The Ouput:

Reference:

[1.] http://shana.worldofcoding.com/en/browser.html

Nenhum comentário: