Gtk Plugin Manual

Next: , Previous: , Up: (dir)  

Gtk Plugin Manual

This manual documents MIT/GNU Scheme Pucked Gtk 0.13.

Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Matthew Birkholz

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”


Next: , Previous: , Up: Top  

1 Introduction

The Gtk system is a collection of Scheme data types and procedures providing a Schemely interface to the GNOME toolkit(s), not entirely unlike Perl’s Gtk2 “binding” (http://gtk2-perl.sourceforge.net) though by no means as extensive. Very little of the libraries’ APIs has been wrapped — just what is listed herein. As one might expect of a “Schemely” interface, all toolkit resources are protected from “leaking” by the garbage collector. When Scheme’s representative of a toolkit resource is dropped and collected, the toolkit resource is freed, just as the C/Unix FFI’s malloced aliens are automatically freed.

The Gtk toolkits are built “on top” of GLib, which is not thread-safe. To ensure that just one Scheme thread is “in” the toolkits, the with-glib-lock procedure should be used, else every callout will write a warning line to stderr. See with-glib-lock in GLib Plugin Manual.

Hello, World!

Here is the “Hello, World!” program from the C/Unix FFI (here) re-written to use the Gtk system. Notice that the program does not need the FFI; it uses no FFI syntax. There is no need to (load-option 'ffi).

#| -*-Scheme-*-

This is Havoc Pennington's Hello World example
from GGAD, wrapped in Scheme. |#

(define (hello)
  (with-glib-lock
   (lambda ()
     (let ((window (gtk-window-new 'toplevel))
	   (button (gtk-button-new))
	   (label (gtk-label-new "Hello, World!")))
       (gtk-container-add button label)
       (gtk-container-add window button)
       (gtk-window-set-title window "Hello")
       (gtk-container-set-border-width button 10)
       (let ((counter 0))
	 (set-gtk-window-delete-event-callback!
	  window
	  (lambda (window)
	    (outf-error ";Bite me "(- 2 counter)" times.\n")
	    (set! counter (1+ counter))
	    ;; Three or more is the charm.
	    (if (> counter 2) 0 1)))
	 (set-gtk-button-clicked-callback!
	  button
	  (lambda (button)
	    (let ((text (gtk-label-get-text label)))
	      (gtk-label-set-text
	       label (list->string (reverse! (string->list text)))))
	    unspecific)))
       (gtk-widget-show-all window)
       window))))

To run this program, enter the following lines.

  mit-scheme
  (load-option 'gtk)
  (ge '(gtk))
  (load "hello")
  (hello)

Gtk Event Viewer

The Gtk Event Viewer is a simple Scheme widget — a GtkWidget whose methods are implemented by calls back into Scheme — and a straightforward translation of Havoc Pennington’s GtkEv (from GGAD). To see this widget enter the following lines.

  mit-scheme
  (load-option 'gtk)
  (make-gtk-event-viewer-demo)

The code can be found in gtk-ev.scm.

Procedure: make-gtk-event-viewer-demo

Create a window displaying the Gtk Event Viewer app.

Fix Layout Demo

The Gtk system provides a fixnum-centric canvas abstraction based on the ancient X Window draw requests: XDrawLine, XDrawRectangle, XDrawArc, etc. The canvas is a fix-drawing composed of fix-inks, each rendered on fix-layout widgets according to ancient custom.

A demo of two fix-layout widgets displaying one drawing is provided. The drawing contains a sample of each type of fix-ink with animation and mouse tracking (highlighting the character under the pointer, and reporting the inks under a click). To see these widgets in action, enter the following lines.

  mit-scheme
  (load-option 'gtk)
  (make-fix-layout-demo)

The code can be found in fix-demo.scm.

Procedure: make-fix-layout-demo

Create a window displaying the Fix Layout Demo app.

SWAT

The Gtk system contains a proof-of-concept emulation of the old Tk3.2 interface — SWAT, The Scheme Widget Application Toolkit, as described in Introduction to SWAT, by Hal Abelson, Natalya Cohen and Jim Miller. The emulation lacks many widget types and options, and is just sufficient to run Pole Zero.

To see the Pole Zero application, enter the following lines.

  mit-scheme-pucked
  (load-option 'gtk)
  (make-pole-zero)
Procedure: make-pole-zero

Create a window displaying the SWAT Pole Zero app.

The Gtk Package

Most of the Gtk system’s public bindings are in the (gtk) package — not exported to the global environment. It is assumed that modules mucking about with the toolkit(s) will be loaded in a subpackage where they will define Gtk-specific procedures, such as methods for generics imported from a more abstract interface.

Debugging

The Scheme machine can be configured (via the --enable-debugging option) to include some debugging facilities, like a time slice counter. Evaluating the following expression should cause a small window to pop up.

  (gtk-time-slice-window! #t)

The window is created and updated on the toolkit side of the interface, and shows a running count of the number of times the toolkit has yielded to Scheme (or vice versa), and the channels currently being polled by Scheme. The count can be slowed and stopped by evaluating the first and second expressions below.

  (set-thread-timer-interval! 1000)
  (set-thread-timer-interval! #f)

See Debugging Facilities.


Next: , Previous: , Up: Top  

2 GTK Graphics Device

The Gtk system includes a graphics device type like those described in the reference manual (here). With the Gtk option loaded and running on a display, enumerate-graphics-types will include the symbol gtk.

A graphics device for Gtk is created by passing the symbol gtk as the graphics device type name to make-graphics-device:

(make-graphics-device 'gtk #!optional width height no-window?)

A Cairo image surface is created width pixels by height pixels in size. If no-window? is specified (not #f) the device will write to the surface, but not put the surface in a window. Instead the device’s descriptor, a <surface-ink>, can be added to any fix-drawing, or its Cairo surface can be passed to e.g. cairo-surface-write-to-png.

By default (or when no-window? is #f) the device’s output appears in a scrollable window.

You can draw on the surface with the simple graphics interface and/or the following procedures.

Procedure: gtk-graphics/fill-polygon-list device points

Draws a filled polygon. Points is a list of flo:vectors each containing at least two flonums, the x and y coordinates of a point.

Procedure: gtk-graphics/draw-circle device x y radius

Draws a circle centered at (x, y) with radius.

Procedure: gtk-graphics/draw-text device x y string

Draws string at (x, y). This was intended to implement the graphics-draw-text operation (upright, left to right, at x) but it may be drawing text at y, not y-baseline.

Procedure: gtk-graphics/draw-line device x0 y0 x1 y1

Draws a line that connects the points (x0, y0) and (x1, y1).

Procedure: gtk-graphics/set-foreground-color device color
Procedure: gtk-graphics/set-background-color device color

Sets the foreground and background colors for future drawing operations. Color should be a color name or specification understood by the Cairo plugin. See Cairo Colors in MIT/GNU Scheme Cairo Plugin.

Procedure: gtk-graphics/clear device

Paints the background color over all of device’s Cairo surface, after resetting its clip region.

Procedure: gtk-graphics/flush device

Applies cairo-surface-flush to device’s Cairo surface, and updates any drawings containing device’s descriptor, a <surface-ink>. This is the method used by graphics-flush.


Next: , Previous: , Up: Top  

Appendix A API Reference

This appendix lists all of the procedures and data types that make up the Gtk interface.


Next: , Previous: , Up: API Reference  

A.1 Pixbuf Loader

A pixbuf loader encapsulates the loading of a pixbuf. The load-pixbuf-from-port procedure can feed data directly from a Scheme input port into a pixbuf loader, and the loader’s various hooks will notify the user when the pixbuf size is determined, when the pixbuf is allocated, when areas of the pixbuf have been updated, and when the pixbuf is complete.

Class: <pixbuf-loader>

A direct subclass of gobject representing a reference to a GdkPixbufLoader.

Class: <pixbuf>

A direct subclass of gobject representing a reference to a GdkPixbuf.

Procedure: make-pixbuf-loader

A new pixbuf-loader instance.

Procedure: load-pixbuf-from-port loader input-port

Initializes loader and starts a new thread loading from input-port.

Procedure: load-pixbuf-from-file loader filename

Initializes loader and starts a new thread loading from filename.

Procedure: pixbuf-loader-size-hook loader

#f or the procedure that will be applied to the pixbuf size (two integers, width and height).

Procedure: set-pixbuf-loader-size-hook! loader receiver

Arrange for receiver to be applied to loader’s pixbuf’s size (two integers, width and height) as soon as it can be determined. If the size has already been determined, receiver is applied immediately.

Procedure: pixbuf-loader-pixbuf-hook loader

#f or the procedure that will be applied to the pixbuf as soon as it is allocated.

Procedure: set-pixbuf-loader-pixbuf-hook! loader receiver

Arrange for receiver to be applied to loader’s pixbuf (an instance of <pixbuf>) as soon as it is allocated. If the pixbuf has already been created, receiver is applied immediately.

Procedure: pixbuf-loader-update-hook loader

#f or the procedure that will be applied to areas of the pixbuf recently updated.

Procedure: set-pixbuf-loader-update-hook! loader receiver

Arrange for receiver to be applied to areas of the pixbuf as they are updated. Receiver will be applied to four integers — the x and y coordinates of the upper-left corner, and width and height of the updated area. If the pixbuf is complete before receiver is set, it will never be called.

Procedure: pixbuf-loader-close-hook loader

#f or the thunk that will be invoked when loading is complete.

Procedure: set-pixbuf-loader-close-hook! loader thunk

Arrange for thunk to be invoked when loading is complete. If loading is complete before thunk is set, it will be invoked immediately.

Procedure: pixbuf-loader-pixbuf loader

#f or the pixbuf that is loading (or was loaded).

Procedure: pixbuf-loader-error-message loader

#f or a string describing any error encountered during the loading.


Next: , Previous: , Up: API Reference  

A.2 Gtk Adjustment

Class: <gtk-adjustment>

A direct subclass of gobject representing a reference to a GtkAdjustment.

Procedure: gtk-adjustment? object

Type predicate.

Procedure: guarantee-gtk-adjustment object operator

Type guarantor.

Procedure: make-gtk-adjustment

A new gtk-adjustment instance.

Procedure: set-gtk-adjustment! adjustment value lower upper page-size step-incr page-incr

Set the members of a GtkAdjustment and emit the changed and/or value_changed signals.

value

A real magnitude.

lower

The minimum value.

upper

The maximum value.

step_increment

The increment to use to make minor changes to the value. In a GtkScrollbar this increment is used when the mouse is clicked on the arrows at the top and bottom.

page_increment

The increment to use to make major changes to the value. In a GtkScrollbar this increment is used when the mouse is clicked in the trough.

page_size

The page size. In a GtkScrollbar this is the size of the area which is currently visible.


Next: , Previous: , Up: API Reference  

A.3 Gtk Widget

A gtk-widget is a gobject that can be "destroyed". Each instance is connected to the "destroy" signal of its GtkWidget. The callback applies gobject-unref! to the instance, allowing the toolkit to finalize and dispose of the widget.

If a Gtk Widget is "dropped", never destroyed, eventually GCed, the usual gobject cleanup will effect a gobject-unref! and (potentially) release the toolkit resources.

A Gtk Widget also has a “parent” slot — a gtk-container or #f.

Class: <gtk-widget>

An abstract, direct subclass of gobject.

Procedure: gtk-widget? object

Type predicate.

Procedure: guarantee-gtk-widget object operator

Type guarantor.

Procedure: gtk-widget-destroyed? widget

#f if widget has not been destroyed.

Procedure: gtk-widget-destroy widget

Destroys widget.

Generic Procedure: gtk-widget-parent widget

The parent gtk-container, or #f.

A.3.1 Gtk Widget Callbacks

Procedure: set-gtk-widget-size-allocate-callback! widget callback

Arrange for callback to be applied to widget and an alien GtkAllocation whenever the widget’s size changes. Do not capture widget in callback’s closure, else it cannot be GCed.

Procedure: set-gtk-widget-realize-callback! widget callback

Arrange for callback to be applied to widget when it is realized. Do not capture widget in callback’s closure, else it cannot be GCed.

Procedure: set-gtk-widget-unrealize-callback! widget callback

Arrange for callback to be applied to widget when it is unrealized. Do not capture widget in callback’s closure, else it cannot be GCed.

Procedure: set-gtk-widget-draw-callback! widget callback

Arranges for callback to be applied to widget and a cairo context clipped to the area to be re-drawn.

Procedure: set-gtk-widget-event-callback! widget callback

Arrange for callback to be applied to widget and an alien GdkEvent whenever the widget receives an event signal. Callback should return #t to stop emission of more specific signals like focus-in-event and focus. It must return either #t or #f else a warning is issued. Do not capture widget in callback’s closure, else it cannot be GCed.

A.3.2 Gtk Widget Operators

Procedure: gtk-widget-realized? widget

#t if widget has been realized.

Procedure: gtk-widget-drawable? widget

#t if widget can be drawn, i.e. it is realized and visible.

Procedure: gtk-widget-grab-focus widget

Causes widget to have the keyboard focus for the GtkWindow it’s inside. Widget must be a focusable widget, such as a GtkEntry; something like a GtkFrame will not work. The widget also needs to be realized. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.

Procedure: gtk-widget-has-focus? widget

#t if widget has the keyboard.

Procedure: gtk-widget-set-opacity widget opacity

Request a partially transparent widget. Opacity can vary from 0.0 (fully transparent) to 1.0 (fully opaque). On X11 the request has no effect without a compositing manager. Note that setting a window’s opacity after the window has been shown causes it to flicker once on Windows.

Procedure: gtk-widget-show widget

Indicates widget is ready to be displayed. If you want to show all widgets in a container, it is easier to call gtk-widget-show-all on the container. Note that the containers containing widget must also be “shown” else widget cannot be displayed. When a toplevel container is shown, it is immediately realized, as well as any descendents that are “showing”.

Procedure: gtk-widget-show-all widget

Recursively shows widget all of its children (if any).

Procedure: gtk-widget-error-bell widget

Notifies the user about an input-related error on widget. This may sound a short beep, flash a visual cue associated with widget’s toplevel window, or do nothing at all, per user preference and window manager support.

Procedure: gtk-widget-queue-draw widget

The area occupied by widget is invalidated. An expose event for the entire area will be delivered when the toolkit is idle.

Procedure: gtk-widget-queue-resize widget

Flags widget to have its size renegotiated and invalidates its area. An expose event for the entire area will be delivered when the toolkit is idle.

Procedure: gtk-widget-queue-resize-no-redraw widget

Flags widget to have its size renegotiated but does not invalidate its entire area.

Procedure: gtk-widget-get-pango-context widget

A PangoContext with the appropriate font map, font description, and base direction for widget. This context is owned by widget but it can be used until widget’s screen or toplevel changes. It will be updated to match changes to widget’s attributes. Widget’s style-set and direction-changed signals indicate when the context has changed. If you keep a PangoLayout using this default context, the signal callbacks should apply pango-layout-context-changed.

Procedure: gtk-widget-create-pango-layout widget #!optional text

Creates a new pango-layout with the appropriate font map, font description, and base direction for drawing text for widget. The layout will be empty unless text, a string, is provided. If widget’s base direction or font changes, apply pango-layout-context-changed to re-lay-out the text.

Procedure: gtk-widget-get-size widget

Gets widget’s size allocation, a pair of integers: (width . height).

Procedure: gtk-widget-set-hexpand widget expand?

Set whether widget would like any available extra horizontal space or not, overriding the default expand behavior.

Procedure: gtk-widget-set-vexpand widget expand?

Set whether widget would like any available extra vertical space or not, overriding the default expand behavior.

Procedure: gtk-widget-set-size-request widget width height

Notify the toolkit of widget’s natural size. Width and height should be positive. This is just a request. Widget’s size-allocate callback will be applied when its size is initialized or changed. Unfortunately this procedure also overrides the minimum width and height so that a top-level window cannot be resized to a smaller size.


Next: , Previous: , Up: API Reference  

Gtk CSS Provider

A GtkWidget’s GtkStyleContext specifies its default font and colors per its state and theme. A GtkCssProvider can be added to the context to specify defaults (or overrides) using a language similar to Cascading Style Sheets (CSS). In this language, element names select widgets by class (e.g. ScmWidget) and element ids select widgets by name.

Procedure: gtk-widget-set-name widget name

Gives widget name. The style of the widget (its font, colors, etc.) can then be specified using name in syntax much like the id selectors of Cascading Style Sheets (CSS). Note that the CSS selector syntax allows only alphanumerics, dashes and underscores in widget names.

Procedure: gtk-widget-get-style-context widget

Returns the GtkStyleContext associated with widget. Widget must be realized. The returned object is only valid until widget changes style.

Procedure: gtk-style-context? object

Type predicate.

Procedure: gtk-style-context-add-provider context provider priority

Adds provider, a GtkStyleProvider, to the style context. Priority can be a non-negative integer or one of the symbols fallback, theme, settings, application or user (equivalent to the integers 1, 200, 400, 600 and 800 respectively). Styles specified with high priority override lower priority specifications.

Class: <gtk-css-provider>

A direct subclass of gobject representing a reference to a GtkCssProvider.

Procedure: gtk-css-provider?

Type predicate.

Procedure: guarantee-gtk-css-provider

Type guarantor.

Procedure: gtk-css-provider-new

A new GtkCssProvider.

Procedure: gtk-css-provider-get-default

Returns the provider containing the style settings used as a fallback for all widgets.

Procedure: gtk-css-provider-get-named name variant

Returns a GtkCssProvider in which a named theme has been loaded. Name must be a string. Variant can be #f or a string, for example: "dark".

Procedure: gtk-css-provider-load-from-data provider string

Loads the CSS-like string into provider, clearing any previously loaded information.

Procedure: gtk-css-provider-load-from-file provider gfile

Loads the CSS-like content of gfile (a GFile) into provider, clearing any previously loaded information.

Procedure: gtk-css-provider-load-from-path provider path

Loads the CSS-like content of the file named path (a string or pathname) into provider, clearing any previously loaded information.


Next: , Previous: , Up: API Reference  

A.4 Gtk Container

A Gtk widget with a list of “children”. The list records only the children that were created and added via this interface. Other toolkit code may add, remove or re-order children and this list will not be updated. This should probably be fixed with add and remove signal callbacks.

Class: <gtk-container>

An abstract, direct subclass of gtk-widget.

Procedure: gtk-container? object

Type predicate.

Procedure: guarantee-gtk-container object operator

Type guarantor.

Procedure: gtk-container-children container

A fresh list of container’s known children — those created and added via this interface.

Procedure: gtk-bin-child container

The first known child in a container, e.g. the only child of a GtkBin created via this interface.

Procedure: gtk-container-add container child

Adds child to container. Child should not already be in a container. Typically used for GtkBins, where positioning the child in the container is trivial. When applied to a more complex container, the results may be unexpected. Consider a more specialized procedure like gtk-grid-attach.

Procedure: gtk-container-remove container child

Removes child from container. If child is not in container, an error is signaled. If you intend to destroy child, you do not need to remove it.

Procedure: gtk-container-set-border-width container width

Sets the border width of container to width. The border width of a container is the amount of space to leave around the outside of the container. The only exception to this is Gtk window; because toplevel windows can’t leave space outside, they leave the space inside.


Next: , Previous: , Up: API Reference  

A.5 Gtk Window

These objects are not GCed, but held strongly by the toplevel-windows list in the (gtk gtk-object) package. The toolkit object is a GtkBin, and should have no more than one child, though this is not enforced, on the Scheme side, yet.

Class: <gtk-window>

A direct subclass of gtk-container representing a reference to a GtkWindow.

Procedure: gtk-window? object

Type predicate.

Procedure: guarantee-gtk-window object operator

Type guarantor.

Procedure: gtk-window-new type

A new gtk-window instance. Type should be the symbol toplevel. It can also be popup, but the window will not be managed by the window manager, like a tooltip or popup menu window.

Procedure: gtk-window-type window

The symbol toplevel, unless window is a popup. See gtk-window-new.

Procedure: gtk-window-set-geometry-hints window widget . hints

Sets window’s geometry hints. Widget can be #f or any widget that is “showing” in window (not just window’s immediate child). When specified, the geometry hints are applied to widget’s size, sizing window to account for decorations, scrollbars, etc. Hints should be an alist. Values associated with names (symbols) in the following table will specify certain resizing constraints.

min-width min-height

The minimum fixnum dimensions of widget or window. -1 specifies their natural size. Both width and height should be specified.

max-width max-height

The maximum dimensions of widget or window.

base-width base-height width-increment height-increment

Allow dimensions that are N increments greater than a base value, for non-negative integers N. Both width and height, for base and increment, should be specified — four fixnums.

min-aspect max-aspect

The minimum and maximum aspect ratios (reals).

gravity

Keep the specified reference point of each child a constant distance from the corresponding reference point of the window when it is resized. The value of this property should be one of these symbols: north, northeast, east, southeast, south, southwest, west, northwest, or center.

Procedure: gtk-window-set-title window string

Sets the title of window to string. The title of a window is displayed in its title bar. It should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document.

Procedure: gtk-window-set-default-size window width height

Sets window’s default size to width x height. If either dimension is -1, the default for that dimension is unset. If a dimension is 0, it is treated like 1, which means “as small as possible”. With a default size set, window may still request a larger size. The final size will be clamped according to window’s geometry hints. If window has already been shown, this procedure has no effect; it will not resize window.

Procedure: gtk-window-set-type-hint window hint

By setting the type hint for window, you allow the window manager to decorate and handle the window in a way which is suitable to the function of the window in your application. This function should be called before realizing window. Hint can be one of the symbols in the following table. See the Extended Window Manager Hints specification at http://www.freedesktop.org/Standards/wm-spec for more details about window types.

normal

Normal toplevel window.

dialog

Dialog window.

menu

Window used to implement a menu; GTK+ uses this hint only for torn-off menus, see GtkTearoffMenuItem.

toolbar

Window used to implement toolbars.

splashscreen

Window used to display a splash screen during application startup.

utility

Utility windows which are not detached toolbars or dialogs.

dock

Used for creating dock or panel windows.

desktop

Used for creating the desktop background window.

dropdown-menu

A menu that belongs to a menubar.

popup-menu

A menu that does not belong to a menubar, e.g. a context menu.

tooltip

A tooltip.

notification

A notification - typically a "bubble" that belongs to a status icon.

combo

A popup from a combo box.

dnd

A window that is used to implement a DND cursor.

Procedure: gtk-window-get-default-size window receiver

Applies receiver to window’s default width and height.

Procedure: gtk-window-resize window width height

Resizes window as if the user had done so, obeying geometry constraints. width and height should be positive fixnums. When applied before window is shown for the first time, this procedure overrides window’s default size. See gtk-window-set-default-size.

These come from geometry hints, and a default constraint that windows not be sized smaller than their natural size.

Procedure: gtk-window-present window

Presents window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user’s platform, window manager, and preferences. If window is hidden, it is shown.

Procedure: set-gtk-window-delete-event-callback! window callback

Connect callback to window’s delete_event signal. The signal will apply callback to window. Do not capture window in callback’s closure, else it cannot be GCed.


Next: , Previous: , Up: API Reference  

A.6 Gtk Label

Class: <gtk-label>

A direct subclass of gtk-container representing a reference to a GtkLabel.

Procedure: gtk-label? object

Type predicate.

Procedure: guarantee-gtk-label object operator

Type guarantor.

Procedure: gtk-label-new text

A new gtk-label instance. Text, a string, will be displayed in the new label.

Procedure: gtk-label-get-text label

The text of label.

Procedure: gtk-label-set-text label string

Sets label’s text to string.

Procedure: gtk-label-set-width-chars label n-chars

Sets label’s natural size to n-chars.


Next: , Previous: , Up: API Reference  

A.7 Gtk Button

Class: <gtk-button>

A direct subclass of gtk-container representing a reference to a GtkButton.

Procedure: gtk-button? object

Type predicate.

Procedure: guarantee-gtk-button object operator

Type guarantor.

Procedure: gtk-button-new

A new gtk-button instance.

Procedure: set-gtk-button-clicked-callback! button callback

Connect callback to button’s "clicked" signal. The signal will apply callback to button. Do not capture button in callback’s closure, else it cannot be GCed.


Next: , Previous: , Up: API Reference  

A.8 Gtk Check Button

Class: <gtk-check-button>

A direct subclass of gtk-container representing a reference to a GtkCheckButton.

Procedure: gtk-check-button? object

Type predicate.

Procedure: guarantee-gtk-check-button object operator

Type guarantor.

Procedure: gtk-check-button-new

A new gtk check button.

Procedure: gtk-check-button-get-active button

#t if button is “on”, #f if it is “off”.

Procedure: gtk-check-button-set-active button active?

If active?, turns button “on”, else “off”.

Procedure: set-gtk-check-button-toggled-callback! button callback

Connect callback to button’s "toggled" signal. The signal will apply callback to button. Do not capture button in callback’s closure, else it cannot be GCed.


Next: , Previous: , Up: API Reference  

A.9 Gtk Grid

GtkGrids arrange their children in rows and columns.

Class: <gtk-grid>

A direct subclass of gtk-container representing a reference to a GtkGrid.

Procedure: gtk-grid? object

Type predicate.

Procedure: guarantee-gtk-grid object operator

Type guarantor.

Procedure: gtk-grid-new

A new gtk-grid.

Procedure: gtk-grid-set-row-spacing grid space

Set the distance between rows of grid to space pixels.

Procedure: gtk-grid-set-column-spacing grid space

Set the distance between columns of grid to space pixels.

Procedure: gtk-grid-set-row-homogeneous grid homogeneous?

Set the homogeneity of row heights. If homogeneous? is #f, rows can have different heights. Else they are all allocated the same height.

Procedure: gtk-grid-set-column-homogeneous grid homogeneous?

Set the homogeneity of column widths. If homogeneous? is #f, columns can have different widths. Else they are all allocated the same width.

Procedure: gtk-grid-attach grid widget left top width height

Place widget in grid at column left spanning width columns, and at row top spanning height rows.

Procedure: gtk-grid-attach-next-to grid widget sibling side width height

Add widget to grid at side of sibling spanning width columns and height rows. Side should be one of the symbols left, right, top or bottom. Sibling must be a child widget of grid or #f. When sibling is #f, widget is placed on the side of row or column 0. Thus adding three widgets on the left (with sibling #f) causes the third widget to be layed out at (-2,0), the first at (0,0).

Procedure: gtk-orientable-get-orientation orientable

Returns a GtkOrientable’s orientation — one of the symbols horizontal or vertical.

Procedure: gtk-orientable-set-orientation orientable orientation

Set a GtkOrientable to orientation which should be one of the symbols horizontal or vertical.


Next: , Previous: , Up: API Reference  

A.10 Gtk Frame

A bin with a decorative frame and optional label.

Class: <gtk-frame>

A direct subclass of gtk-container representing a reference to a GtkFrame.

Procedure: gtk-frame? object

Type predicate.

Procedure: guarantee-gtk-frame object operator

Type guarantor.

Procedure: gtk-frame-new label

A new gtk frame. Label should be a string. A null string punts the label.

Procedure: gtk-frame-set-shadow-type frame type

Type should be one of the symbols none, in, out, etched-in, or etched-out.


Next: , Previous: , Up: API Reference  

A.11 Gtk Paned

A paned widget draws a separator between two child widgets with a small handle that the user can drag to move the separator. Each child has two options that can be set, “resize” and “shrink”. If resize is not #f, then when the GtkPaned is resized, that child will expand or shrink along with the paned widget. At least one child should be resizable; if resize is #f for both children, they will both be resized. If shrink is #f, then the child will not be made smaller than its minimum size.

Class: <gtk-paned>

A direct subclass of gtk-container representing a reference to a GtkPaned widget.

Procedure: gtk-paned? object

Type predicate.

Procedure: gtk-paned-new orientation

A new gtk-paned instance. Orientation should be one of the symbols horizontal or vertical.

Procedure: gtk-paned-pack1 paned child resize? shrink?

Sets paned’s first child to child which should be a gtk-widget. Child is allowed to resize or shrink when resize? or shrink? are not #f respectively.

Procedure: gtk-paned-pack2 paned child resize? shrink?

Sets paned’s second child to child which should be a gtk-widget. Child is allowed to resize or shrink when resize? or shrink? are not #f respectively.

Generic Procedure: gtk-paned-get-child1 paned

Returns paned’s first child, or #f if there is none.

Generic Procedure: gtk-paned-get-child2 paned

Returns paned’s second child, or #f if there is none.

Generic Procedure: gtk-paned-get-position paned

Returns the position of the divider between the two panes—the pixel size of child1.

Generic Procedure: gtk-paned-set-position paned position

Sets the position of the divider between the two panes, forcing child1’s allocation to be position pixels. A negative size causes the position to be unset.

Class: <gtk-paned-view>

A direct subclass of gtk-scrolled-view representing a reference to a GtkPanedView. This is an extension to the Gtks, a specialization of GtkPaned that overrides its widget geometry protocol.

A GtkPaned allows the user to shrink a child (or not!), displaying it in a smaller area than its minimum size normally allows. If neither child is indicated as the shrinkable one, it is assumed both childen can be shrunk. The geometry implementation completely ignores the natural size of the children, sizing and expanding them in proportion to their minimum sizes (until the divider’s position is set). It will truncate the “beginning” of a child that does not fit, displaying its “end” (per the writing direction).

A GtkPanedView sizes/expands its children according to their natural sizes and respects their minimum sizes (while the position of its divider is unset, unless indicated as shrinkable). If neither child is allowed to shrink, it is assumed neither child should be shrunk. The minimum size of the paned view allows for the minimum sizes of both children.

The difference between paned windows and paned viewports can be observed by substituting gtk-paned-new and gtk-paned-view-new in the fix layout demo. See Fix Layout Demo.

Procedure: gtk-paned-view? object

Type predicate.

Procedure: gtk-paned-view-new orientation

A new gtk-paned-view instance. Orientation should be one of the symbols horizontal or vertical.


Next: , Previous: , Up: API Reference  

A.12 Gtk Scrolled Window

Class: <gtk-scrolled-window>

A direct subclass of gtk-container representing a reference to a GtkScrolledWindow.

Procedure: gtk-scrolled-window? object

Type predicate.

Procedure: guarantee-gtk-scrolled-window object operator

Type guarantor.

Procedure: gtk-scrolled-window-new

A new gtk scrolled window.

Procedure: gtk-scrolled-window-set-policy window horizontal vertical

Horizontal and vertical should be one of the symbols always, auto or never.

Procedure: gtk-scrolled-window-set-placement window placement

Placement should be one of the symbols top-left, bottom-left, top-right or bottom-right. This is the placement of the scrolled window, not the scrollbars. If the scrolled window is placed “bottom left”, the scrollbars will appear above and to the right.

Class: <gtk-scrolled-view>

A direct subclass of gtk-scrolled-window representing a reference to a GtkScrolledView. This is an extension to the Gtks, a specialization of GtkScrolledWindow that overrides its widget geometry protocol.

A GtkScrolledWindow is used to squeeze an overly large widget into a smaller space and allow the user to scroll it. The geometry implementation ignores the natural size of the problem widget, expecting gtk_widget_set_size_request to override its minimum size.

A GtkScrolledView is used to stick scrollbars on a viewport. Its natural size is the natural size of the viewport, plus scrollbars, frame, etc. Using gtk_widget_set_size_request is unnecessary and interferes with resizing.

The difference between a scrolled window and a scrolled viewport can be observed by substituting gtk-scrolled-view-new and gtk-scrolled-window-new in the fix layout demo. See Fix Layout Demo.

Procedure: gtk-scrolled-view? object

Type predicate.

Procedure: gtk-scrolled-view-new orientation

A new gtk-paned-view instance. Orientation should be one of the symbols horizontal or vertical.


Next: , Previous: , Up: API Reference  

A.13 Scheme Widget

A Scheme widget is a GtkWidget implemented by Scheme. Scheme creates a ScmWidget toolkit object and connects to its various gsignals, like size_allocate and realize. Its representative in Scheme, a scm-widget instance, arranges to clean these up if it is garbage collected, like any other gobject instance. Scheme widgets implement the GtkScrollable interface, emitting a set_scroll_adjustments signal when the “vadjustment” or “hadjustment” properties are set. They also participate in the width-for-height (or height-for-width) geometry management protocol in GTK_SIZE_REQUEST_CONSTANT_SIZE mode.

Class: <scm-widget>

A direct subclass of gtk-widget representing a reference to a ScmWidget.

Procedure: guarantee-scm-widget object operator

Type guarantor.

Procedure: set-scm-widget-set-scroll-adjustments-callback! widget callback

Arranges for callback to be applied to widget and the horizontal and vertical GtkAdjustments (aliens). These need to be informed of any change to the widget’s scroll position. The aliens will be NULL when the widget’s scrollbars are removed.

Procedure: set-scm-widget-minimum-size! widget width height

Sets widget’s minimum width and height. This procedure does not request a resize; it only changes the values returned by ScmWidget methods like get_preferred_width.

Procedure: set-scm-widget-natural-size! widget width height

Sets widget’s natural width and height. This procedure does not request a resize; it only changes the values returned by ScmWidget methods like get_preferred_height_for_width.

A.14 Fix Widget

This simple Scheme widget manages the GdkWindow on which more specialized methods will draw. It allocates, moves and resizes the GdkWindow, and dispatches events received on it.

Note that the event handlers are run by the generic event signal, and can return #t to stop emission of more specific signals like focus-in-event and focus. They must return either #t or #f else a warning is issued.

Class: <fix-widget>

A direct subclass of scm-widget. A ScmWidget toolkit object.

Procedure: fix-widget? object

Type predicate.

Procedure: set-fix-widget-pointer-shape! widget shape

Shape can be any one of the following symbols: x-cursor, arrow, based-arrow-down, based-arrow-up, boat, bogosity, bottom-left-corner, bottom-right-corner, bottom-side, bottom-tee, box-spiral, center-ptr, circle, clock, coffee-mug, cross, cross-reverse, crosshair, diamond-cross, dot, dotbox, double-arrow, draft-large, draft-small, draped-box, exchange, fleur, gobbler, gumby, hand1, hand2, heart, icon, iron-cross, left-ptr, left-side, left-tee, leftbutton, ll-angle, lr-angle, man, middlebutton, mouse, pencil, pirate, plus, question-arrow, right-ptr, right-side, right-tee, rightbutton, rtl-logo, sailboat, sb-down-arrow, sb-h-double-arrow, sb-left-arrow, sb-right-arrow, sb-up-arrow, sb-v-double-arrow, shuttle, sizing, spider, spraycan, star, target, tcross, top-left-arrow, top-left-corner, top-right-corner, top-side, top-tee, trek, ul-angle, umbrella, ur-angle, watch, or xterm.

Generic Procedure: fix-widget-new-geometry-callback widget

This procedure is called when widget is resized.

Generic Procedure: fix-widget-realize-callback widget

This procedure is called when widget is being realized.

Procedure: set-fix-widget-enter-notify-handler! widget handler

Arranges to apply handler to widget when the pointer enters. handler must return #t or #f. See event-handler-note.

Procedure: set-fix-widget-leave-notify-handler! widget handler

Arranges to apply handler to widget when the pointer leaves. handler must return #t or #f. See event-handler-note.

Procedure: set-fix-widget-focus-change-handler! widget handler

Arranges to apply handler to widget and a boolean value when it receives a focus change event. The boolean is #t if widget is now in focus. handler must return #t or #f. See event-handler-note.

Procedure: set-fix-widget-visibility-notify-handler! widget handler

Arranges to apply handler to widget and a symbol: one of visible, partially-obscured or obscured. handler must return #t or #f. See event-handler-note.

Procedure: set-fix-widget-key-press-handler! widget handler

Arranges to apply handler every time widget gets a key press event. Handler is applied to widget, a key name, and a bitmap of char-bits. handler must return #t or #f. See event-handler-note.

Procedure: set-fix-widget-motion-handler! widget handler

Arranges to apply handler every time the mouse moves. Handler is applied to widget, a list of modifiers, and the x and y coordinates of the pointer in the widget’s window (not in the drawing’s coordinates). The modifiers include zero or more of the symbols shift, lock, control, mod1, mod2, mod3, mod4, mod5, button1, button2, button3, button4, button5, super, hyper, meta and release. handler must return #t or #f. See event-handler-note.

Procedure: set-fix-widget-button-handler! widget type handler

Arranges to apply handler whenever widget receives a button event of the specified type — one of the symbols press, release, double-press or triple-press. Handler is applied to widget, type, the button number (a fixnum), the modifiers, and the coordinates of the pointer. See set-fix-widget-motion-handler!. handler must return #t or #f. See event-handler-note.


Next: , Previous: , Up: API Reference  

A.15 Fix Layout

The Gtk system provides a fixnum-centric canvas abstraction based on the ancient X Window draw requests: XDrawLine, XDrawRectangle, XDrawArc, etc. A fix-layout is a Scheme widget that uses these requests to paint (and repaint) a view of a canvas on its GdkWindow. The canvas is a logical device space; all positions and dimensions are in fixnum pixels. Thus flonums are rarely needed, and actually avoided. For a flonum-oriented canvas (with scale, rotate, splines, etc.), a cairo-layout seems inevitable.

Just a few types of fix-ink have been implemented: line-ink, rectangle-ink, arc-ink, simple-text-ink, and image-ink.

Each fix-ink has a position on the canvas and a position in the drawing’s display list. The display list determines the order in which the inks are (re)drawn. An ink can be drawn in all views or conditionally, such that it only appears in specific widgets. Multiple fix-layout widgets can display different views of the same fix-drawing.

Animation (editing) is supported through the standard Gtk mechanism. Each change to a drawing “invalidates” areas of affected widgets. The toolkit batches up the damaged areas, repairing them via the expose event handlers.

Class: <fix-layout>

A direct subclass of fix-widget.

Procedure: fix-layout? object

Type predicate.

Procedure: make-fix-layout width height bgcolor

A new fix-layout with natural size width x height and background color bgcolor.

Generic Procedure: fix-layout-drawing layout

The fix-drawing displayed in layout, or #f.

Procedure: set-fix-layout-drawing! layout drawing x y

Drawing must be a fix-drawing. X and y are the integer coordinates of the upper-left corner of the view. They are required so that the drawing, and the position from which to view it, are all set in one fell swoop. If layout is already viewing drawing, but at a different position, "move" to that position — snap, not scroll. Note that a drawing may only be viewed by multiple layouts that are on compatible screens.

Generic Procedure: fix-layout-view layout

The rectangle describing the area currently in view. It is shared with layout; do not modify it.

Procedure: fix-layout-scroll-step layout

A pair: the horizontal and vertical scroll increments. It is shared with layout; do not modify it.

Procedure: set-fix-layout-scroll-step! layout width height

Sets the horizontal and vertical “step-increments” to be used by layout’s scrollbars.

Procedure: fix-layout-scroll-to! layout x y

X and y are the integer coordinates of the upper-left corner of layout’s view of the drawing. If layout is already displaying the view at that position, this procedure does nothing. Else it scrolls layout to the new position.

Procedure: fix-layout-scroll-nw! widget extent

Scroll just enough to view the entire extent (a fix-rect). If the view is too small to include the entire extent, the layout is scrolled so that its NW corner matches the NW corner of the extent.

A.15.1 Fix Drawing

Fixnum-centric canvas, to which you can affix fix-ink spots.

Class: <fix-drawing>

A direct subclass of instance.

Procedure: guarantee-fix-drawing object

Type guarantor.

Procedure: make-fix-drawing

A new fix-drawing.

Procedure: fix-drawing-widgets drawing

A list of fix-layout widgets displaying views of drawing. This is shared with drawing; do not modify it.

Procedure: set-fix-drawing-size! drawing width height

This is just the scrollable area, used mostly by scrollbars to scale their thumbs(?).

Procedure: fix-drawing-pick-list drawing widget x y

A list of fix-inks in drawing, displayed in widget, whose bounding boxes include the point (x, y).

Procedure: fix-drawing-add-ink! drawing ink #!optional where

Adds ink to the top of the display list for drawing. If where is specified, it should be the symbol top (or #f), the symbol bottom, or an ink already in the display list. When where is an ink, ink is spliced in just under (before) it.

A.15.2 Fix Ink

Abstract class for all inks that can be found in fix-drawings and rendered on fix-layouts.

Class: <fix-ink>

A direct subclass of instance.

Procedure: fix-ink? object

Type predicate.

Generic Procedure: fix-ink-drawing ink

Ink’s fix-drawing, or #f.

Procedure: fix-ink-widgets ink

The widgets in which ink should be drawn, #t if it is drawn in all views.

Procedure: set-fix-ink-widgets! ink widgets

Draw ink only in the widgets. If widgets is #t, ink will appear in all views of the drawing.

Generic Procedure: fix-ink-move! ink dx dy

Moves ink by the specified x and y offsets.

Procedure: fix-ink-remove! ink

Removes ink from its drawing.

A.15.3 Draw Ink

This type of ink draws (outlines and/or fills) a shape according to a variety of options similar to those kept in an X GC (graphics context) for e.g. XDrawLine.

Class: <draw-ink>

A direct subclass of fix-ink.

A.15.4 Line Ink

A draw-ink rendered with color, width and dashes as if by an XDrawLine request.

Class: <line-ink>

A direct subclass of draw-ink.

Procedure: line-ink? object

Type predicate.

Procedure: make-line-ink

A new line-ink.

Procedure: set-line-ink! line x1 y1 x2 y2

Set line to start at (x1,y1) and end at (x2,y2).

Procedure: line-ink-width line

The width of line. () if not set.

Procedure: set-line-ink-width! line width

Width should be a small positive integer (fixnum). Line will be redrawn unless it is already drawn at the specified width.

Procedure: line-ink-color line

() if line’s color is not set, else the color last provided to set-line-ink-color!.

Procedure: set-line-ink-color! line color

Sets line’s foreground color.

Procedure: line-ink-dashes line

() if line’s dash pattern is not set, else the pattern last provided to set-line-ink-dashes!.

Procedure: set-line-ink-dashes! line dashes

Dashes must be a list of flonums specifying the lengths for dashes and spaces. One flonum is the same as two of the same. An empty list makes the line solid. Note that the line-ink-dash-color (if any) is painted along the line between the dashes.

Procedure: line-ink-dash-color line

() if line’s dash color is not set, else the color last provided to set-line-ink-dash-color!.

Procedure: set-line-ink-dash-color! line color

Sets line’s dash color. This color will appear between the foreground colored dashes along the line. Note that a dash pattern must also be set using set-line-ink-dashes!.

A.15.5 Rectangle Ink

A draw-ink rendered with a fill color or outline width and color as if by an XDrawRectangle request.

Class: <rectangle-ink>

A direct subclass of draw-ink.

Procedure: rectangle-ink? object

Type predicate.

Procedure: make-rectangle-ink

A new rectangle-ink.

Procedure: set-rectangle-ink! rectangle x y width height

Sets the size and position of rectangle.

Procedure: rectangle-ink-color rectangle

() if rectangle’s line color is not set, else the color last provided to set-rectangle-ink-color!.

Procedure: set-rectangle-ink-color! rectangle color

Sets rectangle’s line color (not the fill color).

Procedure: rectangle-ink-width rectangle

() if rectangle’s line width is not set, else the width last provided to set-rectangle-ink-width!.

Procedure: set-rectangle-ink-width! rectangle width

Sets the width of the line used to draw rectangle’s outline.

Procedure: rectangle-ink-fill-color rectangle

() if rectangle’s fill color is not set, else the color last provided to set-rectangle-ink-fill-color!.

Procedure: set-rectangle-ink-fill-color! rectangle color

Sets rectangle’s fill color. If color is #f, rectangle is outlined, not filled.

A.15.6 Arc Ink

A draw-ink rendered with a fill color or outline width and color as if by an XDrawArc request. Its position, width and height define the bounding box of an ellipse. The portion drawn starts with a start-angle and ends after a sweep-angle. Both angles are in degrees and are measured clockwise from 3 o’clock on the ellipse’s circle — the ellipse scaled into a circle.

Class: <arc-ink>

A direct subclass of draw-ink.

Procedure: arc-ink? object

Type predicate.

Procedure: make-arc-ink

A new arc-ink.

Procedure: set-arc-ink! arc x y width height

Sets the position and size of arc’s ellipse.

Procedure: arc-ink-start-angle arc

Arc’s start-angle (degrees).

Procedure: set-arc-ink-start-angle! arc degrees

Sets arc’s start-angle.

Procedure: arc-ink-sweep-angle arc

Arc’s sweep-angle (degrees).

Procedure: set-arc-ink-sweep-angle! arc degrees

Sets arc’s sweep-angle.

Procedure: arc-ink-color arc

() if arc’s line color is not set, else the color last provided to set-arc-ink-color!.

Procedure: set-arc-ink-color! arc color

Sets arc’s line color (not the fill color).

Procedure: arc-ink-width arc

() if arc’s line width not set, else the width last provided to set-arc-ink-width!.

Procedure: set-arc-ink-width! arc width

Sets the width of the line used to draw arc.

Procedure: arc-ink-fill-color arc

() if arc’s fill color is not set, else the color last provided to set-arc-ink-fill-color!.

Procedure: set-arc-ink-fill-color! arc color

Sets arc’s fill color. If color is #f, arc is not filled.

A.15.7 Text Ink

A draw-ink rendered by a PangoLayout. This abstract class uses an abstract pango-layout slot provided by the generic function text-ink-pango-layout, which is implemented by e.g. the simple text ink (below).

Class: <text-ink>

An abstract, direct subclass of draw-ink.

Procedure: text-ink? object

Type predicate.

Procedure: set-text-ink-position! text x y

Sets the position of the upper left corner of text, a text-ink.

Procedure: text-ink-xy-to-index text x y

If (x, y) is in text’s extent, return the index of the character at that point, else #f.

Procedure: with-text-ink-grapheme-rect text index receiver

Applies receiver to the position and size (four fixnums) of the indexth character in text’s text. If text has no text, this procedure just returns #f; it does not apply receiver. It normally returns receiver’s return value.

Procedure: text-ink-color text

() if text’s color is not set, else the color last provided to set-text-ink-color!.

Procedure: set-text-ink-color! text color

Sets text’s default color.

A.15.8 Simple Text Ink

A text-ink whose abstract text-ink-pango-layout slot is implemented by an actual instance slot. Use set-simple-text-ink-text! to fill it.

Class: <simple-text-ink>

A direct subclass of text-ink.

Procedure: simple-text-ink? object

Type predicate.

Procedure: make-simple-text-ink

A new simple-text-ink.

Procedure: simple-text-ink-text ink

Ink’s text — a string.

Procedure: set-simple-text-ink-text! ink widget string

Sets ink’s text to string, using widget’s font and direction. It is assumed widget is compatible with all widgets displaying ink. See set-fix-layout-drawing!.

Procedure: simple-text-ink-font text

#f or a PangoFontDescription alien.

Procedure: set-simple-text-ink-font! text font

Sets text’s pango layout’s font to font. Font should be a PangoFontDescription, or a string acceptable to pango-font-description-from-string (e.g. courier 12).

A.15.9 Image Ink

A draw-ink rendered by a pixbuf. It uses a pixbuf-loader so that it can render the pixbuf as it loads.

Class: <image-ink>

A direct subclass of fix-ink.

Procedure: make-image-ink-from-file filename

A new image-ink whose pixbuf-loader is loading from filename.

Procedure: set-image-ink! image x y

Set the position of image to (x, y).

A.15.10 Surface Ink

A fix-ink rendered by a Cairo image surface.

Class: <surface-ink>

A direct subclass of fix-ink.

Procedure: surface-ink? object

Type predicate.

Procedure: make-surface-ink width height

Return a new surface ink — a new Cairo RGB24 image surface widthxheight pixels in size.

Procedure: set-surface-ink-position! ink x y

Set the position of ink to (x, y).

Procedure: surface-ink-surface ink

Return the cairo image surface used to render ink. If you draw on this surface, you need to call drawing-damage to notify any widgets.


Next: , Previous: , Up: API Reference  

A.16 Gdk Functions

Procedure: gdk-key-state->char-bits modifier-state

A bitmap of char-bits (char-bit:control, char-bit:meta, char-bit:super, and char-bit:hyper) corresponding to the bits set in modifier-state, a GdkModifierType bitmap from a key or button event.

Procedure: gdk-keyval->name keyval

The key name (character or symbol) associated with the Gdk keyval.


Next: , Previous: , Up: API Reference  

A.17 Debugging Facilities

Procedure: gtk-time-slice-window?

#t if the time slice window is open, else #f.

Procedure: gtk-time-slice-window! open?

If open? is #f, the time slice window is closed, else it is opened.


Next: , Previous: , Up: Top  

B Implementation Notes

This chapter is for the hapless debugger, or potential widget developer. It provides an overview of the mechanisms behind the scenes, like gtk-thread.

The procedures implementing the API are thin wrappers, trivial convenience functions that do type checking and conversion, and hide the details of the C API. For example, a GtkLabel’s text is retrieved in two steps: a toolkit function returns an alien address, and the C string at that address is copied into the heap.

  (let ((retval (make-alien '|gchar|)))
    (C-call "gtk_label_get_text" retval (gobject-alien label))
    (c-peek-cstring retval))
⇒ "!dlrow ,olleH"

The gtk-label-get-text wrapper procedure hides these details.

  (gtk-label-get-text label)
⇒ "!dlrow ,olleH"

In the example call to gtk-label-get-text above, a Scheme object represents the GtkLabel. It is a gtk-label instance, whose class is a specialization of the abstract gtk-object class.


Previous: , Up: Top  

Appendix C GNU Free Documentation License

Version 1.2, November 2002
Copyright © 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
  1. PREAMBLE

    The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

    This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

    We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

  2. APPLICABILITY AND DEFINITIONS

    This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

    A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

    A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

    The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

    The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

    A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

    Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

    The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

    A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

    The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

  3. VERBATIM COPYING

    You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

    You may also lend copies, under the same conditions stated above, and you may publicly display copies.

  4. COPYING IN QUANTITY

    If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

    If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

    If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

    It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

  5. MODIFICATIONS

    You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

    1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
    2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
    3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
    4. Preserve all the copyright notices of the Document.
    5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
    6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
    7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
    8. Include an unaltered copy of this License.
    9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
    10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
    11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
    12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
    13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
    14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
    15. Preserve any Warranty Disclaimers.

    If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

    You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

    You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

    The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

  6. COMBINING DOCUMENTS

    You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

    The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

    In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”

  7. COLLECTIONS OF DOCUMENTS

    You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

    You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

  8. AGGREGATION WITH INDEPENDENT WORKS

    A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

    If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

  9. TRANSLATION

    Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warrany Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

    If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

  10. TERMINATION

    You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

  11. FUTURE REVISIONS OF THIS LICENSE

    The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

    Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

C.1 ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

  Copyright (C)  year  your name.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.2
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with...Texts.” line with this:

    with the Invariant Sections being list their titles, with
    the Front-Cover Texts being list, and with the Back-Cover Texts
    being list.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.