TOPIC: Suneido call GTK (enjoy)
#1026
Suneido call GTK (enjoy) 2 Years, 10 Months ago
Well no Rocket science at all but interesting;

A made a few test on how the GTK Server and Scripting languages are working together, and I have to say, for just an hour or so, I have to say I am impressed:
A few lines of code to give you an idea, later some links:
Code:


/* Welcome to Suneido */
gtkserver = SocketClient("192.168.1.10", 50000,60);
//Alert(gtkserver.Readline());

gtkserver.Writeline("gtk_init NULL NULL"');
tmp = gtkserver.Readline();
Print(tmp);

gtkserver.Writeline("gtk_window_new 0"');
win = gtkserver.Readline();
Print(win);
gtkserver.Writeline("gtk_window_set_title " $ win $ "Suneido calls GTK-Server with TCP"');
tmp = gtkserver.Readline();
Print (tmp);

gtkserver.Writeline("gtk_widget_set_usize " $ win $ " 450 400"');
tmp = gtkserver.Readline();
Print(tmp);

gtkserver.Writeline("gtk_table_new 50 50 1"');
table = gtkserver.Readline();
Print(table);

gtkserver.Writeline("gtk_container_add " $ win $ " " $ table);
tmp = gtkserver.Readline();
Print(tmp);

// the EXIT button
gtkserver.Writeline("gtk_button_new_with_label Exit"');
button = gtkserver.Readline();
Print(button);

gtkserver.Writeline("gtk_table_attach_defaults " $ table $ " " $ button $ " 41 49 45 49"');
tmp = gtkserver.Readline();
Print(tmp);

// an entry field
gtkserver.Writeline("gtk_entry_new"');
entry = gtkserver.Readline();
Print(entry);

gtkserver.Writeline("gtk_table_attach_defaults " $ table $ " " $ entry $ " 1 40 45 49"');
tmp = gtkserver.Readline();
Print(tmp);

// a text field
gtkserver.Writeline("gtk_text_new NULL NULL"');
text = gtkserver.Readline();
Print (text);

gtkserver.Writeline("gtk_table_attach_defaults " $ table $ " " $ text $ " 1 49 8 44"');
tmp = gtkserver.Readline();
Print(tmp);

// now some radio buttons
gtkserver.Writeline("gtk_radio_button_new_with_label_from_widget NULL Yes"');
radio1 = gtkserver.Readline();
Print(radio1);

gtkserver.Writeline("gtk_table_attach_defaults " $ table $ " " $ radio1 $ " 1 10 1 4"');
tmp = gtkserver.Readline();
Print(tmp);

gtkserver.Writeline("gtk_radio_button_new_with_label_from_widget " $ radio1 $ " No"');
radio2 = gtkserver.Readline();
Print(radio2);

gtkserver.Writeline("gtk_table_attach_defaults " $ table $ " " $ radio2 $ " 1 10 4 7"');
tmp = gtkserver.Readline();
Print (tmp);

// the widgets have been created, so show them
gtkserver.Writeline("gtk_widget_show_all " $ win);
tmp = gtkserver.Readline();
Print(tmp);

gtkserver.Writeline("gtk_widget_grab_focus " $ entry);
tmp = gtkserver.Readline();
Print(tmp);

event = "";
while (event != button)
{

gtkserver.Writeline("gtk_server_callback WAIT"');
event = gtkserver.Readline();
Print (tmp);
if (event == entry)
{ gtkserver.Writeline("gtk_entry_get_text " $ entry);
tmp = gtkserver.Readline();
tmp = "" $ '"' $ tmp $ "\n" $ '"';
Print(tmp);
// gtk_text_insert, NONE, NONE, 6, WIDGET, NULL, NULL, NULL, STRING, LONG
gtkserver.Writeline("gtk_text_insert " $ text $ " NULL NULL NULL " $  tmp  $ " -1"');
tmp = gtkserver.Readline();

Print (tmp);
gtkserver.Writeline("gtk_entry_set_text " $ entry $ '"' $ " " $'"');
tmp = gtkserver.Readline();
Print(tmp);
}
}

gtkserver.Writeline("gtk_exit 0"');
gtkserver.Close();




You can try it from the workbench.
GTK-Server:
www.gtk-server.org/
I'll add a second message to keep the things clear...
Bjoern
 
 
#1027
Re:Suneido call GTK (enjoy) 2 Years, 10 Months ago
Suneido function wrapper can be generated automagically by using a python script ;
echempel.freezope.org/programming/mkbinding/FrontPage
The GTK-Server (68 Kb) can run on a dedicated Linux machine and support several Suneido clients.

I've tested it on Win XP,; there are issues. Socket timeout, probabely more a matter of my hack.

To test it :
download the gtk-server and the gtk runtime libs.
istall both, start your shell, f.i.
You can to start the GTK-Server from the command line using :
gtk-server tcp=192.168.1.10:50000
use ipconfig to examine your IP address.

Regards, Bjoern

Post edited by: nana, at: 2007/10/12 17:11
 
 
#1029
Re:Suneido call GTK (enjoy) 2 Years, 10 Months ago
Sounds interesting! I will try it out when I have time.

Thanks!
 
 
andrew
 
#1034
Re:Suneido call GTK (enjoy) 2 Years, 10 Months ago
There are also GTK-Server shared libraries available which can be used. Using the GTK Server this way is probabely more comfortable.

Since I am actually interested in Lisp like lists (CONS)I found out that there is a Java/SWING Server available. For what it's worth, I can say that the SWING Server is really worth a second look.

newlisp.org/

You'll find two screenshots on the main page. A newLips IDE written in newLisp using the SWING Server.
Bjoern