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.6 2006/02/19 19:31:15 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 (define-callback %clipboard-get-callback nil
187 ((clipboard pointer) (selection-data selection-data)
188 (info int) (callback-ids unsigned-int))
189 (funcall (car (find-user-data callback-ids)) selection-data info))
191 (define-callback %clipboard-clear-callback nil
192 ((clipboard pointer) (callback-ids unsigned-int))
193 (funcall (cdr (find-user-data callback-ids))))
195 (defbinding clipboard-set-with-data (clipboard targets get-func clear-func) gobject
196 (clipboard clipboard)
197 (targets (vector (inlined target-entry)))
198 ((length targets) unsigned-int)
199 (%clipboard-get-callback callback)
200 (%clipboard-clear-callback callback)
201 ((register-user-data (cons get-func clear-func)) unsigned-int))
203 (defbinding clipboard-clear () nil
204 (clipboard clipboard))
206 (defbinding clipboard-set-text (clipboard text) nil
207 (clipboard clipboard)
212 (defbinding clipboard-set-image () nil
213 (clipboard clipboard)
216 (defun clipboard-set (clipboard object)
218 (string (clipboard-set-text clipboard object))
220 (gdk:pixbuf (clipboard-set-image clipboard object))))
222 (define-callback-marshal %clipboard-receive-callback nil
223 ((:ignore clipboard) selection-data))
225 (defbinding clipboard-request-contents (clipboard target callback) nil
226 (clipboard clipboard)
227 ((gdk:atom-intern target) gdk:atom)
228 (%clipboard-receive-callback callback)
229 ((register-callback-function callback) unsigned-int))
231 (define-callback-marshal %clipboard-text-receive-callback nil
232 ((:ignore clipboard) (text string)))
235 (defbinding clipboard-request-text (clipboard callback) nil
236 (clipboard clipboard)
237 (%clipboard-text-receive-callback callback)
238 ((register-callback-function callback) unsigned-int))
242 (define-callback-marshal %clipboard-image-receive-callback nil
243 ((:ignore clipboard) (image gdk:pixbuf)))
245 (defbinding clipboard-request-image (clipboard callback) nil
246 (clipboard clipboard)
247 (%clipboard-image-receive-callback callback)
248 ((register-callback-function callback) unsigned-int)))
251 (define-callback %clipboard-targets-receive-callback nil
252 ((clipboard pointer) (atoms (vector gdk:atom n-atoms))
253 (n-atoms unsigned-int) (callback-id unsigned-int))
254 (funcall (find-user-data callback-id) atoms))
256 (defbinding clipboard-request-targets (clipboard callback) nil
257 (clipboard clipboard)
258 (%clipboard-targets-receive-callback callback)
259 ((register-callback-function callback) unsigned-int))
261 (defbinding clipboard-wait-for-contents () selection-data
262 (clipboard clipboard))
264 (defbinding clipboard-wait-for-text () string
265 (clipboard clipboard))
268 (defbinding clipboard-wait-for-image () (referenced gdk:pixbuf)
269 (clipboard clipboard))
271 (defbinding clipboard-wait-is-text-available-p () boolean
272 (clipboard clipboard))
275 (defbinding clipboard-wait-is-image-available-p () boolean
276 (clipboard clipboard))
278 (defbinding clipboard-wait-for-targets () boolean
279 (clipboard clipboard)
280 (targets (vector gdk:atom n-targets) :out)
281 (n-targets unsigned-int :out))
284 (defbinding clipboard-wait-is-target-available-p () boolean
285 (clipboard clipboard)
289 (defbinding clipboard-set-can-store () nil
290 (clipboard clipboard)
291 (targets (vector gdk:atom))
292 ((length targets) int))
295 (defbinding clipboard-store () nil
296 (clipboard clipboard))
301 (defbinding drag-dest-set (widget flags targets actions) nil
303 (flags dest-defaults)
305 ((or vector list) targets)
306 (target-entry (vector targets)))
307 (vector (inlined target-entry)))
309 ((or vector list) (length targets))
312 (actions gdk:drag-action))
314 (defbinding drag-dest-set-proxy () nil
317 (protocol gdk:drag-protocol)
318 (use-coordinates-p boolean))
320 (defbinding drag-dest-unset () nil
323 (defbinding drag-dest-find-target () gdk:atom
325 (context gdk:drag-context)
326 (targets target-list))
328 (defbinding drag-dest-get-target-list () target-list
331 (defbinding drag-dest-set-target-list () nil
333 (targets target-list))
337 (defbinding drag-dest-add-text-targets () nil
340 (defbinding drag-dest-add-image-targets () nil
343 (defbinding drag-dest-add-uri-targets () nil
346 (defbinding drag-finish () nil
347 (context gdk:drag-context)
352 (defbinding drag-get-data () nil
354 (context gdk:drag-context)
358 (defbinding drag-get-source-widget () widget
359 (context gdk:drag-context))
361 (defbinding drag-highlight () nil
364 (defbinding drag-unhighlight () nil
367 (defbinding drag-begin () gdk:drag-context
369 (targets target-list)
370 (actions gdk:drag-action)
374 (defbinding %drag-set-icon-widget () nil
375 (context gdk:drag-context)
380 (defbinding %drag-set-icon-pixmap () nil
381 (context gdk:drag-context)
387 (defbinding %drag-set-icon-pixbuf () nil
388 (context gdk:drag-context)
393 (defbinding %drag-set-icon-stock () nil
394 (context gdk:drag-context)
399 (defbinding %drag-set-icon-default () nil
400 (context gdk:drag-context))
402 (defun drag-set-icon (context icon &optional (hot-x 0) (hot-y 0))
404 (widget (%drag-set-icon-widget context icon hot-x hot-y))
405 (gdk:pixbuf (%drag-set-icon-pixbuf context icon hot-x hot-y))
406 (string (%drag-set-icon-stock context icon hot-x hot-y))
407 (vector (multiple-value-bind (pixmap mask) (gdk:pixmap-create icon)
408 (%drag-set-icon-pixmap context pixmap mask hot-x hot-y)))
409 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
410 (%drag-set-icon-pixbuf context pixbuf hot-x hot-y)))
411 (null (%drag-set-icon-default context))))
413 (defbinding drag-check-threshold-p () boolean
420 (defbinding drag-source-set (widget start-button-mask targets actions) nil
422 (start-button-mask gdk:modifier-type)
424 ((or vector list) targets)
425 (target-entry (vector targets)))
426 (vector (inlined target-entry)))
428 ((or vector list) (length targets))
431 (actions gdk:drag-action))
433 (defbinding %drag-source-set-icon-pixbuf () nil
437 (defbinding %drag-source-set-icon-stock () nil
441 (defun drag-source-set-icon (widget icon)
443 (gdk:pixbuf (%drag-source-set-icon-pixbuf widget icon))
444 (string (%drag-source-set-icon-stock widget icon))
446 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
447 (%drag-source-set-icon-pixbuf widget pixbuf)))))
449 (defbinding drag-source-unset () nil
452 (defbinding drag-source-set-target-list () nil
454 (targets (or null target-list)))
456 (defbinding drag-source-get-target-list () target-list
461 (defbinding drag-source-add-text-targets () nil
464 (defbinding drag-source-add-image-targets () nil
467 (defbinding drag-source-add-uri-targets () nil