Next: , Previous: define-g-object-class, Up: Generating type definitions by introspection


13.2 define-g-interface

— Macro: define-g-interface
     (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)

Parameters of define-g-interface

export
Whether to export the name of the interface and names of autogenerated properties names from the current package.
type-initializer
A string naming the type initiliazer function. It is usually named interface_get_type.
properties
A list of slots of a interface

Parameters of property:

name
A symbol naming the slot
accessor
A symbol naming the accessor function for this slot
gname
A string naming the property of GObject
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)
readable
A boolean specifying whether the slot can be read
writable
A boolean specifying whether the slot can be assigned to
reader
A string or a symbol naming getter function. See description of gobject-class metaclass for information.
writter
A string or a symbol naming setter function. See description of gobject-class metaclass for information.

Macro that expands to defclass for specified interface. Additionally, if export is true, it exports accessor names and name of a interface.

Example:

     (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))