Next: GdkPixbuf Module, Previous: Gtk Module, Up: Top
The following extra Gtk level functions are provided by Guile Gtk.
Get or set the trampoline procedure for Gtk callbacks. With no arguments, the current trampoline is returned. With an argument, the trampoline procedure is set, and the old procedure returned.
When making a callback for signals etc, Guile Gtk goes through this trampoline. tramp is called as
(
trampproc args)
, whereproc
is the application procedure to call, andargs
is 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
apply
itself, no need for a new definition).The default trampoline uses
catch
to 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
GtkType
with the given name (a string), created as a sub-class of type.Instances of the new type can be created with
gtk-widget-new
in 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
'MyFooButton
like the builtin types, instead of holding the type inmy-foo-button-type
.
Append or prepend a single item to a
GtkList
.
Return a new
GtkPixmap
widget, containing an XPM image loaded from filename as pergdk-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
GtkSignalRunType
flags, rettype is the return type for the handler, and paramtypes is a list of parameter types for it (GType
values 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-enter
/gdk-threads-leave
pair in the standard way for a threaded program, as per the following.(gdk-threads-enter) (gtk-main) (gdk-threads-leave)