The following extra Gtk level functions are provided by Guile Gtk.
When making a callback for signals etc, Guile Gtk goes through this trampoline. tramp is called as
proc args), where
procis the application procedure to call, and
argsis a list of arguments for it (possibly empty). A minimal trampoline would be,(define (my-trampoline proc args) (apply proc args))
(which of course is just
applyitself, no need for a new definition).
The default trampoline uses
catchto trap errors from the callback, and displays them in a window (see Catching Exceptions). The aim is to give the user some feedback in the GUI about what has gone wrong, rather than suddenly terminating. An application can set a new trampoline to do this in its preferred way.
Return a new
GtkTypewith the given name (a string), created as a sub-class of type.
Instances of the new type can be created with
gtk-widget-newin the usual way. The new type has the same size as the given type, there's no mechanism to add extra data fields. (The suggestion would be to use Guile object properties for such things, See Object Properties.)
The main advantage of a new class is that it can be type checked in a fashion similar to other Gtk objects. For instance,(define my-foo-button-type (gtk-class-new 'GtkButton "MyFooButton"))) (define (my-foo-button-new) (gtk-widget-new my-foo-button-type #:label "something"))) (define (my-foo-button? obj) (gtk-check-type obj my-foo-button-type)) (define (my-foo-button-dosomething obj) (or (my-foo-button? obj) (error "Wrong object type: ~a" obj)) ...)
It also works to use
'MyFooButtonlike the builtin types, instead of holding the type in
Append or prepend a single item to a
Return a new
GtkPixmapwidget, containing an XPM image loaded from filename as per
gdk-pixmap-colormap-create-from-xpm. parent is an intended parent widget, used to get the colormap for the image.
Create a new signal name for use by objtype and return the signal ID (an integer). flags is
GtkSignalRunTypeflags, rettype is the return type for the handler, and paramtypes is a list of parameter types for it (
GTypevalues or symbols).
This function is like the C function
gtk_signal_newv, but doesn't setup any particular marshaller, rather it's for use with Scheme level handlers which are invoked “generically” based on the type information provided.
For instance the following adds a new signal to
GtkAdjustment, taking a string and a boolean as parameters. Clearly Gtk itself won't use or emit something like this, it'd just be for an application.(gtk-signal-new-generic "big_change_soon" '(no-recurse) 'GtkAdjustment 'void '(GtkString gboolean))
The following functions are provided by
(use-modules (gtk threads))
Start a Gtk main loop in a new Guile thread, if this function has not previously done that. This is a convenient way for an application to ensure a main loop exists, but continue with other things.
The main loop is started within a
gdk-threads-leavepair in the standard way for a threaded program, as per the following.(gdk-threads-enter) (gtk-main) (gdk-threads-leave)