Next: Gdk Extras, Previous: General Conventions, Up: Top
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.
Currently, the (gtk-2.0 gdk) module also initializes Gtk
(gtk_init etc, see Gtk Module). Perhaps this will change in the
future.
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.
GObject and 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 eq? (nor with equal?). Standard
Gdk functions like gdk-font-equal and gdk-color-equal can be
used in the usual way though.
GdkAtomWM_NAME.
GdkBitmapBadMatch error will occur if it's not.
GdkColorGdkColor object 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,
GdkDragContextGdkEventMouse 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).
GdkFontGdkFont object can be passed
the name of a font as a string, which will be loaded as per
gdk-font-intern (see Gdk Extras).
GdkPoint(x . y).
(see Pairs)
GdkRectangle((x
. y) . (width . height)). Notice the (x
. y) pair corresponds to the way a GdkPoint is represented.
GdkSegment((x1
. y1) . (x2 . y2)). Notice each (x
. y) corresponds to the way a GdkPoint is represented.
GdkWCharGdkWChar values are represented as integers, and
GdkWChar strings as vectors of integers. So for instance
gdk-wcstombs expects such a vector.
This representation might change in the future if Guile gets its own notion of
characters bigger than 8 bits.
GdkWindowgdk-window-destroy to 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.The
pixelfield of eachGdkColoris 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#tor#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 newGdkColorobjects, with fields set as pergdk-color-parse. Those objects are then allocated and modified as described above.
The
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)
The
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)
Create a
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_major_versionandgtk_minor_version, rather than the compile-time constantsGTK_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
GdkWCharabove), or#fif conversion failed.
Return a
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#f.
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.
gdk-set-localeis called automatically when the(gtk-2.0 gdk)module is loaded, so applications don't need to do so explicitly.
Unlike other multiple-return values functions, these return a pair
(x.y)or(width.height), rather than a list.
The
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")
The
GdkGeometrystructure is not used, instead optional keyword arguments are taken. The keyword names correspond to theGdkWindowHintsenumeration, and the arguments are the values for the fields of theGdkGeometrystructure.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.