How to create a multi-process webkitgtk application (Vala)?
I want to make a web browser in Vala using webkit.
But, I don't know how to开发者_运维知识库 make it multi-process.
I want each tab to have its own process.
How can I do that using Vala and Gtk+.
Thanks for your answer.
Check out Gtk.Plug
and Gtk.Socket
. You'll need to put a Gtk.Socket
in each tab you open. Then spawn a process using one of the GLib.Process
functions, and in that process construct a Gtk.Plug
containing your WebView
. Then you'll need some way of inter-process communication, for one thing to connect your plug to your socket, and to pass commands from your user-interface to the webview (such as "make the font larger").
It looks like the Vala documentation doesn't contain very much explanation, you might want to check out the C documentation for more information on how plugs and sockets work.
EDIT:
You asked for more information on inter-process communication. There are several ways, and I'm not sure which one is the most appropriate for you. Perhaps you can try GLib.Process.spawn_async_with_pipes()
to start your child process and get file descriptors for the child's standard input and output. You can then pass these file descriptors to GLib.IOChannel.unix_new()
to pass messages back and forth between your processes.
Another way is to use DBus, but that's more complicated and less documented.
You may want to use GtkPlug see this discussion in Vala-list (and gtk forum).
精彩评论