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.3 2006-02-08 21:58:49 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)
51 (slot-value target-list 'location)
52 (%target-list-new targets))
55 (defbinding target-list-add (target-list target &optional flags info) nil
56 (target-list target-list)
61 (defbinding target-list-add-table (target-list targets) nil
62 (target-list target-list)
64 ((or vector list) targets)
65 (target-entry (vector targets)))
66 (vector (inlined target-entry)))
68 ((or vector list) (length targets))
74 (defbinding target-list-add-text-targets (target-list info &optional writable-p) nil
75 (target-list target-list)
79 (defbinding target-list-add-image-targets (target-list info &optional writable-p) nil
80 (target-list target-list)
84 (defbinding target-list-add-uri-targets (target-list info &optional writable-p) nil
85 (target-list target-list)
87 (writable-p boolean)))
89 (defbinding target-list-remove () nil
90 (target-list target-list)
93 ;; (defbinding target-list-find () nil
94 ;; (target-list target-list)
98 (defbinding (selection-set-owner "gtk_selection_owner_set_for_display")
99 (widget selection time &optional (display (gdk:display-get-default)))
101 (display gdk:display)
103 ((gdk:atom-intern selection) gdk:atom))
105 (defbinding selection-add-target () nil
111 (defbinding selection-add-targets (widget selection targets) nil
115 ((or vector list) targets)
116 (target-entry (vector targets)))
117 (vector (inlined target-entry)))
119 ((or vector list) (length targets))
123 (defbinding selection-clear-targets () nil
125 (selection gdk:atom))
127 (defbinding selection-convert () boolean
133 (defbinding selection-data-set () boolean
134 (selection-data selection-data)
140 (defbinding selection-data-set-text () boolean
141 (selection-data selection-data)
145 (defbinding selection-data-get-text () string
146 (selection-data selection-data))
150 (defbinding selection-data-set-pixbuf () boolean
151 (selection-data selection-data)
154 (defbinding selection-data-get-pixbuf () gdk:pixbuf
155 (selection-data selection-data))
157 (defbinding selection-data-set-uris () boolean
158 (selection-data selection-data)
159 (uris (null-terminated-vector string)))
161 (defbinding selection-data-get-uris () (null-terminated-vector string)
162 (selection-data selection-data)))
164 (defbinding selection-data-get-targets () boolean
165 (selection-data selection-data)
166 (targets (vector gdk:atom n-atoms))
170 (defbinding selection-data-targets-include-image-p (selection-data &optional writable-p) boolean
171 (selection-data selection-data)
172 (writable-p boolean))
174 (defbinding selection-data-targets-include-text-p (selection-data) boolean
175 (selection-data selection-data))
177 (defbinding selection-remove-all () boolean
181 ;;; Clipboard -- untestet
183 (defbinding (clipboard-get "gtk_clipboard_get_for_display")
184 (selection &optional (display (gdk:display-get-default))) clipboard
185 (display gdk:display)
186 ((gdk:atom-intern selection) gdk:atom))
189 (defcallback %clipboard-get-func (nil (clipboard pointer)
190 (selection-data selection-data)
192 (user-data unsigned-int))
193 (funcall (car (find-user-data user-data)) selection-data info))
195 (defcallback %clipboard-clear-func (nil (clipboard pointer)
196 (user-data unsigned-int))
197 (funcall (cdr (find-user-data user-data))))
199 (defbinding clipboard-set-with-data (clipboard targets get-func clear-func) gobject
200 (clipboard clipboard)
201 (targets (vector (inlined target-entry)))
202 ((length targets) unsigned-int)
203 (%clipboard-get-func callback)
204 (%clipboard-clear-func callback)
205 ((register-user-data (cons get-func clear-func)) unsigned-int))
207 (defbinding clipboard-clear () nil
208 (clipboard clipboard))
210 (defbinding clipboard-set-text (clipboard text) nil
211 (clipboard clipboard)
216 (defbinding clipboard-set-image () nil
217 (clipboard clipboard)
220 (defun clipboard-set (clipboard object)
222 (string (clipboard-set-text clipboard object))
224 (gdk:pixbuf (clipboard-set-image clipboard object))))
226 (defcallback %clipboard-receive-func (nil (clipboard pointer)
227 (selection-data selection-data)
228 (user-data unsigned-int))
229 (funcall (find-user-data user-data) selection-data))
231 (defbinding clipboard-request-contents (clipboard target callback) nil
232 (clipboard clipboard)
233 ((gdk:atom-intern target) gdk:atom)
234 (%clipboard-receive-func callback)
235 ((register-callback-function callback) unsigned-int))
237 (defcallback %clipboard-text-receive-func (nil (clipboard pointer)
238 (text (copy-of string))
239 (user-data unsigned-int))
240 (funcall (find-user-data user-data) text))
242 (defbinding clipboard-request-text (clipboard callback) nil
243 (clipboard clipboard)
244 (%clipboard-text-receive-func callback)
245 ((register-callback-function callback) unsigned-int))
249 (defcallback %clipboard-image-receive-func (nil (clipboard pointer)
251 (user-data unsigned-int))
252 (funcall (find-user-data user-data) image))
254 (defbinding clipboard-request-image (clipboard callback) nil
255 (clipboard clipboard)
256 (%clipboard-image-receive-func callback)
257 ((register-callback-function callback) unsigned-int)))
260 (defcallback %clipboard-targets-receive-func
261 (nil (clipboard pointer)
262 (atoms (vector gdk:atom n-atoms))
263 (n-atoms unsigned-int)
264 (user-data unsigned-int))
265 (funcall (find-user-data user-data) atoms))
267 (defbinding clipboard-request-targets (clipboard callback) nil
268 (clipboard clipboard)
269 (%clipboard-targets-receive-func callback)
270 ((register-callback-function callback) unsigned-int))
272 (defbinding clipboard-wait-for-contents () selection-data
273 (clipboard clipboard))
275 (defbinding clipboard-wait-for-text () string
276 (clipboard clipboard))
279 (defbinding clipboard-wait-for-image () (referenced gdk:pixbuf)
280 (clipboard clipboard))
282 (defbinding clipboard-wait-is-text-available-p () boolean
283 (clipboard clipboard))
286 (defbinding clipboard-wait-is-image-available-p () boolean
287 (clipboard clipboard))
289 (defbinding clipboard-wait-for-targets () boolean
290 (clipboard clipboard)
291 (targets (vector gdk:atom n-targets) :out)
292 (n-targets unsigned-int :out))
295 (defbinding clipboard-wait-is-target-available-p () boolean
296 (clipboard clipboard)
300 (defbinding clipboard-set-can-store () nil
301 (clipboard clipboard)
302 (targets (vector gdk:atom))
303 ((length targets) int))
306 (defbinding clipboard-store () nil
307 (clipboard clipboard))
312 (defbinding drag-dest-set (widget flags targets actions) nil
314 (flags dest-defaults)
316 ((or vector list) targets)
317 (target-entry (vector targets)))
318 (vector (inlined target-entry)))
320 ((or vector list) (length targets))
323 (actions gdk:drag-action))
325 (defbinding drag-dest-set-proxy () nil
328 (protocol gdk:drag-protocol)
329 (use-coordinates-p boolean))
331 (defbinding drag-dest-unset () nil
334 (defbinding drag-dest-find-target () gdk:atom
336 (context gdk:drag-context)
337 (targets target-list))
339 (defbinding drag-dest-get-target-list () target-list
342 (defbinding drag-dest-set-target-list () nil
344 (targets target-list))
348 (defbinding drag-dest-add-text-targets () nil
351 (defbinding drag-dest-add-image-targets () nil
354 (defbinding drag-dest-add-uri-targets () nil
357 (defbinding drag-finish () nil
358 (context gdk:drag-context)
363 (defbinding drag-get-data () nil
365 (context gdk:drag-context)
369 (defbinding drag-get-source-widget () widget
370 (context gdk:drag-context))
372 (defbinding drag-highlight () nil
375 (defbinding drag-unhighlight () nil
378 (defbinding drag-begin () gdk:drag-context
380 (targets target-list)
381 (actions gdk:drag-action)
385 (defbinding %drag-set-icon-widget () nil
386 (context gdk:drag-context)
391 (defbinding %drag-set-icon-pixmap () nil
392 (context gdk:drag-context)
398 (defbinding %drag-set-icon-pixbuf () nil
399 (context gdk:drag-context)
404 (defbinding %drag-set-icon-stock () nil
405 (context gdk:drag-context)
410 (defbinding %drag-set-icon-default () nil
411 (context gdk:drag-context))
413 (defun drag-set-icon (context icon &optional (hot-x 0) (hot-y 0))
415 (widget (%drag-set-icon-widget context icon hot-x hot-y))
416 (gdk:pixbuf (%drag-set-icon-pixbuf context icon hot-x hot-y))
417 (string (%drag-set-icon-stock context icon hot-x hot-y))
418 (vector (multiple-value-bind (pixmap mask) (gdk:pixmap-create icon)
419 (%drag-set-icon-pixmap context pixmap mask hot-x hot-y)))
420 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
421 (%drag-set-icon-pixbuf context pixbuf hot-x hot-y)))
422 (null (%drag-set-icon-default context))))
424 (defbinding drag-check-threshold-p () boolean
431 (defbinding drag-source-set (widget start-button-mask targets actions) nil
433 (start-button-mask gdk:modifier-type)
435 ((or vector list) targets)
436 (target-entry (vector targets)))
437 (vector (inlined target-entry)))
439 ((or vector list) (length targets))
442 (actions gdk:drag-action))
444 (defbinding %drag-source-set-icon-pixbuf () nil
448 (defbinding %drag-source-set-icon-stock () nil
452 (defun drag-source-set-icon (widget icon)
454 (gdk:pixbuf (%drag-source-set-icon-pixbuf widget icon))
455 (string (%drag-source-set-icon-stock widget icon))
457 (pathname (let ((pixbuf (gdk:pixbuf-load icon)))
458 (%drag-source-set-icon-pixbuf widget pixbuf)))))
460 (defbinding drag-source-unset () nil
463 (defbinding drag-source-set-target-list () nil
465 (targets (or null target-list)))
467 (defbinding drag-source-get-target-list () target-list
472 (defbinding drag-source-add-text-targets () nil
475 (defbinding drag-source-add-image-targets () nil
478 (defbinding drag-source-add-uri-targets () nil