Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtk-based Mono.WebBrowser on Windows

Tags:

c#

webkit

mono

gtk

I'm trying to come up with the simplest example of using the Mono.WebBrowser using Gtk on Windows. The Windows.Forms version works fine (the default if you don't specify Platform.Gtk), but I need to integrate into an existing Gtk cross-platform application.

Here is a simple example:

public static void Main (string[] args)
{
    Gtk.Application.Init ();
    Gtk.Window win = new Gtk.Window ("Title");
    Mono.WebBrowser.IWebBrowser browser =
        Mono.WebBrowser.Manager.GetNewInstance(Mono.WebBrowser.Platform.Gtk);
    browser.Load(win.Handle, 500, 250);
    win.ShowAll ();
    GLib.Timeout.Add( 500, delegate {
        browser.Navigation.Go ("http://google.com/");
        return false;
    });
    Gtk.Application.Run ();
}

which compiles, runs, and browser.Initialized is true. But it doesn't render into a Gtk.Window (or any other Gtk.widget I have tried). What triggers the browser to actually render itself? It may be that I can't render this directly into a Window (I've looked at the mono-docbrowser [1] source, and have a more complicated example, but it doesn't render either).

I have looked at webkit-sharp, but can't get it to work on Windows or Mac with Gtk.

[1] https://github.com/mono/mono-tools/tree/master/docbrowser

like image 814
Doug Blank Avatar asked Feb 11 '13 14:02

Doug Blank


1 Answers

I can't recall exactly where, but I read somewhere that the Mono.WebBrowser namespace was somehow deprecated in favor of WebkitSharp.

I tried something like that before, but I used webkit-sharp.dll from my linux distribution. Tried to compile it and run it on windows but it did not worked. So it turned out that I was missing the webkit-gtk dll which is the one that actually renders the whole thing (webkit-sharp is just glue-code, a wrapper if you will)

I sent an email back then to one of the maintainers (Andreia Gaita) and got a response that might help you (about using webkit-sharp in windows/osx) drop me a line and I'll forward you that mail.

like image 84
Gustavo Rubio Avatar answered Nov 13 '22 12:11

Gustavo Rubio