1 ;; Common Lisp bindings for GTK+ v2.x
2 ;; Copyright 2005-2006 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.9 2006-04-26 12:30:30 espen Exp $
31 (defbinding %target-list-ref () pointer
34 (defbinding %target-list-unref () nil
37 (defbinding %target-list-new () pointer
38 (targets (vector (inlined target-entry)))
39 ((length targets) int))
41 (defmethod allocate-foreign ((target-list target-list) &key targets)
42 (%target-list-new targets))
44 (defbinding target-list-add (target-list target &optional flags info) nil
45 (target-list target-list)
50 (defbinding target-list-add-table (target-list targets) nil
51 (target-list target-list)
53 ((or vector list) targets)
54 (target-entry (vector targets)))
55 (vector (inlined target-entry)))
57 ((or vector list) (length targets))
61 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
63 (defbinding target-list-add-text-targets (target-list info &optional writable-p) nil
64 (target-list target-list)
68 (defbinding target-list-add-image-targets (target-list info &optional writable-p) nil
69 (target-list target-list)
73 (defbinding target-list-add-uri-targets (target-list info &optional writable-p) nil
74 (target-list target-list)
76 (writable-p boolean)))
78 (defbinding target-list-remove () nil
79 (target-list target-list)
82 ;; (defbinding target-list-find () nil
83 ;; (target-list target-list)
87 (defbinding (selection-set-owner "gtk_selection_owner_set_for_display")
88 (widget selection time &optional (display (gdk:display-get-default)))
92 ((gdk:atom-intern selection) gdk:atom)
95 (defbinding selection-add-target () nil
101 (defbinding selection-add-targets (widget selection targets) nil
105 ((or vector list) targets)
106 (target-entry (vector targets)))
107 (vector (inlined target-entry)))
109 ((or vector list) (length targets))
113 (defbinding selection-clear-targets () nil
115 (selection gdk:atom))
117 (defbinding selection-convert () boolean
123 (defbinding selection-data-set () boolean
124 (selection-data selection-data)
130 (defbinding selection-data-set-text () boolean
131 (selection-data selection-data)
135 (defbinding selection-data-get-text () string
136 (selection-data selection-data))
138 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
140 (defbinding selection-data-set-pixbuf () boolean
141 (selection-data selection-data)
144 (defbinding selection-data-get-pixbuf () gdk:pixbuf
145 (selection-data selection-data))
147 (defbinding selection-data-set-uris () boolean
148 (selection-data selection-data)
149 (uris (null-terminated-vector string)))
151 (defbinding selection-data-get-uris () (null-terminated-vector string)
152 (selection-data selection-data)))
154 (defbinding selection-data-get-targets () boolean
155 (selection-data selection-data)
156 (targets (vector gdk:atom n-atoms))
159 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
160 (defbinding selection-data-targets-include-image-p (selection-data &optional writable-p) boolean
161 (selection-data selection-data)
162 (writable-p boolean))
164 (defbinding selection-data-targets-include-text-p (selection-data) boolean
165 (selection-data selection-data))
167 (defbinding selection-remove-all () boolean
171 ;;; Clipboard -- untestet
173 (defbinding (clipboard-get "gtk_clipboard_get_for_display")
174 (selection &optional (display (gdk:display-get-default))) clipboard
175 (display gdk:display)
176 ((gdk:atom-intern selection) gdk:atom))
179 (define-callback %clipboard-get-callback nil
180 ((clipboard pointer) (selection-data selection-data)
181 (info int) (callback-ids unsigned-int))
182 (declare (ignore clipboard))
183 (funcall (car (find-user-data callback-ids)) selection-data info))
185 (define-callback %clipboard-clear-callback nil
186 ((clipboard pointer) (callback-ids unsigned-int))
187 (declare (ignore clipboard))
188 (funcall (cdr (find-user-data callback-ids))))
190 (defbinding clipboard-set-with-data (clipboard targets get-func clear-func) gobject
191 (clipboard clipboard)
192 (targets (vector (inlined target-entry)))
193 ((length targets) unsigned-int)
194 (%clipboard-get-callback callback)
195 (%clipboard-clear-callback callback)
196 ((register-user-data (cons get-func clear-func)) unsigned-int))
198 (defbinding clipboard-clear () nil
199 (clipboard clipboard))
201 (defbinding clipboard-set-text (clipboard text) nil
202 (clipboard clipboard)
206 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
207 (defbinding clipboard-set-image () nil
208 (clipboard clipboard)
211 (defun clipboard-set (clipboard object)
213 (string (clipboard-set-text clipboard object))
214 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
215 (gdk:pixbuf (clipboard-set-image clipboard object))))
217 (define-callback-marshal %clipboard-receive-callback nil
218 ((:ignore clipboard) selection-data))
220 (defbinding clipboard-request-contents (clipboard target callback) nil
221 (clipboard clipboard)
222 ((gdk:atom-intern target) gdk:atom)
223 (%clipboard-receive-callback callback)
224 ((register-callback-function callback) unsigned-int))
226 (define-callback-marshal %clipboard-text-receive-callback nil
227 ((:ignore clipboard) (text string)))
230 (defbinding clipboard-request-text (clipboard callback) nil
231 (clipboard clipboard)
232 (%clipboard-text-receive-callback callback)
233 ((register-callback-function callback) unsigned-int))
235 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
237 (define-callback-marshal %clipboard-image-receive-callback nil
238 ((:ignore clipboard) (image gdk:pixbuf)))
240 (defbinding clipboard-request-image (clipboard callback) nil
241 (clipboard clipboard)
242 (%clipboard-image-receive-callback callback)
243 ((register-callback-function callback) unsigned-int)))
246 (define-callback %clipboard-targets-receive-callback nil
247 ((clipboard pointer) (atoms (vector gdk:atom n-atoms))
248 (n-atoms unsigned-int) (callback-id unsigned-int))
249 (declare (ignore clipboard))
250 (funcall (find-user-data callback-id) atoms))
252 (defbinding clipboard-request-targets (clipboard callback) nil
253 (clipboard clipboard)
254 (%clipboard-targets-receive-callback callback)
255 ((register-callback-function callback) unsigned-int))
257 (defbinding clipboard-wait-for-contents () selection-data
258 (clipboard clipboard))
260 (defbinding clipboard-wait-for-text () string
261 (clipboard clipboard))
263 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
264 (defbinding clipboard-wait-for-image () (referenced gdk:pixbuf)
265 (clipboard clipboard))
267 (defbinding clipboard-wait-is-text-available-p () boolean
268 (clipboard clipboard))
270 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
271 (defbinding clipboard-wait-is-image-available-p () boolean
272 (clipboard clipboard))
274 (defbinding clipboard-wait-for-targets () boolean
275 (clipboard clipboard)
276 (targets (vector gdk:atom n-targets) :out)
277 (n-targets unsigned-int :out))
279 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
280 (defbinding clipboard-wait-is-target-available-p () boolean
281 (clipboard clipboard)
284 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
285 (defbinding clipboard-set-can-store () nil
286 (clipboard clipboard)
287 (targets (vector gdk:atom))
288 ((length targets) int))
290 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
291 (defbinding clipboard-store () nil
292 (clipboard clipboard))
297 (defbinding drag-dest-set (widget flags targets actions) nil
299 (flags dest-defaults)
301 ((or vector list) targets)
302 (target-entry (vector targets)))
303 (vector (inlined target-entry)))
305 ((or vector list) (length targets))
308 (actions gdk:drag-action))
310 (defbinding drag-dest-set-proxy () nil
313 (protocol gdk:drag-protocol)
314 (use-coordinates-p boolean))
316 (defbinding drag-dest-unset () nil
319 (defbinding drag-dest-find-target () gdk:atom
321 (context gdk:drag-context)
322 (targets target-list))
324 (defbinding drag-dest-get-target-list () target-list
327 (defbinding drag-dest-set-target-list () nil
329 (targets target-list))
331 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
333 (defbinding drag-dest-add-text-targets () nil
336 (defbinding drag-dest-add-image-targets () nil
339 (defbinding drag-dest-add-uri-targets () nil
342 (defbinding drag-finish () nil
343 (context gdk:drag-context)
348 (defbinding drag-get-data () nil
350 (context gdk:drag-context)
354 (defbinding drag-get-source-widget () widget
355 (context gdk:drag-context))
357 (defbinding drag-highlight () nil
360 (defbinding drag-unhighlight () nil
363 (defbinding drag-begin () gdk:drag-context
365 (targets target-list)
366 (actions gdk:drag-action)
370 (defbinding %drag-set-icon-widget () nil
371 (context gdk:drag-context)
376 (defbinding %drag-set-icon-pixmap () nil
377 (context gdk:drag-context)
383 (defbinding %drag-set-icon-pixbuf () nil
384 (context gdk:drag-context)
389 (defbinding %drag-set-icon-stock () nil
390 (context gdk:drag-context)
395 (defbinding %drag-set-icon-default () nil
396 (context gdk:drag-context))
398 (defun drag-set-icon (context icon &optional (hot-x 0) (hot-y 0))
400 (widget (%drag-set-icon-widget context icon hot-x hot-y))
401 (gdk:pixbuf (%drag-set-icon-pixbuf context icon hot-x hot-y))
402 (string (%drag-set-icon-stock context icon hot-x hot-y))
403 (vector (multiple-value-bind (pixmap mask) (gdk:pixmap-create icon)
404 (%drag-set-icon-pixmap context pixmap mask hot-x hot-y)))
405 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
406 (%drag-set-icon-pixbuf context pixbuf hot-x hot-y)))
407 (null (%drag-set-icon-default context))))
409 (defbinding drag-check-threshold-p () boolean
416 (defbinding drag-source-set (widget start-button-mask targets actions) nil
418 (start-button-mask gdk:modifier-type)
420 ((or vector list) targets)
421 (target-entry (vector targets)))
422 (vector (inlined target-entry)))
424 ((or vector list) (length targets))
427 (actions gdk:drag-action))
429 (defbinding %drag-source-set-icon-pixbuf () nil
433 (defbinding %drag-source-set-icon-stock () nil
437 (defun drag-source-set-icon (widget icon)
439 (gdk:pixbuf (%drag-source-set-icon-pixbuf widget icon))
440 (string (%drag-source-set-icon-stock widget icon))
442 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
443 (%drag-source-set-icon-pixbuf widget pixbuf)))))
445 (defbinding drag-source-unset () nil
448 (defbinding drag-source-set-target-list () nil
450 (targets (or null target-list)))
452 (defbinding drag-source-get-target-list () target-list
455 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
457 (defbinding drag-source-add-text-targets () nil
460 (defbinding drag-source-add-image-targets () nil
463 (defbinding drag-source-add-uri-targets () nil