tags:

views:

76

answers:

3

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.

A: 

You may want to use GtkPlug see this discussion in Vala-list (and gtk forum).

elmarco
+1  A: 

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.

ptomato
Hello, thanks for your answer.I don't know how to use Glib.Process.I follow a tutoriel about Plugs and Sockets (gtkmm book - http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-plugs-sockets-example.html.en), but the way of transmitting the window ID is not very appropriate (in a file).So, how can I communicate between two processes using Glib.Process ?I did that to launch the other process (C++) :list<string> myList;myList.push_back("../Plug/Plug");Glib::spawn_async(".", myList);which launch the process but, I want to communicate between them.How ?Thanks for your answer.
antoyo
See my updated answer.
ptomato
A: 

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.

antoyo
You should only put answers to your own question here. Nobody will find this question here (I only found it because you accepted my above answer, thanks ;-), so if you want answers you should delete it and open a new question.
ptomato

related questions