Typo.
[cl-gtk2.git] / glib / gobject.package.lisp
1 (defpackage :gobject
2   (:use :c2cl :glib :cffi :tg :bordeaux-threads :iter :closer-mop :gobject.ffi)
3   (:export #:g-type
4            #:gtype
5            #:gtype-name
6            #:gtype-id
7            #:g-type-children
8            #:g-type-parent
9            #:g-type-designator
10            #:g-type-fundamental
11            #:g-type-depth
12            #:g-type-next-base
13            #:g-type-is-a
14            #:g-type-interfaces
15            #:g-type-interface-prerequisites
16            #:g-strv-get-type
17            #:g-closure-get-type
18            #:g-class-property-definition
19            #:g-class-property-definition-name
20            #:g-class-property-definition-type
21            #:g-class-property-definition-readable
22            #:g-class-property-definition-writable
23            #:g-class-property-definition-constructor
24            #:g-class-property-definition-constructor-only
25            #:g-class-property-definition-owner-type
26            #:parse-g-param-spec
27            #:class-properties
28            #:interface-properties
29            #:enum-item
30            #:enum-item-name
31            #:enum-item-value
32            #:enum-item-nick
33            #:get-enum-items
34            #:flags-item
35            #:flags-item-name
36            #:flags-item-value
37            #:flags-item-nick
38            #:get-flags-items
39            #:signal-info
40            #:signal-info-id
41            #:signal-info-name
42            #:signal-info-owner-type
43            #:signal-info-flags
44            #:signal-info-return-type
45            #:signal-info-param-types
46            #:signal-info-detail
47            #:query-signal-info
48            #:type-signals
49            #:parse-signal-name
50            #:class-property-info
51            #:+g-type-invalid+
52            #:+g-type-void+
53            #:+g-type-interface+
54            #:+g-type-char+
55            #:+g-type-uchar+
56            #:+g-type-boolean+
57            #:+g-type-int+
58            #:+g-type-uint+
59            #:+g-type-long+
60            #:+g-type-ulong+
61            #:+g-type-int64+
62            #:+g-type-uint64+
63            #:+g-type-enum+
64            #:+g-type-flags+
65            #:+g-type-float+
66            #:+g-type-double+
67            #:+g-type-string+
68            #:+g-type-pointer+
69            #:+g-type-boxed+
70            #:+g-type-param+
71            #:+g-type-object+
72            #:g-object
73            #:pointer
74            #:g-type-from-object
75            #:g-signal-connect
76            #:define-g-object-class
77            #:g-initially-unowned
78            #:define-g-enum
79            #:*lisp-name-package*
80            #:define-g-flags
81            #:fixed-array
82            #:g-boxed-inline
83            #:g-boxed-ptr
84            #:define-g-interface
85            #:release
86            #:using
87            #:using*
88            #:g-boxed-ref
89            #:allocate-stable-pointer
90            #:free-stable-pointer
91            #:get-stable-pointer-value
92            #:with-stable-pointer
93            #:release*
94            #:disown-boxed-ref
95            #:g-type-interface
96            #:g-value
97            #:register-object-type-implementation
98            #:ensure-g-type
99            #:define-vtable
100            #:g-type
101            #:set-g-value
102            #:parse-g-value
103            #:emit-signal
104            #:g-value-unset
105            #:g-value-zero
106            #:g-value-init
107            #:g-type-class-ref
108            #:g-object-class
109            #:gobject-class
110            #:g-param-spec
111            #:type-instance
112            #:g-type-class-unref
113            #:registered-object-type-by-name
114            #:g-type-children
115            #:g-signal-lookup
116            #:g-type-parent
117            #:connect-signal
118            #:boxed-c-structure-name
119            #:g-type-designator
120            #:g-type-fundamental
121            #:g-type-depth
122            #:g-type-next-base
123            #:g-type-is-a
124            #:g-type-interfaces
125            #:g-type-interface-prerequisites
126            #:g-type-name
127            #:g-type
128            #:g-type-children
129            #:g-type-parent
130            #:g-type-designator
131            #:g-type-fundamental
132            #:g-type-depth
133            #:g-type-next-base
134            #:g-type-is-a
135            #:g-type-interfaces
136            #:g-type-interface-prerequisites
137            #:g-strv-get-type
138            #:g-closure-get-type
139            #:g-class-property-definition
140            #:g-class-property-definition-name
141            #:g-class-property-definition-type
142            #:g-class-property-definition-readable
143            #:g-class-property-definition-writable
144            #:g-class-property-definition-constructor
145            #:g-class-property-definition-constructor-only
146            #:g-class-property-definition-owner-type
147            #:parse-g-param-spec
148            #:class-properties
149            #:interface-properties
150            #:enum-item
151            #:enum-item-name
152            #:enum-item-value
153            #:enum-item-nick
154            #:get-enum-items
155            #:flags-item
156            #:flags-item-name
157            #:flags-item-value
158            #:flags-item-nick
159            #:get-flags-items
160            #:stable-pointer-value
161            #:g-value-type
162            #:g-object-call-constructor
163            #:g-object-call-get-property
164            #:g-object-call-set-property
165            #:register-enum-type
166            #:register-flags-type
167            #:register-object-type
168            #:generate-types-hierarchy-to-file
169            #:get-g-flags-definition
170            #:get-g-enum-definition
171            #:get-g-interface-definition
172            #:get-g-class-definition
173            #:*strip-prefix*
174            #:*lisp-name-exceptions*
175            #:*additional-properties*
176            #:g-type=
177            #:g-type/=
178            #:define-g-boxed-cstruct
179            #:define-g-boxed-opaque
180            #:g-boxed-opaque
181            #:g-boxed-opaque-pointer
182            #:define-g-boxed-variant-cstruct
183            #:g-boxed-foreign
184            #:boxed-related-symbols
185            #:define-boxed-opaque-accessor
186            #:glib-defcallback
187            #:create-signal-handler-closure
188            #:save-handler-to-object
189            #:retrieve-handler-from-object
190            #:delete-handler-from-object
191            #:disconnect-signal
192            #:define-cb-methods
193            #:create-fn-ref
194            #:copy-boxed-slots-to-foreign
195            #:with-foreign-boxed-array
196            #:get-g-type-definition)
197   (:documentation
198    "CL-GTK2-GOBJECT is a binding to GObject type system.
199 For information on GObject, see its @a[http://library.gnome.org/devel/gobject/stable/]{documentation}.
200
201 CL-GTK2-GOBJECT is structured as follows:
202 @itemize{
203 @item{Binding to GObject API, providing low-level means to use functionality of GObject. This includes introspection facilities and means to invoke functionality of GObject.}
204 @item{GObject wrapper that bridges Lisp language with GObject API.}
205 }
206
207 @begin[GObject instrospection API]{section}
208 The base of GObject type system is GType. GType is a numerical value that is the unique identifier of a registered type.
209 Each GType has a name that is retrieved with @fun{g-type-name}. Conversely, GType can be retrieved from its name via @fun{g-type-from-name}.
210
211 There are several predefined GType values that correspond to fundamental or base types.
212 @begin{itemize}
213 @item{@variable{+g-type-invalid+}}
214 @item{@variable{+g-type-void+}}
215 @item{@variable{+g-type-interface+}}
216 @item{@variable{+g-type-char+}}
217 @item{@variable{+g-type-uchar+}}
218 @item{@variable{+g-type-boolean+}}
219 @item{@variable{+g-type-int+}}
220 @item{@variable{+g-type-uint+}}
221 @item{@variable{+g-type-long+}}
222 @item{@variable{+g-type-ulong+}}
223 @item{@variable{+g-type-int64+}}
224 @item{@variable{+g-type-uint64+}}
225 @item{@variable{+g-type-enum+}}
226 @item{@variable{+g-type-flags+}}
227 @item{@variable{+g-type-float+}}
228 @item{@variable{+g-type-double+}}
229 @item{@variable{+g-type-string+}}
230 @item{@variable{+g-type-pointer+}}
231 @item{@variable{+g-type-boxed+}}
232 @item{@variable{+g-type-param+}}
233 @item{@variable{+g-type-object+}}
234 @end{itemize}
235
236 GType values form type hierarchies via signle inheritance. Functions @fun{g-type-parent} and @fun{g-type-children} enable to traverse through the type hierarchy.
237
238 For some types, additional information is available. Functions @fun{class-properties} and @fun{interface-properties} return properties of classes and interfaces. Functions @fun{get-enum-items} and @fun{get-flags-items} return members of enum and flags types.
239
240 //TODO: document and refactor signals
241
242 @end{section}
243
244 @begin[GValue]{section}
245 GObject uses GValues as a generic way to pass values. It is used when calling closures, emitting signals, setting and getting properties' values, passing values to object constructors. @class{g-value} foreign structure is used for holding GValue. It used like all foreign structures: either with @code{cffi:foreign-alloc} or with @code{cffi:with-foreign-object}. Before first use, @class{g-value} should be zeroed with @fun{g-value-zero}. Zeroed @class{g-value} may be configured to hold a GValue of a given type with @fun{g-value-init}. @fun{parse-g-value} retrieves the Lisp object corresponding to the value stored in GValue. @fun{set-g-value} sets the GValue from Lisp object.
246 @end{section}"))
247
248 (in-package :gobject)
249
250 (defvar *gobject-debug* nil)
251
252 (defvar *debug-gc* nil)
253 (defvar *debug-subclass* nil)
254
255 (defvar *debug-stream* t)
256
257 (defmacro log-for (categories control-string &rest args)
258   (let ((vars (iter (for sym in (if (listp categories) categories (list categories)))
259                     (collect (intern (format nil "*DEBUG-~A*" (symbol-name sym)) (find-package :gobject))))))
260     `(progn
261        (when (or ,@vars)
262          (format *debug-stream* ,control-string ,@args))
263        nil)))