+CL-GTK2-GOBJECT includes facilities for automatically generating parts of bindings for libraries that use GObject type system.
+
+@node define-g-object-class
+@section define-g-object-class
+
+@Macro define-g-object-class
+@lisp
+(define-g-object-class g-type-name name
+ (&key (superclass 'g-object) (export t) interfaces type-initializer)
+ (&rest property*))
+
+property ::= (name accessor gname type readable writable)
+property ::= (:cffi name acessor type reader writer)
+@end lisp
+
+Parameters of @code{define-g-object-class}
+@table @var
+@item @var{superclass}
+A symbol naming the superclass of this class
+@item @var{export}
+Whether to export the name of the class and names of autogenerated properties names from the current package.
+@item @var{interfaces}
+A list of interfaces the this class implements
+@item @var{type-initializer}
+A string naming the type initiliazer function. It is usually named @code{class_get_type}.
+@item @var{properties}
+A list of slots of a class
+@end table
+
+Parameters of @code{property}:
+@table @var
+@item @var{name}
+A symbol naming the slot
+@item @var{accessor}
+A symbol naming the accessor function for this slot
+@item @var{gname}
+A string naming the property of GObject
+@item @var{type}
+A string naming the type of property of GObject (for GObject properties); or a symbol naming CFFI foreign type (for slots mapped to foreign accessors)
+@item @var{readable}
+A boolean specifying whether the slot can be read
+@item @var{writable}
+A boolean specifying whether the slot can be assigned to
+@item @var{reader}
+A string or a symbol naming getter function. See description of @code{gobject-class} metaclass for information.
+@item @var{writter}
+A string or a symbol naming setter function. See description of @code{gobject-class} metaclass for information.
+@end table
+
+Macro that expands to @code{defclass} for specified class. Additionally, if @code{export} is true, it exports accessor names and name of a class.
+
+Example:
+@lisp
+(define-g-object-class "GtkContainer" container
+ (:superclass widget :export t :interfaces
+ ("AtkImplementorIface" "GtkBuildable")
+ :type-initializer "gtk_container_get_type")
+ ((border-width container-border-width "border-width" "guint" t t)
+ (resize-mode container-resize-mode "resize-mode" "GtkResizeMode" t t)
+ (child container-child "child" "GtkWidget" nil t)
+ (:cffi focus-child container-focus-child g-object "gtk_container_get_focus_child" "gtk_container_set_focus_child")
+ (:cffi focus-vadjustment container-focus-vadjustment (g-object adjustment) "gtk_container_get_focus_vadjustment" "gtk_container_set_focus_vadjustment")
+ (:cffi focus-hadjustment container-focus-hadjustment (g-object adjustment) "gtk_container_get_focus_hadjustment" "gtk_container_set_focus_hadjustment")))
+@end lisp
+
+@node define-g-interface
+@section define-g-interface
+
+@Macro define-g-interface
+@lisp
+(define-g-interface g-type-name name (&key (export t) type-initializer)
+ &body property*)
+
+property ::= (name accessor gname type readable writable)
+property ::= (:cffi name acessor type reader writer)
+@end lisp
+
+Parameters of @code{define-g-interface}
+@table @var
+@item @var{export}
+Whether to export the name of the interface and names of autogenerated properties names from the current package.
+@item @var{type-initializer}
+A string naming the type initiliazer function. It is usually named @code{interface_get_type}.
+@item @var{properties}
+A list of slots of a interface
+@end table
+
+Parameters of @code{property}:
+@table @var
+@item @var{name}
+A symbol naming the slot
+@item @var{accessor}
+A symbol naming the accessor function for this slot
+@item @var{gname}
+A string naming the property of GObject
+@item @var{type}
+A string naming the type of property of GObject (for GObject properties); or a symbol naming CFFI foreign type (for slots mapped to foreign accessors)
+@item @var{readable}
+A boolean specifying whether the slot can be read
+@item @var{writable}
+A boolean specifying whether the slot can be assigned to
+@item @var{reader}
+A string or a symbol naming getter function. See description of @code{gobject-class} metaclass for information.
+@item @var{writter}
+A string or a symbol naming setter function. See description of @code{gobject-class} metaclass for information.
+@end table
+
+Macro that expands to @code{defclass} for specified interface. Additionally, if @code{export} is true, it exports accessor names and name of a interface.
+
+Example:
+@lisp
+(define-g-interface "GtkFileChooser" file-chooser
+ (:export t :type-initializer "gtk_file_chooser_get_type")
+ (do-overwrite-confirmation file-chooser-do-overwrite-confirmation "do-overwrite-confirmation" "gboolean" t t)
+ (select-multiple file-chooser-select-multiple "select-multiple" "gboolean" t t)
+ (filter file-chooser-filter "filter" "GtkFileFilter" t t)
+ (local-only file-chooser-local-only "local-only" "gboolean" t t)
+ (preview-widget file-chooser-preview-widget "preview-widget" "GtkWidget" t t)
+ (use-preview-label file-chooser-use-preview-label "use-preview-label" "gboolean" t t)
+ (preview-widget-active file-chooser-preview-widget-active "preview-widget-active" "gboolean" t t)
+ (file-system-backend file-chooser-file-system-backend "file-system-backend" "gchararray" nil nil)
+ (extra-widget file-chooser-extra-widget "extra-widget" "GtkWidget" t t)
+ (show-hidden file-chooser-show-hidden "show-hidden" "gboolean" t t)
+ (action file-chooser-action "action" "GtkFileChooserAction" t t)
+ (:cffi current-name file-chooser-current-name
+ (:string :free-to-foreign t :encoding :utf-8) nil "gtk_file_chooser_set_current_name")
+ (:cffi filename file-chooser-filename
+ (g-string :free-from-foreign t :free-to-foreign t)
+ "gtk_file_chooser_get_filename" "gtk_file_chooser_set_filename")
+ (:cffi current-folder file-chooser-current-folder
+ (g-string :free-from-foreign t :free-to-foreign t)
+ "gtk_file_chooser_get_current_folder"
+ "gtk_file_chooser_set_current_folder")
+ (:cffi uri file-chooser-uri
+ (g-string :free-from-foreign t :free-to-foreign t)
+ "gtk_file_chooser_get_uri" "gtk_file_chooser_set_uri")
+ (:cffi current-folder-uri file-chooser-current-folder-uri
+ (g-string :free-from-foreign t :free-to-foreign t)
+ "gtk_file_chooser_get_current_folder_uri"
+ "gtk_file_chooser_set_current_folder_uri")
+ (:cffi preview-filename file-chooser-preview-filename
+ (g-string :free-from-foreign t :free-to-foreign t)
+ "gtk_file_chooser_get_preview_filename" nil)
+ (:cffi preview-uri file-chooser-preview-uri
+ (g-string :free-from-foreign t :free-to-foreign t)
+ "gtk_file_chooser_get_preview_uri" nil))
+@end lisp
+
+@node define-g-enum
+@section define-g-enum
+
+@Macro define-g-enum
+@lisp
+(define-g-enum g-name name (&key (export t) type-initializer) &body value*)
+
+value ::= :keyword
+value ::= (:keyword integer)
+@end lisp
+
+@table @var
+@item @var{g-name}
+A string naming the GEnum type
+@item @var{name}
+A symbol naming the CFFI enumeration type
+@item @var{export}
+A boolean indicating whether to export @code{name}
+@item @var{type-initializer}
+A string naming the foreign type initializer function. Usually named @code{enum_get_type}.
+@end table
+
+Macro that defines CFFI enumeration, registers it with GValue, and calls the type initializer.
+
+Example:
+@lisp
+(define-g-enum "GtkTextDirection" text-direction
+ (:export t :type-initializer "gtk_text_direction_get_type")
+ (:none 0) (:ltr 1) (:rtl 2))
+
+(define-g-enum "GtkSizeGroupMode" size-group-mode
+ (:export t :type-initializer "gtk_size_group_mode_get_type")
+ :none :horizontal :vertical :both)
+@end lisp
+
+@node define-g-flags
+@section define-g-flags
+
+@Macro define-g-flags
+@lisp
+(define-g-flags g-name name (&key (export t) type-initializer) &body value*)
+
+value ::= :keyword
+value ::= (:keyword integer)
+@end lisp
+
+@table @var
+@item @var{g-name}
+A string naming the GFlags type
+@item @var{name}
+A symbol naming the CFFI flags type
+@item @var{export}
+A boolean indicating whether to export @code{name}
+@item @var{type-initializer}
+A string naming the foreign type initializer function. Usually named @code{flags_get_type}.
+@end table
+
+Macro that defines CFFI bitfield, registers it with GValue, and calls the type initializer.
+
+Example:
+@lisp
+(define-g-flags "GtkAttachOptions" attach-options
+ (:export t :type-initializer "gtk_attach_options_get_type")
+ (:expand 1) (:shrink 2) (:fill 4))
+
+(define-g-flags "GtkButtonAction" button-action
+ (:export t :type-initializer "gtk_button_action_get_type")
+ :ignored :selects :drags :expands)
+@end lisp
+
+@node get-g-enum-definition
+@section get-g-enum-definition
+
+@Function get-g-enum-definition
+@lisp
+(get-g-enum-definition type &optional lisp-name-package) @result{} definition
+@end lisp
+
+@table @var
+@item @var{type}
+A string naming the GEnum type
+@item @var{lisp-name-package}
+A package that will be used as a package for generated symbols (enum name). If not specified, symbols are interned in @code{*package*}
+@item @var{definition}
+A Lisp form that when evaluated defines the GEnum.
+@end table
+
+Uses GObject introspection capabilities to automatically produce the definition of GEnum. The foreign library that defines the enum type should be loaded.
+
+See @ref{Generating names for CLOS classes and accessors} for information about used method for generating names.
+
+Example:
+@lisp
+(get-g-enum-definition "GtkDirectionType")
+@result{}
+(DEFINE-G-ENUM "GtkDirectionType" GTK-DIRECTION-TYPE
+ (:EXPORT T :TYPE-INITIALIZER "gtk_direction_type_get_type")
+ (:TAB-FORWARD 0) (:TAB-BACKWARD 1) (:UP 2) (:DOWN 3) (:LEFT 4)
+ (:RIGHT 5))
+@end lisp
+
+@node get-g-flags-definition
+@section get-g-flags-definition
+
+@Function get-g-flags-definition
+@lisp
+(get-g-flags-definition type &optional lisp-name-package) @result{} definition
+@end lisp
+
+@table @var
+@item @var{type}
+A string naming the GFlags type
+@item @var{lisp-name-package}
+A package that will be used as a package for generated symbols (flags name). If not specified, symbols are interned in @code{*package*}
+@item @var{definition}
+A Lisp form that when evaluated defines the GFlags.
+@end table
+
+Uses GObject introspection capabilities to automatically produce the definition of GFlags. The foreign library that defines the flags type should be loaded.
+
+See @ref{Generating names for CLOS classes and accessors} for information about used method for generating names.
+
+Example:
+@lisp
+(get-g-flags-definition "GtkCalendarDisplayOptions")
+@result{}
+(DEFINE-G-FLAGS "GtkCalendarDisplayOptions" GTK-CALENDAR-DISPLAY-OPTIONS
+ (:EXPORT T :TYPE-INITIALIZER
+ "gtk_calendar_display_options_get_type")
+ (:SHOW-HEADING 1) (:SHOW-DAY-NAMES 2) (:NO-MONTH-CHANGE 4)
+ (:SHOW-WEEK-NUMBERS 8) (:WEEK-START-MONDAY 16)
+ (:SHOW-DETAILS 32))
+@end lisp
+
+@node get-g-interface-definition
+@section get-g-interface-definition
+
+@Function get-g-interface-definition
+@lisp
+get-g-interface-definition type &optional lisp-name-package) @result{} definition
+@end lisp
+
+@table @var
+@item @var{type}
+A string naming the GInterface type
+@item @var{lisp-name-package}
+A package that will be used as a package for generated symbols (type name, accessor names). If not specified, symbols are interned in @code{*package*}
+@item @var{definition}
+A Lisp form that when evaluated defines the GInterface.
+@end table
+
+Uses GObject introspection capabilities to automatically produce the definition of GInterface. The foreign library that defines the GInterface type should be loaded.
+
+See @ref{Generating names for CLOS classes and accessors} for information about used method for generating names.
+
+Example:
+@lisp
+(get-g-interface-definition "GtkActivatable")
+@result{}
+(DEFINE-G-INTERFACE "GtkActivatable" GTK-ACTIVATABLE
+ (:EXPORT T :TYPE-INITIALIZER "gtk_activatable_get_type")
+ (USE-ACTION-APPEARANCE
+ GTK-ACTIVATABLE-USE-ACTION-APPEARANCE
+ "use-action-appearance" "gboolean" T T)
+ (RELATED-ACTION GTK-ACTIVATABLE-RELATED-ACTION
+ "related-action" "GtkAction" T T))
+@end lisp
+
+@node get-g-class-definition
+@section get-g-class-definition
+
+@Function get-g-class-definition
+@lisp
+(get-g-class-definition type &optional lisp-name-package) @result{} definition
+@end lisp
+
+@table @var
+@item @var{type}
+A string naming the GObject type
+@item @var{lisp-name-package}
+A package that will be used as a package for generated symbols (type name, accessor names). If not specified, symbols are interned in @code{*package*}
+@item @var{definition}
+A Lisp form that when evaluated defines the GObject.
+@end table
+
+Uses GObject introspection capabilities to automatically produce the definition of GClass. The foreign library that defines the GObject type should be loaded.
+
+See @ref{Generating names for CLOS classes and accessors} for information about used method for generating names.
+
+Example:
+@lisp
+(get-g-class-definition "GtkButton")
+@result{}
+(DEFINE-G-OBJECT-CLASS "GtkButton" GTK-BUTTON
+ (:SUPERCLASS GTK-BIN :EXPORT T :INTERFACES
+ ("AtkImplementorIface" "GtkActivatable" "GtkBuildable")
+ :TYPE-INITIALIZER "gtk_button_get_type")
+ ((LABEL GTK-BUTTON-LABEL "label" "gchararray" T T)
+ (IMAGE GTK-BUTTON-IMAGE "image" "GtkWidget" T T)
+ (RELIEF GTK-BUTTON-RELIEF "relief" "GtkReliefStyle" T
+ T)
+ (USE-UNDERLINE GTK-BUTTON-USE-UNDERLINE "use-underline"
+ "gboolean" T T)
+ (USE-STOCK GTK-BUTTON-USE-STOCK "use-stock" "gboolean"
+ T T)
+ (FOCUS-ON-CLICK GTK-BUTTON-FOCUS-ON-CLICK
+ "focus-on-click" "gboolean" T T)
+ (XALIGN GTK-BUTTON-XALIGN "xalign" "gfloat" T T)
+ (YALIGN GTK-BUTTON-YALIGN "yalign" "gfloat" T T)
+ (IMAGE-POSITION GTK-BUTTON-IMAGE-POSITION
+ "image-position" "GtkPositionType" T T)))
+@end lisp
+
+@node Specifying additional properties for CLOS classes
+@section Specifying additional properties for CLOS classes
+
+Some properties are not exposed through GObject introspection facilities, but are rather present as a pair of functions (@code{class_get_property}, @code{class_set_property}). @code{gobject-class} metaclass supports such properties. For these properties to be included in automatically generated class definitions, they should be made known to the generator.
+
+Definitions generator uses variable @code{*additional-properties*} to get this information.
+
+Variable @code{*additional-properties*} contains a plist that maps GType names to a list of properties definitions (See @ref{define-g-object-class} for syntax of properties definitions).
+
+To supply the bindings generator with this information, bind @code{*additional-properties*} to such list when the generator is run.
+
+Example:
+@lisp
+(("GtkTreeViewColumn"
+ (:cffi gtk::tree-view
+ gtk::tree-view-column-tree-view
+ g-object "gtk_tree_view_column_get_tree_view" nil)
+ (:cffi gtk::sort-column-id
+ gtk::tree-view-column-sort-column-id
+ :int "gtk_tree_view_column_get_sort_column_id" "gtk_tree_view_column_set_sort_column_id")
+ (:cffi gtk::cell-renderers
+ gtk::tree-view-column-cell-renderers
+ (glist g-object :free-from-foreign t) "gtk_tree_view_column_get_cell_renderers" nil))
+ ("GtkTreeSelection"
+ (:cffi gtk::mode
+ gtk::tree-selection-mode
+ gtk::selection-mode "gtk_tree_selection_get_mode" "gtk_tree_selection_set_mode")
+ (:cffi gtk::select-function
+ gtk::tree-selection-select-function
+ nil gtk::tree-selection-get-selection-function gtk::tree-selection-set-select-function)))
+@end lisp
+
+@node Generating names for CLOS classes and accessors
+@section Generating names for CLOS classes and accessors
+
+Names of types are generated by mapping @code{CamelCaseNames} to @code{dash-separated-names} and interning them in specified package. Additionally, prefix from beginning of the name may be stripped (@code{"GtkWidget"} has prefix @code{"Gtk"}, after stripping it maps to @code{widget}). Some names may require special processing (e.g., @code{"GObject"}, @code{"GInitiallyUnowned"} should map to class names in @code{gobject} package; @code{"GtkWindow"} and @code{"GdkWindow"} should receive different @code{symbol-name}s so that they can both be imported in one package).
+
+Accessors for slots are generated by concatenating class name, dash and slot name, producing names like @code{class-slot}: @code{container-child}, @code{button-label}, etc.
+
+Name generation affected by following variables:
+@itemize
+@item @var{*strip-prefix*}
+A string variable specifying the prefix that should to be stripped from the names to generate symbols (e.g., if @code{(equal "Gtk" *strip-prefix*)}, then type named @code{"GtkWidget"} will map to class named @code{widget}.
+@item @var{*lisp-name-exceptions*}
+A plist mapping from strings (type names) to symbols (class names) that have special name processing.
+Example:
+@lisp
+`(("GObject" gobject:g-object)
+ ("GtkObject" ,(intern "GTK-OBJECT" (find-package :gtk)))
+ ("GInitiallyUnowned" gobject::g-initially-unowned)
+ ("GtkWindow" ,(intern "GTK-WINDOW" (find-package :gtk)))
+ ("GtkUIManager" ,(intern "UI-MANAGER" (find-package :gtk)))
+ ("GtkUIManagerItemType" ,(intern "UI-MANAGER-ITEM-TYPE" (find-package :gtk))))
+@end lisp
+@end itemize