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

  • From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Fri, 02 Dec 2005 21:02:11 +0100

Hi Landon,

The 'gtk_server_callback'-function actually calls "gtk_main_iteration()", which
runs through a GTK event loop, and returns to the caller as soon a signal has
occured. The occured callback signals and widgets are kept in a global struct,
so as soon 'gtk_server_callback' returns to the client script, the value of the
widget is returned (also as a string). The function "gtk_main()" however calls
the GTK library but never returns, and the GTK-server never can pass information
to the client script.

FFI stands for "Foreign Function Interface". The original homepage can be found
at http://sources.redhat.com/libffi/.

Peter

Citeren Sunburned Surveyor <sunburned.surveyor@xxxxxxxxx>:

> Peter,
>
> Thank you for your quick responses!
>
> I will make sure that I forward information about my NewLISP wrapper for
> GTK-Server as work progresses. I also hope to work on parsing glade-xml
> files to generate GTK GUI's in NewLISP.
>
> I had a couple more questions for you:
>
> I was reading this morning that you use the gtk_main (void) function to
> start GTK's main loop, and gtk_main_quit (void) function to terminate the
> main loop when programming GTK GUI applications in the C programmig
> language. However, I don't see either of these functions in the GTK-Server
> dmeo for NewLISP. Are these 2 function calls handled automatically by
> GTK-Server? How do indicate to GTK-Server when the main loop should start
> and stop? Are these two functions somehow embodied in the
> "gtk_server_callback WAIT" function that is called in the "main loop"
> section of the GTK-Server demo for NewLISP?
>
> What is the full name for FFI? I did a Google search but came up dry...I'd
> like to learn more about it.
>
>
> On 12/1/05, Peter van Eerten <administrator@xxxxxxxxxxxxxx> wrote:
> >
> > 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
> > nowadays).
> >
> > 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!
> >
> > Br,
> > Peter
> >
> >
> > 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.
> > >
> >
> > --
> > http://www.gtk-server.org
> >
> >
>


-- 
http://www.gtk-server.org

Other related posts: