Indeed, Seed comes in two flavors:
- As a command line interpreter (/usr/bin/seed).
- As a C library (libseed).
A simple Seed script
To install Seed in Ubuntu, type:
$ sudo apt-get install seed libseed-gtk3-dev
This is a simple GTK+ program, which just shows a window with a button.
#!/usr/bin/seed /* Imports GTK+ libraries */ Gtk = imports.gi.Gtk; /* Inits GTK+ */ Gtk.init(null, null); /* Creates window */ var window = new Gtk.Window(); /* Terminates program if window is closed */ window.signal.hide.connect(Gtk.main_quit); /* Creates button */ var button = new Gtk.Button(); button.set_label('Hello world'); /* Terminates program if button is clicked */ button.signal.clicked.connect(Gtk.main_quit); /* Add button to window */ window.add(button); /* Shows */ window.set_default_size(100,100); window.show_all(); /* Main loop */ Gtk.main();
To run it:
$ seed gtk.js
WebViews and Seed
This the source code of our program which exposes Seed libraries to a WebKitGTK+ web view.
To compile it, type:
$ gcc -o webkit-seed webkit-seed.c `pkg-config --cflags --libs webkitgtk-3.0 seed`
And this is the webkit-seed.html file:
To run the program:
This time, the browser will appear, but the fun action will be in the /tmp directory. There we'll found a new SQLite 3 database, with a two-field table.
P.S.: Of course, I tried to run the GTK+ example inside the WebView. Unfortunately, it didn't work :-(