newLISP and the gtk-server

Started by pjot, February 26, 2004, 02:31:23 PM

Previous topic - Next topic

pjot

Hi Lutz, hi all newLISP users!



Compliments of the day. I am new to this programming language newLISP, but after some attempts to create a couple of programs, I must say: this rules! Why did I not earlier bump into newLISP?



I really like the broad spectrum of extra functions. TK is fine, though, I prefer to use GTK myself. Therefore I have written a small newLISP program to demonstrate that the newLISP language even works with my gtk-server (http://www.turtle.dds.nl/gtk-server/">//http://www.turtle.dds.nl/gtk-server/).  Maybe it is of use for somebody else.



Thank you for this intriguing language (and your C code compiles with -pedantic, amazing),



Regards



Peter.

nigelbrown

#1
Hello Peter,

I tried out gtk-server with newLISP on a winXP-pro laptop.

Rather than doing (process "gtk-server localhost:50000 log")

which with the windows newlisp-tk doesn't keep gtk-server alive I have a batch file

that starts the server in the windows directory where the exe and cfg are

startgtk.bat:

c:

cd c:windows

gtk-server localhost:50000 log



then run the lisp without the (process "gtk-server localhost:50000 log")

and sleep lines. The window comes up fine and the exit button signals via the callback.



However, there is no killall in winxp so I have to ^C the batch file in its

command prompt window to close the gtk window.

Looking through the gtk-server site tutorial I can't see how you can close a window without killing the server - although I admit I've not played around with catching the delete message.



Have you some pointers on using newlisp and gtk-server together on windows?

Regards

Nigel

pjot

#2
Hi Nigel,



Well, I am surprised that it works with the Windows version as well, but OK, it's nice to know.



Indeed your problem is annoying. The programming language Scriptbasic has some kind of "KILL" command. Starting a process returns the PID, which can be used to kill the process again. With GNU Prolog the "close socket" action also kills the gtk-server, but for newLISP this seems not to be the case.



I am afraid this situation only can be resolved by changing the functionality of the gtk-server.



For the Win32 environment I will try to check if a client script is connected, and if not, the gtk-server exits. Since the Win32 version cannot fork itself (like in Linux), it is only possible to have 1 connection at all. So the proposed Win32 functionality will be like this: starting the gtk-server, listening for a connection, if the connection quits exit the gtk-server.



For Linux I will keep things unchanged. I will try to implement this asap and let you know.



Regards



Peter.

pjot

#3
Well, I've uploaded a new gtk-server.exe. You can get it from the same location. Please let me know if it works according to your wishes. If so, I'll release the new sourcecode as well.



Regards



Peter.

Lutz

#4
Hi Peter,



just looked at your home page about GTK-server, seems like an excellent idea to me and I will dig into it a little bit further. At one point I also thaught to use GTK instead of TK for newLISP but at that time GTK wasn't as well developed for Win32. I wonder if it is now also available for the Mac OS X?



Thanks for giving us a pointer in this direction,



Lutz

pjot

#5
Hi Lutz,



Thank you for your kind words. Actually, GTK is not really well developed for Win32. Some functions are not available at all, and the widgets are looking ugly. My gtk-server for Win32 uses GTK 1.2 since the current GTK2 port is still work-in-progress and unusable for production environments.



For multiplatform widgets you probably better stick to TK (or change to wxwindows).



My primary platform is Slackware Linux for which I mainly will develop and test software. GTK fits perfectly well in Unix environments. My ports to Win32 must be looked at as a "service" to the rest of the world... :-) How well GTK is ported to MacOS I am not sure.



I'll keep studying your newLISP the next weeks.



Thanks,



Peter.

pjot

#6
Quote from: "pjot"Well, I've uploaded a new gtk-server.exe. You can get it from the same location. Please let me know if it works according to your wishes. If so, I'll release the new sourcecode as well.



Regards



Peter.


Hi again Nigel,



My solution will exit the Win32 gtk-server if started from the same script (e.g. newLISP program). But I just found that when starting the gtk-server from a batchfile your ^C problem still appear to exist. That is, only when you click on the GTK window so it becomes active, the gtk-server will exit.



The reason for this is that GTK waits for an event, and after it has received such an event it returns to the server. Then the server discovers there is no client script and exits.



To resolve this situation you can change the following line in the demo newLISP script:



(set 'tmp (gtk socket "gtk_main_iteration()"))



to:



(set 'tmp (gtk socket "gtk_main_iteration_do(0)"))



This will continuously update all GTK-events. The downside however is that your systemload will increase dramatically.



Probably an explicit "gtk_exit()" also works (see the new script on my site).



Cheers



Peter.

pjot

#7
Everybody,



Now the Win32 version of the GTK-server has access to GTK2 as well.



Still, this port of GTK2 is considered to be work in progress and might not have access to all widgets yet. In spite of that,  it's looking far more better than GTK1 since, among other things, GTK2 has support for anti-aliased fonts.



N-joy!



Peter.



(Lutz, if you are still interested in GTK for the MacOS, the project can be found at http://gtk-osx.sourceforge.net/">http://gtk-osx.sourceforge.net/. It's still based on GTK1.)

newdep

#8
A little off the topic...



And for the people who want to experiment with GTK but dont want to do binding

but want to use TCL, GnoCL is a nice alternative for calling GTK from TCL ;-)



http://www.dr-baum.net/gnocl/">http://www.dr-baum.net/gnocl/



Norman.
-- (define? (Cornflakes))