[gtk-server] Re: GTK Server ".cfg" File

  • From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Thu, 01 Dec 2005 19:20:48 +0100

Hi Landon,

To answer your questions one by one:

1) Indeed this is an internal call of the GTK-server itself. The purpose of it
is to 'wait' for a new event on the created widgets. If such an event occurs
(e.g. a mouseclick on a button for example) the call will return the WidgetID to
the script. Then the script can use this ID to take further action.

The 'wait' argument will always wait for an event, meaning that the client
script will not continue with execution. Instead of the 'wait' argument, you can
also specify 'none' or 'update'. In these cases, the gtk_server_callback
function will check for an event only once, and return immediately. If and only
if an event has happened, the WidgetID is returned, otherwise a '0' is returned.
The difference between 'none' and 'update' is, that the 'update' also will
update all changes and visible mutations to the widgets. (So if you use 'none'
then this has to be done within your client script.)

2) Your observation is correct. A client script always has to send a string in
S-expression format to the GTK-server. First the GTK library needs to be opened
with 'dlopen'. On a Linux system, just check 'man dlopen' for details. On Win32
platforms I use a similar function for this called 'LoadLibrary' - see
msdn.microsoft.com. Then the GTK-server parses the incoming string and creates a
void pointer out of the function call.

The problem of course is that GTK functions have arguments of a certain type
(int, char, float etc). But we do not know in advance how many arguments a GTK
function has, and which type. Therefore this has to be configured in a
configfile. With the FFI library I can actually realize the GTK function. FFI
was written especially for situations in which interpreted programs needed to
execute compiled functions. FFI is part of GCC 3.x and newer (also part of MinGW

3) I did not create a particular developer document. But as you will see, the
sourcecode is commented very heavily. Also you can ask additional questions to
this mailinglist.

BTW I am very curious to see your newLisp wrapper!


Citeren Sunburned Surveyor <sunburned.surveyor@xxxxxxxxx>:

> Peter,
> It's been a few months since I've had a chance to work with GTK-Server. But
> I had the Flu this last weekend, so I was laid up in the house for a couple
> of days and I had some time to play around with it and NewLISP.
> Once again, I would like to thank you for your work on this great tool.
> I've learned quite a bit of C-Programming since I spoke to you last, and
> I've set up a Linux box at home, and at work. (I'm using Debian though, not
> Slackware.) The C Programming language has proved more of a challenge than I
> thought it would be. I'm am picking it up, but a slower pace than I would
> like. I really got thrown with the whole subject of pointers, but I'm
> getting a handle on it now.
> At any rate, I've got a couple more questions for you.
> [1] What is the purpose of the "gtk server-callback WAIT" function that is
> included in the main loop portion of the GTK-Server/NewLISP demo? (I
> couldn't find any info on this function in the GTK API docs, and I'm
> guessing by the name that it is a function internal to GTK-Server.)
> [2] It seems like the GTK-Server simply accepts GTK function calls and
> arguments as a single string from NewLISP. Is this a correct observation? I
> am really curious how the GTK-Server works. Do you parse those strings and
> translate them into actual C calls? If so, how does this work? Are the
> function calls in C compiled and executed as they are recieved, or are you
> using some other mechanism?
> [3] I'm interested in taking a look at the code for GTK-Server. I'd still
> like to contribute improvements and assist with maintenance as my knowledge
> of C programming improves. Is there any documentation on how the program
> works, or should I just take a look at the source code and ask my questions
> on this mailing list?
> Thanks Peter,
> Landon
> P.S. - I hope to wrap many of the GTK-Server functions in NewLISP functions.
> This will allow NewLISP users to use GTK GUI's without having to aquire an
> extensive knowledge of GTK-Server. I'll keep you posted on how things work
> out.


Other related posts: