GTK-server
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.[src] It releases free and open-source software under the GNU General Public License.[src]
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.[src] It releases free and open-source software under the GNU General Public License.[src] ==Philosophy== The GTK-server provides a stream-oriented interface to GTK.[src] 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).[src] 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.[src] After each request, the GTK-server returns a result, depending on the type of GTK function invoked.[src] If the GTK-server is compiled as a shared object, it exports the function 'gtk', which must be imported in the client program first.[src] After that, the client program can start sending GTK function calls in S-expression format as argument to the imported 'gtk' function.[src] Before the GTK-server can execute GTK functions, it must read a configuration file in which the prototypes of the GTK functions are described.[src] Since version 2.2.3 this also can be done on-the-fly, allowing the GTK-server to run without configuration file.[src] ==Implementation== Implementing the GTK-server leads to the following considerations.[src] Accessing foreign functions is only possible when the accessed libraries are created with a non object oriented programming language like C or Pascal.[src] Libraries created with C++ for example, use name mangling to unify overloaded functions.[src] This means that the functionname in a C++ library cannot be known once the shared library has been compiled.[src] Hence the functions in such a library cannot be accessed.[src] Therefore, libraries like wxWidgets, the Qt toolkit, Fast Light Toolkit (FLTK) which are programmed in C++, cannot be accessed with the GTK-server concept.[src] The GTK library was implemented in the programming language C.[src] Since C is a strongly typed programming language, the interpreted program needs to know the data type of arguments and the type of the return value for each GTK function during runtime.[src] These can be defined on-the-fly or in a configuration file, which is parsed by the GTK-server during startup.[src] However, the GTK-server does not know the functions which are going to be used by the interpreted client program, so for GTK-server all arguments and return values for each GTK function are variable types.[src] 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.[src] The way to resolve this is by using a foreign function interface.[src] Currently, four external foreign function interfaces are supported by GTK-server: libffi, FFCALL, C/Invoke and dyncall.[src] One of these libraries should be available on the target system, to compile the GTK-server successfully.[src] ==Example== The following KornShell script starts the GTK-server in stdin mode, and creates a simple window with an exit button: !/bin/ksh Start GTK-server gtk-server -stdin |& Communicate with GTK-server and assign function function gtk { print -p $1; read -p GTK; } function define { $2 "$3"; eval $1="$GTK"; } Setup GUI gtk "gtk_init NULL NULL" define WINDOW gtk "gtk_window_new 0" gtk "gtk_window_set_title $WINDOW 'Korn GTK-server demo'" gtk "gtk_window_set_default_size $WINDOW 400 200" define TABLE gtk "gtk_table_new 10 10 1" gtk "gtk_container_add $WINDOW $TABLE" define BUTTON gtk "gtk_button_new_with_label 'Click to Quit'" gtk "gtk_table_attach_defaults $TABLE $BUTTON 5 9 5 9" gtk "gtk_widget_show_all $WINDOW" Mainloop until | $EVENT = $WINDOW do define EVENT gtk "gtk_server_callback wait" done Exit GTK-server gtk "gtk_server_exit" ==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.[src] Also, GTK 1.x, GTK2.x, GTK 3.x and GTK 4.x can be reached.[src] Optionally, any other shared library can be used, like OpenGL related libraries, Poppler, Mozilla, but also libc, sqlite and a music library like MikMod.[src] When using the GTK-server as a standalone binary, it inevitably creates an additional process in the processlist.[src] Also, GTK functions defined as a macro cannot be reached by a client program.[src] ==References==[src]
32 sentences · 32 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"GTK-server." encyclopegia.org, 2024, https://encyclopegia.org/wiki/gtk-server. Accessed 02 December 2026.
Chicago
"GTK-server." encyclopegia.org. Accessed December 2, 2026. https://encyclopegia.org/wiki/gtk-server.
APA
encyclopegia.org. (2024). GTK-server. Retrieved December 2, 2026, from https://encyclopegia.org/wiki/gtk-server
Accessed December 2, 2026 · CC BY-SA 4.0 · citation page · JSON