2.3. G+, a higher-level GTK+ interface

(require 'g+)
G+ is based on the ideas in JLib, a library for building GUI widget trees which comes with Jscheme.

2.3.1. Core macros and functions

macro: (g+predicate-case (varname ...) ((predicate ...) body ...) ...)

Expands into a cond expression which tests each varname against the corresponding predicate, executing the body of the first clause for which all the predicates return true. (A clause may also have the keyword else instead of a list of predicates, with effect similar to cond and case.)

macro: (g+define-ctor name (base-ctor args ...))

Expands into a definition of name, a function which accepts args ... and passes them to base-ctor, keeping the result, passing the result to g+:configure with any extra arguments supplied, and then returning the result of the call to base-ctor.

For example:


 (g+define-ctor X (A B C D))
 
expands into:

 (define (X B C D . g+args)
   (let ((x (A B C D)))
     (g+:configure x g+args)
     x))
 

2.3.2. Constructors and modifiers

procedure: (g+:configure x items)

Given an object x, and a list of items, takes different actions depending on the types of x and each item in turn. In general, if x is some kind of container, and an item is some kind of widget or object appropriate for containment within that container, it will be placed inside it. If an item is a string, and x has some kind of intuitively-default text-string property on it, the property will be set. If an item is a procedure, the procedure will be called with x as its single argument.

This function is the core of the G+ library, and is the main idea taken from JLib: the heavy use of lambdas makes for a fairly clean way of building an extensible optional-argument and -property system.

procedure: (g+property name value)

Returns a function that when applied to a GObject, sets a property on its argument. For use with g+:configure (and by extension constructors defined with g+define-ctor).

procedure: (g+signal name handler)

Returns a function that when applied to a GObject, installs a signal-handler on it using gsignal-connect.

procedure: (g+pack-start expand fill padding widgets ...)

Returns a function that when applied to a GtkBox, packs all the widgets into it using gtk-box-pack-start.

procedure: (g+pack-end expand fill padding widgets ...)

Returns a function that when applied to a GtkBox, packs all the widgets into it using gtk-box-pack-end.

procedure: (g+tip tooltips text)

Returns a function that when applied to a GtkWidget, sets the tooltip on that widget in the tooltips set to be text.

procedure: (g+label-markup markup-mnemonic)

Returns a function that when applied to a GtkLabel, sets its markup and mnemonic keysequence according to markup-mnemonic.

procedure: (g+label-markup* markup)

Returns a function that when applied to a GtkLabel, sets its markup according to markup.

procedure: (g+button mnemonic ...)

procedure: (g+button* ...)

procedure: (g+stock-button stock-id ...)

These three constructors use g+:configure to build variants on GtkButton.

procedure: (g+label mnemonic ...)

procedure: (g+label text ...)

These constructors use g+:configure to build variants on GtkLabel.

procedure: (g+entry ...)

procedure: (g+entry/max-length max-length ...)

These constructors use g+:configure to build variants on GtkEntry.

procedure: (g+window type ...)

Builds a GtkWindow using gtk-window-new and g+:configure.

procedure: (g+dialog ...)

Builds a GtkDialog using gtk-dialog-new and g+:configure.

procedure: (g+vbox homogeneous spacing ...)

procedure: (g+hbox homogeneous spacing ...)

These constructors use g+:configure to build variants on GtkBox.

procedure: (g+vbutton-box ...)

procedure: (g+hbutton-box ...)

These constructors use g+:configure to build variants on GtkButtonBox.

procedure: (g+vpaned ...)

procedure: (g+hpaned ...)

These constructors use g+:configure to build variants on GtkPaned.

procedure: (g+menu ...)

procedure: (g+menu-bar ...)

procedure: (g+menu-item mnemonic ...)

procedure: (g+menu-item* ...)

These constructors use g+:configure to build variants on GtkMenu and GtkOptionMenu.

procedure: (g+option-menu ...)

Builds a GtkOptionMenu using gtk-option-menu-new and g+:configure.

procedure: (g+tooltips ...)

Builds a GtkTooltips object using gtk-tooltips-new and g+:configure.

procedure: (g+toolbar ...)

Builds a GtkToolbar object using gtk-toolbar-new and g+:configure.

procedure: (g+calendar ...)

Builds a GtkCalendar object using gtk-calendar-new and g+:configure.

procedure: (g+check-button mnemonic ...)

procedure: (g+check-button* ...)

These constructors use g+:configure to build variants on GtkCheckButton.

procedure: (g+radio-button group-or-null-gobject mnemonic ...)

procedure: (g+radio-button* group-or-null-gobject ...)

These constructors use g+:configure to build variants on GtkRadioButton.

procedure: (g+adjustment current min max stepincr pageincr pagesize ...)

procedure: (g+hscrollbar adjustment ...)

procedure: (g+vscrollbar adjustment ...)

procedure: (g+hscale adjustment ...)

procedure: (g+vscale adjustment ...)

procedure: (g+spin-button adjustment climbrate numdigits ...)

procedure: (g+spin-button/range min max step ...)

These constructors use g+:configure to build variants on GtkAdjustment, GtkScrollbar, GtkScale and GtkSpinButton.

procedure: (g+arrow arrow-type shadow-type ...)

Builds a GtkArrow object using gtk-arrow-new and g+:configure.

procedure: (g+scrolled-window hscrollbar vscrollbar ...)

Builds a GtkScrolledWindow object using gtk-scrolled-window-new and g+:configure.

procedure: (g+table rows columns homogeneous)

Builds a GtkTable using gtk-table-new and g+:configure.

procedure: (g+table-cell left right top bottom widget)

Uses gtk-table-attach-defaults to place a widget within a GtkTable.

procedure: (g+table-cell* left right top bottom xoptions yoptions xpadding ypadding widget)

Uses gtk-table-attach to place a widget within a GtkTable.

procedure: (g+notebook ...)

Builds a GtkNotebook object using gtk-notebook-new and g+:configure.

procedure: (g+notebook-page label-widget page-widget)

Returns a function that when applied to a GtkNotebook, appends a page to it using gtk-notebook-append-page.

procedure: (g+notebook-page* label-widget menu-widget page-widget)

Returns a function that when applied to a GtkNotebook, appends a page to it using gtk-notebook-append-page-menu.

procedure: (g+list-store typelist rows ...)

Builds a GtkListStore object using g+:make-list-store and g+:configure.

procedure: (g+:make-list-store typelist rows)

Creates a new GtkListStore, and creates (length typelist) columns. Each element of typelist should be a GType record. The rows should contain zero or more lists of entries to put in the list store. Each row must contain items that correspond to the GTypes passed in typelist.

procedure: (g+:list-store-append! ls typelist rows)

Appends rows to ls, using the list of GType records in typelist to build the intermediate GValues.

procedure: (g+tree-store typelist rows ...)

Builds a GtkTreeStore object using g+:make-tree-store and g+:configure.

procedure: (g+:make-tree-store typelist rows)

Creates a new GtkTreeStore, and creates (length typelist) columns. Each element of typelist should be a GType record. The rows should contain zero or more lists of entries to put in at the root of the tree. Each row must contain items that correspond to the GTypes passed in typelist, followed by child rows (that follow the same definition).

For example:


(g+:make-tree-store (list gtype:string gtype:int)
                    '(("A" 100
                           ("AA" 110
                                 ("AAA" 111))
                           ("AB" 120))
                      ("B" 200
                           ("BA" 210)
                           ("BB" 220))))

