Previous: set-g-value, Up: Using GValues


6.6 Registering types

In order to be able to parse GValues and set them, it is necessary for GValue binding to know type mapping between GObject types and Lisp types. Type registration serves to this purpose.

GEnum and GFlags are mapped to CFFI defcenum and defbitfield types. Functions register-enum-type and register-flags-type add the type to the mapping.

6.6.1 register-enum-type

— Function: register-enum-type
     (register-enum-type name type)
name
A string naming the GEnum type
type
A symbol - name of CFFI foreign enum type

Registers the type to be used for passing value of GEnum type name between GObject and Lisp.

Example:

     (defcenum text-direction
       :none :ltr :rtl)
     (register-enum-type "GtkTextDirection" 'text-direction)

6.6.2 register-flags-type

— Function: register-flags-type
     (register-flags-type name type)
name
A string naming the GFlags type
type
A symbol - name of CFFI foreign flags type

Registers the type to be used for passing value of GFlags type name between GObject and Lisp.

Example:

     (defcenum state-type
       :normal :active :prelight :selected :insensitive)
     (register-enum-type "GtkStateType" 'state-type)