| 1 | ;; Common Lisp bindings for GTK+ v2.0 |
| 2 | ;; Copyright (C) 1999-2001 Espen S. Johnsen <esj@stud.cs.uit.no> |
| 3 | ;; |
| 4 | ;; This library is free software; you can redistribute it and/or |
| 5 | ;; modify it under the terms of the GNU Lesser General Public |
| 6 | ;; License as published by the Free Software Foundation; either |
| 7 | ;; version 2 of the License, or (at your option) any later version. |
| 8 | ;; |
| 9 | ;; This library is distributed in the hope that it will be useful, |
| 10 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | ;; Lesser General Public License for more details. |
| 13 | ;; |
| 14 | ;; You should have received a copy of the GNU Lesser General Public |
| 15 | ;; License along with this library; if not, write to the Free Software |
| 16 | ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | |
| 18 | ;; $Id: gtktree.lisp,v 1.4 2004-12-17 00:36:32 espen Exp $ |
| 19 | |
| 20 | |
| 21 | (in-package "GTK") |
| 22 | |
| 23 | |
| 24 | ;;;; Cell Layout |
| 25 | |
| 26 | (defbinding cell-layout-pack-start () nil |
| 27 | (cell-layout cell-layout) |
| 28 | (cell cell-renderer) |
| 29 | (expand boolean)) |
| 30 | |
| 31 | (defbinding cell-layout-pack-end () nil |
| 32 | (cell-layout cell-layout) |
| 33 | (cell cell-renderer) |
| 34 | (expand boolean)) |
| 35 | |
| 36 | (defun cell-layout-pack (layout cell &key end expand) |
| 37 | (if end |
| 38 | (cell-layout-pack-end layout cell expand) |
| 39 | (cell-layout-pack-start layout cell expand))) |
| 40 | |
| 41 | |
| 42 | (defbinding cell-layout-reorder () nil |
| 43 | (cell-layout cell-layout) |
| 44 | (cell cell-renderer) |
| 45 | (position int)) |
| 46 | |
| 47 | (defbinding cell-layout-clear () nil |
| 48 | (cell-layout cell-layout)) |
| 49 | |
| 50 | (defbinding cell-layout-add-attribute (cell-layout cell attribute column) nil |
| 51 | (cell-layout cell-layout) |
| 52 | (cell cell-renderer) |
| 53 | ((string-downcase attribute) string) |
| 54 | (column int)) |
| 55 | |
| 56 | (def-callback-marshal %cell-layout-data-func |
| 57 | (nil cell-layout cell-renderer tree-model (copy-of tree-iter))) |
| 58 | |
| 59 | (defbinding cell-layout-set-cell-data-func (cell-layout cell function) nil |
| 60 | (cell-layout cell-layout) |
| 61 | (cell cell-renderer) |
| 62 | ((callback %cell-layout-data-func) pointer) |
| 63 | ((register-callback-function function) unsigned-int) |
| 64 | ((callback %destroy-user-data) pointer)) |
| 65 | |
| 66 | (defbinding cell-layout-clear-attributes () nil |
| 67 | (cell-layout cell-layout) |
| 68 | (cell cell-renderer)) |
| 69 | |
| 70 | |
| 71 | |
| 72 | ;;;; List Store |
| 73 | |
| 74 | (defmethod initialize-instance ((list-store list-store) &key column-types |
| 75 | column-names initial-content) |
| 76 | (call-next-method) |
| 77 | (%list-store-set-column-types list-store column-types) |
| 78 | (when column-names |
| 79 | (setf (object-data list-store 'column-names) column-names)) |
| 80 | (when initial-content |
| 81 | (loop |
| 82 | with iter = (make-instance 'tree-iter) |
| 83 | for row in initial-content |
| 84 | do (list-store-append list-store row iter)))) |
| 85 | |
| 86 | |
| 87 | (defmethod column-setter-name ((list-store list-store)) |
| 88 | (declare (ignore list-store)) |
| 89 | "gtk_list_store_set") |
| 90 | |
| 91 | (defbinding %list-store-set-column-types () nil |
| 92 | (list-store list-store) |
| 93 | ((length columns) unsigned-int) |
| 94 | (columns (vector gtype))) |
| 95 | |
| 96 | (defbinding %list-store-remove () boolean |
| 97 | (list-store list-store) |
| 98 | (tree-iter tree-iter)) |
| 99 | |
| 100 | (defun list-store-remove (store row) |
| 101 | (etypecase row |
| 102 | (tree-iter |
| 103 | (%list-store-remove store row)) |
| 104 | (tree-path |
| 105 | (multiple-value-bind (valid iter) (tree-model-get-iter store row) |
| 106 | (if valid |
| 107 | (%list-store-remove store iter) |
| 108 | (error "~A not poiniting to av valid iterator in ~A" row store)))) |
| 109 | (tree-row-reference |
| 110 | (let ((path (tree-row-reference-get-path row))) |
| 111 | (if path |
| 112 | (list-store-remove store path) |
| 113 | (error "~A not valid" row)))))) |
| 114 | |
| 115 | |
| 116 | (defbinding %list-store-insert () nil |
| 117 | (list-store list-store) |
| 118 | (tree-iter tree-iter) |
| 119 | (position int)) |
| 120 | |
| 121 | (defun list-store-insert |
| 122 | (store position &optional data (iter (make-instance 'tree-iter))) |
| 123 | (%list-store-insert store iter position) |
| 124 | (when data (%tree-model-set store iter data)) |
| 125 | iter) |
| 126 | |
| 127 | (defbinding %list-store-insert-before () nil |
| 128 | (list-store list-store) |
| 129 | (tree-iter tree-iter) |
| 130 | (sibling (or null tree-iter))) |
| 131 | |
| 132 | (defun list-store-insert-before |
| 133 | (store sibling &optional data (iter (make-instance 'tree-iter))) |
| 134 | (%list-store-insert-before store iter sibling) |
| 135 | (when data (%tree-model-set store iter data)) |
| 136 | iter) |
| 137 | |
| 138 | (defbinding %list-store-insert-after |
| 139 | (list-store &optional sibling (tree-iter (make-instance 'tree-iter))) nil |
| 140 | (list-store list-store) |
| 141 | (tree-iter tree-iter) |
| 142 | (sibling (or null tree-iter))) |
| 143 | |
| 144 | (defun list-store-insert-after |
| 145 | (store sibling &optional data (iter (make-instance 'tree-iter))) |
| 146 | (%list-store-insert-after store iter sibling) |
| 147 | (when data (%tree-model-set store iter data)) |
| 148 | iter) |
| 149 | |
| 150 | (defbinding %list-store-prepend () nil |
| 151 | (list-store list-store) |
| 152 | (tree-iter tree-iter)) |
| 153 | |
| 154 | (defun list-store-prepend |
| 155 | (store &optional data (iter (make-instance 'tree-iter))) |
| 156 | (%list-store-prepend store iter) |
| 157 | (when data (%tree-model-set store iter data)) |
| 158 | iter) |
| 159 | |
| 160 | (defbinding %list-store-append () nil |
| 161 | (list-store list-store) |
| 162 | (tree-iter tree-iter)) |
| 163 | |
| 164 | (defun list-store-append |
| 165 | (store &optional data (iter (make-instance 'tree-iter))) |
| 166 | (%list-store-append store iter) |
| 167 | (when data (%tree-model-set store iter data)) |
| 168 | iter) |
| 169 | |
| 170 | (defbinding list-store-clear () nil |
| 171 | (list-store list-store)) |
| 172 | |
| 173 | (defbinding list-store-reorder () nil |
| 174 | (list-store list-store) |
| 175 | (new-order (vector int))) |
| 176 | |
| 177 | (defbinding list-store-swap () nil |
| 178 | (list-store list-store) |
| 179 | (a tree-iter) |
| 180 | (b tree-iter)) |
| 181 | |
| 182 | (defbinding list-store-move-before () nil |
| 183 | (list-store list-store) |
| 184 | (iter tree-iter) |
| 185 | (psoition (or null tree-iter))) |
| 186 | |
| 187 | (defbinding list-store-move-after () nil |
| 188 | (list-store list-store) |
| 189 | (iter tree-iter) |
| 190 | (psoition tree-iter)) |
| 191 | |
| 192 | |
| 193 | ;;; Tree Model |
| 194 | |
| 195 | (defbinding %tree-path-free () nil |
| 196 | (location pointer)) |
| 197 | |
| 198 | (defbinding %tree-path-get-indices () pointer |
| 199 | (location pointer)) |
| 200 | |
| 201 | (defbinding %tree-path-get-depth () int |
| 202 | (location pointer)) |
| 203 | |
| 204 | (defun %make-tree-path (path) |
| 205 | (let ((c-vector (make-c-vector 'int (length path) path)) |
| 206 | (location (allocate-memory (+ (size-of 'int) (size-of 'pointer))))) |
| 207 | (funcall (writer-function 'int) (length path) location) |
| 208 | (funcall (writer-function 'pointer) c-vector location (size-of 'int)) |
| 209 | location)) |
| 210 | |
| 211 | (defun %tree-path-to-vector (location) |
| 212 | (let ((indices (%tree-path-get-indices location)) |
| 213 | (depth (%tree-path-get-depth location))) |
| 214 | (if (null-pointer-p indices) |
| 215 | #() |
| 216 | (map-c-vector 'vector #'identity indices 'int depth)))) |
| 217 | |
| 218 | (eval-when (:compile-toplevel :load-toplevel :execute) |
| 219 | (defmethod alien-type ((type (eql 'tree-path)) &rest args) |
| 220 | (declare (ignore type args)) |
| 221 | (alien-type 'pointer)) |
| 222 | |
| 223 | (defmethod size-of ((type (eql 'tree-path)) &rest args) |
| 224 | (declare (ignore type args)) |
| 225 | (size-of 'pointer)) |
| 226 | |
| 227 | (defmethod to-alien-form (path (type (eql 'tree-path)) &rest args) |
| 228 | (declare (ignore type args)) |
| 229 | `(%make-tree-path ,path)) |
| 230 | |
| 231 | (defmethod from-alien-form (location (type (eql 'tree-path)) &rest args) |
| 232 | (declare (ignore type args)) |
| 233 | `(let ((location ,location)) |
| 234 | (prog1 |
| 235 | (%tree-path-to-vector location) |
| 236 | (%tree-path-free location)))) |
| 237 | |
| 238 | (defmethod copy-from-alien-form (location (type (eql 'tree-path)) &rest args) |
| 239 | (declare (ignore type args)) |
| 240 | `(%tree-path-to-vector ,location)) |
| 241 | |
| 242 | (defmethod cleanup-form (location (type (eql 'tree-path)) &rest args) |
| 243 | (declare (ignore type args)) |
| 244 | `(%tree-path-free ,location))) |
| 245 | |
| 246 | (defmethod to-alien-function ((type (eql 'tree-path)) &rest args) |
| 247 | (declare (ignore type args)) |
| 248 | #'%make-tree-path) |
| 249 | |
| 250 | (defmethod from-alien-function ((type (eql 'tree-path)) &rest args) |
| 251 | (declare (ignore type args)) |
| 252 | #'(lambda (location) |
| 253 | (prog1 |
| 254 | (%tree-path-to-vector location) |
| 255 | (%tree-path-free location)))) |
| 256 | |
| 257 | (defmethod copy-from-alien-function ((type (eql 'tree-path)) &rest args) |
| 258 | (declare (ignore type args)) |
| 259 | #'%tree-path-to-vector) |
| 260 | |
| 261 | (defmethod cleanup-function ((type (eql 'tree-path)) &rest args) |
| 262 | (declare (ignore type args)) |
| 263 | #'%tree-path-free) |
| 264 | |
| 265 | (defmethod writer-function ((type (eql 'tree-path)) &rest args) |
| 266 | (declare (ignore type args)) |
| 267 | (let ((writer (writer-function 'pointer))) |
| 268 | #'(lambda (path location &optional (offset 0)) |
| 269 | (funcall writer (%make-tree-path path) location offset)))) |
| 270 | |
| 271 | (defmethod reader-function ((type (eql 'tree-path)) &rest args) |
| 272 | (declare (ignore type args)) |
| 273 | (let ((reader (reader-function 'pointer))) |
| 274 | #'(lambda (location &optional (offset 0)) |
| 275 | (%tree-path-to-vector (funcall reader location offset))))) |
| 276 | |
| 277 | |
| 278 | (defbinding %tree-row-reference-new () pointer |
| 279 | (model tree-model) |
| 280 | (path tree-path)) |
| 281 | |
| 282 | (defmethod initialize-instance ((reference tree-row-reference) &key model path) |
| 283 | (setf |
| 284 | (slot-value reference 'location) |
| 285 | (%tree-row-reference-new model path)) |
| 286 | (call-next-method)) |
| 287 | |
| 288 | (defbinding tree-row-reference-get-path () tree-path |
| 289 | (reference tree-row-reference)) |
| 290 | |
| 291 | (defbinding (tree-row-reference-valid-p "gtk_tree_row_reference_valid") () boolean |
| 292 | (reference tree-row-reference)) |
| 293 | |
| 294 | |
| 295 | (defbinding tree-model-get-column-type () gtype ;type-number |
| 296 | (tree-model tree-model) |
| 297 | (index int)) |
| 298 | |
| 299 | (defbinding tree-model-get-iter |
| 300 | (model path &optional (iter (make-instance 'tree-iter))) boolean |
| 301 | (model tree-model) |
| 302 | (iter tree-iter :return) |
| 303 | (path tree-path)) |
| 304 | |
| 305 | (defbinding tree-model-get-path () tree-path |
| 306 | (tree-model tree-model) |
| 307 | (iter tree-iter)) |
| 308 | |
| 309 | (defbinding %tree-model-get-value () nil |
| 310 | (tree-model tree-model) |
| 311 | (iter tree-iter) |
| 312 | (column int) |
| 313 | (gvalue gvalue)) |
| 314 | |
| 315 | (defun tree-model-column-value (model iter column) |
| 316 | (let ((index (column-index model column))) |
| 317 | (with-gvalue (gvalue (tree-model-get-column-type model index)) |
| 318 | (%tree-model-get-value model iter index gvalue)))) |
| 319 | |
| 320 | (defbinding tree-model-iter-next () boolean |
| 321 | (tree-model tree-model) |
| 322 | (iter tree-iter :return)) |
| 323 | |
| 324 | (defbinding tree-model-iter-children |
| 325 | (tree-model parent &optional (iter (make-instance 'tree-iter))) boolean |
| 326 | (tree-model tree-model) |
| 327 | (iter tree-iter :return) |
| 328 | (parent (or null tree-iter))) |
| 329 | |
| 330 | (defbinding (tree-model-iter-has-child-p "gtk_tree_model_iter_has_child") |
| 331 | () boolean |
| 332 | (tree-model tree-model) |
| 333 | (iter tree-iter)) |
| 334 | |
| 335 | (defbinding tree-model-iter-n-children () int |
| 336 | (tree-model tree-model) |
| 337 | (iter tree-iter)) |
| 338 | |
| 339 | (defbinding tree-model-iter-nth-child |
| 340 | (tree-model parent &optional (iter (make-instance 'tree-iter))) boolean |
| 341 | (tree-model tree-model) |
| 342 | (iter tree-iter :return) |
| 343 | (parent (or null tree-iter)) |
| 344 | (n int)) |
| 345 | |
| 346 | (defbinding tree-model-iter-parent |
| 347 | (tree-model child &optional (iter (make-instance 'tree-iter))) boolean |
| 348 | (tree-model tree-model) |
| 349 | (iter tree-iter :return) |
| 350 | (child tree-iter)) |
| 351 | |
| 352 | (def-callback-marshal %tree-model-foreach-func |
| 353 | (boolean tree-model (path (copy-of tree-path)) (iter (copy-of tree-iter)))) |
| 354 | |
| 355 | (defbinding %tree-model-foreach () nil |
| 356 | (tree-model tree-model) |
| 357 | ((callback %tree-model-foreach-func) pointer) |
| 358 | (callback-id unsigned-int)) |
| 359 | |
| 360 | (defun tree-model-foreach (model function) |
| 361 | (with-callback-function (id function) |
| 362 | (%tree-model-foreach model id))) |
| 363 | |
| 364 | (defbinding tree-model-row-changed () nil |
| 365 | (tree-model tree-model) |
| 366 | (path tree-path) |
| 367 | (iter tree-iter)) |
| 368 | |
| 369 | (defbinding tree-model-row-inserted () nil |
| 370 | (tree-model tree-model) |
| 371 | (path tree-path) |
| 372 | (iter tree-iter)) |
| 373 | |
| 374 | (defbinding tree-model-row-has-child-toggled () nil |
| 375 | (tree-model tree-model) |
| 376 | (path tree-path) |
| 377 | (iter tree-iter)) |
| 378 | |
| 379 | (defbinding tree-model-row-deleted () nil |
| 380 | (tree-model tree-model) |
| 381 | (path tree-path) |
| 382 | (iter tree-iter)) |
| 383 | |
| 384 | (defbinding tree-model-rows-reordered () nil |
| 385 | (tree-model tree-model) |
| 386 | (path tree-path) |
| 387 | (iter tree-iter) |
| 388 | (new-order int)) |
| 389 | |
| 390 | |
| 391 | (defun column-types (model columns) |
| 392 | (map 'vector |
| 393 | #'(lambda (column) |
| 394 | (find-type-number (first (mklist column)))) |
| 395 | columns)) |
| 396 | |
| 397 | (defun column-index (model column) |
| 398 | (or |
| 399 | (etypecase column |
| 400 | (number column) |
| 401 | (symbol (position column (object-data model 'column-names))) |
| 402 | (string (position column (object-data model 'column-names) |
| 403 | :test #'string=))) |
| 404 | (error "~A has no column ~S" model column))) |
| 405 | |
| 406 | (defun tree-model-column-value-setter (model column) |
| 407 | (let ((setters (or |
| 408 | (object-data model 'column-setters) |
| 409 | (setf |
| 410 | (object-data model 'column-setters) |
| 411 | (make-array (tree-model-n-columns model) |
| 412 | :initial-element nil))))) |
| 413 | (let ((index (column-index model column))) |
| 414 | (or |
| 415 | (svref setters index) |
| 416 | (setf |
| 417 | (svref setters index) |
| 418 | (let ((setter |
| 419 | (mkbinding (column-setter-name model) |
| 420 | nil (type-of model) 'tree-iter 'int |
| 421 | ; (type-from-number (tree-model-get-column-type model index)) |
| 422 | (tree-model-get-column-type model index) |
| 423 | 'int))) |
| 424 | #'(lambda (value iter) |
| 425 | (funcall setter model iter index value -1)))))))) |
| 426 | |
| 427 | (defun tree-model-row-setter (model) |
| 428 | (or |
| 429 | (object-data model 'row-setter) |
| 430 | (progn |
| 431 | ;; This will create any missing column setter |
| 432 | (loop |
| 433 | for i from 0 below (tree-model-n-columns model) |
| 434 | do (tree-model-column-value-setter model i)) |
| 435 | (let ((setters (object-data model 'column-setters))) |
| 436 | (setf |
| 437 | (object-data model 'row-setter) |
| 438 | #'(lambda (row iter) |
| 439 | (map nil #'(lambda (value setter) |
| 440 | (funcall setter value iter)) |
| 441 | row setters))))))) |
| 442 | |
| 443 | (defun (setf tree-model-column-value) (value model iter column) |
| 444 | (funcall (tree-model-column-value-setter model column) value iter) |
| 445 | value) |
| 446 | |
| 447 | (defun (setf tree-model-row-data) (data model iter) |
| 448 | (funcall (tree-model-row-setter model) data iter) |
| 449 | data) |
| 450 | |
| 451 | (defun %tree-model-set (model iter data) |
| 452 | (etypecase data |
| 453 | (vector (setf (tree-model-row-data model iter) data)) |
| 454 | (cons |
| 455 | (loop |
| 456 | as (column value . rest) = data then rest |
| 457 | do (setf (tree-model-column-value model iter column) value) |
| 458 | while rest)))) |
| 459 | |
| 460 | |
| 461 | ;;; Tree Selection |
| 462 | |
| 463 | (def-callback-marshal %tree-selection-func (boolean tree-selection tree-model (path (copy-of tree-path)) (path-currently-selected boolean))) |
| 464 | |
| 465 | (defbinding tree-selection-set-select-function (selection function) nil |
| 466 | (selection tree-selection) |
| 467 | ((callback %tree-selection-func) pointer) |
| 468 | ((register-callback-function function) unsigned-int) |
| 469 | ((callback %destroy-user-data) pointer)) |
| 470 | |
| 471 | (defbinding tree-selection-get-selected |
| 472 | (selection &optional (iter (make-instance 'tree-iter))) boolean |
| 473 | (selection tree-selection) |
| 474 | (nil null) |
| 475 | (iter tree-iter :return)) |
| 476 | |
| 477 | (def-callback-marshal %tree-selection-foreach-func (nil tree-model (path (copy-of tree-path)) (iter (copy-of tree-iter)))) |
| 478 | |
| 479 | (defbinding %tree-selection-selected-foreach () nil |
| 480 | (tree-selection tree-selection) |
| 481 | ((callback %tree-selection-foreach-func) pointer) |
| 482 | (callback-id unsigned-int)) |
| 483 | |
| 484 | (defun tree-selection-selected-foreach (selection function) |
| 485 | (with-callback-function (id function) |
| 486 | (%tree-selection-selected-foreach selection id))) |
| 487 | |
| 488 | (defbinding tree-selection-get-selected-rows () (glist tree-path) |
| 489 | (tree-selection tree-selection) |
| 490 | (nil null)) |
| 491 | |
| 492 | (defbinding tree-selection-count-selected-rows () int |
| 493 | (tree-selection tree-selection)) |
| 494 | |
| 495 | (defbinding %tree-selection-select-path () nil |
| 496 | (tree-selection tree-selection) |
| 497 | (tree-path tree-path)) |
| 498 | |
| 499 | (defbinding %tree-selection-unselect-path () nil |
| 500 | (tree-selection tree-selection) |
| 501 | (tree-path tree-path)) |
| 502 | |
| 503 | (defbinding %tree-selection-path-is-selected () boolean |
| 504 | (tree-selection tree-selection) |
| 505 | (tree-path tree-path)) |
| 506 | |
| 507 | (defbinding %tree-selection-select-iter () nil |
| 508 | (tree-selection tree-selection) |
| 509 | (tree-path tree-path)) |
| 510 | |
| 511 | (defbinding %tree-selection-unselect-iter () nil |
| 512 | (tree-selection tree-selection) |
| 513 | (tree-path tree-path)) |
| 514 | |
| 515 | (defbinding %tree-selection-iter-is-selected () boolean |
| 516 | (tree-selection tree-selection) |
| 517 | (tree-path tree-path)) |
| 518 | |
| 519 | (defun tree-selection-select (selection row) |
| 520 | (etypecase row |
| 521 | (tree-path (%tree-selection-select-path selection row)) |
| 522 | (tree-iter (%tree-selection-select-iter selection row)))) |
| 523 | |
| 524 | (defun tree-selection-unselect (selection row) |
| 525 | (etypecase row |
| 526 | (tree-path (%tree-selection-unselect-path selection row)) |
| 527 | (tree-iter (%tree-selection-unselect-iter selection row)))) |
| 528 | |
| 529 | (defun tree-selection-is-selected-p (selection row) |
| 530 | (etypecase row |
| 531 | (tree-path (%tree-selection-path-is-selected selection row)) |
| 532 | (tree-iter (%tree-selection-iter-is-selected selection row)))) |
| 533 | |
| 534 | (defbinding tree-selection-select-all () nil |
| 535 | (tree-selection tree-selection)) |
| 536 | |
| 537 | (defbinding tree-selection-unselect-all () nil |
| 538 | (tree-selection tree-selection)) |
| 539 | |
| 540 | (defbinding tree-selection-select-range () nil |
| 541 | (tree-selection tree-selection) |
| 542 | (start tree-path) |
| 543 | (end tree-path)) |
| 544 | |
| 545 | (defbinding tree-selection-unselect-range () nil |
| 546 | (tree-selection tree-selection) |
| 547 | (start tree-path) |
| 548 | (end tree-path)) |
| 549 | |
| 550 | |
| 551 | |
| 552 | ;;; Tree Store |
| 553 | |
| 554 | (defbinding %tree-store-set-column-types () nil |
| 555 | (tree-store tree-store) |
| 556 | ((length columns) unsigned-int) |
| 557 | (columns (vector gtype))) |
| 558 | |
| 559 | (defmethod initialize-instance ((tree-store tree-store) &key column-types |
| 560 | column-names) |
| 561 | (call-next-method) |
| 562 | (%tree-store-set-column-types tree-store column-types) |
| 563 | (when column-names |
| 564 | (setf (object-data tree-store 'column-names) column-names))) |
| 565 | |
| 566 | (defmethod column-setter-name ((tree-store tree-store)) |
| 567 | (declare (ignore tree-store)) |
| 568 | "gtk_tree_store_set") |
| 569 | |
| 570 | (defbinding tree-store-remove () boolean |
| 571 | (tree-store tree-store) |
| 572 | (tree-iter tree-iter)) |
| 573 | |
| 574 | (defbinding %tree-store-insert () nil |
| 575 | (tree-store tree-store) |
| 576 | (tree-iter tree-iter) |
| 577 | (parent (or null tree-iter)) |
| 578 | (position int)) |
| 579 | |
| 580 | (defun tree-store-insert |
| 581 | (store parent position &optional data (iter (make-instance 'tree-iter))) |
| 582 | (%tree-store-insert store iter parent position) |
| 583 | (when data (%tree-model-set store iter data)) |
| 584 | iter) |
| 585 | |
| 586 | (defbinding %tree-store-insert-before () nil |
| 587 | (tree-store tree-store) |
| 588 | (tree-iter tree-iter) |
| 589 | (parent (or null tree-iter)) |
| 590 | (sibling (or null tree-iter))) |
| 591 | |
| 592 | (defun tree-store-insert-after |
| 593 | (store parent sibling &optional data (iter (make-instance 'tree-iter))) |
| 594 | (%tree-store-insert-before store iter parent sibling) |
| 595 | (when data (%tree-model-set store iter data)) |
| 596 | iter) |
| 597 | |
| 598 | (defbinding %tree-store-insert-after () nil |
| 599 | (tree-store tree-store) |
| 600 | (tree-iter tree-iter) |
| 601 | (parent (or null tree-iter)) |
| 602 | (sibling (or null tree-iter))) |
| 603 | |
| 604 | (defun tree-store-insert-after |
| 605 | (store parent sibling &optional data (iter (make-instance 'tree-iter))) |
| 606 | (%tree-store-insert-after store iter parent sibling) |
| 607 | (when data (%tree-model-set store iter data)) |
| 608 | iter) |
| 609 | |
| 610 | (defbinding %tree-store-prepend () nil |
| 611 | (tree-store tree-store) |
| 612 | (tree-iter tree-iter) |
| 613 | (parent (or null tree-iter))) |
| 614 | |
| 615 | (defun tree-store-prepend |
| 616 | (store parent &optional data (iter (make-instance 'tree-iter))) |
| 617 | (%tree-store-prepend store iter parent) |
| 618 | (when data (%tree-model-set store iter data)) |
| 619 | iter) |
| 620 | |
| 621 | (defbinding %tree-store-append () nil |
| 622 | (tree-store tree-store) |
| 623 | (tree-iter tree-iter) |
| 624 | (parent (or null tree-iter))) |
| 625 | |
| 626 | (defun tree-store-append |
| 627 | (store parent &optional data (iter (make-instance 'tree-iter))) |
| 628 | (%tree-store-append store iter parent) |
| 629 | (when data (%tree-model-set store iter data)) |
| 630 | iter) |
| 631 | |
| 632 | (defbinding (tree-store-is-ancestor-p "gtk_tree_store_is_ancestor") () boolean |
| 633 | (tree-store tree-store) |
| 634 | (tree-iter tree-iter) |
| 635 | (descendant tree-iter)) |
| 636 | |
| 637 | (defbinding tree-store-iter-depth () int |
| 638 | (tree-store tree-store) |
| 639 | (tree-iter tree-iter)) |
| 640 | |
| 641 | (defbinding tree-store-clear () nil |
| 642 | (tree-store tree-store)) |
| 643 | |
| 644 | (defbinding tree-store-reorder () nil |
| 645 | (tree-store tree-store) |
| 646 | (parent tree-iter) |
| 647 | (new-order (vector int))) |
| 648 | |
| 649 | (defbinding tree-store-swap () nil |
| 650 | (tree-store tree-store) |
| 651 | (a tree-iter) |
| 652 | (b tree-iter)) |
| 653 | |
| 654 | (defbinding tree-store-move-before () nil |
| 655 | (tree-store tree-store) |
| 656 | (iter tree-iter) |
| 657 | (psoition (or null tree-iter))) |
| 658 | |
| 659 | |
| 660 | (defbinding tree-store-move-after () nil |
| 661 | (tree-store tree-store) |
| 662 | (iter tree-iter) |
| 663 | (psoition tree-iter)) |
| 664 | |
| 665 | |
| 666 | |
| 667 | ;;; Tree View |
| 668 | |
| 669 | (defmethod initialize-instance ((tree-view tree-view) &rest initargs |
| 670 | &key column) |
| 671 | (call-next-method) |
| 672 | (mapc #'(lambda (column) |
| 673 | (tree-view-append-column tree-view column)) |
| 674 | (get-all initargs :column))) |
| 675 | |
| 676 | |
| 677 | (defbinding tree-view-columns-autosize () nil |
| 678 | (tree-view tree-view)) |
| 679 | |
| 680 | (defbinding tree-view-append-column () int |
| 681 | (tree-view tree-view) |
| 682 | (tree-view-column tree-view-column)) |
| 683 | |
| 684 | (defbinding tree-view-remove-column () int |
| 685 | (tree-view tree-view) |
| 686 | (tree-view-column tree-view-column)) |
| 687 | |
| 688 | (defbinding tree-view-insert-column (view columnd position) int |
| 689 | (view tree-view) |
| 690 | (column tree-view-column) |
| 691 | ((if (eq position :end) -1 position) int)) |
| 692 | |
| 693 | (defbinding tree-view-get-column () tree-view-column |
| 694 | (tree-view tree-view) |
| 695 | (position int)) |
| 696 | |
| 697 | (defbinding tree-view-move-column-after () nil |
| 698 | (tree-view tree-view) |
| 699 | (column tree-view-column) |
| 700 | (base-column (or null tree-view-column))) |
| 701 | |
| 702 | ;;(defbinding tree-view-set-column drag-function ...) |
| 703 | |
| 704 | (defbinding tree-view-scroll-to-point () nil |
| 705 | (tree-view tree-view) |
| 706 | (tree-x int) |
| 707 | (tree-y int)) |
| 708 | |
| 709 | (defbinding tree-view-scroll-to-cell () nil |
| 710 | (tree-view tree-view) |
| 711 | (path (or null tree-path)) |
| 712 | (column (or null tree-view-column)) |
| 713 | (use-align boolean) |
| 714 | (row-align single-float) |
| 715 | (col-align single-float)) |
| 716 | |
| 717 | (defbinding tree-view-set-cursor () nil |
| 718 | (tree-view tree-view) |
| 719 | (path tree-path) |
| 720 | (focus-column tree-view-column) |
| 721 | (start-editing boolean)) |
| 722 | |
| 723 | (defbinding tree-view-set-cursor-on-cell () nil |
| 724 | (tree-view tree-view) |
| 725 | (path tree-path) |
| 726 | (focus-column (or null tree-view-column)) |
| 727 | (focus-cell (or null cell-renderer)) |
| 728 | (start-editing boolean)) |
| 729 | |
| 730 | (defbinding tree-view-get-cursor () nil |
| 731 | (tree-view tree-view) |
| 732 | (path tree-path :out ) |
| 733 | (focus-column tree-view-column :out)) |
| 734 | |
| 735 | (defbinding tree-view-row-activated () nil |
| 736 | (tree-view tree-view) |
| 737 | (path tree-path ) |
| 738 | (column tree-view-column)) |
| 739 | |
| 740 | (defbinding tree-view-expand-all () nil |
| 741 | (tree-view tree-view)) |
| 742 | |
| 743 | (defbinding tree-view-collapse-all () nil |
| 744 | (tree-view tree-view)) |
| 745 | |
| 746 | (defbinding tree-view-expand-to-path () nil |
| 747 | (tree-view tree-view) |
| 748 | (path tree-path)) |
| 749 | |
| 750 | (defbinding tree-view-expand-row () nil |
| 751 | (tree-view tree-view) |
| 752 | (path tree-path) |
| 753 | (open-all boolean)) |
| 754 | |
| 755 | (defbinding tree-view-collapse-row () nil |
| 756 | (tree-view tree-view) |
| 757 | (path tree-path)) |
| 758 | |
| 759 | (def-callback-marshal %tree-view-mapping-func (nil tree-view (path (copy-of tree-path)))) |
| 760 | |
| 761 | (defbinding %tree-view-map-expanded-rows () nil |
| 762 | (tree-view tree-view) |
| 763 | ((callback %tree-view-mapping-func) pointer) |
| 764 | (callback-id unsigned-int)) |
| 765 | |
| 766 | (defun map-expanded-rows (function tree-view) |
| 767 | (with-callback-function (id function) |
| 768 | (%tree-view-map-expanded-rows tree-view id))) |
| 769 | |
| 770 | (defbinding (tree-view-row-expanded-p "gtk_tree_view_row_expanded") () boolean |
| 771 | (tree-view tree-view) |
| 772 | (path tree-path)) |
| 773 | |
| 774 | (defbinding tree-view-get-path-at-pos |
| 775 | (tree-view x y &optional (cell-x 0) (cell-y 0)) boolean |
| 776 | (tree-view tree-view) |
| 777 | (x int) |
| 778 | (y int) |
| 779 | (path tree-path :out) |
| 780 | (column tree-view-column :out) |
| 781 | (cell-x int) |
| 782 | (cell-y int)) |
| 783 | |
| 784 | (defbinding tree-view-get-cell-area () nil |
| 785 | (tree-view tree-view) |
| 786 | (path (or null tree-path)) |
| 787 | (column (or null tree-view-column)) |
| 788 | ((make-instance 'gdk:rectangle) gdk:rectangle :return)) |
| 789 | |
| 790 | (defbinding tree-view-get-background-area () nil |
| 791 | (tree-view tree-view) |
| 792 | (path (or null tree-path)) |
| 793 | (column (or null tree-view-column)) |
| 794 | ((make-instance 'gdk:rectangle) gdk:rectangle :return)) |
| 795 | |
| 796 | (defbinding tree-view-get-visible-rect () nil |
| 797 | (tree-view tree-view) |
| 798 | ((make-instance 'gdk:rectangle) gdk:rectangle :return)) |
| 799 | |
| 800 | ;; and many more functions which we'll add later |
| 801 | |
| 802 | |
| 803 | ;;; Tree View Column |
| 804 | |