-(defun expand-container-type (type-number &optional slots)
- (let* ((class (type-from-number type-number))
- (super (supertype type-number))
- (child-class (default-container-child-name class))
- (expanded-child-slots
- (mapcar
- #'(lambda (param)
- (with-slots (name flags value-type documentation) param
- (let* ((slot-name (default-slot-name name))
- (slot-type (type-from-number value-type #|t|#))
- (accessor (default-slot-accessor
- child-class slot-name slot-type)))
- `(,slot-name
- :allocation :property
- :pname ,name
- ,@(cond
- ((and
- (member :writable flags)
- (member :readable flags))
- (list :accessor accessor))
- ((member :writable flags)
- (list :writer `(setf ,accessor)))
- ((member :readable flags)
- (list :reader accessor)))
- ,@(when (or
- (member :construct flags)
- (member :writable flags))
- (list :initarg (intern (string slot-name) "KEYWORD")))
- :type ,slot-type
- ,@(when documentation
- (list :documentation documentation))))))
- (query-container-class-child-properties type-number))))
- `(progn
- ,(expand-gobject-type type-number slots)
- (defclass ,child-class
- (,(default-container-child-name super))
- ,expanded-child-slots
- (:metaclass child-class)
- (:container ,class)))))
-
-(register-derivable-type 'container "GtkContainer" 'expand-container-type)
+(defun expand-container-type (type forward-p options)
+ (let* ((class (type-from-number type))
+ (super (supertype type))
+ (child-class (default-container-child-name class)))
+ (if forward-p
+ (expand-gobject-type type t options)
+ `(progn
+ ,(expand-gobject-type type nil options)
+ ,(let ((child-properties (query-container-class-child-properties type t)))
+ (when child-properties
+ `(defclass ,child-class (,(default-container-child-name super))
+ ,(slot-definitions child-class child-properties nil)
+ (:metaclass container-child-class)
+ (:container ,class))))))))
+
+(defun container-child-class (container-class)
+ (gethash container-class *container-to-child-class-mappings*))
+
+(defun container-dependencies (type options)
+ (delete-duplicates
+ (append
+ (gobject-dependencies type options)
+ (mapcar #'param-value-type (query-container-class-child-properties type)))))
+
+(register-derivable-type 'container "GtkContainer" 'expand-container-type 'container-dependencies)
+
+
+(defmacro define-callback-setter (name arg return-type &rest rest-args)
+ (let ((callback (gensym)))
+ (if arg
+ `(progn
+ (define-callback-marshal ,callback ,return-type
+ ,(cons arg rest-args))
+ (defbinding ,name () nil
+ ,arg
+ (,callback callback)
+ (function user-callback)
+ (user-data-destroy-callback callback)))
+ `(progn
+ (define-callback-marshal ,callback ,return-type ,rest-args)
+ (defbinding ,name () nil
+ (,callback callback)
+ (function user-callback)
+ (user-data-destroy-callback callback))))))
+