X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/1de3a4180b9466454eeb09e9e690ff50097be710..0d46865dfcbe69bbc1825d83c4985b703c4024e7:/gtk/gtkwidget.lisp?ds=sidebyside diff --git a/gtk/gtkwidget.lisp b/gtk/gtkwidget.lisp index b510ec0..c680614 100644 --- a/gtk/gtkwidget.lisp +++ b/gtk/gtkwidget.lisp @@ -15,50 +15,65 @@ ;; License along with this library; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -;; $Id: gtkwidget.lisp,v 1.8 2002-03-24 12:58:34 espen Exp $ +;; $Id: gtkwidget.lisp,v 1.14 2005-01-06 21:00:51 espen Exp $ (in-package "GTK") (defmethod shared-initialize ((widget widget) names &rest initargs &key parent) - (declare (ignore initargs names)) + (remf initargs :parent) (prog1 - (call-next-method) + (apply #'call-next-method widget names initargs) (when parent - (let ((old-parent (widget-parent widget)) - (parent-widget (first (mklist parent))) + (when (slot-boundp widget 'parent) + (container-remove (widget-parent widget) widget)) + (let ((parent-widget (first (mklist parent))) (args (rest (mklist parent)))) - (when old-parent - (container-remove old-parent widget)) (apply #'container-add parent-widget widget args))))) (defmethod shared-initialize :after ((widget widget) names &rest initargs - &key show-all) + &key show-all all-visible) (declare (ignore initargs names)) - (when show-all + (when (or all-visible show-all) (widget-show-all widget))) (defmethod slot-unbound ((class gobject-class) (object widget) slot) (cond - ((and (eq slot 'child-slots) (slot-value object 'parent)) - (with-slots (parent child-slots) object + ((and (eq slot 'child-properties) (slot-value object 'parent)) + (with-slots (parent child-properties) object (setf - child-slots + child-properties (make-instance (gethash (class-of parent) *container-to-child-class-mappings*) :parent parent :child object)))) (t (call-next-method)))) - -(defun child-slot-value (widget slot) - (slot-value (widget-child-slots widget) slot)) - -(defun (setf child-slot-value) (value widget slot) - (setf (slot-value (widget-child-slots widget) slot) value)) - -(defmacro with-child-slots (slots widget &body body) - `(with-slots ,slots (widget-child-slots ,widget) +(defmethod create-callback-function ((widget widget) function arg1) + (if (eq arg1 :parent) + #'(lambda (&rest args) + (if (slot-boundp widget 'parent) + (apply function (widget-parent widget) (rest args)) + (signal-connect widget 'parent-set + #'(lambda (old-parent) + (declare (ignore old-parent)) + (let ((*signal-stop-emission* + #'(lambda () + (warn "Ignoring emission stop in delayed signal handler")))) + (apply function (widget-parent widget) (rest args)))) + :remove t) +; (warn "Widget has no parent -- ignoring signal") + )) + (call-next-method))) + +(defun child-property-value (widget slot) + (slot-value (widget-child-properties widget) slot)) + +(defun (setf child-property-value) (value widget slot) + (setf (slot-value (widget-child-properties widget) slot) value)) + +(defmacro with-child-properties (slots widget &body body) + `(with-slots ,slots (widget-child-properties ,widget) ,@body)) @@ -156,8 +171,7 @@ (defbinding %widget-intersect () boolean (widget widget) (area gdk:rectangle) - (intersection pointer)) - + (intersection (or null gdk:rectangle))) (defun widget-intersection (widget area) (let ((intersection (make-instance 'gdk:rectangle))) @@ -165,10 +179,10 @@ intersection))) (defun widget-intersect-p (widget area) - (%widget-intersect widget area (make-pointer 0))) + (%widget-intersect widget area nil)) -(defbinding (widget-is-focus-p "gtk_widget_is_focus") () boolean - (widget widget)) +;; (defbinding (widget-is-focus-p "gtk_widget_is_focus") () boolean +;; (widget widget)) (defbinding widget-grab-focus () nil (widget widget)) @@ -361,7 +375,7 @@ received." (defun widget-get-size-request (widget) (multiple-value-bind (width height) (%widget-get-size-request widget) - (values (unless (= width -1) width) (unless (= height -1) height)))) + (values (unless (= width -1) width) (unless (= height -1) height)))) (defbinding widget-set-size-request (widget width height) nil (widget widget) @@ -374,7 +388,7 @@ received." ;;; Additional bindings and functions -(defbinding widget-mapped-p () boolean +(defbinding (widget-mapped-p "gtk_widget_mapped_p") () boolean (widget widget)) (defbinding widget-get-size-allocation () nil @@ -386,5 +400,5 @@ received." (event gdk:event)) (defun (setf widget-cursor) (cursor-type widget) - (let ((cursor (make-instance 'cursor :type cursor-type))) + (let ((cursor (make-instance 'gdk:cursor :type cursor-type))) (gdk:window-set-cursor (widget-window widget) cursor)))