procedure: (g+:tree-store-append! ts typelist parent-iter rows)

Appends rows to ts, under the parent element at parent-iter (pass in (null-gboxed) to refer to the root element), using the list of GType records in typelist to build the intermediate GValues.

procedure: (g+tree-view tree-model ...)

Wraps gtk-tree-view-new-with-model with a g+:configure step.

procedure: (g+tree-view-column title renderer column-id updater editable-column g+args ...)

Creates and returns a configured instance of GtkTreeViewColumn.

title should be the text used as the column heading. renderer should be either one of the symbols (text toggle pixbuf), or an instance of GtkCellRenderer. column-id should be the column from the GtkTreeModel to fetch data to render from. (To render the data in the first column on the GtkTreeModel, pass in 0; the third column, pass 2; etc.)

updater may supply a function which will be called when the content of the cell renderer is edited by the user. Set it to #f if you don't want to install a handler for edited cells. editable-column may supply a GtkTreeModel column number which contains GBoolean information specifying whether the cell rendered by this column at a particular row should be user-editable or not. Supply #f if you want the cell to be left in its default state with regard to editability.

Both updater and editable-column are only relevant if renderer is a symbol - if it's a GtkCellRenderer instance, this function has no way of working out how to set updater or edit-column properties, so it leaves it up to its caller.