Can't use webkit2gtk-4.0 and webkit2gtk-web-extension-4.0 in my program at the same time

2.5k views Asked by At

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?

2

There are 2 answers

4
Chris Timberlake On BEST ANSWER

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

2
nemequ On

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.