[PATCH] gtk/gtktree.lisp: Fixing string representations of tree paths.

[email protected] (Mark Wooding) Sat, 3 Jan 2009 01:46:34 +0000
Newsgroups gmane.lisp.clg.devel
Message-ID <[email protected]>
  * The old ensure-tree-path returned a vector of strings, which is
    useless.  Fixed to return a vector of integers, using parse-integer.

  * Make tree-model-get-iter apply ensure-tree-path to its argument.

  * Enable ensure-tree-iter to coerce string representations of paths.
--
This one's been lying around in my tree for a while.  Here's the actual
motivation.

The basic problem is that the :EDITED signal from a
GTK:CELL-RENDERER-TEXT passes its path argument as a string.  This would
be fine, except for two things.

Handily, (SETF GTK:TREE-MODEL-VALUE) applies ENSURE-TREE-ITER to its ROW
argument.  Less handily, ENSURE-TREE-ITER doesn't call ENSURE-TREE-PATH
to convert a string to a path.  Even worse, ENSURE-TREE-PATH botches the
string-to-path conversion by producing a vector of strings, which nobody
really wanted.

diff --git a/gtk/gtktree.lisp b/gtk/gtktree.lisp
index e882bdb..5f9a181 100644
--- a/gtk/gtktree.lisp
+++ b/gtk/gtktree.lisp
@@ -348,7 +348,8 @@
 
 (defun ensure-tree-path (path)
   (etypecase path
-    (string (coerce (clg-utils:split-string path :delimiter #\:) 'vector))
+    (string (map 'vector #'parse-integer
+		 (clg-utils:split-string path :delimiter #\:)))
     (vector path)))
 
 
@@ -383,7 +384,7 @@
 (defbinding tree-model-get-iter (model path &optional (iter (make-instance 'tree-iter))) boolean
   (model tree-model)
   (iter tree-iter :in/return)
-  (path tree-path))
+  ((ensure-tree-path path) tree-path))
 
 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
 (defmethod allocate-foreign ((tree-iter tree-iter) &rest initargs)
@@ -394,7 +395,7 @@
 (defun ensure-tree-iter (model row)
   (etypecase row
     (tree-iter row)
-    (tree-path 
+    ((or tree-path string)
      (multiple-value-bind (valid-p iter) (tree-model-get-iter model row)
        (if valid-p
 	   iter


-- [mdw]

------------------------------------------------------------------------------