-(define-foreign ("gtk_timeout_add_full" timeout-add)
- (interval function) unsigned-int
- (interval (unsigned 32))
- (0 unsigned-long)
- (*callback-marshal* pointer)
- ((register-callback-function function) unsigned-long)
- (*destroy-marshal* pointer))
-
-(define-foreign timeout-remove () nil
- (timeout-handler-id unsigned-int))
-
-(define-foreign ("gtk_idle_add_full" idle-add)
- (function &optional (priority 200)) unsigned-int
- (priority int)
- (0 unsigned-long)
- (*callback-marshal* pointer)
- ((register-callback-function function) unsigned-long)
- (*destroy-marshal* pointer))
-
-(define-foreign idle-remove () nil
- (idle-handler-id unsigned-int))
-
-
-(system:add-fd-handler (gdk:event-poll-fd) :input #'main-iterate-all)
-(setq lisp::*periodic-polling-function* #'main-iterate-all)
-(setq lisp::*max-event-to-sec* 0)
-(setq lisp::*max-event-to-usec* 1000)
-
-
-
-;;;; Signals
-
-(define-foreign %signal-emit-stop () nil
- (object object)
- (signal-id unsigned-int))
-
-(define-foreign %signal-emit-stop-by-name (object signal) nil
- (object object)
- ((name-to-string signal) string))
-
-(defun signal-emit-stop (object signal)
- (if (numberp signal)
- (%signal-emit-stop object signal)
- (%signal-emit-stop-by-name object signal)))
-
-(define-foreign %signal-connect-full
- (object signal function after) unsigned-int
- (object object)
- ((name-to-string signal) string)
- (0 unsigned-long)
- (*callback-marshal* pointer)
- ((register-callback-function function) unsigned-long)
- (*destroy-marshal* pointer)
- (nil boolean)
- (after boolean))
-
-(defun signal-connect (object signal function
- &key after ((:object callback-object)))
- (let* ((callback-object (if (eq callback-object t)
- object
- callback-object))
- (callback-function
- (if callback-object
- #'(lambda (&rest args) (apply function callback-object args))
- function)))
- (%signal-connect-full object signal callback-function after)))
-
-(define-foreign signal-disconnect () nil
- (object object)
- (handler unsigned-int))
-
-(define-foreign signal-handler-block () nil
- (object object)
- (handler unsigned-int))
-
-(define-foreign signal-handler-unblock () nil
- (object object)
- (handler unsigned-int))
-
-
-;;;; Metaclass used for subclasses of object
-
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (defclass object-class (gobject-class))
-
- (defclass direct-object-slot-definition (direct-virtual-slot-definition))
-
- (defclass effective-object-slot-definition
- (effective-virtual-slot-definition)))
-
-
-(defmethod initialize-instance :after ((slotd direct-object-slot-definition)
- &rest initargs &key)
- (declare (ignore initargs))
- (unless (slot-boundp slotd 'location)
- (with-slots (pcl::name location pcl::class) slotd
- (setf
- location
- (format nil "~A::~A"
- (alien-type-name (class-name pcl::class))
- (name-to-string pcl::name))))))
-
-
-(defmethod direct-slot-definition-class ((class object-class) initargs)
- (case (getf initargs :allocation)
- (:arg (find-class 'direct-object-slot-definition))
- (t (call-next-method))))
-
-
-(defmethod effective-slot-definition-class ((class object-class) initargs)
- (case (getf initargs :allocation)
- (:arg (find-class 'effective-object-slot-definition))
- (t (call-next-method))))
-
-
-(defmethod compute-virtual-slot-location
- ((class object-class) (slotd effective-object-slot-definition)
- direct-slotds)
- (with-slots (type) slotd
- (let ((location (slot-definition-location (first direct-slotds)))
- (type-number (find-type-number type))
- (reader (get-reader-function type))
- (writer (get-writer-function type))
- (destroy (get-destroy-function type)))
- (list
- #'(lambda (object)
- (with-gc-disabled
- (let ((arg (arg-new type-number)))
- (setf (arg-name arg) location)
- (object-get-arg object arg)
- (prog1
- (funcall reader arg +arg-value-offset+)
- (arg-free arg t t)))))
- #'(lambda (value object)
- (with-gc-disabled
- (let ((arg (arg-new type-number)))
- (setf (arg-name arg) location)
- (funcall writer value arg +arg-value-offset+)
- (object-set-arg object arg)
- (funcall destroy arg +arg-value-offset+)
- (arg-free arg nil)
- value)))))))
-
-
-(defmethod validate-superclass ((class object-class)
- (super pcl::standard-class))
- (subtypep (class-name super) 'object))
-
-
-;;;; Metaclasses used for widgets and containers
-
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (defclass widget-class (object-class))
-
- (defclass container-class (widget-class)
- (child-class)))
-
-
-(defvar *child-to-container-class-mappings* (make-hash-table))
-
-(defmethod shared-initialize ((class container-class) names
- &rest initargs &key name child-class)
- (declare (ignore initargs))
- (call-next-method)
- (with-slots ((child-class-slot child-class)) class
- (setf
- child-class-slot
- (or
- (first child-class)
- (intern (format nil "~A-CHILD" (or name (class-name class)))))
- (gethash child-class-slot *child-to-container-class-mappings*)
- class)))