-(defmethod initialize-instance ((widget widget) &rest initargs &key parent)
- (declare (ignore initargs))
- (cond
- ((consp parent)
- (with-slots ((container parent) child-slots) widget
- (setf
- container (car parent)
- child-slots
- (apply
- #'make-instance
- (slot-value (class-of container) 'child-class)
- :parent container :child widget (cdr parent)))))
- (parent
- (setf (slot-value widget 'parent) parent)))
- (call-next-method))
+(defmethod shared-initialize ((widget widget) names &rest initargs &key parent)
+ (declare (ignore initargs names))
+ (call-next-method)
+ (when parent
+ (let ((old-parent (widget-parent widget))
+ (parent-widget (first (mklist parent)))
+ (args (rest (mklist parent))))
+ (when old-parent
+ (container-remove old-parent widget))
+ (apply #'container-add parent-widget widget args))))