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.4 2006-02-08 22:21:07 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 initialize-instance ((target-list target-list) &key targets)
50 (setf (foreign-location target-list) (%target-list-new targets))
53 (defbinding target-list-add (target-list target &optional flags info) nil
54 (target-list target-list)
59 (defbinding target-list-add-table (target-list targets) nil
60 (target-list target-list)
62 ((or vector list) targets)
63 (target-entry (vector targets)))
64 (vector (inlined target-entry)))
66 ((or vector list) (length targets))
72 (defbinding target-list-add-text-targets (target-list info &optional writable-p) nil
73 (target-list target-list)
77 (defbinding target-list-add-image-targets (target-list info &optional writable-p) nil
78 (target-list target-list)
82 (defbinding target-list-add-uri-targets (target-list info &optional writable-p) nil
83 (target-list target-list)
85 (writable-p boolean)))
87 (defbinding target-list-remove () nil
88 (target-list target-list)
91 ;; (defbinding target-list-find () nil
92 ;; (target-list target-list)
96 (defbinding (selection-set-owner "gtk_selection_owner_set_for_display")
97 (widget selection time &optional (display (gdk:display-get-default)))
101 ((gdk:atom-intern selection) gdk:atom))
103 (defbinding selection-add-target () nil
109 (defbinding selection-add-targets (widget selection targets) nil
113 ((or vector list) targets)
114 (target-entry (vector targets)))
115 (vector (inlined target-entry)))
117 ((or vector list) (length targets))
121 (defbinding selection-clear-targets () nil
123 (selection gdk:atom))
125 (defbinding selection-convert () boolean
131 (defbinding selection-data-set () boolean
132 (selection-data selection-data)
138 (defbinding selection-data-set-text () boolean
139 (selection-data selection-data)
143 (defbinding selection-data-get-text () string
144 (selection-data selection-data))
148 (defbinding selection-data-set-pixbuf () boolean
149 (selection-data selection-data)
152 (defbinding selection-data-get-pixbuf () gdk:pixbuf
153 (selection-data selection-data))
155 (defbinding selection-data-set-uris () boolean
156 (selection-data selection-data)
157 (uris (null-terminated-vector string)))
159 (defbinding selection-data-get-uris () (null-terminated-vector string)
160 (selection-data selection-data)))
162 (defbinding selection-data-get-targets () boolean
163 (selection-data selection-data)
164 (targets (vector gdk:atom n-atoms))
168 (defbinding selection-data-targets-include-image-p (selection-data &optional writable-p) boolean
169 (selection-data selection-data)
170 (writable-p boolean))
172 (defbinding selection-data-targets-include-text-p (selection-data) boolean
173 (selection-data selection-data))
175 (defbinding selection-remove-all () boolean
179 ;;; Clipboard -- untestet
181 (defbinding (clipboard-get "gtk_clipboard_get_for_display")
182 (selection &optional (display (gdk:display-get-default))) clipboard
183 (display gdk:display)
184 ((gdk:atom-intern selection) gdk:atom))
187 (defcallback %clipboard-get-func (nil (clipboard pointer)
188 (selection-data selection-data)
190 (user-data unsigned-int))
191 (funcall (car (find-user-data user-data)) selection-data info))
193 (defcallback %clipboard-clear-func (nil (clipboard pointer)
194 (user-data unsigned-int))
195 (funcall (cdr (find-user-data user-data))))
197 (defbinding clipboard-set-with-data (clipboard targets get-func clear-func) gobject
198 (clipboard clipboard)
199 (targets (vector (inlined target-entry)))
200 ((length targets) unsigned-int)
201 (%clipboard-get-func callback)
202 (%clipboard-clear-func callback)
203 ((register-user-data (cons get-func clear-func)) unsigned-int))
205 (defbinding clipboard-clear () nil
206 (clipboard clipboard))
208 (defbinding clipboard-set-text (clipboard text) nil
209 (clipboard clipboard)
214 (defbinding clipboard-set-image () nil
215 (clipboard clipboard)
218 (defun clipboard-set (clipboard object)
220 (string (clipboard-set-text clipboard object))
222 (gdk:pixbuf (clipboard-set-image clipboard object))))
224 (defcallback %clipboard-receive-func (nil (clipboard pointer)
225 (selection-data selection-data)
226 (user-data unsigned-int))
227 (funcall (find-user-data user-data) selection-data))
229 (defbinding clipboard-request-contents (clipboard target callback) nil
230 (clipboard clipboard)
231 ((gdk:atom-intern target) gdk:atom)
232 (%clipboard-receive-func callback)
233 ((register-callback-function callback) unsigned-int))
235 (defcallback %clipboard-text-receive-func (nil (clipboard pointer)
236 (text (copy-of string))
237 (user-data unsigned-int))
238 (funcall (find-user-data user-data) text))
240 (defbinding clipboard-request-text (clipboard callback) nil
241 (clipboard clipboard)
242 (%clipboard-text-receive-func callback)
243 ((register-callback-function callback) unsigned-int))
247 (defcallback %clipboard-image-receive-func (nil (clipboard pointer)
249 (user-data unsigned-int))
250 (funcall (find-user-data user-data) image))
252 (defbinding clipboard-request-image (clipboard callback) nil
253 (clipboard clipboard)
254 (%clipboard-image-receive-func callback)
255 ((register-callback-function callback) unsigned-int)))
258 (defcallback %clipboard-targets-receive-func
259 (nil (clipboard pointer)
260 (atoms (vector gdk:atom n-atoms))
261 (n-atoms unsigned-int)
262 (user-data unsigned-int))
263 (funcall (find-user-data user-data) atoms))
265 (defbinding clipboard-request-targets (clipboard callback) nil
266 (clipboard clipboard)
267 (%clipboard-targets-receive-func callback)
268 ((register-callback-function callback) unsigned-int))
270 (defbinding clipboard-wait-for-contents () selection-data
271 (clipboard clipboard))
273 (defbinding clipboard-wait-for-text () string
274 (clipboard clipboard))
277 (defbinding clipboard-wait-for-image () (referenced gdk:pixbuf)
278 (clipboard clipboard))
280 (defbinding clipboard-wait-is-text-available-p () boolean
281 (clipboard clipboard))
284 (defbinding clipboard-wait-is-image-available-p () boolean
285 (clipboard clipboard))
287 (defbinding clipboard-wait-for-targets () boolean
288 (clipboard clipboard)
289 (targets (vector gdk:atom n-targets) :out)
290 (n-targets unsigned-int :out))
293 (defbinding clipboard-wait-is-target-available-p () boolean
294 (clipboard clipboard)
298 (defbinding clipboard-set-can-store () nil
299 (clipboard clipboard)
300 (targets (vector gdk:atom))
301 ((length targets) int))
304 (defbinding clipboard-store () nil
305 (clipboard clipboard))
310 (defbinding drag-dest-set (widget flags targets actions) nil
312 (flags dest-defaults)
314 ((or vector list) targets)
315 (target-entry (vector targets)))
316 (vector (inlined target-entry)))
318 ((or vector list) (length targets))
321 (actions gdk:drag-action))
323 (defbinding drag-dest-set-proxy () nil
326 (protocol gdk:drag-protocol)
327 (use-coordinates-p boolean))
329 (defbinding drag-dest-unset () nil
332 (defbinding drag-dest-find-target () gdk:atom
334 (context gdk:drag-context)
335 (targets target-list))
337 (defbinding drag-dest-get-target-list () target-list
340 (defbinding drag-dest-set-target-list () nil
342 (targets target-list))
346 (defbinding drag-dest-add-text-targets () nil
349 (defbinding drag-dest-add-image-targets () nil
352 (defbinding drag-dest-add-uri-targets () nil
355 (defbinding drag-finish () nil
356 (context gdk:drag-context)
361 (defbinding drag-get-data () nil
363 (context gdk:drag-context)
367 (defbinding drag-get-source-widget () widget
368 (context gdk:drag-context))
370 (defbinding drag-highlight () nil
373 (defbinding drag-unhighlight () nil
376 (defbinding drag-begin () gdk:drag-context
378 (targets target-list)
379 (actions gdk:drag-action)
383 (defbinding %drag-set-icon-widget () nil
384 (context gdk:drag-context)
389 (defbinding %drag-set-icon-pixmap () nil
390 (context gdk:drag-context)
396 (defbinding %drag-set-icon-pixbuf () nil
397 (context gdk:drag-context)
402 (defbinding %drag-set-icon-stock () nil
403 (context gdk:drag-context)
408 (defbinding %drag-set-icon-default () nil
409 (context gdk:drag-context))
411 (defun drag-set-icon (context icon &optional (hot-x 0) (hot-y 0))
413 (widget (%drag-set-icon-widget context icon hot-x hot-y))
414 (gdk:pixbuf (%drag-set-icon-pixbuf context icon hot-x hot-y))
415 (string (%drag-set-icon-stock context icon hot-x hot-y))
416 (vector (multiple-value-bind (pixmap mask) (gdk:pixmap-create icon)
417 (%drag-set-icon-pixmap context pixmap mask hot-x hot-y)))
418 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
419 (%drag-set-icon-pixbuf context pixbuf hot-x hot-y)))
420 (null (%drag-set-icon-default context))))
422 (defbinding drag-check-threshold-p () boolean
429 (defbinding drag-source-set (widget start-button-mask targets actions) nil
431 (start-button-mask gdk:modifier-type)
433 ((or vector list) targets)
434 (target-entry (vector targets)))
435 (vector (inlined target-entry)))
437 ((or vector list) (length targets))
440 (actions gdk:drag-action))
442 (defbinding %drag-source-set-icon-pixbuf () nil
446 (defbinding %drag-source-set-icon-stock () nil
450 (defun drag-source-set-icon (widget icon)
452 (gdk:pixbuf (%drag-source-set-icon-pixbuf widget icon))
453 (string (%drag-source-set-icon-stock widget icon))
455 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
456 (%drag-source-set-icon-pixbuf widget pixbuf)))))
458 (defbinding drag-source-unset () nil
461 (defbinding drag-source-set-target-list () nil
463 (targets (or null target-list)))
465 (defbinding drag-source-get-target-list () target-list
470 (defbinding drag-source-add-text-targets () nil
473 (defbinding drag-source-add-image-targets () nil
476 (defbinding drag-source-add-uri-targets () nil