Merge remote-tracking branch 'andy128k/master'
[cl-gtk2.git] / gtk / gtk.tree-store.lisp
blobcb765b201f1a3db393a39b12965e2f56576fed96
1 (in-package :gtk)
3 (defcfun gtk-tree-store-set-column-types :void
4 (tree-store (g-object tree-store))
5 (n-columns :int)
6 (types :pointer))
8 (defun call-tree-store-set-column-types (tree-store column-types)
9 (let ((n (length column-types)))
10 (with-foreign-object (types-ar 'g-type-designator n)
11 (iter (for i from 0 below n)
12 (for type in column-types)
13 (setf (mem-aref types-ar 'g-type-designator i) type))
14 (gtk-tree-store-set-column-types tree-store n types-ar))))
16 (defmethod initialize-instance :after ((store tree-store) &rest initargs &key (column-types nil column-types-supplied-p) &allow-other-keys)
17 (declare (ignore initargs))
18 (when column-types-supplied-p
19 (call-tree-store-set-column-types store column-types)))
21 (defcfun (%gtk-tree-store-set-value "gtk_tree_store_set_value") :void
22 (tree-store (g-object tree-store))
23 (iter (g-boxed-foreign tree-iter))
24 (column :int)
25 (value :pointer))
27 (defun gtk-tree-store-set-value (tree-store iter column value)
28 (with-foreign-object (v 'g-value)
29 (set-g-value v value (tree-model-column-type tree-store column) :zero-g-value t)
30 (%gtk-tree-store-set-value tree-store iter column v)
31 (g-value-unset v)
32 (values)))
34 (defun tree-store-value (tree-store iter column)
35 (tree-model-value tree-store iter column))
37 (defun (setf tree-store-value) (new-value tree-store iter column)
38 (gtk-tree-store-set-value tree-store iter column new-value)
39 new-value)
41 (export 'tree-store-value)
43 ;; not implemented
44 ;; void gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
45 ;; GtkTreeIter *iter,
46 ;; gint *columns,
47 ;; GValue *values,
48 ;; gint n_values);
50 (defcfun (tree-store-remove "gtk_tree_store_remove") :boolean
51 (tree-store (g-object tree-store))
52 (iter (g-boxed-foreign tree-iter)))
54 (export 'tree-store-remove)
56 (defcfun gtk-tree-store-insert :void
57 (tree-store (g-object tree-store))
58 (iter (g-boxed-foreign tree-iter))
59 (parent (g-boxed-foreign tree-iter))
60 (position :int))
62 (defun tree-store-insert (tree-store parent position)
63 (let ((iter (make-tree-iter)))
64 (gtk-tree-store-insert tree-store iter parent position)
65 iter))
67 (defcfun gtk-tree-store-insert-before :void
68 (tree-store (g-object tree-store))
69 (iter (g-boxed-foreign tree-iter))
70 (parent (g-boxed-foreign tree-iter))
71 (sibling (g-boxed-foreign tree-iter)))
73 (defun tree-store-insert-before (tree-store parent sibling)
74 (let ((iter (make-tree-iter)))
75 (gtk-tree-store-insert-before tree-store iter parent sibling)
76 iter))
78 (defcfun gtk-tree-store-insert-after :void
79 (tree-store (g-object tree-store))
80 (iter (g-boxed-foreign tree-iter))
81 (parent (g-boxed-foreign tree-iter))
82 (sibling (g-boxed-foreign tree-iter)))
84 (defun tree-store-insert-after (tree-store parent sibling)
85 (let ((iter (make-tree-iter)))
86 (gtk-tree-store-insert-after tree-store iter parent sibling)
87 iter))
89 (export '(tree-store-insert tree-store-insert-before tree-store-insert-after))
91 (defcfun gtk-tree-store-insert-with-valuesv :void
92 (tree-store (g-object tree-store))
93 (iter (g-boxed-foreign tree-iter))
94 (parent (g-boxed-foreign tree-iter))
95 (position :int)
96 (columns :pointer)
97 (values :pointer)
98 (n-values :int))
100 (defun tree-store-insert-with-values (tree-store parent position &rest values)
101 (let ((n (length values))
102 (iter (make-tree-iter)))
103 (with-foreign-objects ((v-ar 'g-value n)
104 (columns-ar :int n))
105 (iter (for i from 0 below n)
106 (for value in values)
107 (for type = (tree-model-column-type tree-store i))
108 (setf (mem-aref columns-ar :int i) i)
109 (set-g-value (mem-aref v-ar 'g-value i) value type :zero-g-value t))
110 (gtk-tree-store-insert-with-valuesv tree-store iter parent position columns-ar v-ar n)
111 (iter (for i from 0 below n)
112 (g-value-unset (mem-aref v-ar 'g-value i)))
113 iter)))
115 (export 'tree-store-insert-with-values)
117 (defcfun gtk-tree-store-prepend :void
118 (tree-store (g-object tree-store))
119 (iter (g-boxed-foreign tree-iter))
120 (parent (g-boxed-foreign tree-iter)))
122 (defun tree-store-prepend (tree-store parent)
123 (let ((iter (make-tree-iter)))
124 (gtk-tree-store-prepend tree-store iter parent)
125 iter))
127 (defcfun gtk-tree-store-append :void
128 (tree-store (g-object tree-store))
129 (iter (g-boxed-foreign tree-iter))
130 (parent (g-boxed-foreign tree-iter)))
132 (defun tree-store-append (tree-store parent)
133 (let ((iter (make-tree-iter)))
134 (gtk-tree-store-append tree-store iter parent)
135 iter))
137 (export '(tree-store-prepend tree-store-append))
139 (defcfun (tree-store-is-ancestor "gtk_tree_store_is_ancestor") :boolean
140 (tree-store (g-object tree-store))
141 (iter (g-boxed-foreign tree-iter))
142 (descendant (g-boxed-foreign tree-iter)))
144 (export 'tree-store-is-ancestor)
146 (defcfun (tree-store-iter-depth "gtk_tree_store_iter_depth") :int
147 (tree-store (g-object tree-store))
148 (tree-iter (g-boxed-foreign tree-iter)))
150 (export 'tree-store-iter-depth)
152 (defcfun (tree-store-clear "gtk_tree_store_clear") :void
153 (tree-store (g-object tree-store)))
155 (export 'tree-store-clear)
157 (defcfun (tree-store-iter-is-valid "gtk_tree_store_iter_is_valid") :boolean
158 (tree-store (g-object tree-store))
159 (iter (g-boxed-foreign tree-iter)))
161 (export 'tree-store-iter-is-valid)
163 ;; not implemented
164 ;; void gtk_tree_store_reorder (GtkTreeStore *tree_store,
165 ;; GtkTreeIter *parent,
166 ;; gint *new_order);
169 (defcfun (tree-store-swap "gtk_tree_store_swap") :void
170 (tree-store (g-object tree-store))
171 (a (g-boxed-foreign tree-iter))
172 (b (g-boxed-foreign tree-iter)))
174 (export 'tree-store-swap)
176 (defcfun (tree-store-move-before "gtk_tree_store_move_before") :void
177 (tree-store (g-object tree-store))
178 (iter (g-boxed-foreign tree-iter))
179 (position (g-boxed-foreign tree-iter)))
181 (export 'tree-store-move-before)
183 (defcfun (tree-store-move-after "gtk_tree_store_move_after") :void
184 (tree-store (g-object tree-store))
185 (iter (g-boxed-foreign tree-iter))
186 (position (g-boxed-foreign tree-iter)))
188 (export 'tree-store-move-after)