chiark / gitweb /
Bug fix
[clg] / gtk / gtktree.lisp
index e67e26f0902af69d176d6bb38b0ae83330b92058..e86546017c12cd93c4654937090db1e976c41fca 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: gtktree.lisp,v 1.20 2006-04-26 20:31:12 espen Exp $
+;; $Id: gtktree.lisp,v 1.23 2006-08-15 10:13:42 espen Exp $
 
 
 (in-package "GTK")
@@ -73,6 +73,14 @@ (defbinding cell-layout-clear-attributes () nil
   (cell cell-renderer))
 
 
+;;;; Cell Renderer
+
+(defmethod compute-signal-function ((gobject cell-renderer-toggle) (signal (eql 'toggled)) function object)
+  (declare (ignore gobject signal function object))
+  (let ((function (call-next-method)))
+    #'(lambda (object path)
+       (funcall function object (ensure-tree-path path)))))
+
 
 ;;;; List Store
 
@@ -210,10 +218,11 @@ (defbinding %tree-path-get-depth () int
   (location pointer))
 
 (defun %make-tree-path (path)
-  (let ((c-vector (make-c-vector 'int (length path) :content path))
-       (location (allocate-memory (+ (size-of 'int) (size-of 'pointer)))))
+  (let* ((c-vector (make-c-vector 'int (length path) :content path))
+        (pointer-offset (adjust-offset (size-of 'int) 'pointer))
+        (location (allocate-memory (+ pointer-offset (size-of 'pointer)))))
     (funcall (writer-function 'int) (length path) location)
-    (funcall (writer-function 'pointer) c-vector location (size-of 'int))
+    (funcall (writer-function 'pointer) c-vector location pointer-offset)
     location))
 
 (defun %tree-path-to-vector (location)
@@ -224,10 +233,11 @@ (defun %tree-path-to-vector (location)
       (map-c-vector 'vector #'identity indices 'int depth))))
 
 (defmacro %with-tree-path ((var path) &body body)
-  (let ((vector-offset (+ (size-of 'int) (size-of 'pointer))))
-    `(with-memory (,var (+ ,(size-of 'int) ,(size-of 'pointer) (* ,(size-of 'int) (length ,path))))
+  (let* ((pointer-offset (adjust-offset (size-of 'int) 'pointer))
+        (vector-offset (adjust-offset (+ pointer-offset (size-of 'pointer)) 'int)))
+    `(with-memory (,var (+ ,vector-offset (* ,(size-of 'int) (length ,path))))
       (funcall (writer-function 'int) (length ,path) ,var)
-      (setf (ref-pointer ,var ,(size-of 'int)) (pointer+ ,var ,vector-offset))
+      (setf (ref-pointer ,var ,pointer-offset) (pointer+ ,var ,vector-offset))
       (make-c-vector 'int (length ,path) :content ,path :location (pointer+ ,var ,vector-offset))
       ,@body)))
 
@@ -306,6 +316,11 @@ (define-type-method destroy-function ((type tree-path) &key temp inlined)
   #'(lambda (location &optional (offset 0))
       (%tree-path-free (ref-pointer location offset))))
 
+(defun ensure-tree-path (path)
+  (etypecase path
+    (string (coerce (clg-utils:split-string path :delimiter #\:) 'vector))
+    (vector path)))
+
 
 (defbinding %tree-row-reference-new () pointer
   (model tree-model)