The Gdk interface module can be used with
(use-modules (gtk-2.0 gdk))
A call to
gdk_init is made automatically, an application doesn't need
to do that itself. Standard Gdk command line options are taken from the
program command line (eg. ‘--display’), and removed from there, leaving
other options and the rest of the command line for the application.
see Runtime Environment.
(gtk-2.0 gdk) module also initializes Gtk
gtk_init etc, see Gtk Module). Perhaps this will change in the
The following rules apply to the various Gdk types.
gdk-window?. These test only for an object of the type, so when say a string is automatically converted for
GdkFont, the corresponding
gdk-font?is false for a string, it's true only for an actual font object.
GObjectand the rules for it apply to them (see General Conventions). But those few not like this, such as
GdkFont, are not uniquely represented by a single Scheme level object and so cannot be compared with
equal?). Standard Gdk functions like
gdk-color-equalcan be used in the usual way though.
BadMatcherror will occur if it's not.
GdkColorobject can be passed a string, which will be parsed and allocated in the default colormap, using
gdk-color-intern(see Gdk Extras).
The following field accessors and setters are provided,
Mouse pointer positions as floating point numbers, eg. for motion notify events.
Window position and sizes as exact integers, for a configure notify event.
gdk-event-messagereturns its data as a vector of 5, 10 or 20 integers, according to the data format (32, 16, or 8 bits, respectively).
GdkFontobject can be passed the name of a font as a string, which will be loaded as per
gdk-font-intern(see Gdk Extras).
). (see Pairs)
) . (width
)). Notice the
)pair corresponds to the way a
) . (x2
)). Notice each
)corresponds to the way a
GdkWCharvalues are represented as integers, and
GdkWCharstrings as vectors of integers. So for instance
gdk-wcstombsexpects such a vector.
This representation might change in the future if Guile gets its own notion of
characters bigger than 8 bits.
gdk-window-destroyto destroy a window which it created and no longer needs. This is not done automatically by the garbage collector, a window forgotten will continue to exist until the program exits. Windows from a Gtk widget should not be destroyed, that's done by the widget code when the widget is destroyed or unrealized.
Note that the final release of memory only actually takes place under the Gtk
main loop (
gtk-main etc), so be sure it runs (periodically at least)
when creating and destroying.
The following standard Gdk functions have particular notes for the Guile Gtk interface.
Return a new
GdkBitmapof widthxheight created from raw data bytes in XBM format (which is bits of each row packed into bytes, least significant bit first, and each row padded to a byte boundary). data can be a string, a vector of integers, or a uniform vector of bytes. In each case the length must be what widthxheight implies.
The return value is a
GdkColorobject with red/green/blue fields set and the pixel allocated in the given colormap, or
#fif allocation fails.
colors is a list or vector of
GdkColorobjects which are to be allocated in colormap. writable and bestmatch are booleans.
pixelfield of each
GdkColoris changed to the allocated color. And if bestmatch is true then the red, green and blue fields are changed to the actual color allocated.
The return is a list
(failcount statuslist). failcount is the number of allocations which failed, statuslist is a list of
#fflags, one for each entry in colors, indicating which colors were successfully allocated or not.
colors can contain strings, the same as other functions taking
GdkColorparameters. In this case those entries are changed to new
GdkColorobjects, with fields set as per
gdk-color-parse. Those objects are then allocated and modified as described above.
GdkGCValuestype is not used, instead the return is a list,(foreground background font function fill tile stipple clip-mask subwindow-mode ts-x-origin ts-y-origin clip-x-origin clip-y-origin graphics-exposures line-width line-style cap-style join-style)
GdkGCValuestype is not used, instead keyword arguments are taken corresponding to the fields of that structure.
For example,(gdk-gc-new-with-values my-window #:foreground "orange" #:line-width 5 #:graphics-exposures #f)
GdkImagebitmap of widthxheight using the given data. data is raw byte values, either as a string, a vector of integers, or a uniform vector of bytes. In each case the length of data must be what widthxheight implies. The data format is not well documented by Gdk, but the bits of each row are packed into bytes (most significant bit first), and each row padded out so the next starts on a byte boundary.
data is copied to form the image, so changes with
gdk-image-put-pixeletc don't alter the original data. (Unlike at the C level, where the data space there is acquired and used directly by the image.)
These are set from the corresponding Gtk library variables
gtk_minor_version, rather than the compile-time constants
GTK_MAJOR_VERIONetc. This means the values seen in Scheme code are the library actually used at run time, not merely the one Guile Gtk was compiled against.
Convert a string of multi-byte characters to wide characters. The return is a vector of integers (per notes for
#fif conversion failed.
GdkPixmapcreated from an XPM file or string data.
bitmaploc is a vector or list of length 1, into which the
GdkBitmapcreated for the transparency mask is stored. If the bitmap is not wanted, bitmaploc can be
depth defaults to -1, meaning copy from drawable.
The return is a rectangle which is the intersection of rect1 and rect2, or
#ffor no intersection.
Unlike other multiple-return values functions, these return a pair
), rather than a list.
GdkWindowAttrstructure is not used, instead mandatory fields are taken as fixed arguments, and the optional fields in keyword form. For example, for a top-level window,(gdk-window-new #f 200 100 '(exposure-mask) 'input-output 'toplevel #:title "my window")
GdkGeometrystructure is not used, instead optional keyword arguments are taken. The keyword names correspond to the
GdkWindowHintsenumeration, and the arguments are the values for the fields of the
For example,(gdk-window-set-geometry-hints my-window #:min-size 20 10 #:aspect 1.0 2.0 #:pos #:win-gravity 'south-east)
The following standard Gdk functions are not provided, for the reasons outlined.
There are no separate init functions to call, all initializations are done automatically when the
(gtk-2.0 gdk)module is loaded.
Gtk sets the “user data” on a window to point to the associated widget, and uses this for event dispatch. Non-widget windows need
NULLto avoid another value being treated as a widget pointer. On this basis the user data generally cannot be used by applications.
If some sort of attached data is required then the suggestion is to use Guile object properties (see Object Properties). Because the Scheme-level object is kept alive as long as the window exists, such properties remain until the window is destroyed.