0

I am using webkit2gtk in my Vala program to show some pages to the user and webkit2gtk-web-extension to manage DOM. But I can't use these 2 packages at the same time because of the build error. When I add these 2 packages to the cmake system, it shows this error:

webkit2gtk-web-extension-4.0.vapi:2619.2-2619.38: error: `WebKit' already contains a definition for `URIRequest'
    public class URIRequest : GLib.Object {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webkit2gtk-4.0.vapi:488.2-488.38: note: previous definition of `URIRequest' was here
    public class URIRequest : GLib.Object {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webkit2gtk-web-extension-4.0.vapi:2628.2-2628.39: error: `WebKit' already contains a definition for `URIResponse'
    public class URIResponse : GLib.Object {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
webkit2gtk-4.0.vapi:497.2-497.39: note: previous definition of `URIResponse' was here
    public class URIResponse : GLib.Object {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If I remove one of the packages from the CMakeLists.txt, either WebKit.WebView or WebKit.Webpage is not found.

Maybe this is caused by the fact that I build the webkit2gtk-4.0 package myself and didn't use the repositories version, I don't know.

So, the question: how to manage it?

serge1peshcoff
  • 4,342
  • 11
  • 45
  • 76

2 Answers2

1

Building upon nemequ's answer. Those two libraries cannot be used at the same time, etc. The Webkit2GTK-4.0 binding(s) needs work to support DOM Manipulation. Specifically the WebKit2GTK Binding needs JSCore support. Without JSCore it is difficult if not possible to modify the JS Context within WebKit2GTK. Atleast this is how it is setup in WebKitGtk-3.

In the meantime, You can actually use WebKitGtk-3.0 DaveDoesDev has a perfect tutorial on this listed here: http://www.davedoesdev.com/wrapping-webkit-part-1-gtk+-vala/

You can view a working implimentation here: https://github.com/CT-Architecture/AbstractStudio-Baseline/blob/master/src/widgets/webkitView.vala

This is the JSCore Vapi: https://github.com/CT-Architecture/AbstractStudio-Baseline/blob/master/vapi/javascriptcore.vapi

Chris Timberlake
  • 490
  • 4
  • 16
  • It would be nice if you could file a bug about what exactly needs work in Webkit2-4.0. Bugs are unlikely to get fixed unless someone lets us know about them, especially since (AFAIK) none of the Vala developers use WebKit in their other projects. – nemequ Dec 30 '14 at 19:06
  • JSCore needs to be ported to Webkit2GTK. Exact details of that i'm not entirely sure. Thus a bug report hasn't been filed. – Chris Timberlake Dec 30 '14 at 19:18
  • You said "The Webkit2GTK-4.0 binding needs work to support DOM Manipulation", that's what I'm asking about. AFAIK that should be unrelated to JSCore, and I'm not currently aware of any bugs in the Webkit2-4.0 bindings. – nemequ Dec 30 '14 at 19:23
  • I consider JSCore to be integral to WebKit2's bindings due to the fact without it you really can't modify the DOM Via Javascript. I've revised my answer to be more clear however. – Chris Timberlake Dec 31 '14 at 17:36
0

Those two packages cannot be used at the same time. This isn't an issue with the Vala bindings—the same is true at the C level, and it is by design.

nemequ
  • 16,623
  • 1
  • 43
  • 62
  • Specifically, `webkit2gtk-4.0` is for your main program and `webkit2gtk-web-extension` is for your web extension, which should be a plugin that is loaded by WebKit's web process. – ptomato Dec 24 '14 at 06:09
  • Oh, I understand now. Is there any way to manage DOM inside WebVIew then? – serge1peshcoff Dec 24 '14 at 06:37