1. gtk-server
    1. Introduction
    2. Author
    3. Repository
    4. Current state of the bindings
    5. API
    6. Example
    7. License
    8. Version history
      1. 0.1


A trivial GTK3 binding using GTK-server.


Felix Winkelmann, Vasilij Schneidermann


Current state of the bindings

Based on a demo by Felix Winkelmann.

Only the stdin API is supported. If you need to communicate with GTK-server via TCP, UDP, FIFO, IPC or FFI, please use gtk-server-impl.scm as your starting point.


[procedure] (start-gtk-server! [program-name: PROGRAM-NAME] [args: ARGS])

Launches a gtk-server process using the stdin API and returns a GTK-SERVER record representing it. The location of the gtk-server executable can be customized by using the #:program-name keyword argument. Further customizations to the GTK-server behavior can be performed by passing a list of command-line arguments using the #:args keyword argument. Refer to the GTK-server manual for a list of all supported command-line arguments.

[procedure] (gtk-send! GTK-SERVER #!rest ARGS)

Send a GTK command to GTK-SERVER. Command arguments are converted to strings if necessary and concatenated into a space-separated string. To pass a string argument containing spaces to GTK, it must be quoted using single or double quotes. For example (gtk-send gtk-server "foo bar baz"), (gtk-send gtk-server "foo" "bar" "baz") and (gtk-send gtk-server 'foo 'bar 'baz) are all interpreted as three arguments, but (gtk-send gtk-server "\"foo bar baz\"") and (gtk-send gtk-server "'foo bar baz'") are interpreted as one string argument.

Refer to the GTK-server and GNOME documentation for allowed commands.

[procedure] (stop-gtk-server! GTK-SERVER)

Shuts down the process associated with GTK-SERVER and frees all open resources. This procedure should be called at the end of the program, for example after exiting the main loop.


(import scheme)
(import (chicken base))
(import gtk-server)

(define gtk-server (start-gtk-server! args: '("-log=/tmp/scheme.gtk")))
(define (gtk #!rest args) (apply gtk-send! gtk-server args))

(gtk "gtk_init NULL NULL")
(define win (gtk "gtk_window_new 0"))
(gtk "gtk_window_set_title" win "'This is a title'")
(gtk "gtk_window_set_default_size" win "100 100")
(gtk "gtk_window_set_position" win "1")
(define table (gtk "gtk_table_new 30 30 1"))
(gtk "gtk_container_add" win table)
(define button1 (gtk "gtk_button_new_with_label Exit"))
(gtk "gtk_table_attach_defaults" table button1 "17 28 20 25")
(define button2 (gtk "gtk_button_new_with_label 'Print text'"))
(gtk "gtk_table_attach_defaults" table  button2 "2 13 20 25")
(define entry (gtk "gtk_entry_new"))
(gtk "gtk_table_attach_defaults" table entry "2 28 5 15")
(gtk "gtk_widget_show_all" win)

(let loop ()
  (let ((event (gtk "gtk_server_callback wait")))
    (when (equal? event button2)
      (print "This is the contents: " (gtk "gtk_entry_get_text" entry)))
    (unless (member event (list button1 win))

(stop-gtk-server! gtk-server)

See the examples directory for further examples.


Copyright 2021 Vasilij Schneidermann

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
General Public License for more details.

A full copy of the GPL license can be found at

Version history