Here is your standard GTK-Server demo in S-Lang. (FIFO Interface)
%
% Tested with S-Lang 1.4.9 on Slackware 10 --- http://www.s-lang.org/
%
% Feb 26, 2005 - PvE.
% Revised for GTK-server 2.0.6 at december 17, 2005
% Tested with S-Lang 2.1.4 and GTK-server 2.3.1 at december 17, 2008.
%
%--------------------------------------------------------------------
define gtk(str)
{
variable fp, buf;
fp = fopen ("/tmp/demo.sl", "a");
() = fputs (str, fp);
() = fclose (fp);
fp = fopen ("/tmp/demo.sl", "r");
() = fgets (&buf, fp);
() = fclose (fp);
return buf;
}
% Declare variables
variable WIN, TBL, BUT, LAB, EVENT;
% Start GTK-server and wait for initialization
() = system ("gtk-server -fifo=/tmp/demo.sl -detach");
% Build GUI
() = gtk ("gtk_init NULL NULL");
WIN = gtk ("gtk_window_new 0");
() = gtk ("gtk_widget_set_usize " + WIN + " 300 100");
() = gtk ("gtk_window_set_title " + WIN + " \"S-Lang with GTK\"");
() = gtk ("gtk_window_set_position " + WIN + " 1");
TBL = gtk ("gtk_table_new 20 20 1");
() = gtk ("gtk_container_add " + WIN + " " + TBL);
BUT = gtk ("gtk_button_new_with_label \"Click to Quit\"");
() = gtk ("gtk_table_attach_defaults " + TBL + " " + BUT + " 12 19 12 19");
LAB = gtk ("gtk_label_new \"S-Lang uses GTK now!!\"");
() = gtk ("gtk_table_attach_defaults " + TBL + " " + LAB + " 1 15 1 10");
() = gtk ("gtk_widget_show_all " + WIN);
% Mainloop
do {
EVENT = gtk("gtk_server_callback wait");
} while (EVENT != BUT and EVENT != WIN);
% Exit GTK-server
() = gtk ("gtk_server_exit");
% Exit
exit (0);
* Requires standalone GTK-Server