Hello, 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.
Hello, 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.
You may want to use GtkPlug see this discussion in Vala-list (and gtk forum).
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.
Edit : I forgot a "null" parameter before "out numEntree" ; now it’s working. Thanks.
Hello ! I tried to make something working, but I failed. I tried with a chess software (gnuchess).
Here is my code :
public class Main {
public static int main(string[] args) {
Gtk.init(ref args);
Gtk.Window window = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
window.set_default_size(300, 200);
window.destroy.connect(Gtk.main_quit);
int numEntree = 0;
int numSortie = 0;
string[] commande = {"gnuchess"};
GLib.Process.spawn_async_with_pipes("/usr/games/", commande, null,
GLib.SpawnFlags.FILE_AND_ARGV_ZERO, null, out numEntree, out numSortie);
GLib.IOChannel sortie = new GLib.IOChannel.unix_new(numSortie);
GLib.IOChannel entree = new GLib.IOChannel.unix_new(numEntree);
string ligne = "";
if(sortie.read_line(out ligne, null, null) != GLib.IOStatus.ERROR) {
window.add(new Gtk.Label(ligne));
}
window.show_all();
Gtk.main();
return 0;
}
}
I got these errors at the execution :
(Commande2:18155): GLib-WARNING **: /build/buildd/glib2.0-2.24.1/glib/giounix.c:406Error while getting flags for FD: Mauvais descripteur de fichier (9)
(Commande2:18155): GLib-CRITICAL **: g_io_channel_read_line: assertion `channel->is_readable' failed
The terminal show the lines I want my program to read :
GNU Chess 5.07 Adjusting HashSize to 1024 slots Transposition table: Entries=1K Size=40K Pawn hash table: Entries=0K Size=28K
And I got a lot of :
White (1) : Illegal move:
but I am not supposed to.
What is wrong in that code ?
Thanks for your help.