8cd52853 |
1 | ;; Common Lisp bindings for GTK+ v2.x |
2 | ;; Copyright 2005 Espen S. Johnsen <espen@users.sf.net> |
3 | ;; |
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: |
11 | ;; |
12 | ;; The above copyright notice and this permission notice shall be |
13 | ;; included in all copies or substantial portions of the Software. |
14 | ;; |
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. |
22 | |
f8b57f5a |
23 | ;; $Id: gtkselection.lisp,v 1.2 2006/02/06 14:02:17 espen Exp $ |
8cd52853 |
24 | |
25 | |
26 | (in-package "GTK") |
27 | |
28 | |
29 | ;;;; Selection |
30 | |
8cd52853 |
31 | (defbinding %target-list-ref () pointer |
32 | (location pointer)) |
33 | |
34 | (defbinding %target-list-unref () nil |
35 | (location pointer)) |
36 | |
37 | (defmethod reference-foreign ((class (eql (find-class 'target-list))) location) |
38 | (declare (ignore class)) |
39 | (%target-list-ref location)) |
40 | |
41 | (defmethod unreference-foreign ((class (eql (find-class 'target-list))) location) |
42 | (declare (ignore class)) |
43 | (%target-list-unref location)) |
44 | |
45 | (defbinding %target-list-new () pointer |
46 | (targets (vector (inlined target-entry))) |
47 | ((length targets) int)) |
48 | |
49 | (defmethod initialize-instance ((target-list target-list) &key targets) |
50 | (setf |
51 | (slot-value target-list 'location) |
52 | (%target-list-new targets)) |
53 | (call-next-method)) |
54 | |
55 | (defbinding target-list-add (target-list targets &optional flags info) nil |
56 | (target-list target-list) |
57 | (target gdk:atom) |
58 | (flags unsigned-int) |
59 | (info unsigned-int)) |
60 | |
61 | (defbinding target-list-add-table (target-list targets) nil |
62 | (target-list target-list) |
63 | ((etypecase targets |
64 | ((or vector list) targets) |
65 | (target-entry (vector targets))) |
66 | (vector (inlined target-entry))) |
67 | ((etypecase targets |
68 | ((or vector list) (length targets)) |
69 | (target-entry 1)) |
70 | int)) |
71 | |
72 | #+gtk2.6 |
73 | (progn |
74 | (defbinding target-list-add-text-targets (target-list info &optional writable-p) nil |
75 | (target-list target-list) |
76 | (info unsigned-int) |
77 | (writable-p boolean)) |
78 | |
79 | (defbinding target-list-add-image-targets (target-list info &optional writable-p) nil |
80 | (target-list target-list) |
81 | (info unsigned-int) |
82 | (writable-p boolean)) |
83 | |
84 | (defbinding target-list-add-uri-targets (target-list info &optional writable-p) nil |
85 | (target-list target-list) |
86 | (info unsigned-int) |
87 | (writable-p boolean))) |
88 | |
89 | (defbinding target-list-remove () nil |
90 | (target-list target-list) |
91 | (target gdk:atom)) |
92 | |
93 | ;; (defbinding target-list-find () nil |
94 | ;; (target-list target-list) |
95 | ;; (target gdk:atom) |
96 | ;; ...) |
97 | |
98 | (defbinding (selection-set-owner "gtk_selection_owner_set_for_display") |
99 | (widget selection time &optional (display (gdk:display-get-default))) |
100 | boolean |
101 | (display gdk:display) |
102 | (widget widget) |
103 | ((gdk:atom-intern selection) gdk:atom)) |
104 | |
105 | (defbinding selection-add-target () nil |
106 | (widget widget) |
107 | (selection gdk:atom) |
108 | (target gdk:atom) |
109 | (info unsigned-int)) |
110 | |
111 | (defbinding selection-add-targets (widget selection targets) nil |
112 | (widget widget) |
113 | (selection gdk:atom) |
114 | ((etypecase targets |
115 | ((or vector list) targets) |
116 | (target-entry (vector targets))) |
117 | (vector (inlined target-entry))) |
118 | ((etypecase targets |
119 | ((or vector list) (length targets)) |
120 | (target-entry 1)) |
121 | int)) |
122 | |
123 | (defbinding selection-clear-targets () nil |
124 | (widget widget) |
125 | (selection gdk:atom)) |
126 | |
127 | (defbinding selection-convert () boolean |
128 | (widget widget) |
129 | (selection gdk:atom) |
130 | (target gdk:atom) |
131 | (time unsigned-int)) |
132 | |
133 | (defbinding selection-data-set () boolean |
134 | (selection-data selection-data) |
135 | (type gdk:atom) |
136 | (format int) |
137 | (data pointer) |
138 | (length int)) |
139 | |
140 | (defbinding selection-data-set-text () boolean |
141 | (selection-data selection-data) |
142 | (text string) |
143 | (-1 integer)) |
144 | |
145 | (defbinding selection-data-get-text () string |
146 | (selection-data selection-data)) |
147 | |
148 | #+gtk2.6 |
149 | (progn |
150 | (defbinding selection-data-set-pixbuf () boolean |
151 | (selection-data selection-data) |
152 | (puxbuf gdk:pixbuf)) |
153 | |
154 | (defbinding selection-data-get-pixbuf () gdk:pixbuf |
155 | (selection-data selection-data)) |
156 | |
157 | (defbinding selection-data-set-uris () boolean |
158 | (selection-data selection-data) |
159 | (uris (null-terminated-vector string))) |
160 | |
161 | (defbinding selection-data-get-uris () (null-terminated-vector string) |
162 | (selection-data selection-data))) |
163 | |
164 | (defbinding selection-data-get-targets () boolean |
165 | (selection-data selection-data) |
166 | (targets (vector gdk:atom n-atoms)) |
167 | (n-atoms int)) |
168 | |
169 | #+gtk2.6 |
170 | (defbinding selection-data-targets-include-image-p (selection-data &optional writable-p) boolean |
171 | (selection-data selection-data) |
172 | (writable-p boolean)) |
173 | |
174 | (defbinding selection-data-targets-include-text-p (selection-data) boolean |
175 | (selection-data selection-data)) |
176 | |
177 | (defbinding selection-remove-all (selection-data) boolean |
178 | (widget widget)) |
179 | |
180 | |
181 | ;;; Clipboard -- untestet |
182 | |
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)) |
187 | |
188 | |
189 | (defcallback %clipboard-get-func (nil (clipboard pointer) |
190 | (selection-data selection-data) |
191 | (info int) |
192 | (user-data unsigned-int)) |
193 | (funcall (car (find-user-data user-data)) selection-data info)) |
194 | |
195 | (defcallback %clipboard-clear-func (nil (clipboard pointer) |
196 | (user-data unsigned-int)) |
197 | (funcall (cdr (find-user-data user-data)))) |
198 | |
199 | (defbinding clipboard-set-with-data (clipboard targets get-func clear-func) gobject |
200 | (clipboard clipboard) |
f8b57f5a |
201 | (targets (vector (inlined target-entry))) |
8cd52853 |
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)) |
206 | |
207 | (defbinding clipboard-clear () nil |
208 | (clipboard clipboard)) |
209 | |
210 | (defbinding clipboard-set-text (clipboard text) nil |
211 | (clipboard clipboard) |
212 | (text string) |
213 | ((length text) int)) |
214 | |
215 | #+gtk2.6 |
216 | (defbinding clipboard-set-image () nil |
217 | (clipboard clipboard) |
218 | (pixbuf gdk:pixbuf)) |
219 | |
220 | (defun clipboard-set (clipboard object) |
221 | (etypecase object |
222 | (string (clipboard-set-text clipboard object)) |
223 | #+gtk2.6 |
224 | (gdk:pixbuf (clipboard-set-image clipboard object)))) |
225 | |
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)) |
230 | |
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)) |
236 | |
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)) |
241 | |
242 | (defbinding clipboard-request-text (clipboard callback) nil |
243 | (clipboard clipboard) |
244 | (%clipboard-text-receive-func callback) |
245 | ((register-callback-function callback) unsigned-int)) |
246 | |
247 | #+gtk2.6 |
248 | (progn |
249 | (defcallback %clipboard-image-receive-func (nil (clipboard pointer) |
250 | (image gdk:pixbuf) |
251 | (user-data unsigned-int)) |
252 | (funcall (find-user-data user-data) image)) |
253 | |
254 | (defbinding clipboard-request-image (clipboard callback) nil |
255 | (clipboard clipboard) |
256 | (%clipboard-image-receive-func callback) |
257 | ((register-callback-function callback) unsigned-int))) |
258 | |
259 | |
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)) |
266 | |
267 | (defbinding clipboard-request-targets (clipboard callback) nil |
268 | (clipboard clipboard) |
269 | (%clipboard-targets-receive-func callback) |
270 | ((register-callback-function callback) unsigned-int)) |
271 | |
272 | (defbinding clipboard-wait-for-contents () selection-data |
273 | (clipboard clipboard)) |
274 | |
275 | (defbinding clipboard-wait-for-text () string |
276 | (clipboard clipboard)) |
277 | |
278 | #+gtk2.6 |
279 | (defbinding clipboard-wait-for-image () (referenced gdk:pixbuf) |
280 | (clipboard clipboard)) |
281 | |
282 | (defbinding clipboard-wait-is-text-available-p () boolean |
283 | (clipboard clipboard)) |
284 | |
285 | #+gtk2.6 |
286 | (defbinding clipboard-wait-is-image-available-p () boolean |
287 | (clipboard clipboard)) |
288 | |
289 | (defbinding clipboard-wait-for-targets () boolean |
290 | (clipboard clipboard) |
291 | (targets (vector gdk:atom n-targets) :out) |
292 | (n-targets unsigned-int :out)) |
293 | |
294 | #+gtk2.6 |
295 | (defbinding clipboard-wait-is-target-available-p () boolean |
296 | (clipboard clipboard) |
297 | (target gdk:atom)) |
298 | |
299 | #+gtk2.6 |
300 | (defbinding clipboard-set-can-store () nil |
301 | (clipboard clipboard) |
302 | (targets (vector gdk:atom)) |
303 | ((length targets) int)) |
304 | |
305 | #+gtk2.6 |
306 | (defbinding clipboard-store () nil |
307 | (clipboard clipboard)) |
308 | |
f8b57f5a |
309 | |
8cd52853 |
310 | ;;;; Drag and Drop |
311 | |
312 | (defbinding drag-dest-set (widget flags targets actions) nil |
313 | (widget widget) |
314 | (flags dest-defaults) |
315 | ((etypecase targets |
316 | ((or vector list) targets) |
317 | (target-entry (vector targets))) |
318 | (vector (inlined target-entry))) |
319 | ((etypecase targets |
320 | ((or vector list) (length targets)) |
321 | (target-entry 1)) |
322 | int) |
323 | (actions gdk:drag-action)) |
324 | |
325 | (defbinding drag-dest-set-proxy () nil |
326 | (widget widget) |
327 | (window gdk:window) |
328 | (protocol gdk:drag-protocol) |
329 | (use-coordinates-p boolean)) |
330 | |
331 | (defbinding drag-dest-unset () nil |
332 | (widget widget)) |
333 | |
334 | (defbinding drag-dest-find-target () gdk:atom |
335 | (widget widget) |
336 | (context gdk:drag-context) |
337 | (targets target-list)) |
338 | |
339 | (defbinding drag-dest-get-target-list () target-list |
340 | (widget widget)) |
341 | |
342 | (defbinding drag-dest-set-target-list () nil |
343 | (widget widget) |
344 | (targets target-list)) |
345 | |
346 | #+gtk2.6 |
347 | (progn |
348 | (defbinding drag-dest-add-text-targets () nil |
349 | (widget widget)) |
350 | |
351 | (defbinding drag-dest-add-image-targets () nil |
352 | (widget widget)) |
353 | |
354 | (defbinding drag-dest-add-uri-targets () nil |
355 | (widget widget))) |
356 | |
357 | (defbinding drag-finish () nil |
358 | (context gdk:drag-context) |
359 | (success boolean) |
360 | (delete boolean) |
361 | (time unsigned-int)) |
362 | |
363 | (defbinding drag-get-data () nil |
364 | (widget widget) |
365 | (context gdk:drag-context) |
366 | (target gdk:atom) |
367 | (time unsigned-int)) |
368 | |
369 | (defbinding drag-get-source-widget () widget |
370 | (context gdk:drag-context)) |
371 | |
372 | (defbinding drag-highlight () nil |
373 | (widget widget)) |
374 | |
375 | (defbinding drag-unhighlight () nil |
376 | (widget widget)) |
377 | |
378 | (defbinding drag-begin () gdk:drag-context |
379 | (widget widget) |
380 | (targets target-list) |
381 | (actions gdk:drag-action) |
382 | (button int) |
383 | (event gdk:event)) |
384 | |
385 | (defbinding %drag-set-icon-widget () nil |
386 | (context gdk:drag-context) |
387 | (widget widget) |
388 | (hot-x int) |
389 | (hot-y int)) |
390 | |
391 | (defbinding %drag-set-icon-pixmap () nil |
392 | (context gdk:drag-context) |
393 | (pixmap gdk:pixmap) |
394 | (mask gdk:bitmap) |
395 | (hot-x int) |
396 | (hot-y int)) |
397 | |
398 | (defbinding %drag-set-icon-pixbuf () nil |
399 | (context gdk:drag-context) |
400 | (pixbuf gdk:pixbuf) |
401 | (hot-x int) |
402 | (hot-y int)) |
403 | |
404 | (defbinding %drag-set-icon-stock () nil |
405 | (context gdk:drag-context) |
406 | (stock-id string) |
407 | (hot-x int) |
408 | (hot-y int)) |
409 | |
410 | (defbinding %drag-set-icon-default () nil |
411 | (context gdk:drag-context)) |
412 | |
413 | (defun drag-set-icon (context icon &optional (hot-x 0) (hot-y 0)) |
414 | (etypecase icon |
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)))) |
423 | |
424 | (defbinding drag-check-threshold-p () boolean |
425 | (widget widget) |
426 | (start-x int) |
427 | (start-y int) |
428 | (current-x int) |
429 | (current-y int)) |
430 | |
431 | (defbinding drag-source-set (widget start-button-mask targets actions) nil |
432 | (widget widget) |
433 | (start-button-mask gdk:modifier-type) |
434 | ((etypecase targets |
435 | ((or vector list) targets) |
436 | (target-entry (vector targets))) |
437 | (vector (inlined target-entry))) |
438 | ((etypecase targets |
439 | ((or vector list) (length targets)) |
440 | (target-entry 1)) |
441 | int) |
442 | (actions gdk:drag-action)) |
443 | |
444 | (defbinding %drag-source-set-icon-pixbuf () nil |
445 | (widget widget) |
446 | (pixbuf gdk:pixbuf)) |
447 | |
448 | (defbinding %drag-source-set-icon-stock () nil |
449 | (widget widget) |
450 | (pixbuf gdk:pixbuf)) |
451 | |
452 | (defun drag-source-set-icon (widget icon) |
453 | (etypecase icon |
454 | (gdk:pixbuf (%drag-source-set-icon-pixbuf widget icon)) |
455 | (string (%drag-source-set-icon-stock widget icon)) |
456 | ; (vector ) |
457 | (pathname (let ((pixbuf (gdk:pixbuf-load icon))) |
458 | (%drag-source-set-icon-pixbuf widget pixbuf))))) |
459 | |
460 | (defbinding drag-source-unset () nil |
461 | (widget widget)) |
462 | |
463 | (defbinding drag-source-set-target-list () nil |
464 | (widget widget) |
465 | (targets (or null target-list))) |
466 | |
467 | (defbinding drag-source-get-target-list () target-list |
468 | (widget widget)) |
469 | |
470 | #+gtk2.6 |
471 | (progn |
472 | (defbinding drag-source-add-text-targets () nil |
473 | (widget widget)) |
474 | |
475 | (defbinding drag-source-add-image-targets () nil |
476 | (widget widget)) |
477 | |
478 | (defbinding drag-source-add-uri-targets () nil |
479 | (widget widget))) |