[webkit-gtk] rendering page from gresource

Michael Nazzareno Trimarchi michael at amarulasolutions.com
Mon Mar 22 03:28:54 PDT 2021


Hi

On Mon, Mar 22, 2021 at 11:19 AM Adrian Perez de Castro
<aperez at igalia.com> wrote:
>
> Hello Michael,
>
> On Sun, 21 Mar 2021 20:28:44 +0100 Michael Nazzareno Trimarchi <michael at amarulasolutions.com> wrote:
>
> > I'm playing a bit with Alexa and gtkmm and I'm trying to do really
> > simple things. Read from the resource index.html and main...js
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <gresources>
> >   <gresource prefix="@APPLICATION_PREFIX@">
> >     <file preprocess="xml-stripblanks">ui/window.glade</file>
> >     <file preprocess="xml-stripblanks">ui/headerbar.glade</file>
> >     <file preprocess="xml-stripblanks">ui/preferences.glade</file>
> >     <file preprocess="xml-stripblanks">ui/menu.glade</file>
> >     <file>alexa/index.html</file>
> >     <file>alexa/main.bundle.js</file>
> >     <file>icons/48x48/icon.png</file>
> >   </gresource>
> > </gresources>
> >
> > Things are inside the resource and
> >
> > webview->load_uri(projectdefinitions::getApplicationPrefix() +
> > "alexa/index.html");
> > webview->set_visible();
> >
> > This does not fail but:
> > gtk_on_load_changed(WebKitWebView* webView, WebKitLoadEvent loadEvent,
> > gpointer userData)
> >
> > this is not triggered. If I load from a local file things are ok. Can
> > anyone knows what is going on?
>
> What does “getApplicationPrefix()” return? I suspect that the load-changed
> signal is not being emitted because there is a load error caused by an invalid
> URI, or an URI that has a scheme that is unknown to WebKit.
>
> The best option to make WebKit load content from a GResource bundle is to
> use “webkit_web_context_register_uri_scheme()” to install a custom URI scheme
> handler for resources. You can find the documentation here:
>
>   https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebContext.html#webkit-web-context-register-uri-scheme
>

Yes, I know but ->

resources that are local inside the page need to be loaded so we need
to intercept load resource signals to get them
somehow.

> If you want a more complete code example, GNOME Web (a.k.a. Epiphany) uses
> this. You can see the code here:
>
>   https://gitlab.gnome.org/GNOME/epiphany/-/blob/701aa05d70bb206cee67bfc9e834784f88000a30/embed/ephy-embed-shell.c#L934
>   https://gitlab.gnome.org/GNOME/epiphany/-/blob/701aa05d70bb206cee67bfc9e834784f88000a30/embed/ephy-embed-shell.c#L711
>
> I hope this helps =)

I will give it a try. I think that the change should be landed inside
the webkit gtk component.

Michael
>
> Cheers,
> -Adrian



-- 
Michael Nazzareno Trimarchi
Amarula Solutions Corporate
CEO Co-Founder
Cruquiuskade 47 Amsterdam 1018 AM NL
T. +31(0)851119172
M. +39(0)3479132170
[`as] https://www.amarulasolutions.com


More information about the webkit-gtk mailing list