newLISP and the gtk-server

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

newLISP and the gtk-server

Post by 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/). 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
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Post by nigelbrown »

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
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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.
Last edited by pjot on Fri Feb 27, 2004 1:18 pm, edited 1 time in total.

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by 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.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

pjot wrote: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
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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/. It's still based on GTK1.)

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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/

Norman.

Locked