[webkit-gtk] Interface between embedded Javascript and the main GTK app
Gavin Smith
gavinsmith0123 at gmail.com
Sun Aug 18 04:25:08 PDT 2024
On Sun, Aug 18, 2024 at 11:27:43AM +0300, Sim Tov wrote:
> Anybody?... Is it possible to pass a string from a JavaScript running
> inside WebKitGTK to the main GTK app to be used inside another widget?
If I understand your question you want to pass information from the
process running the browser to the main process that runs the GTK UI.
You should be able to use normal IPC processes. You can see an example
of doing this with sockets in the Texinfo sources:
https://git.savannah.gnu.org/cgit/texinfo.git/commit/infog/extension.c?id=e0928ef5109cc32b75af52232a03cc23e4b8817c
https://git.savannah.gnu.org/cgit/texinfo.git/commit/infog/main.c?id=e0928ef5109cc32b75af52232a03cc23e4b8817c
The program here is a help browser for HTML documentation. The browser
process extracts information from the HTML files using JavaScript, for
example document indices (in extension.c:send_index). This information is
then passed to the main process with the 'packetize' and 'send_datagram'
functions in extension.c. In the main process this is received by
main.c:socket_cb, which is the callback on the "GSocket" object.
It has been a few years since I worked on this and there may be better
ways of doing this.
>
> On Tue, Aug 13, 2024 at 5:52 PM Sim Tov <smntov at gmail.com> wrote:
>
> > I have a GtkTextView that contains a Markdown-like document. I also have a
> > WebKitGTK that contains a JavaScript that can parse and convert Markdown to
> > HTML. I want to pass the Markdown document to JavaScript to be rendered and
> > displayed in the WebKitGTK. While parsing, JavaScript produces json that
> > contains all recognized markup. I want to pass that json as a string back
> > to GtkTextView somehow so it can highlight the Markdown document with
> > different colors/styles etc. there. This way one can implement Markdown
> > Live Preview (in WebKitGTK) while also having its source highlighted (in
> > GtkTextView) - both by the same code. All this while user types...
> >
> > Is this possible? If yes - how?
> >
> > Thank you!
> >
> _______________________________________________
> webkit-gtk mailing list
> webkit-gtk at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-gtk
More information about the webkit-gtk
mailing list