Fix typo in gl-drawing-area code
[cl-gtk2.git] / gtk / gtk.tree-model.lisp
blob82c451f85b1affd1cbf27588286975eb6a9d4a8e
1 (in-package :gtk)
3 (define-vtable ("GtkTreeModel" tree-model)
4 (:skip parent-instance g-type-interface)
5 ;;some signals
6 (:skip tree-model-row-changed :pointer)
7 (:skip tree-model-row-inserted :pointer)
8 (:skip tree-model-row-has-child-toggled :pointer)
9 (:skip tree-model-row-deleted :pointer)
10 (:skip tree-model-rows-reordered :pointer)
11 ;;methods
12 (get-flags (tree-model-flags (tree-model g-object)))
13 (get-n-columns (:int (tree-model g-object)))
14 (get-column-type (g-type-designator
15 (tree-model g-object)
16 (index :int)))
17 (get-iter (:boolean
18 (tree-model g-object)
19 (iter (g-boxed-foreign tree-iter))
20 (path (g-boxed-foreign tree-path))))
21 (get-path ((g-boxed-foreign tree-path :return)
22 (tree-model g-object)
23 (iter (g-boxed-foreign tree-iter))))
24 (get-value (:void
25 (tree-model g-object)
26 (iter (g-boxed-foreign tree-iter))
27 (n :int)
28 (value (:pointer g-value)))
29 :impl-call
30 ((tree-model iter n)
31 (multiple-value-bind (v type) (tree-model-get-value-impl tree-model iter n)
32 (set-g-value value v type))))
33 (iter-next (:boolean
34 (tree-model g-object)
35 (iter (g-boxed-foreign tree-iter))))
36 (iter-children (:boolean
37 (tree-model g-object)
38 (iter (g-boxed-foreign tree-iter))
39 (parent (g-boxed-foreign tree-iter))))
40 (iter-has-child (:boolean
41 (tree-model g-object)
42 (iter (g-boxed-foreign tree-iter))))
43 (iter-n-children (:int
44 (tree-model g-object)
45 (iter (g-boxed-foreign tree-iter))))
46 (iter-nth-child (:boolean
47 (tree-model g-object)
48 (iter (g-boxed-foreign tree-iter))
49 (parent (g-boxed-foreign tree-iter))
50 (n :int)))
51 (iter-parent (:boolean
52 (tree-model g-object)
53 (iter (g-boxed-foreign tree-iter))
54 (child (g-boxed-foreign tree-iter))))
55 (ref-node (:void
56 (tree-model g-object)
57 (iter (g-boxed-foreign tree-iter))))
58 (unref-node (:void
59 (tree-model g-object)
60 (iter (g-boxed-foreign tree-iter)))))
62 (define-vtable ("GtkTreeSortable" tree-sortable)
63 (:skip parent-instance g-type-interface)
64 ;; signal
65 (:skip sort-columns-changed :pointer)
66 ;; methods
67 (get-sort-column-id
68 (:boolean (sortable (g-object tree-sortable))
69 (sort-column-id (:pointer :int))
70 (order (:pointer sort-type)))
71 :impl-call ((sortable)
72 (multiple-value-bind (sorted-p r-sort-column-id r-order) (tree-sortable-get-sort-column-id-impl sortable)
73 (unless (null-pointer-p sort-column-id)
74 (setf (mem-ref sort-column-id :int) r-sort-column-id))
75 (unless (null-pointer-p order)
76 (setf (mem-ref order 'sort-type) r-order))
77 sorted-p)))
78 (set-sort-column-id (:void (sortable (g-object tree-sortable)) (sort-column-id :int) (order sort-type)))
79 (set-sort-func (:void (sortable (g-object tree-sortable)) (sort-column-id :int) (func :pointer) (data :pointer) (destroy-notify :pointer)))
80 (set-default-sort-func (:void (sortable (g-object tree-sortable)) (func :pointer) (data :pointer) (destroy-notify :pointer)))
81 (has-default-sort-func (:boolean (sortable (g-object tree-sortable)))))
83 (defcfun (tree-model-sort-convert-child-path-to-path "gtk_tree_model_sort_convert_child_path_to_path") (g-boxed-foreign tree-path :return)
84 (tree-model-sort (g-object tree-model-sort))
85 (child-path (g-boxed-foreign tree-path)))
87 (export 'tree-model-sort-conver-child-path-to-path)
89 (defcfun gtk-tree-model-sort-convert-child-iter-to-iter :boolean
90 (tree-model-sort (g-object tree-model-sort))
91 (sort-iter (g-boxed-foreign tree-iter))
92 (child-iter (g-boxed-foreign tree-iter)))
94 (defun tree-model-sort-convert-child-iter-to-iter (tree-model-sort child-iter)
95 (let ((sort-iter (make-tree-iter)))
96 (when (gtk-tree-model-sort-convert-child-iter-to-iter tree-model-sort sort-iter child-iter)
97 sort-iter)))
99 (export 'tree-model-sort-convert-child-iter-to-iter)
101 (defcfun (tree-model-sort-convert-path-to-child-path "gtk_tree_model_sort_convert_path_to_child_path") (g-boxed-foreign tree-path :return)
102 (tree-model-sort (g-object tree-model-sort))
103 (sort-path (g-boxed-foreign tree-path)))
105 (export 'tree-model-sort-convert-path-to-child-path)
107 (defcfun gtk-tree-model-sort-convert-iter-to-child-iter :void
108 (tree-model-sort (g-object tree-model-sort))
109 (child-iter (g-boxed-foreign tree-iter))
110 (sorted-iter (g-boxed-foreign tree-iter)))
112 (defun tree-model-sort-convert-iter-to-child-iter (tree-model-sort sorted-iter)
113 (let ((child-iter (make-tree-iter)))
114 (gtk-tree-model-sort-convert-iter-to-child-iter tree-model-sort child-iter sorted-iter)
115 child-iter))
117 (export 'tree-model-sort-convert-iter-to-child-iter)
119 (defcfun (tree-model-sort-reset-default-sort-func "gtk_tree_model_sort_reset_default_sort_func") :void
120 (tree-model-sort (g-object tree-model-sort)))
122 (export 'tree-model-sort-reset-default-sort-func)
124 (defcfun (tree-model-sort-clear-cache "gtk_tree_model_sort_clear_cache") :void
125 (tree-model-sort (g-object tree-model-sort)))
127 (export 'tree-model-sort-clear-cached)
129 (defcfun (tree-model-sort-iter-is-valid "gtk_tree_model_sort_iter_is_valid") :boolean
130 (tree-model-sort (g-object tree-model-sort))
131 (iter (g-boxed-foreign tree-iter)))
133 (export 'tree-model-sort-iter-is-valid)
135 ; TODO: GtkTreeModelFilter
137 (defclass array-list-store (tree-model)
138 ((items :initform (make-array 0 :adjustable t :fill-pointer t) :reader store-items)
139 (columns-getters :initform (make-array 0 :adjustable t :fill-pointer t) :reader store-getters)
140 (columns-types :initform (make-array 0 :adjustable t :fill-pointer t) :reader store-types))
141 (:metaclass gobject-class)
142 (:g-type-name . "LispArrayListStore"))
144 (export 'array-list-store)
146 (register-object-type-implementation "LispArrayListStore" array-list-store "GObject" ("GtkTreeModel") nil)
148 (defun store-items-count (store)
149 (length (store-items store)))
151 (export 'store-items-count)
153 (defun store-item (store index)
154 (aref (store-items store) index))
156 (export 'store-item)
158 (defun store-add-item (store item)
159 (vector-push-extend item (store-items store))
160 (let* ((path (make-instance 'tree-path))
161 (iter (make-tree-iter)))
162 (setf (tree-path-indices path) (list (1- (length (store-items store)))))
163 (setf (tree-iter-stamp iter) 0 (tree-iter-user-data iter) (1- (length (store-items store))))
164 (emit-signal store "row-inserted" path iter)))
166 (export 'store-add-item)
168 (defun store-remove-item (store item &key (test 'eq))
169 (with-slots (items) store
170 (let ((index (position item items :test test)))
171 (unless index (error "No such item~%~A~%in list-store~%~A" item store))
172 (setf items (delete item items :test test))
173 (let ((path (make-instance 'tree-path)))
174 (setf (tree-path-indices path) (list index))
175 (emit-signal store "row-deleted" path)))))
177 (export 'store-remove-item)
179 (defun store-add-column (store type getter)
180 (vector-push-extend type (store-types store))
181 (vector-push-extend getter (store-getters store))
182 (1- (length (store-types store))))
184 (export 'store-add-column)
186 (defmethod tree-model-get-flags-impl ((model array-list-store))
187 '(:list-only))
189 (defmethod tree-model-get-n-columns-impl ((model array-list-store))
190 (length (store-types model)))
192 (defmethod tree-model-get-column-type-impl ((tree-model array-list-store) index)
193 (aref (store-types tree-model) index))
195 (defmethod tree-model-get-iter-impl ((model array-list-store) iter path)
196 (let ((indices (tree-path-indices path)))
197 (when (and (= 1 (length indices))
198 (< (first indices) (length (store-items model))))
199 (setf (tree-iter-stamp iter) 0 (tree-iter-user-data iter) (first indices))
200 t)))
202 (defmethod tree-model-ref-node-impl ((model array-list-store) iter)
203 (declare (ignorable model iter)))
204 (defmethod tree-model-unref-node-impl ((model array-list-store) iter)
205 (declare (ignorable model iter)))
207 (defmethod tree-model-iter-next-impl ((model array-list-store) iter)
208 (let ((n (tree-iter-user-data iter)))
209 (when (< n (1- (length (store-items model))))
210 (setf (tree-iter-user-data iter) (1+ n))
211 t)))
213 (defmethod tree-model-iter-nth-child-impl ((model array-list-store) iter parent n)
214 (declare (ignorable parent))
215 (setf (tree-iter-stamp iter) 0
216 (tree-iter-user-data iter) n)
219 (defmethod tree-model-iter-children-impl ((model array-list-store) iter parent)
220 (declare (ignore iter parent))
221 nil)
223 (defmethod tree-model-iter-n-children-impl ((model array-list-store) iter)
224 (if (null iter)
225 (length (store-items model))
228 (defmethod tree-model-get-path-impl ((model array-list-store) iter)
229 (let ((path (make-instance 'tree-path)))
230 (setf (tree-path-indices path) (list (tree-iter-user-data iter)))
231 path))
233 (defmethod tree-model-iter-has-child-impl ((model array-list-store) iter)
234 (declare (ignorable iter))
235 nil)
237 (defgeneric tree-model-item (model iter-or-path))
239 (defmethod tree-model-item ((model array-list-store) (iter tree-iter))
240 (let ((n-row (tree-iter-user-data iter)))
241 (aref (store-items model) n-row)))
243 (defmethod tree-model-item ((model array-list-store) (path tree-path))
244 (let ((n-row (first (tree-path-indices path))))
245 (aref (store-items model) n-row)))
247 (export 'tree-model-item)
249 (defmethod tree-model-get-value-impl ((model array-list-store) iter n)
250 (let ((n-row (tree-iter-user-data iter)))
251 (values (funcall (aref (store-getters model) n)
252 (aref (store-items model) n-row))
253 (aref (store-types model) n))))
255 (defcfun (tree-model-flags "gtk_tree_model_get_flags") tree-model-flags
256 (tree-model g-object))
258 (export 'tree-model-flags)
260 (defcfun (tree-model-n-columns "gtk_tree_model_get_n_columns") :int
261 (tree-model g-object))
263 (export 'tree-model-flags)
265 (defcfun (tree-model-column-type "gtk_tree_model_get_column_type") g-type-designator
266 (tree-model g-object)
267 (index :int))
269 (export 'tree-model-column-type)
271 (defcfun (tree-model-set-iter-to-path "gtk_tree_model_get_iter") :boolean
272 (tree-model g-object)
273 (iter (g-boxed-foreign tree-iter))
274 (path (g-boxed-foreign tree-path)))
276 (defun tree-model-iter-by-path (tree-model tree-path)
277 (let ((iter (make-tree-iter)))
278 (if (tree-model-set-iter-to-path tree-model iter tree-path)
279 iter
280 nil)))
282 (export 'tree-model-iter-by-path)
284 (defcfun (tree-model-set-iter-from-string "gtk_tree_model_get_iter_from_string") :boolean
285 (tree-model g-object)
286 (iter (g-boxed-foreign tree-iter))
287 (path-string :string))
289 (defun tree-model-iter-from-string (tree-model path-string)
290 (let ((iter (make-tree-iter)))
291 (if (tree-model-set-iter-from-string tree-model iter path-string)
292 iter
293 nil)))
295 (export 'tree-model-iter-from-string)
297 (defcfun (tree-model-set-iter-to-first "gtk_tree_model_get_iter_first") :boolean
298 (model g-object)
299 (iter (g-boxed-foreign tree-iter)))
301 (defun tree-model-iter-first (tree-model)
302 (let ((iter (make-tree-iter)))
303 (if (tree-model-set-iter-to-first tree-model iter)
304 iter
305 nil)))
307 (export 'tree-model-iter-first)
309 (defcfun (tree-model-path "gtk_tree_model_get_path") (g-boxed-foreign tree-path :return)
310 (tree-model g-object)
311 (iter (g-boxed-foreign tree-iter)))
313 (export 'tree-model-path)
315 (defcfun gtk-tree-model-get-value :void
316 (model g-object)
317 (iter (g-boxed-foreign tree-iter))
318 (column :int)
319 (value (:pointer g-value)))
321 (defun tree-model-value (tree-model iter column)
322 (with-foreign-object (v 'g-value)
323 (g-value-zero v)
324 (gtk-tree-model-get-value tree-model iter column v)
325 (prog1 (parse-g-value v)
326 (g-value-unset v))))
328 (export 'tree-model-value)
330 (defcfun (tree-model-iter-next "gtk_tree_model_iter_next") :boolean
331 (tree-model g-object)
332 (iter (g-boxed-foreign tree-iter)))
334 (export 'tree-model-iter-next)
336 (defcfun gtk-tree-model-iter-children :boolean
337 (tree-model g-object)
338 (iter (g-boxed-foreign tree-iter))
339 (parent (g-boxed-foreign tree-iter)))
341 (defun tree-model-iter-first-child (tree-model parent)
342 (let ((iter (make-tree-iter)))
343 (if (gtk-tree-model-iter-children tree-model iter parent)
344 iter
345 nil)))
347 (export 'tree-model-iter-first-child)
349 (defcfun (tree-model-iter-has-child "gtk_tree_model_iter_has_child") :boolean
350 (tree-model g-object)
351 (iter (g-boxed-foreign tree-iter)))
353 (export 'tree-model-iter-has-child)
355 (defcfun (tree-model-iter-n-children "gtk_tree_model_iter_n_children") :int
356 (tree-model g-object)
357 (iter (g-boxed-foreign tree-iter)))
359 (export 'tree-model-iter-n-children)
361 (defcfun gtk-tree-model-iter-nth-child :boolean
362 (tree-model g-object)
363 (iter (g-boxed-foreign tree-iter))
364 (parent (g-boxed-foreign tree-iter))
365 (n :int))
367 (defun tree-model-iter-nth-child (tree-model parent n)
368 (let ((iter (make-tree-iter)))
369 (if (gtk-tree-model-iter-nth-child tree-model iter parent n)
370 iter
371 n)))
373 (export 'tree-model-iter-nth-child)
375 (defcfun gtk-tree-model-iter-parent :boolean
376 (tree-model g-object)
377 (iter (g-boxed-foreign tree-iter))
378 (parent (g-boxed-foreign tree-iter)))
380 (defun tree-model-iter-parent (tree-model iter)
381 (let ((parent (make-tree-iter)))
382 (if (gtk-tree-model-iter-parent tree-model iter parent)
383 parent
384 nil)))
386 (export 'tree-model-iter-parent)
388 (defcfun (tree-model-iter-to-string "gtk_tree_model_get_string_from_iter") (g-string :free-from-foreign t)
389 (tree-model g-object)
390 (iter (g-boxed-foreign tree-iter)))
392 (export 'tree-model-iter-to-string)
394 (defcfun (tree-model-ref-node "gtk_tree_model_ref_node") :void
395 (tree-model g-object)
396 (iter (g-boxed-foreign tree-iter)))
398 (export 'tree-model-ref-node)
400 (defcfun (tree-model-unref-node "gtk_tree_model_unref_node") :void
401 (tree-model g-object)
402 (iter (g-boxed-foreign tree-iter)))
404 (export 'tree-model-unref-node)
406 (defcallback gtk-tree-model-foreach-cb :boolean ((model g-object) (path (g-boxed-foreign tree-path)) (iter (g-boxed-foreign tree-iter)) (data :pointer))
407 (let ((fn (get-stable-pointer-value data)))
408 (restart-case
409 (funcall fn model path iter)
410 (stop-tree-model-iteration () t)
411 (skip-tree-model-current () nil))))
413 (defcfun gtk-tree-model-foreach :void
414 (model g-object)
415 (func :pointer)
416 (data :pointer))
418 (defun do-tree-model (model fn)
419 (with-stable-pointer (ptr fn)
420 (gtk-tree-model-foreach model (callback gtk-tree-model-foreach-cb) ptr)))
422 (export 'do-tree-model)
424 (defun array-insert-at (array element index)
425 (assert (adjustable-array-p array))
426 (adjust-array array (1+ (length array)) :fill-pointer t)
427 (iter (for i from (1- (length array)) above index)
428 (setf (aref array i)
429 (aref array (1- i))))
430 (setf (aref array index) element)
431 array)
433 (defun array-remove-at (array index)
434 (assert (adjustable-array-p array))
435 (iter (for i from index below (1- (length array)))
436 (setf (aref array i)
437 (aref array (1+ i))))
438 (adjust-array array (1- (length array)) :fill-pointer t)
439 array)
441 (defstruct tree-node
442 (tree nil)
443 (parent nil)
444 (id nil)
445 (item nil)
446 (children (make-array 0 :element-type 'tree-node :adjustable t :fill-pointer t)))
448 (defclass tree-lisp-store (tree-model)
449 ((columns-getters :initform (make-array 0 :adjustable t :fill-pointer t) :reader tree-lisp-store-getters)
450 (columns-types :initform (make-array 0 :adjustable t :fill-pointer t) :reader tree-lisp-store-types)
451 (root :initform (make-tree-node) :reader tree-lisp-store-root)
452 (id-map :initform (make-hash-table) :reader tree-lisp-store-id-map)
453 (next-id-value :initform 0 :accessor tree-lisp-store-next-id-value))
454 (:metaclass gobject-class)
455 (:g-type-name . "LispTreeStore"))
457 (defmethod initialize-instance :after ((object tree-lisp-store) &key &allow-other-keys)
458 (setf (tree-node-tree (tree-lisp-store-root object)) object))
460 (register-object-type-implementation "LispTreeStore" tree-lisp-store "GObject" ("GtkTreeModel") nil)
462 (defun map-subtree (node fn)
463 (funcall fn node)
464 (iter (for child in-vector (tree-node-children node))
465 (map-subtree child fn)))
467 (defun clear-id (node)
468 (map-subtree node
469 (lambda (n)
470 (when (and (tree-node-id n)
471 (tree-node-tree n))
472 (remhash (tree-node-id n)
473 (tree-lisp-store-id-map (tree-node-tree n))))
474 (setf (tree-node-id n) nil))))
476 (defun set-node-tree (node tree)
477 (map-subtree node
478 (lambda (n)
479 (setf (tree-node-tree n) tree))))
481 (defun tree-node-insert-at (node child index)
482 (assert (null (tree-node-parent child)))
483 (clear-id child)
484 (setf (tree-node-parent child) node)
485 (set-node-tree child (tree-node-tree node))
486 (array-insert-at (tree-node-children node) child index)
487 (notice-tree-node-insertion (tree-node-tree node) node child index)
488 node)
490 (defun tree-node-child-at (node index)
491 (aref (tree-node-children node) index))
493 (defun tree-node-remove-at (node index)
494 (assert (<= 0 index (1- (length (tree-node-children node)))))
495 (let ((child (tree-node-child-at node index)))
496 (clear-id child)
497 (setf (tree-node-parent child) nil)
498 (set-node-tree child nil)
499 (array-remove-at (tree-node-children node) index)
500 (notice-tree-node-removal (tree-node-tree node) node child index)))
502 (defun tree-lisp-store-add-column (store column-type column-getter)
503 (vector-push-extend column-getter (tree-lisp-store-getters store))
504 (vector-push-extend column-type (tree-lisp-store-types store)))
506 (defmethod tree-model-get-flags-impl ((store tree-lisp-store))
507 nil)
509 (defmethod tree-model-get-n-columns-impl ((store tree-lisp-store))
510 (length (tree-lisp-store-getters store)))
512 (defmethod tree-model-get-column-type-impl ((store tree-lisp-store) index)
513 (aref (tree-lisp-store-types store) index))
515 (defun get-node-by-indices (root indices)
516 (if indices
517 (get-node-by-indices (tree-node-child-at root (first indices)) (rest indices))
518 root))
520 (defun get-node-by-path (tree path)
521 (let ((indices (tree-path-indices path)))
522 (get-node-by-indices (tree-lisp-store-root tree) indices)))
524 (defun get-node-path (node)
525 (iter (with z = nil)
526 (for parent = (tree-node-parent node))
527 (while parent)
528 (for index = (position node (tree-node-children parent)))
529 (push index z)
530 (setf node parent)
531 (finally (return z))))
533 (defun tree-lisp-store-get-next-id (tree)
534 (incf (tree-lisp-store-next-id-value tree)))
536 (defun tree-lisp-store-add-id-map (tree id node)
537 (setf (gethash id (tree-lisp-store-id-map tree)) node))
539 (defun get-assigned-id (tree node)
540 (or (tree-node-id node)
541 (let ((id (tree-lisp-store-get-next-id tree)))
542 (tree-lisp-store-add-id-map tree id node)
543 (setf (tree-node-id node) id)
544 id)))
546 (defun get-node-by-id (tree id)
547 (gethash id (tree-lisp-store-id-map tree)))
549 (defmethod tree-model-get-iter-impl ((store tree-lisp-store) iter path)
550 (let* ((node (get-node-by-path store path))
551 (node-idx (get-assigned-id store node)))
552 (setf (tree-iter-stamp iter) 0
553 (tree-iter-user-data iter) node-idx)))
555 (defun get-node-by-iter (tree iter)
556 (get-node-by-id tree (tree-iter-user-data iter)))
558 (defmethod tree-model-get-path-impl ((store tree-lisp-store) iter)
559 (let* ((path (make-instance 'tree-path))
560 (node (get-node-by-iter store iter))
561 (indices (get-node-path node)))
562 (setf (tree-path-indices path) indices)
563 path))
565 (defmethod tree-model-get-value-impl ((store tree-lisp-store) iter n)
566 (let* ((node (get-node-by-iter store iter))
567 (getter (aref (tree-lisp-store-getters store) n))
568 (type (aref (tree-lisp-store-types store) n)))
569 (values (funcall getter (tree-node-item node))
570 type)))
572 (defmethod tree-model-iter-next-impl ((store tree-lisp-store) iter)
573 (let* ((node (get-node-by-iter store iter))
574 (parent (tree-node-parent node))
575 (index (position node (tree-node-children parent))))
576 (when (< (1+ index) (length (tree-node-children parent)))
577 (setf (tree-iter-stamp iter)
579 (tree-iter-user-data iter)
580 (get-assigned-id store (tree-node-child-at parent (1+ index))))
581 t)))
583 (defmethod tree-model-iter-children-impl ((store tree-lisp-store) iter parent)
584 (let* ((node (if parent
585 (get-node-by-iter store parent)
586 (tree-lisp-store-root store))))
587 (when (plusp (length (tree-node-children node)))
588 (setf (tree-iter-stamp iter)
590 (tree-iter-user-data iter)
591 (get-assigned-id store (tree-node-child-at node 0)))
592 t)))
594 (defmethod tree-model-iter-has-child-impl ((store tree-lisp-store) iter)
595 (let ((node (get-node-by-iter store iter)))
596 (plusp (length (tree-node-children node)))))
598 (defmethod tree-model-iter-n-children-impl ((store tree-lisp-store) iter)
599 (let* ((node (if iter
600 (get-node-by-iter store iter)
601 (tree-lisp-store-root store))))
602 (length (tree-node-children node))))
604 (defmethod tree-model-iter-nth-child-impl ((store tree-lisp-store) iter parent n)
605 (let* ((node (if parent
606 (get-node-by-iter store parent)
607 (tree-lisp-store-root store)))
608 (requested-node (tree-node-child-at node n)))
609 (setf (tree-iter-stamp iter) 0
610 (tree-iter-user-data iter) (get-assigned-id store requested-node))
613 (defmethod tree-model-iter-parent-impl ((store tree-lisp-store) iter child)
614 (let ((node (get-node-by-iter store child)))
615 (when (tree-node-parent node)
616 (setf (tree-iter-stamp iter) 0
617 (tree-iter-user-data iter) (get-assigned-id store (tree-node-parent node))))))
619 (defmethod tree-model-ref-node-impl ((store tree-lisp-store) iter)
620 (declare (ignorable iter)))
622 (defmethod tree-model-unref-node-impl ((store tree-lisp-store) iter)
623 (declare (ignorable iter)))
625 (defun notice-tree-node-insertion (tree node child index)
626 (declare (ignore node index))
627 (when tree
628 (let* ((path (make-instance 'tree-path))
629 (iter (make-tree-iter)))
630 (setf (tree-path-indices path) (get-node-path child)
631 (tree-iter-stamp iter) 0
632 (tree-iter-user-data iter) (get-assigned-id tree child))
633 (emit-signal tree "row-inserted" path iter)
634 (when (plusp (length (tree-node-children child)))
635 (emit-signal tree "row-has-child-toggled" path iter)))))
637 (defun notice-tree-node-removal (tree node child index)
638 (declare (ignore child))
639 (when tree
640 (let ((path (make-instance 'tree-path)))
641 (setf (tree-path-indices path) (nconc (get-node-path node) (list index)))
642 (emit-signal tree "row-deleted" path))
643 (when (zerop (length (tree-node-children node)))
644 (let* ((path (make-instance 'tree-path))
645 (iter (make-tree-iter)))
646 (setf (tree-path-indices path) (get-node-path node)
647 (tree-iter-stamp iter) 0
648 (tree-iter-user-data iter) (get-assigned-id tree node))
649 (emit-signal tree "row-has-child-toggled" path iter)))))