2.2. GTK+ 2.0 binding

(require 'gtk)
The gtk extension module provides a wrapping for the GTK+ GUI toolkit library, version 2.0. It depends upon the gobject extension.

2.2.1. General

Most of the functions supported by the GTK+ binding extension are automatically generated from *.defs files, taken from James Henstridge's pygtk GTK+ binding for Python.

The generated code is contained in internal modules which don't need to be required separately - they're automatically included when the gtk module is loaded. Some of the generated code is not a good fit for Chicken, so it has been overridden by hand-written code[1] in the gtk module itself.

Generated procedures usually have a name derived from the name of the C function they are wrapping: case is folded to lowercase, and underscores are replaced with hyphens, so for instance gtk_main_quit becomes gtk-main-quit.

Methods on wrapped GtkObject subclasses are registered with the introspection facilities of the gobject module with calls to gobject:register-method!.

procedure: (gtk-signal-connect object signal-name handler-fn)

An alias for gsignal-connect.

procedure: (gtk-main)

Pass control to the GTK+ main loop. This call does not return until the application indicates it is ready to terminate by calling gtk-main-quit.

procedure: (gtk-main-iteration)

Delegates directly to the C function gtk_main_iteration.

2.2.2. Timeouts, idle-handlers, and input-handlers

Input handlers are not currently supported.

procedure: (gtk-timeout-add interval thunk)

Installs a timeout-handling procedure. After interval milliseconds, and every interval thereafter, thunk will be called with no arguments. If thunk returns #f, the timeout-handler will not run again (it will be removed). The semantics are derived from the underlying C procedure, gtk_timeout_add. This function returns a gtk:timeout-handle record, which can be passed in to gtk-timeout-remove.

procedure: (gtk-timeout-remove handle)

Removes a previously-registered timeout handler, using a gtk:timeout-handle record returned by gtk-timeout-add.

procedure: (gtk-idle-add thunk)

Installs thunk as a GTK+ idle handler, as per the C function gtk_idle_add. Returns a gtk:idle-handle record, which may be used with gtk-idle-remove.

procedure: (gtk-idle-remove handle)

Removes a previously installed GTK+ idle handler, using the gtk:idle-handle record returned from gtk-idle-add.

2.2.3. GDK

procedure: (gdk-color->list c)

Return a list (R G B) of the three colour components contained in a GdkColor structure.

procedure: (list->gdk-color l)

Convert a list (R G B) into a GdkColor boxed object.

procedure: (gdk-color-pixel c)

Extract the pixel value from a GdkColor structure.

procedure: (gdk-color-pixel-set! color newpixel)

Update the pixel value within a GdkColor structure.

procedure: (gdk-rectangle->list r)

Convert a GdkRectangle into a list (x y width height).

procedure: (list->gdk-rectangle l)

Convert a list (x y width height) into a GdkRectangle boxed object.

procedure: (gdk-window-get-pointer w)

Returns multiple values: (x y state), where x and y make up the current pointer coordinate, and state is a list of GdkModifierType symbols.

2.2.4. Miscellaneous and overridden procedures

procedure: (gtk:gc-idle-timeout (#:optional value))

If value is omitted, returns the current setting for the number of milliseconds of GTK idleness before a GC is forced; otherwise, sets the setting to the passed-in number of milliseconds. Only used when gtk:gc-when-idle has been enabled. Defaults to 1000 milliseconds.

procedure: (gtk:gc-when-idle (#:optional value))

If value is omitted, returns #t if the GTK-idle-garbage-collector is enabled, or #f otherwise. If value is specified, enables the idle-garbage-collector unless value is #f. Defaults to being switched off.

procedure: (gtk-calendar-get-date cal)

Retrieve the date selected by a GtkCalendar widget, in the form of a list of three numbers, year, month, day: (2002 10 13).

procedure: (gtk-stock-list-ids)

Returns a list of all current GTK+ "stock ID" strings.

procedure: (gtk-tree-iter-new)

Allocates a new instance of GtkTreeIter, for use with various GTK+ tree model and view functions.

procedure: (gtk-list-store-new coltypes ...)

Creates and returns a new instance of GtkListStore with the same number of columns as parameters to the function call. Each parameter should be a gtype record (as returned by gtype-from-name, for example, or as stored in variables such as gtype:string or gtype:boolean).

procedure: (gtk-tree-store-new coltypes ...)

Creates and returns a new instance of GtkTreeStore with the same number of columns as parameters to the function call. Each parameter should be a gtype record, as for gtk-list-store-new.

procedure: (gtk-list-store-set-column-types l coltypes ...)

Sets the number and type of columns associated with the GtkListStore l. coltypes are as for gtk-list-store-new.

procedure: (gtk-tree-store-set-column-types t coltypes ...)

Sets the number and type of columns associated with the GtkTreeStore t. coltypes are as for gtk-tree-store-new.

procedure: (gtk-tree-selection-get-selected sel iter)

Stores the currently-selected row of the GtkTreeSelection sel (single-row-selection mode only) into the GtkTreeIter iter. If there is no current selection, #f is returned; otherwise, the associated GtkTreeModel is returned.

procedure: (gtk-widget-window w)

Extracts the window field of the GtkWidget struct associated with the passed-in object.

procedure: (gtk-widget-allocation w)

Extracts the allocation field of the GtkWidget struct associated with the passed-in object.

procedure: (gtk-widget-get-state w)

Extracts the state field of the GtkWidget struct associated with the passed-in object, and returns it in symbolic form.

procedure: (gtk-style-black-gc style)

Retrieves the black GC from the passed-in style.

procedure: (gtk-style-white-gc style)

Retrieves the white GC from the passed-in style.

procedure: (gtk-style-fg-gc style state)

Retrieves the foreground GC from the passed-in style that is appropriate to the passed-in GtkStateType symbol.

procedure: (gtk-editable-insert-text editable string position)

Inserts text string at the position passed in. Returns the new insertion position after the insert operation.

Notes

[1]

Isn't it nice having procedures in mutable global variables?