Unless otherwise stated, Gtk+ functions and variables are made available in Guile with names transformed to Scheme style. This means underscores become hyphens, and only lower case is used.
For instance the C function
The following general rules are applied to parameters and return values.
NULLis represented as
#f, for functions which accept or return that.
#f. For parameters, any non-
#fvalue is taken to be true.
gtk-container-childrenreturns a list of widgets. In parameters, either a Guile list or vector can be given.
gtk-curve-set-vectortakes a list or vector of floats.
GTK_WINDOW_TOPLEVEL is just the
toplevel, hence a call
For example a
GdkModifierType value could be the list
For example at the C level
gtk_pixmap_get returns a
GdkBitmap via pointers. Guile Gtk function
returns these in a two-element list.
Or for example
gdk_window_at_pointer returns a
y through pointers. These are returned from
gdk-window-at-pointer in a three element list.
gdk-mbstowc (see Gdk Module) is
one way to identify character boundaries at least.
GtkTypewhich is the same thing) values are represented as a distinct kind of Scheme level objects, except for
GTK_TYPE_INVALIDwhich is represented as
#f. Types can be compared with
As a convenience, functions expecting a
GtkType can be passed a symbol
which is the name of the type. For example,
For types known to Guile Gtk (anything appearing in the defs files), Guile Gtk
will call the type initialization functions when necessary. Other types will
be available only once relevant C code has created them.
GObjectis represented uniquely at the Scheme level, so widgets etc can be compared or hashed with
eq?. An object is destroyed when garbage collected, if it's not otherwise in use by Gtk.
Type predicates like
GTK_IS_CHECK_BUTTON are implemented as for
gtk-check-button?. There are no type checking casts like in
C, Guile Gtk functions expecting a particular object class always check they
get it or a sub-class.
GErrorparameters at the C level are implemented as
scm-errorstyle throws see Procedures for Signaling Errors. For example
gdk-pixbuf-new-from-file(see GdkPixbuf Module) is called as
and if an error occurs it may throw for instance
(scm-error 'g-error "gdk-pixbuf-new-from-file" "Failed to open file 'myfile.png': No such file or directory" '(g-file-error-quark 4))
The data parameter is a list of error domain and code number.
gdk-threads-leaveare available though, and can be used the same as in a C program.
Perhaps in the future additional threading protection will be provided by Guile Gtk. Presently two threads both calling Gtk/Gdk can crash the interpreter, the idea would be to guard against that.