Sunday, May 29, 2011

Webkit based WebBrowser written in #Mono (C#) + #Firebird Step 1

I will start with this simple example


Install monodevelop and the mono.webkit (aka webkit-sharp)

sudo apt-get install gtk-sharp2 libwebkit1.1-cil monodevelop

start monodevelop new gtk c# project (copy paste the code from above to match your app main class and namespace my are: coolbrowser,monobrowser)

But i didn't found in the list of installed assemblies
so i use my rusty admin skills and install from git and from webkit-sharp source

git clone https://github.com/mono/webkit-sharp.git

it didn't found the webkit dev libs and the mcs so

sudo apt-get install libwebkit-cil-dev libwebkit-dev
sudo ln -s /usr/bin/gmcs /usr/bin/mcs

./autogen.sh --prefix=/usr
sudo make install

add webkit references to the project


here is the code
using System;
using Gtk;
using WebKit;
namespace monobrowser {
class coolbrowser {
public static void Main () {
Application.Init ();
Window window = new Window ("a browser in 13 lines...");
window.SetDefaultSize(800,600);
window.Destroyed += delegate (object sender, EventArgs e) {
Application.Quit ();
};
ScrolledWindow scrollWindow = new ScrolledWindow ();
WebView webView = new WebView ();
webView.Open ("http://mono-project.com");
scrollWindow.Add (webView);
window.Add (scrollWindow);
window.ShowAll ();
Application.Run ();
}
}
}
view raw monobrowser.cs hosted with ❤ by GitHub


I have added the default size to be 800x600

3 comments:

imboe said...

Hi, I've been trying to follow your instructions and got a error while trying to build webkit-sharp:

error CS2001: Source file `generated/*.cs' could not be found

I have no idea how to fix it, can you please share a webkit-sharp.dll file somehow? Thanks.

Unknown said...

Hi,

I also wrote an applicationwith the webkit, But now I want to display a horizontal or a vertical scrollbar when the window is resized. How can i do that?

yavas said...

Thanks from Colombia, very useful!!