1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 2000 Espen S. Johnsen <esj@stud.cs.uit.no>
4 ;; This library is free software; you can redistribute it and/or
5 ;; modify it under the terms of the GNU Lesser General Public
6 ;; License as published by the Free Software Foundation; either
7 ;; version 2 of the License, or (at your option) any later version.
9 ;; This library is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;; Lesser General Public License for more details.
14 ;; You should have received a copy of the GNU Lesser General Public
15 ;; License along with this library; if not, write to the Free Software
16 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ;; $Id: gparam.lisp,v 1.13 2005-01-03 16:42:03 espen Exp $
22 (deftype gvalue () 'pointer)
24 (register-type 'gvalue "GValue")
26 (eval-when (:compile-toplevel :load-toplevel :execute)
27 (defbinding (size-of-gvalue "size_of_gvalue") () unsigned-int))
29 ;(defconstant +gvalue-size+ (+ (size-of 'type-number) (* 2 (size-of 'double-float))))
30 (defconstant +gvalue-size+ #.(size-of-gvalue))
32 (defconstant +gvalue-value-offset+ (size-of 'type-number))
34 (defbinding (%gvalue-init "g_value_init") () nil
38 (defbinding (gvalue-unset "g_value_unset") () nil
41 (defun gvalue-init (gvalue type &optional (value nil value-p))
42 (%gvalue-init gvalue (find-type-number type))
44 (funcall (writer-function type) value gvalue +gvalue-value-offset+)))
46 (defun gvalue-new (&optional type (value nil value-p))
47 (let ((gvalue (allocate-memory +gvalue-size+)))
49 (value-p (gvalue-init gvalue type value))
50 (type (gvalue-init gvalue type)))
53 (defun gvalue-free (gvalue &optional (unset-p t))
54 (unless (null-pointer-p gvalue)
56 (gvalue-unset gvalue))
57 (deallocate-memory gvalue)))
59 (defun gvalue-type (gvalue)
60 (type-from-number (system:sap-ref-32 gvalue 0)))
62 (defun gvalue-get (gvalue)
63 (funcall (reader-function (gvalue-type gvalue))
64 gvalue +gvalue-value-offset+))
66 (defun gvalue-set (gvalue value)
67 (funcall (writer-function (gvalue-type gvalue))
68 value gvalue +gvalue-value-offset+)
71 (defbinding (gvalue-p "g_type_check_value") () boolean
74 (defmacro with-gvalue ((gvalue &optional type value) &body body)
75 `(let ((,gvalue ,(if type
76 `(gvalue-new ,type ,value)
81 ,(unless type `(gvalue-get ,gvalue)))
82 (gvalue-free ,gvalue))))
85 (deftype param-flag-type ()
94 (eval-when (:compile-toplevel :load-toplevel :execute)
95 (defclass param-spec-class (ginstance-class)
98 (defmethod validate-superclass
99 ((class param-spec-class) (super pcl::standard-class))
100 t ;(subtypep (class-name super) 'param)
104 (defbinding %param-spec-ref () pointer
107 (defbinding %param-spec-unref () nil
110 (defmethod reference-foreign ((class param-spec-class) location)
111 (declare (ignore class))
112 (%param-spec-ref location))
114 (defmethod unreference-foreign ((class param-spec-class) location)
115 (declare (ignore class))
116 (%param-spec-unref location))
120 ;; TODO: rename to param-spec
121 (defclass param (ginstance)
129 :type param-flag-type)
132 :reader param-value-type
136 :reader param-owner-type
140 :getter "g_param_spec_get_nick"
141 :reader param-nickname
142 :type (copy-of string))
145 :getter "g_param_spec_get_blurb"
146 :reader param-documentation
147 :type (copy-of string)))
148 (:metaclass param-spec-class))
151 (defclass param-char (param)
154 :reader param-char-minimum
158 :reader param-char-maximum
162 :reader param-char-default-value
164 (:metaclass param-spec-class))
166 (defclass param-unsigned-char (param)
170 ; :reader param-unsigned-char-minimum
171 ; :type unsigned-char)
174 ; :reader param-unsigned-char-maximum
175 ; :type unsigned-char)
178 ; :reader param-unsigned-char-default-value
179 ; :type unsigned-char)
181 (:metaclass param-spec-class)
182 (:alien-name "GParamUChar"))
184 (defclass param-boolean (param)
187 :reader param-boolean-default-value
189 (:metaclass param-spec-class))
191 (defclass param-int (param)
194 :reader param-int-minimum
198 :reader param-int-maximum
202 :reader param-int-default-value
204 (:metaclass param-spec-class))
206 (defclass param-unsigned-int (param)
209 :reader param-unsigned-int-minimum
213 :reader param-unsigned-int-maximum
217 :reader param-unsigned-int-default-value
219 (:metaclass param-spec-class)
220 (:alien-name "GParamUInt"))
222 (defclass param-long (param)
225 :reader param-long-minimum
229 :reader param-long-maximum
233 :reader param-long-default-value
235 (:metaclass param-spec-class))
237 (defclass param-unsigned-long (param)
240 :reader param-unsigned-long-minimum
244 :reader param-unsigned-long-maximum
248 :reader param-unsigned-long-default-value
249 :type unsigned-long))
250 (:metaclass param-spec-class)
251 (:alien-name "GParamULong"))
253 (defclass param-unichar (param)
255 (:metaclass param-spec-class))
257 (defclass param-enum (param)
260 :reader param-enum-class
264 :reader param-enum-default-value
266 (:metaclass param-spec-class))
268 (defclass param-flags (param)
271 :reader param-flags-class
275 :reader param-flags-default-value
277 (:metaclass param-spec-class))
279 (defclass param-single-float (param)
282 :reader param-single-float-minimum
286 :reader param-single-float-maximum
290 :reader param-single-float-default-value
294 :reader param-single-float-epsilon
296 (:metaclass param-spec-class)
297 (:alien-name "GParamFloat"))
299 (defclass param-double-float (param)
302 :reader param-double-float-minimum
306 :reader param-double-float-maximum
310 :reader param-double-float-default-value
314 :reader param-double-float-epsilon
316 (:metaclass param-spec-class)
317 (:alien-name "GParamDouble"))
319 (defclass param-string (param)
322 :reader param-string-default-value
324 (:metaclass param-spec-class))
326 (defclass param-param (param)
328 (:metaclass param-spec-class))
330 (defclass param-boxed (param)
332 (:metaclass param-spec-class))
334 (defclass param-pointer (param)
336 (:metaclass param-spec-class))
338 (defclass param-value-array (param)
341 :reader param-value-array-element-spec
345 :reader param-value-array-length
347 (:metaclass param-spec-class))
349 ;; (defclass param-closure (param)
351 ;; (:metaclass param-spec-class))
353 (defclass param-object (param)
355 (:metaclass param-spec-class))