I've tried loading a local html file using webkit_web_view_load_uri()
with a file://
URL. However, the webview would display a blank page. To circumvent this, I tried using webkit_web_view_load_html()
and it worked correctly.
Now that I'm trying to load some images in the html using the <img>
tag, the images aren't loaded (It displays a blank page).
I'm puzzled because I tried before (~ 2 months ago) a similar method and it worked.
Note: I copied the contents of the generated HTML into a file and loaded it with Firefox and it worked as it should (The images are visible), but with another WebKitGtk application I had lying around the images didn't load.
Note: I'm using C++ as the main programming language (I'd prefer having C++ types in the solutions only if possible)
Note: I have set webkit_settings_set_allow_file_access_from_file_urls()
and webkit_settings_set_allow_universal_access_from_file_urls()
to TRUE
Ok, I've managed to solve this. The solution had NOTHING to do with webkitgtk, which is strange. It seems that the application was trying to download the page instead of loading it. This traces to a faulty MIME type database.
Tl;Dr:
Execute this:
rm ~/.local/share/mime/packages/user-extension-html.xml
update-mime-database ~/.local/share/mime
and use webkit_web_view_load_uri()
instead of webkit_web_view_load_html()
with a file://
URI