3 (define-g-boxed-cstruct target-entry "GtkTargetEntry"
4 (target :string :initform 0)
5 (flags target-flags :initform 0)
6 (info :uint :initform 0))
8 (export (boxed-related-symbols 'target-entry))
12 (defcfun (selection-owner-set "gtk_selection_owner_set") :boolean
13 (widget (g-object widget))
14 (selection gdk-atom-as-string)
17 (defcfun (selection-owner-set-for-display "gtk_selection_owner_set_for_display")
19 (display (g-object display))
20 (widget (g-object widget))
21 (selection gdk-atom-as-string)
24 (defcfun (selection-add-target "gtk_selection_add_target") :void
25 (widget (g-object display))
26 (selection gdk-atom-as-string)
27 (target gdk-atom-as-string)
30 (defcfun (selection-clear-targets "gtk_selection_clear_targets") :void
31 (widget (g-object display))
32 (selection gdk-atom-as-string))
34 (defcfun (selection-convert "gtk_selection_convert") :boolean
35 (widget (g-object display))
36 (selection gdk-atom-as-string)
37 (target gdk-atom-as-string)
42 (define-g-boxed-opaque selection-data "GtkSelectionData"
43 :alloc (error "Not allocated"))
45 (export (boxed-related-symbols 'selection-data))
47 (defcfun (gtk-selection-data-set "gtk_selection_data_set") :void
48 (selection-data (g-boxed-foreign selection-data))
49 (type gdk-atom-as-string)
54 (defcfun (gtk-selection-data-get-data "gtk_selection_data_get_data") :pointer
55 (selection-data (g-boxed-foreign selection-data)))
57 (defcfun (gtk-selection-data-get-data-type "gtk_selection_data_get_data_type")
59 (selection-data (g-boxed-foreign selection-data)))
61 (defcfun (gtk-selection-data-get-format "gtk_selection_data_get_format")
63 (selection-data (g-boxed-foreign selection-data)))
65 (defcfun (gtk-selection-data-get-length "gtk_selection_data_get_length") :int
66 (selection-data (g-boxed-foreign selection-data)))
68 (defcfun (gtk-selection-data-set-pixbuf "gtk_selection_data_set_pixbuf") :boolean
69 (selection-data (g-boxed-foreign selection-data))
70 (pixbuf (g-object pixbuf)))
72 (defcfun (selection-data-get-pixbuf "gtk_selection_data_get_pixbuf") (g-object pixbuf)
73 (selection-data (g-boxed-foreign selection-data)))
75 (defcfun (selection-data-targets-include-image "gtk_selection_data_targets_include_image")
77 (selection-data (g-boxed-foreign selection-data))
80 (defcfun (selection-data-targets-include-text "gtk_selection_data_targets_include_text")
82 (selection-data (g-boxed-foreign selection-data)))
84 (defcfun (selection-data-targets-include-uri "gtk_selection_data_targets_include_uri")
86 (selection-data (g-boxed-foreign selection-data)))
88 (defcfun (selection-data-targets-include-rich-text "gtk_selection_data_targets_include_rich_text")
90 (selection-data (g-boxed-foreign selection-data))
91 (buffer (g-object text-buffer)))
93 (defcfun (selection-data-get-selection "gtk_selection_data_get_selection")
95 (selection-data (g-boxed-foreign selection-data)))
97 (defcfun (selection-data-get-display "gtk_selection_data_get_display")
99 (selection-data (g-boxed-foreign selection-data)))
101 (defcfun (selection-data-get-target "gtk_selection_data_get_target")
103 (selection-data (g-boxed-foreign selection-data)))
105 ; Easy future extension
106 (defgeneric selection-set (selection-data data &key type &allow-other-keys))
108 (defmethod selection-set ((selection-data selection-data) (data string)
109 &key (type "text/plain"))
110 (with-foreign-string ((ptr len) data)
111 (gtk-selection-data-set selection-data type 8 ptr (1- len))))
113 (defmethod selection-set ((selection-data selection-data) (data pixbuf)
114 &key (type "image/png"))
115 (gtk-selection-data-set selection-data type 8 (null-pointer) 0)
116 (gtk-selection-data-set-pixbuf selection-data data))
118 (defun foreign-to-int-or-array (ptr fmt len)
119 (let ((ctype (case fmt (8 :int8) (16 :int16) (32 :long)))
120 (clen (/ len (if (= fmt 32) (foreign-type-size :long) fmt))))
123 (let ((array (make-array clen :element-type 'fixnum)))
124 (loop for i from 0 below clen
125 do (setf (aref array i) (mem-aref ptr ctype)))
128 (defun selection-get (selection-data)
129 (let ((fmt (gtk-selection-data-get-format selection-data))
130 (len (gtk-selection-data-get-length selection-data))
131 (ptr (gtk-selection-data-get-data selection-data)))
135 ((= fmt 8) (foreign-string-to-lisp ptr :count len))
136 (t (foreign-to-int-or-array ptr fmt len)))
137 (gtk-selection-data-get-data-type selection-data)
140 (export '(selection-set selection-get))