Use new GBoxed in GDK and GTK
[cl-gtk2.git] / gtk / gtk.objects.lisp
1 (in-package :gtk)
2
3 (define-g-boxed-cstruct border "GtkBorder"
4   (left :int :initform 0)
5   (right :int :initform 0)
6   (top :int :initform 0)
7   (bottom :int :initform 0))
8
9 (define-g-boxed-cstruct tree-iter "GtkTreeIter"
10   (stamp :int :initform 0)
11   (user-data :pointer :initform (null-pointer))
12   (user-data-2 :pointer :initform (null-pointer))
13   (user-data-3 :pointer :initform (null-pointer)))
14
15 (export 'tree-iter)
16 (export 'tree-iter-stamp)
17 (export 'tree-iter-user-data)
18
19 (defctype tree-path :pointer)
20
21 (defcfun gtk-tree-path-new :pointer)
22 (defcfun gtk-tree-path-free :void (path :pointer))
23
24 (define-g-boxed-opaque tree-path "GtkTreePath"
25   :alloc (gtk-tree-path-new))
26
27 (defcfun (%gtk-tree-path-get-depth "gtk_tree_path_get_depth") :int
28   (path tree-path))
29
30 (defcfun (%gtk-tree-path-get-indices "gtk_tree_path_get_indices") (:pointer :int)
31   (path tree-path))
32
33 (defcfun (%gtk-tree-path-append-index "gtk_tree_path_append_index") :void
34   (path :pointer)
35   (index :int))
36
37 (defun tree-path-indices (path)
38   (tree-path-get-indices path))
39
40 (defun (setf tree-path-indices) (new-value path)
41   (tree-path-set-indices new-value path))
42
43 (defun tree-path-get-indices (path)
44   (setf path (pointer path))
45   (let ((n (%gtk-tree-path-get-depth path))
46         (indices (%gtk-tree-path-get-indices path)))
47     (loop
48        for i from 0 below n
49        collect (mem-aref indices :int i))))
50
51 (defun tree-path-set-indices (indices path)
52   (setf path (pointer path))
53   (loop 
54      repeat (%gtk-tree-path-get-depth path)
55      do (foreign-funcall "gtk_tree_path_up" :pointer path :boolean))
56   (loop
57      for index in indices
58      do(foreign-funcall "gtk_tree_path_append_index" :pointer path :int index :void)))
59
60 (export 'tree-path)
61 (export 'tree-path-indices)