GTK-server

1

The GTK-server project aims to bring graphical user interface (GUI) programming to any interpreted language using the GNU Image Manipulation Program (GIMP) ToolKit (GTK) or XForms. It releases free and open-source software under the GNU General Public License.

Philosophy

The GTK-server provides a stream-oriented interface to GTK. If the GTK-server is compiled as a standalone program binary, it allows five different interfaces: standard input (stdin), first in, first out (FIFO) (named pipe), inter-process communication (IPC) (message queue), Transmission Control Protocol (TCP), or User Datagram Protocol (UDP). Any interpreted language or shell script with input/output (I/O) abilities can start the GTK-server with an argument specifying the type of interface, and can start sending GTK function calls in S-expression format. After each request, the GTK-server returns a result, depending on the type of GTK function invoked. If the GTK-server is compiled as a shared object, it exports the function 'gtk', which must be imported in the client program first. After that, the client program can start sending GTK function calls in S-expression format as argument to the imported 'gtk' function. Before the GTK-server can execute GTK functions, it must read a configuration file in which the prototypes of the GTK functions are described. Since version 2.2.3 this also can be done on-the-fly, allowing the GTK-server to run without configuration file.

Implementation

Implementing the GTK-server leads to the following considerations. This leads to a problem for the implementation, because the GTK functions and the corresponding arguments and return values cannot be hardcoded into the GTK-server binary. The way to resolve this is by using a foreign function interface. Currently, four external foreign function interfaces are supported by GTK-server: libffi, FFCALL, C/Invoke and dyncall. One of these libraries should be available on the target system, to compile the GTK-server successfully.

Example

The following KornShell script starts the GTK-server in stdin mode, and creates a simple window with an exit button:

Advantages and limitations

Although GTK was meant to be used with the C programming language, it is now possible to use GTK from any interpreted language without changing the implementation of the interpreter. Also, GTK 1.x, GTK2.x, GTK 3.x and GTK 4.x can be reached. Optionally, any other shared library can be used, like OpenGL related libraries, Poppler, Mozilla, but also libc, sqlite and a music library like MikMod. When using the GTK-server as a standalone binary, it inevitably creates an additional process in the processlist. Also, GTK functions defined as a macro cannot be reached by a client program.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original