1 ;; Common Lisp bindings for GTK+ v2.x
2 ;; Copyright 2005 Espen S. Johnsen <espen@users.sf.net>
4 ;; Permission is hereby granted, free of charge, to any person obtaining
5 ;; a copy of this software and associated documentation files (the
6 ;; "Software"), to deal in the Software without restriction, including
7 ;; without limitation the rights to use, copy, modify, merge, publish,
8 ;; distribute, sublicense, and/or sell copies of the Software, and to
9 ;; permit persons to whom the Software is furnished to do so, subject to
10 ;; the following conditions:
12 ;; The above copyright notice and this permission notice shall be
13 ;; included in all copies or substantial portions of the Software.
15 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 ;; $Id: gtkselection.lisp,v 1.5 2006/02/09 22:32:47 espen Exp $
31 (defbinding %target-list-ref () pointer
34 (defbinding %target-list-unref () nil
37 (defmethod reference-foreign ((class (eql (find-class 'target-list))) location)
38 (declare (ignore class))
39 (%target-list-ref location))
41 (defmethod unreference-foreign ((class (eql (find-class 'target-list))) location)
42 (declare (ignore class))
43 (%target-list-unref location))
45 (defbinding %target-list-new () pointer
46 (targets (vector (inlined target-entry)))
47 ((length targets) int))
49 (defmethod allocate-foreign ((target-list target-list) &key targets)
50 (%target-list-new targets))
52 (defbinding target-list-add (target-list target &optional flags info) nil
53 (target-list target-list)
58 (defbinding target-list-add-table (target-list targets) nil
59 (target-list target-list)
61 ((or vector list) targets)
62 (target-entry (vector targets)))
63 (vector (inlined target-entry)))
65 ((or vector list) (length targets))
71 (defbinding target-list-add-text-targets (target-list info &optional writable-p) nil
72 (target-list target-list)
76 (defbinding target-list-add-image-targets (target-list info &optional writable-p) nil
77 (target-list target-list)
81 (defbinding target-list-add-uri-targets (target-list info &optional writable-p) nil
82 (target-list target-list)
84 (writable-p boolean)))
86 (defbinding target-list-remove () nil
87 (target-list target-list)
90 ;; (defbinding target-list-find () nil
91 ;; (target-list target-list)
95 (defbinding (selection-set-owner "gtk_selection_owner_set_for_display")
96 (widget selection time &optional (display (gdk:display-get-default)))
100 ((gdk:atom-intern selection) gdk:atom))
102 (defbinding selection-add-target () nil
108 (defbinding selection-add-targets (widget selection targets) nil
112 ((or vector list) targets)
113 (target-entry (vector targets)))
114 (vector (inlined target-entry)))
116 ((or vector list) (length targets))
120 (defbinding selection-clear-targets () nil
122 (selection gdk:atom))
124 (defbinding selection-convert () boolean
130 (defbinding selection-data-set () boolean
131 (selection-data selection-data)
137 (defbinding selection-data-set-text () boolean
138 (selection-data selection-data)
142 (defbinding selection-data-get-text () string
143 (selection-data selection-data))
147 (defbinding selection-data-set-pixbuf () boolean
148 (selection-data selection-data)
151 (defbinding selection-data-get-pixbuf () gdk:pixbuf
152 (selection-data selection-data))
154 (defbinding selection-data-set-uris () boolean
155 (selection-data selection-data)
156 (uris (null-terminated-vector string)))
158 (defbinding selection-data-get-uris () (null-terminated-vector string)
159 (selection-data selection-data)))
161 (defbinding selection-data-get-targets () boolean
162 (selection-data selection-data)
163 (targets (vector gdk:atom n-atoms))
167 (defbinding selection-data-targets-include-image-p (selection-data &optional writable-p) boolean
168 (selection-data selection-data)
169 (writable-p boolean))
171 (defbinding selection-data-targets-include-text-p (selection-data) boolean
172 (selection-data selection-data))
174 (defbinding selection-remove-all () boolean
178 ;;; Clipboard -- untestet
180 (defbinding (clipboard-get "gtk_clipboard_get_for_display")
181 (selection &optional (display (gdk:display-get-default))) clipboard
182 (display gdk:display)
183 ((gdk:atom-intern selection) gdk:atom))
186 (defcallback %clipboard-get-func (nil (clipboard pointer)
187 (selection-data selection-data)
189 (user-data unsigned-int))
190 (funcall (car (find-user-data user-data)) selection-data info))
192 (defcallback %clipboard-clear-func (nil (clipboard pointer)
193 (user-data unsigned-int))
194 (funcall (cdr (find-user-data user-data))))
196 (defbinding clipboard-set-with-data (clipboard targets get-func clear-func) gobject
197 (clipboard clipboard)
198 (targets (vector (inlined target-entry)))
199 ((length targets) unsigned-int)
200 (%clipboard-get-func callback)
201 (%clipboard-clear-func callback)
202 ((register-user-data (cons get-func clear-func)) unsigned-int))
204 (defbinding clipboard-clear () nil
205 (clipboard clipboard))
207 (defbinding clipboard-set-text (clipboard text) nil
208 (clipboard clipboard)
213 (defbinding clipboard-set-image () nil
214 (clipboard clipboard)
217 (defun clipboard-set (clipboard object)
219 (string (clipboard-set-text clipboard object))
221 (gdk:pixbuf (clipboard-set-image clipboard object))))
223 (defcallback %clipboard-receive-func (nil (clipboard pointer)
224 (selection-data selection-data)
225 (user-data unsigned-int))
226 (funcall (find-user-data user-data) selection-data))
228 (defbinding clipboard-request-contents (clipboard target callback) nil
229 (clipboard clipboard)
230 ((gdk:atom-intern target) gdk:atom)
231 (%clipboard-receive-func callback)
232 ((register-callback-function callback) unsigned-int))
234 (defcallback %clipboard-text-receive-func (nil (clipboard pointer)
235 (text (copy-of string))
236 (user-data unsigned-int))
237 (funcall (find-user-data user-data) text))
239 (defbinding clipboard-request-text (clipboard callback) nil
240 (clipboard clipboard)
241 (%clipboard-text-receive-func callback)
242 ((register-callback-function callback) unsigned-int))
246 (defcallback %clipboard-image-receive-func (nil (clipboard pointer)
248 (user-data unsigned-int))
249 (funcall (find-user-data user-data) image))
251 (defbinding clipboard-request-image (clipboard callback) nil
252 (clipboard clipboard)
253 (%clipboard-image-receive-func callback)
254 ((register-callback-function callback) unsigned-int)))
257 (defcallback %clipboard-targets-receive-func
258 (nil (clipboard pointer)
259 (atoms (vector gdk:atom n-atoms))
260 (n-atoms unsigned-int)
261 (user-data unsigned-int))
262 (funcall (find-user-data user-data) atoms))
264 (defbinding clipboard-request-targets (clipboard callback) nil
265 (clipboard clipboard)
266 (%clipboard-targets-receive-func callback)
267 ((register-callback-function callback) unsigned-int))
269 (defbinding clipboard-wait-for-contents () selection-data
270 (clipboard clipboard))
272 (defbinding clipboard-wait-for-text () string
273 (clipboard clipboard))
276 (defbinding clipboard-wait-for-image () (referenced gdk:pixbuf)
277 (clipboard clipboard))
279 (defbinding clipboard-wait-is-text-available-p () boolean
280 (clipboard clipboard))
283 (defbinding clipboard-wait-is-image-available-p () boolean
284 (clipboard clipboard))
286 (defbinding clipboard-wait-for-targets () boolean
287 (clipboard clipboard)
288 (targets (vector gdk:atom n-targets) :out)
289 (n-targets unsigned-int :out))
292 (defbinding clipboard-wait-is-target-available-p () boolean
293 (clipboard clipboard)
297 (defbinding clipboard-set-can-store () nil
298 (clipboard clipboard)
299 (targets (vector gdk:atom))
300 ((length targets) int))
303 (defbinding clipboard-store () nil
304 (clipboard clipboard))
309 (defbinding drag-dest-set (widget flags targets actions) nil
311 (flags dest-defaults)
313 ((or vector list) targets)
314 (target-entry (vector targets)))
315 (vector (inlined target-entry)))
317 ((or vector list) (length targets))
320 (actions gdk:drag-action))
322 (defbinding drag-dest-set-proxy () nil
325 (protocol gdk:drag-protocol)
326 (use-coordinates-p boolean))
328 (defbinding drag-dest-unset () nil
331 (defbinding drag-dest-find-target () gdk:atom
333 (context gdk:drag-context)
334 (targets target-list))
336 (defbinding drag-dest-get-target-list () target-list
339 (defbinding drag-dest-set-target-list () nil
341 (targets target-list))
345 (defbinding drag-dest-add-text-targets () nil
348 (defbinding drag-dest-add-image-targets () nil
351 (defbinding drag-dest-add-uri-targets () nil
354 (defbinding drag-finish () nil
355 (context gdk:drag-context)
360 (defbinding drag-get-data () nil
362 (context gdk:drag-context)
366 (defbinding drag-get-source-widget () widget
367 (context gdk:drag-context))
369 (defbinding drag-highlight () nil
372 (defbinding drag-unhighlight () nil
375 (defbinding drag-begin () gdk:drag-context
377 (targets target-list)
378 (actions gdk:drag-action)
382 (defbinding %drag-set-icon-widget () nil
383 (context gdk:drag-context)
388 (defbinding %drag-set-icon-pixmap () nil
389 (context gdk:drag-context)
395 (defbinding %drag-set-icon-pixbuf () nil
396 (context gdk:drag-context)
401 (defbinding %drag-set-icon-stock () nil
402 (context gdk:drag-context)
407 (defbinding %drag-set-icon-default () nil
408 (context gdk:drag-context))
410 (defun drag-set-icon (context icon &optional (hot-x 0) (hot-y 0))
412 (widget (%drag-set-icon-widget context icon hot-x hot-y))
413 (gdk:pixbuf (%drag-set-icon-pixbuf context icon hot-x hot-y))
414 (string (%drag-set-icon-stock context icon hot-x hot-y))
415 (vector (multiple-value-bind (pixmap mask) (gdk:pixmap-create icon)
416 (%drag-set-icon-pixmap context pixmap mask hot-x hot-y)))
417 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
418 (%drag-set-icon-pixbuf context pixbuf hot-x hot-y)))
419 (null (%drag-set-icon-default context))))
421 (defbinding drag-check-threshold-p () boolean
428 (defbinding drag-source-set (widget start-button-mask targets actions) nil
430 (start-button-mask gdk:modifier-type)
432 ((or vector list) targets)
433 (target-entry (vector targets)))
434 (vector (inlined target-entry)))
436 ((or vector list) (length targets))
439 (actions gdk:drag-action))
441 (defbinding %drag-source-set-icon-pixbuf () nil
445 (defbinding %drag-source-set-icon-stock () nil
449 (defun drag-source-set-icon (widget icon)
451 (gdk:pixbuf (%drag-source-set-icon-pixbuf widget icon))
452 (string (%drag-source-set-icon-stock widget icon))
454 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
455 (%drag-source-set-icon-pixbuf widget pixbuf)))))
457 (defbinding drag-source-unset () nil
460 (defbinding drag-source-set-target-list () nil
462 (targets (or null target-list)))
464 (defbinding drag-source-get-target-list () target-list
469 (defbinding drag-source-add-text-targets () nil
472 (defbinding drag-source-add-image-targets () nil
475 (defbinding drag-source-add-uri-targets () nil