55212af1 |
1 | ;; Common Lisp bindings for GTK+ v2.x |
f957f519 |
2 | ;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net> |
0d07716f |
3 | ;; |
55212af1 |
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: |
0d07716f |
11 | ;; |
55212af1 |
12 | ;; The above copyright notice and this permission notice shall be |
13 | ;; included in all copies or substantial portions of the Software. |
0d07716f |
14 | ;; |
55212af1 |
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. |
0d07716f |
22 | |
b3c839c9 |
23 | ;; $Id: gtk.lisp,v 1.89 2008/01/11 14:44:28 espen Exp $ |
0d07716f |
24 | |
25 | |
26 | (in-package "GTK") |
27 | |
28 | ;;; Gtk version |
29 | |
84967144 |
30 | (defbinding check-version () (copy-of string) |
0d07716f |
31 | (required-major unsigned-int) |
32 | (required-minor unsigned-int) |
33 | (required-micro unsigned-int)) |
34 | |
a60bd055 |
35 | (defbinding query-version () nil |
0d07716f |
36 | (major unsigned-int :out) |
37 | (minor unsigned-int :out) |
38 | (micro unsigned-int :out)) |
39 | |
40 | (defun gtk-version () |
41 | (multiple-value-bind (major minor micro) |
42 | (query-version) |
43 | (if (zerop micro) |
44 | (format nil "Gtk+ v~A.~A" major minor) |
45 | (format nil "Gtk+ v~A.~A.~A" major minor micro)))) |
46 | |
e69138cc |
47 | (defun clg-version () |
15421c36 |
48 | "clg 0.93") |
0d07716f |
49 | |
50 | |
5233fe44 |
51 | ;;;; Initalization and display handling |
6baf860c |
52 | |
6e21e828 |
53 | (defparameter *event-poll-interval* 10000) ; in microseconds |
54 | |
55 | |
30628c63 |
56 | (defbinding (gtk-init "gtk_parse_args") () boolean |
6baf860c |
57 | "Initializes the library without opening the display." |
58 | (nil null) |
59 | (nil null)) |
60 | |
6e21e828 |
61 | (defun clg-init (&optional display multi-threading-p) |
62 | "Initializes the system and starts event handling." |
6baf860c |
63 | (unless (gdk:display-get-default) |
92afacae |
64 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
65 | (progn |
66 | #+sbcl(sb-int:set-floating-point-modes :traps nil) |
67 | #+cmu(ext:set-floating-point-modes :traps nil)) |
68 | |
6e21e828 |
69 | (gdk:gdk-init) |
70 | (unless (gtk-init) |
71 | (error "Initialization of GTK+ failed.")) |
72 | |
73 | (if (not multi-threading-p) |
74 | (%init-async-event-handling display) |
75 | #+sb-thread(%init-multi-threaded-event-handling display) |
76 | #-sb-thread(error "Multi threading not supported on this platform"))) |
6b465328 |
77 | (gdk:ensure-display display t)) |
6e21e828 |
78 | |
f957f519 |
79 | (defun clg-init-with-threading (&optional display) |
6e21e828 |
80 | (clg-init display t)) |
81 | |
82 | |
83 | #?(sbcl>= 1 0 6) |
84 | ;; A very minimal implementation of CLISP's socket-status |
85 | (defun socket-status (socket seconds microseconds) |
86 | (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set))) |
87 | (let ((fd (sb-sys:fd-stream-fd (car socket)))) |
88 | (sb-unix:fd-zero read-fds) |
89 | (sb-unix:fd-set fd read-fds) |
90 | |
6006b229 |
91 | (let ((num-fds-changed |
92 | (sb-unix:unix-fast-select |
93 | (1+ fd) (sb-alien:addr read-fds) nil nil |
94 | seconds microseconds))) |
95 | (unless (or (not num-fds-changed) (zerop num-fds-changed)) |
96 | (if (peek-char nil (car socket) nil) |
97 | :input |
98 | :eof)))))) |
6e21e828 |
99 | |
100 | (defun %init-async-event-handling (display) |
101 | (let ((style #?(or (featurep :cmu) (sbcl< 1 0 6)) :fd-handler |
102 | #?-(or (featurep :cmu) (sbcl< 1 0 6)) nil)) |
103 | (when (and |
104 | (find-package "SWANK") |
105 | (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style))) |
57fa233b |
106 | (error "When running clg in Slime, the communication style ~S must be used in combination with asynchronous event handling on this platform. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information." style))) |
6e21e828 |
107 | |
108 | #?(or (featurep :cmu) (sbcl< 1 0 6)) |
109 | (progn |
110 | (signal-connect (gdk:display-manager) 'display-opened |
111 | #'(lambda (display) |
112 | (let ((fd (gdk:display-connection-number display))) |
113 | (unless (< fd 0) |
114 | (let ((handler (add-fd-handler |
115 | (gdk:display-connection-number display) |
116 | :input #'main-iterate-all))) |
117 | (signal-connect display 'closed |
118 | #'(lambda (is-error-p) |
119 | (declare (ignore is-error-p)) |
120 | (remove-fd-handler handler)))))))) |
121 | (setq *periodic-polling-function* #'main-iterate-all) |
122 | (setq *max-event-to-sec* 0) |
123 | (setq *max-event-to-usec* *event-poll-interval*)) |
124 | |
125 | #+(and clisp readline) |
126 | ;; Readline will call the event hook at most ten times per second |
127 | (setf readline:event-hook #'main-iterate-all) |
128 | |
129 | #?-(or (featurep :cmu) (sbcl< 1 0 6)) |
130 | ;; When running in Slime we need to hook into the Swank server |
131 | ;; to handle events asynchronously. |
b3c839c9 |
132 | (unless (and |
133 | (find-package "SWANK") |
134 | (let ((connection (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK")))) |
135 | (when connection |
136 | (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))) |
137 | (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") connection))) |
138 | (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")) |
139 | #'(lambda () |
140 | (loop |
141 | (case (socket-status (cons stream :input) 0 |
142 | *event-poll-interval*) |
143 | ((:input :eof) (return (funcall read-from-emacs))) |
144 | (otherwise (main-iterate-all)))))))))) |
6e21e828 |
145 | #-(and clisp readline) |
146 | (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started.")) |
147 | |
148 | (gdk:display-open display)) |
149 | |
150 | #+sb-thread |
151 | (progn |
152 | (defvar *main-thread* nil) |
153 | |
154 | ;; Hopefully, when threading support is added to the Win32 port of |
155 | ;; SBCL in the future, this will work just out of the box. |
156 | #+win32 |
157 | (let ((done (sb-thread:make-waitqueue)) |
158 | (functions ()) |
159 | (results ())) |
160 | |
161 | ;; In Win32 all GDK calls have to be made from the main loop |
162 | ;; thread, so we add a timeout function which will poll for code and |
163 | ;; execute it. |
164 | |
165 | (defun funcall-in-main (function) |
166 | (if (or |
167 | (not *main-thread*) |
168 | (eq sb-thread:*current-thread* *main-thread*)) |
169 | (funcall function) |
170 | (gdk:with-global-lock |
171 | (push function functions) |
172 | (sb-thread:condition-wait done gdk:*global-lock*) |
173 | (pop results)))) |
174 | |
175 | ;; Will lock REPL on error, need to be fixed! |
176 | (defun %funcall-in-main-poll () |
177 | (when functions |
178 | (loop |
179 | for n from 0 |
180 | while functions |
181 | do (push (funcall (pop functions)) results) |
182 | finally (sb-thread:condition-notify done n))) |
183 | t)) |
184 | |
185 | (defmacro within-main-loop (&body body) |
186 | #-win32 `(gdk:with-global-lock ,@body) |
187 | #+win32 `(funcall-in-main #'(lambda () ,@body))) |
188 | |
189 | (defun %init-multi-threaded-event-handling (display) |
190 | (when (and |
191 | (find-package "SWANK") |
192 | (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn))) |
193 | (error "When running clg in Slime, the communication style :spawn must be used in combination with multi threaded event handling. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information.")) |
72cb3e1f |
194 | (gdk:threads-init) |
6e21e828 |
195 | (let ((main-running (sb-thread:make-waitqueue))) |
196 | (gdk:with-global-lock |
197 | (setf *main-thread* |
198 | (sb-thread:make-thread |
199 | #'(lambda () |
6e21e828 |
200 | (gdk:with-global-lock |
201 | (gdk:display-open display) |
202 | #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000) |
203 | #'%funcall-in-main-poll) |
204 | (sb-thread:condition-notify main-running) |
205 | (main))) |
206 | :name "gtk event loop")) |
207 | (sb-thread:condition-wait main-running gdk:*global-lock*))) |
208 | |
209 | ;; We need to hook into the Swank server to protect calls to GDK properly. |
210 | ;; This will *only* protect code entered directly in the REPL. |
211 | (when (find-package "SWANK") |
57fa233b |
212 | (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK"))) |
213 | (if repl-eval-hook |
214 | (push #'(lambda (form) |
215 | (within-main-loop (eval form))) |
216 | (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK"))) |
217 | (warn "Your version of Slime does not have *SLIME-REPL-EVAL-HOOKS* so all calls to Gtk+ functions have to be explicit protected by wrapping them in a WITHIN-MAIN-LOOP form")))))) |
6e21e828 |
218 | |
219 | #-sb-thread |
220 | (defmacro within-main-loop (&body body) |
221 | `(progn ,@body)) |
92afacae |
222 | |
6baf860c |
223 | |
00a8d921 |
224 | |
3c1925ed |
225 | ;;; Generic functions |
226 | |
227 | (defgeneric add-to-radio-group (item1 item2)) |
228 | (defgeneric activate-radio-widget (item)) |
229 | (defgeneric (setf tool-item-tip-text) (tip-text tool-item)) |
230 | (defgeneric (setf tool-item-tip-private) (tip-private tool-item)) |
231 | |
232 | |
6baf860c |
233 | |
17707159 |
234 | ;;; Misc |
235 | |
236 | (defbinding grab-add () nil |
237 | (widget widget)) |
238 | |
3a476d4e |
239 | (defbinding grab-get-current () widget) |
17707159 |
240 | |
241 | (defbinding grab-remove () nil |
242 | (widget widget)) |
243 | |
e69138cc |
244 | (defbinding get-default-language () (copy-of pango:language)) |
245 | |
17707159 |
246 | |
1448a84f |
247 | ;;; About dialog |
248 | |
f957f519 |
249 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
1448a84f |
250 | (progn |
a92553bd |
251 | (define-callback-marshal %about-dialog-activate-link-callback nil |
252 | (about-dialog (link string))) |
1448a84f |
253 | |
254 | (defbinding about-dialog-set-email-hook (function) nil |
a92553bd |
255 | (%about-dialog-activate-link-callback callback) |
1448a84f |
256 | ((register-callback-function function) unsigned-int) |
a92553bd |
257 | (user-data-destroy-callback callback)) |
1448a84f |
258 | |
259 | (defbinding about-dialog-set-url-hook (function) nil |
a92553bd |
260 | (%about-dialog-activate-link-callback callback) |
1448a84f |
261 | ((register-callback-function function) unsigned-int) |
a92553bd |
262 | (user-data-destroy-callback callback))) |
1448a84f |
263 | |
264 | |
d404b3af |
265 | ;;; Acccel group |
0d07716f |
266 | |
213cf4d0 |
267 | (defbinding %accel-group-connect () nil |
268 | (accel-group accel-group) |
269 | (key unsigned-int) |
270 | (modifiers gdk:modifier-type) |
271 | (flags accel-flags) |
272 | (gclosure gclosure)) |
273 | |
274 | (defun accel-group-connect (group accelerator function &optional flags) |
7b6c693b |
275 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
213cf4d0 |
276 | (let ((gclosure (make-callback-closure function))) |
277 | (%accel-group-connect group key modifiers flags gclosure) |
278 | gclosure))) |
279 | |
280 | (defbinding accel-group-connect-by-path (group path function) nil |
281 | (group accel-group) |
282 | (path string) |
f957f519 |
283 | ((make-callback-closure function) gclosure :in/return)) |
213cf4d0 |
284 | |
285 | (defbinding %accel-group-disconnect (group gclosure) boolean |
286 | (group accel-group) |
287 | (gclosure gclosure)) |
288 | |
289 | (defbinding %accel-group-disconnect-key () boolean |
290 | (group accel-group) |
291 | (key unsigned-int) |
292 | (modifiers gdk:modifier-type)) |
293 | |
294 | (defun accel-group-disconnect (group accelerator) |
295 | (etypecase accelerator |
296 | (gclosure (%accel-group-disconnect group accelerator)) |
297 | (string |
7b6c693b |
298 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
213cf4d0 |
299 | (%accel-group-disconnect-key group key modifiers))))) |
300 | |
7b6c693b |
301 | (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n)) |
302 | (accel-group accel-group) |
303 | (key unsigned-int) |
304 | (modifiers gdk:modifier-type) |
305 | (n int :out)) |
306 | |
307 | (defun accel-group-query (accel-group accelerator) |
308 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
309 | (%accel-group-query accel-group key modifiers))) |
310 | |
311 | (defbinding %accel-group-activate () boolean |
312 | (accel-group accel-group) |
313 | (acceleratable gobject) |
314 | (key unsigned-int) |
315 | (modifiers gdk:modifier-type)) |
316 | |
317 | (defun accel-group-activate (accel-group acceleratable accelerator) |
318 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
319 | (%accel-group-activate accel-group acceleratable key modifiers))) |
320 | |
213cf4d0 |
321 | (defbinding accel-group-lock () nil |
322 | (accel-group accel-group)) |
323 | |
324 | (defbinding accel-group-unlock () nil |
325 | (accel-group accel-group)) |
326 | |
7b6c693b |
327 | (defbinding accel-group-from-accel-closure () accel-group |
328 | (closure gclosure)) |
329 | |
213cf4d0 |
330 | (defbinding %accel-groups-activate () boolean |
331 | (object gobject) |
332 | (key unsigned-int) |
333 | (modifiers gdk:modifier-type)) |
334 | |
335 | (defun accel-groups-activate (object accelerator) |
7b6c693b |
336 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
213cf4d0 |
337 | (%accel-groups-activate object key modifiers))) |
338 | |
3f2c422a |
339 | (defbinding accel-groups-from-object () (gslist accel-group) |
213cf4d0 |
340 | (object gobject)) |
341 | |
3d36c5d6 |
342 | (defbinding accelerator-valid-p (key &optional modifiers) boolean |
213cf4d0 |
343 | (key unsigned-int) |
344 | (modifiers gdk:modifier-type)) |
345 | |
346 | (defbinding %accelerator-parse () nil |
347 | (accelerator string) |
348 | (key unsigned-int :out) |
349 | (modifiers gdk:modifier-type :out)) |
350 | |
7b6c693b |
351 | (defgeneric parse-accelerator (accelerator)) |
352 | |
353 | (defmethod parse-accelerator ((accelerator string)) |
213cf4d0 |
354 | (multiple-value-bind (key modifiers) (%accelerator-parse accelerator) |
355 | (if (zerop key) |
356 | (error "Invalid accelerator: ~A" accelerator) |
357 | (values key modifiers)))) |
358 | |
7b6c693b |
359 | (defmethod parse-accelerator ((accelerator cons)) |
360 | (destructuring-bind (key modifiers) accelerator |
361 | (values |
362 | (etypecase key |
363 | (integer key) |
364 | (string |
365 | (or |
366 | (gdk:keyval-from-name key) |
367 | (error "Invalid key name: ~A" key))) |
368 | (character (parse-accelerator key))) |
369 | modifiers))) |
370 | |
371 | (defmethod parse-accelerator ((key integer)) |
372 | key) |
373 | |
374 | (defmethod parse-accelerator ((key character)) |
375 | (or |
376 | (gdk:keyval-from-name (string key)) |
377 | (error "Invalid key name: ~A" key))) |
378 | |
379 | |
213cf4d0 |
380 | (defbinding accelerator-name () string |
381 | (key unsigned-int) |
382 | (modifiers gdk:modifier-type)) |
383 | |
f957f519 |
384 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
213cf4d0 |
385 | (defbinding accelerator-get-label () string |
386 | (key unsigned-int) |
387 | (modifiers gdk:modifier-type)) |
388 | |
389 | (defbinding %accelerator-set-default-mod-mask () nil |
390 | (default-modifiers gdk:modifier-type)) |
391 | |
392 | (defun (setf accelerator-default-modifier-mask) (default-modifiers) |
393 | (%accelerator-set-default-mod-mask default-modifiers)) |
394 | |
395 | (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type) |
0d07716f |
396 | |
eb4f580c |
397 | |
0d07716f |
398 | ;;; Acccel label |
399 | |
7b6c693b |
400 | (defbinding accel-label-get-accel-width () unsigned-int |
401 | (accel-label accel-label)) |
402 | |
a60bd055 |
403 | (defbinding accel-label-refetch () boolean |
0d07716f |
404 | (accel-label accel-label)) |
405 | |
406 | |
213cf4d0 |
407 | |
408 | ;;; Accel map |
409 | |
410 | (defbinding %accel-map-add-entry () nil |
411 | (path string) |
412 | (key unsigned-int) |
413 | (modifiers gdk:modifier-type)) |
414 | |
415 | (defun accel-map-add-entry (path accelerator) |
7b6c693b |
416 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
213cf4d0 |
417 | (%accel-map-add-entry path key modifiers))) |
418 | |
7b6c693b |
419 | (defbinding %accel-map-lookup-entry () boolean |
213cf4d0 |
420 | (path string) |
f957f519 |
421 | ((make-instance 'accel-key) accel-key :in/return)) |
7b6c693b |
422 | |
423 | (defun accel-map-lookup-entry (path) |
424 | (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path) |
425 | (when found-p |
426 | (values |
427 | (slot-value accel-key 'key) |
428 | (slot-value accel-key 'modifiers) |
429 | (slot-value accel-key 'flags))))) |
213cf4d0 |
430 | |
431 | (defbinding %accel-map-change-entry () boolean |
432 | (path string) |
433 | (key unsigned-int) |
434 | (modifiers gdk:modifier-type) |
435 | (replace boolean)) |
436 | |
437 | (defun accel-map-change-entry (path accelerator &optional replace) |
7b6c693b |
438 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
213cf4d0 |
439 | (%accel-map-change-entry path key modifiers replace))) |
440 | |
441 | (defbinding accel-map-load () nil |
442 | (filename pathname)) |
443 | |
444 | (defbinding accel-map-save () nil |
445 | (filename pathname)) |
446 | |
a92553bd |
447 | (define-callback-marshal %accel-map-foreach-callback nil |
448 | ((accel-path string) (key unsigned-int) |
449 | (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first) |
7b6c693b |
450 | |
451 | (defbinding %accel-map-foreach (callback-id) nil |
452 | (callback-id unsigned-int) |
a92553bd |
453 | (%accel-map-foreach-callback callback)) |
7b6c693b |
454 | |
455 | (defbinding %accel-map-foreach-unfiltered (callback-id) nil |
456 | (callback-id unsigned-int) |
a92553bd |
457 | (%accel-map-foreach-callback callback)) |
7b6c693b |
458 | |
459 | (defun accel-map-foreach (function &optional (filter-p t)) |
460 | (with-callback-function (id function) |
461 | (if filter-p |
462 | (%accel-map-foreach id) |
463 | (%accel-map-foreach-unfiltered id)))) |
464 | |
465 | (defbinding accel-map-add-filter () nil |
466 | (filter string)) |
467 | |
213cf4d0 |
468 | (defbinding accel-map-get () accel-map) |
469 | |
470 | (defbinding accel-map-lock-path () nil |
471 | (path string)) |
472 | |
473 | (defbinding accel-map-unlock-path () nil |
474 | (path string)) |
475 | |
476 | |
477 | |
7b6c693b |
478 | ;;; Accessibility |
14eaa563 |
479 | |
480 | (defbinding accessible-connect-widget-destroyed () nil |
481 | (accessible accessible)) |
482 | |
483 | |
d404b3af |
484 | ;;; Adjustment |
0d07716f |
485 | |
14eaa563 |
486 | (defmethod initialize-instance ((adjustment adjustment) &key value) |
eb4f580c |
487 | (prog1 |
488 | (call-next-method) |
489 | ;; we need to make sure that the value is set last, otherwise it |
14eaa563 |
490 | ;; may be outside current limits and ignored |
eb4f580c |
491 | (when value |
492 | (setf (slot-value adjustment 'value) value)))) |
493 | |
494 | |
d404b3af |
495 | (defbinding adjustment-changed () nil |
496 | (adjustment adjustment)) |
497 | |
498 | (defbinding adjustment-value-changed () nil |
499 | (adjustment adjustment)) |
500 | |
501 | (defbinding adjustment-clamp-page () nil |
502 | (adjustment adjustment) |
503 | (lower single-float) |
504 | (upper single-float)) |
0d07716f |
505 | |
d404b3af |
506 | |
49043b9a |
507 | ;;; Alignment |
508 | |
509 | (defbinding alignment-set () nil |
510 | (alognment alignment) |
511 | (x-align single-float) |
512 | (y-align single-float) |
513 | (x-scale single-float) |
514 | (y-scale single-float)) |
515 | |
516 | (defbinding alignment-get-padding () nil |
517 | (alognment alignment) |
518 | (top unsigned-int :out) |
519 | (bottom unsigned-int :out) |
520 | (left unsigned-int :out) |
521 | (right unsigned-int :out)) |
522 | |
523 | (defbinding alignment-set-padding () nil |
524 | (alognment alignment) |
525 | (top unsigned-int) |
526 | (bottom unsigned-int) |
527 | (left unsigned-int) |
528 | (right unsigned-int)) |
529 | |
530 | |
b5b970e8 |
531 | ;;; Assistant |
532 | |
533 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0") |
534 | (progn |
535 | (defbinding assistant-get-nth-page () widget |
536 | (assistant assistant) |
537 | (page-num int)) |
538 | |
539 | (defbinding %assistant-insert-page () int |
540 | (assistant assistant) |
541 | (page widget) |
542 | (pos int)) |
543 | |
544 | (defun assistant-insert-page (assistant page position &rest child-args) |
545 | (let ((pos (case position |
546 | (:first 0) |
547 | (:last -1) |
548 | (t position)))) |
549 | (prog1 |
550 | (%assistant-insert-page assistant page pos) |
551 | (init-child-slots assistant page child-args)))) |
552 | |
553 | (defun assistant-append-page (assistant page &rest child-args) |
554 | (apply #'assistant-insert-page assistant page :last child-args)) |
555 | |
556 | (defun assistant-prepend-page (assistant page &rest child-args) |
557 | (apply #'assistant-insert-page assistant page :first child-args)) |
558 | |
559 | (define-callback-marshal %assistant-page-func-callback int |
560 | ((current-page int))) |
561 | |
4d0c34e5 |
562 | (defbinding assistant-set-forward-page-func (assistant function) nil |
b5b970e8 |
563 | (assistant assistant) |
564 | (%assistant-page-func-callback callback) |
565 | ((register-callback-function function) pointer-data) |
566 | (user-data-destroy-callback callback)) |
567 | |
568 | (defbinding assistant-add-action-widget () nil |
569 | (assistant assistant) |
570 | (child widget)) |
571 | |
572 | (defbinding assistant-remove-action-widget () nil |
573 | (assistant assistant) |
574 | (child widget)) |
575 | |
576 | (defbinding assistant-update-buttons-state () nil |
577 | (assistant assistant))) |
578 | |
579 | |
580 | |
d404b3af |
581 | ;;; Aspect frame |
582 | |
583 | |
584 | ;;; Bin |
0d07716f |
585 | |
586 | (defun (setf bin-child) (child bin) |
d404b3af |
587 | (when-bind (current-child (bin-child bin)) |
588 | (container-remove bin current-child)) |
0d07716f |
589 | (container-add bin child) |
590 | child) |
591 | |
a68868d1 |
592 | (defmethod compute-signal-function ((bin bin) signal function object args) |
d79b3413 |
593 | (declare (ignore signal)) |
594 | (if (eq object :child) |
a68868d1 |
595 | #'(lambda (&rest emission-args) |
596 | (apply function (bin-child bin) (nconc (rest emission-args) args))) |
9617dc95 |
597 | (call-next-method))) |
d404b3af |
598 | |
599 | |
600 | ;;; Box |
601 | |
602 | (defbinding box-pack-start () nil |
603 | (box box) |
604 | (child widget) |
605 | (expand boolean) |
606 | (fill boolean) |
607 | (padding unsigned-int)) |
608 | |
609 | (defbinding box-pack-end () nil |
610 | (box box) |
611 | (child widget) |
612 | (expand boolean) |
613 | (fill boolean) |
614 | (padding unsigned-int)) |
615 | |
14eaa563 |
616 | (defun box-pack (box child &key end (expand t) (fill t) (padding 0)) |
4886872c |
617 | (if end |
378b3c5f |
618 | (box-pack-end box child expand fill padding) |
619 | (box-pack-start box child expand fill padding))) |
d404b3af |
620 | |
621 | (defbinding box-reorder-child () nil |
622 | (box box) |
623 | (child widget) |
624 | (position int)) |
625 | |
626 | (defbinding box-query-child-packing () nil |
627 | (box box) |
628 | (child widget) |
629 | (expand boolean :out) |
630 | (fill boolean :out) |
631 | (padding unsigned-int :out) |
632 | (pack-type pack-type :out)) |
633 | |
634 | (defbinding box-set-child-packing () nil |
635 | (box box) |
636 | (child widget) |
637 | (expand boolean) |
638 | (fill boolean) |
639 | (padding unsigned-int) |
640 | (pack-type pack-type)) |
641 | |
642 | |
643 | |
0d07716f |
644 | ;;; Button |
645 | |
14eaa563 |
646 | (defmethod initialize-instance ((button button) &rest initargs &key stock) |
647 | (if stock |
f957f519 |
648 | (apply #'call-next-method button |
649 | :label stock :use-stock t :use-underline t initargs) |
14eaa563 |
650 | (call-next-method))) |
651 | |
652 | |
a60bd055 |
653 | (defbinding button-pressed () nil |
0d07716f |
654 | (button button)) |
655 | |
d404b3af |
656 | (defbinding button-released () nil |
657 | (button button)) |
658 | |
659 | (defbinding button-clicked () nil |
660 | (button button)) |
661 | |
662 | (defbinding button-enter () nil |
663 | (button button)) |
664 | |
665 | (defbinding button-leave () nil |
666 | (button button)) |
667 | |
668 | |
669 | |
670 | ;;; Calendar |
671 | |
672 | (defbinding calendar-select-month () int |
673 | (calendar calendar) |
674 | (month unsigned-int) |
675 | (year unsigned-int)) |
676 | |
677 | (defbinding calendar-select-day () nil |
678 | (calendar calendar) |
679 | (day unsigned-int)) |
680 | |
681 | (defbinding calendar-mark-day () int |
682 | (calendar calendar) |
683 | (day unsigned-int)) |
684 | |
685 | (defbinding calendar-unmark-day () int |
686 | (calendar calendar) |
687 | (day unsigned-int)) |
688 | |
689 | (defbinding calendar-clear-marks () nil |
690 | (calendar calendar)) |
691 | |
14eaa563 |
692 | (defbinding calendar-get-date () nil |
d404b3af |
693 | (calendar calendar) |
694 | (year unsigned-int :out) |
695 | (month unsigned-int :out) |
696 | (day unsigned-int :out)) |
697 | |
698 | (defbinding calendar-freeze () nil |
699 | (calendar calendar)) |
700 | |
701 | (defbinding calendar-thaw () nil |
702 | (calendar calendar)) |
703 | |
704 | |
d404b3af |
705 | ;;; Check menu item |
706 | |
707 | (defbinding check-menu-item-toggled () nil |
708 | (check-menu-item check-menu-item)) |
709 | |
710 | |
d404b3af |
711 | ;;; Color selection |
712 | |
4e79d27c |
713 | (defbinding color-selection-is-adjusting-p () boolean |
d404b3af |
714 | (colorsel color-selection)) |
715 | |
4e79d27c |
716 | (defbinding (color-selection-previous-color |
717 | "gtk_color_selection_get_previous_color") () nil |
718 | (colorsel color-selection) |
719 | ((make-instance 'gdk:color) gdk:color :in/return)) |
d404b3af |
720 | |
721 | |
722 | ;;; Color selection dialog -- no functions |
723 | |
724 | |
725 | |
4886872c |
726 | ;;;; Combo Box |
d404b3af |
727 | |
14eaa563 |
728 | (defmethod initialize-instance ((combo-box combo-box) &rest initargs |
729 | &key model content active) |
730 | (remf initargs :active) |
731 | (if model |
732 | (apply #'call-next-method combo-box initargs) |
733 | (progn |
734 | (apply #'call-next-method combo-box |
735 | :model (make-instance 'list-store :column-types '(string)) |
736 | initargs) |
737 | (unless (typep combo-box 'combo-box-entry) |
738 | (let ((cell (make-instance 'cell-renderer-text))) |
739 | (cell-layout-pack combo-box cell :expand t) |
740 | (cell-layout-add-attribute combo-box cell :text 0))))) |
741 | (when content |
742 | (mapc #'(lambda (text) |
743 | (combo-box-append-text combo-box text)) |
744 | content)) |
745 | (when active |
746 | (setf (combo-box-active combo-box) active))) |
747 | |
4886872c |
748 | |
749 | ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active) |
750 | ;; (when active |
751 | ;; (signal-emit combo-box 'changed))) |
752 | |
753 | (defbinding combo-box-append-text () nil |
754 | (combo-box combo-box) |
755 | (text string)) |
756 | |
757 | (defbinding combo-box-insert-text () nil |
758 | (combo-box combo-box) |
759 | (position int) |
760 | (text string)) |
761 | |
762 | (defbinding combo-box-prepend-text () nil |
763 | (combo-box combo-box) |
764 | (text string)) |
765 | |
f957f519 |
766 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
4886872c |
767 | (defbinding combo-box-get-active-text () string |
768 | (combo-box combo-box)) |
d404b3af |
769 | |
4886872c |
770 | (defbinding combo-box-popup () nil |
771 | (combo-box combo-box)) |
d404b3af |
772 | |
4886872c |
773 | (defbinding combo-box-popdown () nil |
774 | (combo-box combo-box)) |
775 | |
776 | |
777 | |
778 | ;;;; Combo Box Entry |
779 | |
14eaa563 |
780 | (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model) |
4886872c |
781 | (call-next-method) |
782 | (unless model |
783 | (setf (combo-box-entry-text-column combo-box-entry) 0))) |
d404b3af |
784 | |
785 | |
0ebef6c1 |
786 | ;;;; Dialog |
d404b3af |
787 | |
362f1795 |
788 | (defmethod shared-initialize ((dialog dialog) names &rest initargs |
789 | &key button buttons) |
f957f519 |
790 | (declare (ignore names button buttons)) |
362f1795 |
791 | (prog1 |
792 | (call-next-method) |
793 | (initial-apply-add dialog #'dialog-add-button initargs :button :buttons))) |
0ebef6c1 |
794 | |
d404b3af |
795 | |
d79b3413 |
796 | (defun dialog-response-id (dialog response &optional create-p error-p) |
797 | "Returns a numeric response id" |
798 | (if (typep response 'response-type) |
799 | (response-type-to-int response) |
f957f519 |
800 | (let ((responses (user-data dialog 'responses))) |
d79b3413 |
801 | (cond |
802 | ((and responses (position response responses :test #'equal))) |
803 | (create-p |
eb4f580c |
804 | (cond |
d79b3413 |
805 | (responses |
806 | (vector-push-extend response responses) |
807 | (1- (length responses))) |
eb4f580c |
808 | (t |
809 | (setf |
f957f519 |
810 | (user-data dialog 'responses) |
d79b3413 |
811 | (make-array 1 :adjustable t :fill-pointer t |
812 | :initial-element response)) |
eb4f580c |
813 | 0))) |
814 | (error-p |
d79b3413 |
815 | (error "Invalid response: ~A" response)))))) |
d404b3af |
816 | |
d79b3413 |
817 | (defun dialog-find-response (dialog id) |
818 | "Finds a symbolic response given a numeric id" |
36df51ae |
819 | (cond |
820 | ((not (numberp id)) id) |
821 | ((< id 0) (int-to-response-type id)) |
822 | ((aref (user-data dialog 'responses) id)))) |
d79b3413 |
823 | |
824 | |
825 | (defmethod compute-signal-id ((dialog dialog) signal) |
826 | (if (dialog-response-id dialog signal) |
827 | (ensure-signal-id 'response dialog) |
828 | (call-next-method))) |
829 | |
a68868d1 |
830 | (defmethod compute-signal-function ((dialog dialog) signal function object args) |
831 | (declare (ignore function object args)) |
d79b3413 |
832 | (let ((callback (call-next-method)) |
833 | (id (dialog-response-id dialog signal))) |
36df51ae |
834 | (cond |
835 | (id |
836 | #'(lambda (dialog response) |
837 | (when (= response id) |
838 | (funcall callback dialog)))) |
e67c4de7 |
839 | ((string-equal signal "response") |
36df51ae |
840 | #'(lambda (dialog response) |
841 | (funcall callback dialog (dialog-find-response dialog response)))) |
842 | (callback)))) |
d404b3af |
843 | |
0ebef6c1 |
844 | (defbinding dialog-run () nil |
845 | (dialog dialog)) |
d404b3af |
846 | |
d79b3413 |
847 | (defbinding dialog-response (dialog response) nil |
d404b3af |
848 | (dialog dialog) |
d79b3413 |
849 | ((dialog-response-id dialog response nil t) int)) |
d404b3af |
850 | |
851 | |
852 | (defbinding %dialog-add-button () button |
853 | (dialog dialog) |
854 | (text string) |
d79b3413 |
855 | (response-id int)) |
d404b3af |
856 | |
eb4f580c |
857 | (defun dialog-add-button (dialog label &optional (response label) |
858 | &key default object after) |
fe67c0ec |
859 | "Adds a button to the dialog." |
d79b3413 |
860 | (let* ((signal (if (functionp response) |
861 | label |
862 | response)) |
863 | (id (dialog-response-id dialog signal t)) |
864 | (button (%dialog-add-button dialog label id))) |
eb4f580c |
865 | (when (functionp response) |
d79b3413 |
866 | (signal-connect dialog signal response :object object :after after)) |
eb4f580c |
867 | (when default |
d79b3413 |
868 | (%dialog-set-default-response dialog id)) |
d404b3af |
869 | button)) |
870 | |
871 | |
d79b3413 |
872 | (defbinding %dialog-add-action-widget () nil |
d404b3af |
873 | (dialog dialog) |
874 | (action-widget widget) |
d79b3413 |
875 | (response-id int)) |
d404b3af |
876 | |
eb4f580c |
877 | (defun dialog-add-action-widget (dialog widget &optional (response widget) |
878 | &key default object after) |
d79b3413 |
879 | (let* ((signal (if (functionp response) |
880 | widget |
881 | response)) |
882 | (id (dialog-response-id dialog signal t))) |
883 | (unless (widget-hidden-p widget) |
884 | (widget-show widget)) |
885 | (%dialog-add-action-widget dialog widget id) |
eb4f580c |
886 | (when (functionp response) |
d79b3413 |
887 | (signal-connect dialog signal response :object object :after after)) |
eb4f580c |
888 | (when default |
c2c4f44a |
889 | (setf (widget-can-default-p widget) t) |
d79b3413 |
890 | (%dialog-set-default-response dialog id)) |
d404b3af |
891 | widget)) |
d404b3af |
892 | |
d404b3af |
893 | |
0ebef6c1 |
894 | (defbinding %dialog-set-default-response () nil |
895 | (dialog dialog) |
d79b3413 |
896 | (response-id int)) |
d404b3af |
897 | |
d79b3413 |
898 | (defun dialog-set-default-response (dialog response) |
0ebef6c1 |
899 | (%dialog-set-default-response |
d79b3413 |
900 | dialog (dialog-response-id dialog response nil t))) |
d404b3af |
901 | |
d79b3413 |
902 | (defbinding dialog-set-response-sensitive (dialog response sensitive) nil |
0ebef6c1 |
903 | (dialog dialog) |
d79b3413 |
904 | ((dialog-response-id dialog response nil t) int) |
0ebef6c1 |
905 | (sensitive boolean)) |
d404b3af |
906 | |
f957f519 |
907 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
1448a84f |
908 | (defbinding alternative-dialog-button-order-p (&optional screen) boolean |
909 | (screen (or null gdk:screen))) |
fe67c0ec |
910 | |
f957f519 |
911 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
fe67c0ec |
912 | (defbinding (dialog-set-alternative-button-order |
405b4406 |
913 | "gtk_dialog_set_alternative_button_order_from_array") |
914 | (dialog new-order) nil |
fe67c0ec |
915 | (dialog dialog) |
916 | ((length new-order) int) |
d79b3413 |
917 | ((map 'vector #'(lambda (response) |
918 | (dialog-response-id dialog response nil t)) |
fe67c0ec |
919 | new-order) (vector int))) |
d404b3af |
920 | |
0ebef6c1 |
921 | |
f957f519 |
922 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
92ba85d4 |
923 | (progn |
924 | (defbinding %dialog-get-response-for-widget () int |
925 | (dialog dialog) |
926 | (widget widget)) |
927 | |
928 | (defun dialog-get-response-for-widget (dialog widget) |
929 | (dialog-find-response dialog (dialog-get-response-for-widget dialog widget)))) |
930 | |
931 | |
0ebef6c1 |
932 | (defmethod container-add ((dialog dialog) (child widget) &rest args) |
eb4f580c |
933 | (apply #'container-add (dialog-vbox dialog) child args)) |
0ebef6c1 |
934 | |
d79b3413 |
935 | |
0ebef6c1 |
936 | (defmethod container-remove ((dialog dialog) (child widget)) |
eb4f580c |
937 | (container-remove (dialog-vbox dialog) child)) |
d404b3af |
938 | |
0ebef6c1 |
939 | (defmethod container-children ((dialog dialog)) |
eb4f580c |
940 | (container-children (dialog-vbox dialog))) |
0ebef6c1 |
941 | |
942 | (defmethod (setf container-children) (children (dialog dialog)) |
eb4f580c |
943 | (setf (container-children (dialog-vbox dialog)) children)) |
0d07716f |
944 | |
0d07716f |
945 | |
5233fe44 |
946 | ;;; Drawing Area |
947 | |
948 | (defun drawing-area-scroll (drawing-area dx dy) |
949 | (gdk:window-scroll (widget-window drawing-area) dx dy)) |
950 | |
951 | |
c2c4a7e9 |
952 | ;;; Entry |
0d07716f |
953 | |
c2c4a7e9 |
954 | (defbinding entry-get-layout-offsets () nil |
955 | (entry entry) |
956 | (x int :out) |
957 | (y int :out)) |
0d07716f |
958 | |
14eaa563 |
959 | (defbinding entry-layout-index-to-text-index () int |
960 | (entry entry) |
961 | (layout-index int)) |
962 | |
963 | (defbinding entry-text-index-to-layout-index () int |
964 | (entry entry) |
965 | (text-index int)) |
966 | |
0d07716f |
967 | |
a03a718a |
968 | ;;; Entry Completion |
969 | |
a92553bd |
970 | (define-callback-marshal %entry-completion-match-callback boolean |
971 | (entry-completion string tree-iter)) |
a03a718a |
972 | |
973 | (defbinding entry-completion-set-match-func (completion function) nil |
974 | (completion entry-completion) |
a92553bd |
975 | (%entry-completion-match-callback callback) |
a03a718a |
976 | ((register-callback-function function) unsigned-int) |
a92553bd |
977 | (user-data-destroy-callback callback)) |
a03a718a |
978 | |
979 | (defbinding entry-completion-complete () nil |
980 | (completion entry-completion)) |
981 | |
93c531f0 |
982 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0") |
983 | (defbinding entry-completion-get-completion-prefix () string |
984 | (completion entry-completion)) |
985 | |
f957f519 |
986 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
a03a718a |
987 | (defbinding entry-completion-insert-prefix () nil |
988 | (completion entry-completion)) |
989 | |
990 | (defbinding entry-completion-insert-action-text () nil |
991 | (completion entry-completion) |
992 | (index int) |
993 | (text string)) |
994 | |
995 | (defbinding entry-completion-insert-action-markup () nil |
996 | (completion entry-completion) |
997 | (index int) |
998 | (markup string)) |
999 | |
1000 | (defbinding entry-completion-delete-action () nil |
1001 | (completion entry-completion) |
1002 | (index int)) |
1003 | |
1004 | |
49043b9a |
1005 | ;;; File Chooser |
1006 | |
1007 | (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs |
1008 | &key filter filters shortcut-folder |
1009 | shortcut-folders shortcut-folder-uti |
1010 | shortcut-folder-uris) |
1011 | (declare (ignore filter filters shortcut-folder shortcut-folders |
1012 | shortcut-folder-uti shortcut-folder-uris)) |
1013 | (prog1 |
1014 | (call-next-method) |
1015 | (initial-add file-chooser #'file-chooser-add-filter |
1016 | initargs :filer :filters) |
1017 | (initial-add file-chooser #'file-chooser-add-shortcut-folder |
1018 | initargs :shortcut-folder :shortcut-folders) |
1019 | (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri |
1020 | initargs :shortcut-folder-uri :shortcut-folders-uris))) |
1021 | |
1022 | |
1023 | (defbinding file-chooser-select-filename () boolean |
1024 | (file-chooser file-chooser) |
1025 | (filename string)) |
1026 | |
1027 | (defbinding file-chooser-unselect-filename () nil |
1028 | (file-chooser file-chooser) |
1029 | (filename string)) |
1030 | |
1031 | (defbinding file-chooser-select-all () boolean |
1032 | (file-chooser file-chooser)) |
1033 | |
1034 | (defbinding file-chooser-unselect-all () boolean |
1035 | (file-chooser file-chooser)) |
1036 | |
1037 | (defbinding file-chooser-get-filenames () (gslist string) |
1038 | (file-chooser file-chooser)) |
1039 | |
1040 | (defbinding file-chooser-select-uri () boolean |
1041 | (file-chooser file-chooser) |
1042 | (uri string)) |
1043 | |
1044 | (defbinding file-chooser-unselect-uri () nil |
1045 | (file-chooser file-chooser) |
1046 | (uri string)) |
1047 | |
1048 | (defbinding file-chooser-get-uris () (gslist string) |
1049 | (file-chooser file-chooser)) |
1050 | |
1051 | (defbinding file-chooser-add-filter () nil |
1052 | (file-chooser file-chooser) |
1053 | (filter file-filter)) |
1054 | |
1055 | (defbinding file-chooser-remove-filter () nil |
1056 | (file-chooser file-chooser) |
1057 | (filter file-filter)) |
1058 | |
1059 | (defbinding file-chooser-list-filters () (gslist file-filter) |
1060 | (file-chooser file-chooser)) |
1061 | |
1062 | (defbinding file-chooser-add-shortcut-folder () boolean |
1063 | (file-chooser file-chooser) |
1064 | (folder string) |
1065 | (nil null)) |
1066 | |
1067 | (defbinding file-chooser-remove-shortcut-folder () nil |
1068 | (file-chooser file-chooser) |
1069 | (folder string) |
1070 | (nil null)) |
1071 | |
1072 | (defbinding file-chooser-list-shortcut-folders () (gslist string) |
1073 | (file-chooser file-chooser)) |
1074 | |
1075 | (defbinding file-chooser-add-shortcut-folder-uri () boolean |
1076 | (file-chooser file-chooser) |
1077 | (uri string) |
1078 | (nil null)) |
1079 | |
1080 | (defbinding file-chooser-remove-shortcut-folder-uri () nil |
1081 | (file-chooser file-chooser) |
1082 | (uri string) |
1083 | (nil null)) |
1084 | |
1085 | (defbinding file-chooser-list-shortcut-folder-uris () (gslist string) |
1086 | (file-chooser file-chooser)) |
1087 | |
1088 | |
1089 | ;;; File Filter |
1090 | |
1091 | (defmethod initialize-instance ((file-filter file-filter) &rest initargs |
1092 | &key mime-type mime-types pattern patterns |
1093 | pixbuf-formats) |
1094 | (declare (ignore mime-type mime-types pattern patterns)) |
1095 | (prog1 |
1096 | (call-next-method) |
1097 | (when pixbuf-formats |
f957f519 |
1098 | #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
1099 | (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk") |
1100 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
1101 | (file-filter-add-pixbuf-formats file-filter)) |
49043b9a |
1102 | (initial-add file-filter #'file-filter-add-mime-type |
1103 | initargs :mime-type :mime-types) |
1104 | (initial-add file-filter #'file-filter-add-pattern |
1105 | initargs :pattern :patterns))) |
1106 | |
1107 | |
1108 | (defbinding file-filter-add-mime-type () nil |
1109 | (filter file-filter) |
1110 | (mime-type string)) |
1111 | |
1112 | (defbinding file-filter-add-pattern () nil |
1113 | (filter file-filter) |
1114 | (pattern string)) |
1115 | |
f957f519 |
1116 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
49043b9a |
1117 | (defbinding file-filter-add-pixbuf-formats () nil |
1448a84f |
1118 | (filter file-filter)) |
49043b9a |
1119 | |
a92553bd |
1120 | (define-callback-marshal %file-filter-callback boolean (file-filter-info)) |
49043b9a |
1121 | |
3d36c5d6 |
1122 | (defbinding file-filter-add-custom (filter needed function) nil |
49043b9a |
1123 | (filter file-filter) |
1124 | (needed file-filter-flags) |
a92553bd |
1125 | (%file-filter-callback callback) |
49043b9a |
1126 | ((register-callback-function function) unsigned-int) |
a92553bd |
1127 | (user-data-destroy-callback callback)) |
49043b9a |
1128 | |
1129 | (defbinding file-filter-get-needed () file-filter-flags |
1130 | (filter file-filter)) |
1131 | |
1132 | (defbinding file-filter-filter () boolean |
1133 | (filter file-filter) |
1134 | (filter-info file-filter-info)) |
1135 | |
1136 | |
1137 | |
eb4f580c |
1138 | ;;; Image |
1139 | |
1140 | (defbinding image-set-from-file () nil |
1141 | (image image) |
1142 | (filename pathname)) |
1143 | |
14eaa563 |
1144 | (defmethod (setf image-pixmap) ((data vector) (image image)) |
1145 | (multiple-value-bind (pixmap mask) (gdk:pixmap-create data) |
1146 | (setf (image-pixmap image) pixmap) |
1147 | (setf (image-mask image) mask))) |
1148 | |
1149 | (defmethod initialize-instance ((image image) &rest initargs &key pixmap file) |
1150 | (cond |
1151 | ((typep pixmap 'vector) |
1152 | (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap) |
1153 | (apply #'call-next-method image :pixmap pixmap :mask mask initargs))) |
1154 | (file |
1155 | (prog1 |
1156 | (call-next-method) |
1157 | (image-set-from-file image file))) |
1158 | ((call-next-method)))) |
eb4f580c |
1159 | |
9617dc95 |
1160 | (defun create-image-widget (source &optional mask) |
14eaa563 |
1161 | (etypecase source |
1162 | (gdk:pixbuf (make-instance 'image :pixbuf source)) |
1163 | (string (make-instance 'image :stock source)) |
1164 | (pathname (make-instance 'image :file source)) |
1165 | ((or list vector) (make-instance 'image :pixmap source)) |
1166 | (gdk:pixmap (make-instance 'image :pixmap source :mask mask)))) |
eb4f580c |
1167 | |
f957f519 |
1168 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
92ba85d4 |
1169 | (defbinding image-clear () nil |
1170 | (image image)) |
1171 | |
1172 | |
eb4f580c |
1173 | |
14eaa563 |
1174 | ;;; Image menu item |
eb4f580c |
1175 | |
14eaa563 |
1176 | (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image) |
1177 | (if (and image (not (typep image 'widget))) |
9617dc95 |
1178 | (apply #'call-next-method item :image (create-image-widget image) initargs) |
14eaa563 |
1179 | (call-next-method))) |
eb4f580c |
1180 | |
14eaa563 |
1181 | |
1182 | (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item)) |
1183 | (setf (slot-value item 'image) widget)) |
1184 | |
1185 | (defmethod (setf image-menu-item-image) (image (item image-menu-item)) |
9617dc95 |
1186 | (setf (image-menu-item-image item) (create-image-widget image))) |
eb4f580c |
1187 | |
0d07716f |
1188 | |
d404b3af |
1189 | ;;; Label |
0d07716f |
1190 | |
29aa1cc3 |
1191 | (defmethod shared-initialize ((label label) names &key pattern) |
1192 | (declare (ignore names)) |
1193 | (call-next-method) |
1194 | (when pattern |
1195 | (setf (label-pattern label) pattern))) |
1196 | |
c2c4a7e9 |
1197 | (defbinding label-get-layout-offsets () nil |
eb4f580c |
1198 | (label label) |
c2c4a7e9 |
1199 | (x int :out) |
1200 | (y int :out)) |
1201 | |
d404b3af |
1202 | (defbinding label-select-region () nil |
1203 | (label label) |
1204 | (start int) |
1205 | (end int)) |
0d07716f |
1206 | |
eb4f580c |
1207 | (defbinding label-get-selection-bounds () boolean |
c2c4a7e9 |
1208 | (label label) |
1209 | (start int :out) |
1210 | (end int :out)) |
30481825 |
1211 | |
0d07716f |
1212 | |
1213 | |
1214 | ;;; Radio button |
1215 | |
dd392521 |
1216 | (defbinding %radio-button-get-group () pointer |
2afcd8bd |
1217 | (radio-button radio-button)) |
1218 | |
a60bd055 |
1219 | (defbinding %radio-button-set-group () nil |
2afcd8bd |
1220 | (radio-button radio-button) |
1221 | (group pointer)) |
0d07716f |
1222 | |
9617dc95 |
1223 | (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button)) |
2afcd8bd |
1224 | "Add BUTTON1 to the group which BUTTON2 belongs to." |
1225 | (%radio-button-set-group button1 (%radio-button-get-group button2))) |
1226 | |
30628c63 |
1227 | (defun %add-activate-callback (widget signal function object after) |
1228 | (if object |
1229 | (signal-connect widget signal |
1230 | #'(lambda (object) |
1231 | (when (slot-value widget 'active) |
1232 | (funcall function object (slot-value widget 'value)))) |
1233 | :object object :after after) |
1234 | (signal-connect widget signal |
1235 | #'(lambda () |
1236 | (when (slot-value widget 'active) |
1237 | (funcall function (slot-value widget 'value)))) |
1238 | :after after))) |
1239 | |
1240 | (defmethod activate-radio-widget ((button radio-button)) |
1241 | (signal-emit button 'clicked)) |
1242 | |
4a8bb854 |
1243 | (defgeneric add-activate-callback (action function &key object after)) |
1244 | |
30628c63 |
1245 | (defmethod add-activate-callback ((button radio-button) function &key object after) |
1246 | (%add-activate-callback button 'clicked function object after)) |
1247 | |
14eaa563 |
1248 | (defmethod initialize-instance ((button radio-button) &key group) |
1249 | (prog1 |
1250 | (call-next-method) |
1251 | (when group |
9617dc95 |
1252 | (add-to-radio-group button group)))) |
0d07716f |
1253 | |
1254 | |
0d07716f |
1255 | ;;; Item |
1256 | |
a60bd055 |
1257 | (defbinding item-select () nil |
0d07716f |
1258 | (item item)) |
1259 | |
a60bd055 |
1260 | (defbinding item-deselect () nil |
0d07716f |
1261 | (item item)) |
1262 | |
a60bd055 |
1263 | (defbinding item-toggle () nil |
0d07716f |
1264 | (item item)) |
1265 | |
1266 | |
1267 | |
1268 | ;;; Menu item |
1269 | |
14eaa563 |
1270 | (defmethod initialize-instance ((item menu-item) &key label) |
1271 | (prog1 |
1272 | (call-next-method) |
1273 | (when label |
1274 | (setf (menu-item-label item) label)))) |
1275 | |
1276 | |
30481825 |
1277 | (defun (setf menu-item-label) (label menu-item) |
1278 | (make-instance 'accel-label |
1279 | :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item |
14eaa563 |
1280 | :use-underline (menu-item-use-underline-p menu-item) |
1281 | :visible t :parent menu-item) |
30481825 |
1282 | label) |
0d07716f |
1283 | |
378b3c5f |
1284 | (defun menu-item-label (menu-item) |
14eaa563 |
1285 | (when (and (slot-boundp menu-item 'child) |
1286 | (typep (bin-child menu-item) 'label)) |
1287 | (label-label (bin-child menu-item)))) |
378b3c5f |
1288 | |
14eaa563 |
1289 | (defbinding menu-item-remove-submenu () nil |
30481825 |
1290 | (menu-item menu-item)) |
0d07716f |
1291 | |
378b3c5f |
1292 | (defbinding menu-item-set-accel-path () nil |
1293 | (menu-item menu-item) |
1294 | (accel-path string)) |
1295 | |
a60bd055 |
1296 | (defbinding menu-item-select () nil |
30481825 |
1297 | (menu-item menu-item)) |
0d07716f |
1298 | |
a60bd055 |
1299 | (defbinding menu-item-deselect () nil |
30481825 |
1300 | (menu-item menu-item)) |
0d07716f |
1301 | |
a60bd055 |
1302 | (defbinding menu-item-activate () nil |
30481825 |
1303 | (menu-item menu-item)) |
0d07716f |
1304 | |
378b3c5f |
1305 | (defbinding menu-item-toggle-size-request () nil |
1306 | (menu-item menu-item) |
1307 | (requisition int :out)) |
1308 | |
1309 | (defbinding menu-item-toggle-size-allocate () nil |
1310 | (menu-item menu-item) |
1311 | (allocation int)) |
1312 | |
0d07716f |
1313 | |
14eaa563 |
1314 | ;;; Menu tool button |
1315 | |
f957f519 |
1316 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
1448a84f |
1317 | (defbinding menu-tool-button-set-arrow-tooltip () nil |
14eaa563 |
1318 | (menu-tool-button menu-tool-button) |
1319 | (tooltips tooltips) |
1320 | (tip-text string) |
1321 | (tip-private string)) |
1322 | |
1323 | |
30e8a60a |
1324 | ;;; Message dialog |
1325 | |
39db92d4 |
1326 | (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info) |
36df51ae |
1327 | button buttons flags transient-parent) |
1328 | (let ((stock-buttons |
1329 | (cond |
1330 | ((and (not buttons) (not button)) |
1331 | (case message-type |
1332 | (:question :yes-no) |
1333 | (t :ok))) |
1334 | ((listp buttons) :none) |
1335 | (t buttons)))) |
1336 | (%message-dialog-new transient-parent flags message-type stock-buttons))) |
1337 | |
1338 | |
1339 | (defmethod shared-initialize ((dialog message-dialog) names &rest initargs |
d453ba38 |
1340 | &key message-type buttons button text |
f957f519 |
1341 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
1342 | secondary-text) |
39db92d4 |
1343 | (declare (ignore names)) |
4c308d58 |
1344 | (when text |
1345 | (message-dialog-set-markup dialog text)) |
f957f519 |
1346 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
4c308d58 |
1347 | (when secondary-text |
1348 | (message-dialog-format-secondary-markup dialog secondary-text)) |
d453ba38 |
1349 | (when (and (not buttons) (not button)) |
1350 | (loop |
1351 | for (key value) on initargs by #'cddr |
1352 | when (and (eq key :signal) (eq (first value) :close)) |
1353 | do (warn "Default button configuration changed from ~A to ~A" :close |
1354 | (if (eq message-type :question) :yes-no :ok)) |
1355 | (loop-finish))) |
36df51ae |
1356 | (if (typep buttons 'buttons-type) |
1357 | (apply #'call-next-method dialog names (plist-remove :buttons initargs)) |
1358 | (call-next-method))) |
30e8a60a |
1359 | |
1360 | |
1361 | (defbinding %message-dialog-new () pointer |
1362 | (parent (or null window)) |
1363 | (flags dialog-flags) |
1364 | (type message-type) |
1365 | (buttons buttons-type) |
4c308d58 |
1366 | (nil null)) |
30e8a60a |
1367 | |
1368 | (defbinding message-dialog-set-markup () nil |
1369 | (message-dialog message-dialog) |
1370 | (markup string)) |
1371 | |
f957f519 |
1372 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
30e8a60a |
1373 | (defbinding message-dialog-format-secondary-text () nil |
1374 | (message-dialog message-dialog) |
1375 | (text string)) |
1376 | |
f957f519 |
1377 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
30e8a60a |
1378 | (defbinding message-dialog-format-secondary-markup () nil |
1379 | (message-dialog message-dialog) |
1380 | (markup string)) |
1381 | |
1382 | |
0d07716f |
1383 | |
30481825 |
1384 | ;;; Radio menu item |
0d07716f |
1385 | |
dd392521 |
1386 | (defbinding %radio-menu-item-get-group () pointer |
2afcd8bd |
1387 | (radio-menu-item radio-menu-item)) |
1388 | |
a60bd055 |
1389 | (defbinding %radio-menu-item-set-group () nil |
2afcd8bd |
1390 | (radio-menu-item radio-menu-item) |
1391 | (group pointer)) |
1392 | |
30628c63 |
1393 | (defmethod activate-radio-widget ((item radio-menu-item)) |
1394 | (menu-item-activate item)) |
1395 | |
9617dc95 |
1396 | (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item)) |
2afcd8bd |
1397 | "Add ITEM1 to the group which ITEM2 belongs to." |
1398 | (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2))) |
1399 | |
30628c63 |
1400 | (defmethod add-activate-callback ((item radio-menu-item) function &key object after) |
1401 | (%add-activate-callback item 'activate function object after)) |
1402 | |
14eaa563 |
1403 | (defmethod initialize-instance ((item radio-menu-item) &key group) |
378b3c5f |
1404 | (prog1 |
1405 | (call-next-method) |
14eaa563 |
1406 | (when group |
9617dc95 |
1407 | (add-to-radio-group item group)))) |
1408 | |
2afcd8bd |
1409 | |
0d07716f |
1410 | |
14eaa563 |
1411 | ;;; Radio tool button |
1412 | |
1413 | (defbinding %radio-tool-button-get-group () pointer |
1414 | (radio-tool-button radio-tool-button)) |
1415 | |
1416 | (defbinding %radio-tool-button-set-group () nil |
1417 | (radio-tool-button radio-tool-button) |
1418 | (group pointer)) |
1419 | |
30628c63 |
1420 | (defmethod activate-radio-widget ((button radio-tool-button)) |
1421 | (signal-emit button 'clicked)) |
1422 | |
9617dc95 |
1423 | (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button)) |
14eaa563 |
1424 | "Add BUTTON1 to the group which BUTTON2 belongs to." |
1425 | (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2))) |
30628c63 |
1426 | (defmethod add-activate-callback ((button radio-tool-button) function &key object after) |
1427 | (%add-activate-callback button 'clicked function object after)) |
14eaa563 |
1428 | |
1429 | (defmethod initialize-instance ((button radio-tool-button) &key group) |
1430 | (prog1 |
1431 | (call-next-method) |
1432 | (when group |
9617dc95 |
1433 | (add-to-radio-group button group)))) |
1434 | |
14eaa563 |
1435 | |
0d07716f |
1436 | |
c2c4a7e9 |
1437 | ;;; Toggle button |
1438 | |
1439 | (defbinding toggle-button-toggled () nil |
1440 | (toggle-button toggle-button)) |
1441 | |
1442 | |
0d07716f |
1443 | ;;; Window |
1444 | |
362f1795 |
1445 | (defmethod initialize-instance ((window window) &rest initargs |
6e21e828 |
1446 | &key display accel-group accel-groups) |
362f1795 |
1447 | (declare (ignore accel-group accel-groups)) |
1448 | (prog1 |
6e21e828 |
1449 | (if display |
1450 | (apply #'call-next-method |
6b465328 |
1451 | window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs) |
6e21e828 |
1452 | (call-next-method)) |
362f1795 |
1453 | (initial-add window #'window-add-accel-group |
1454 | initargs :accel-group :accel-groups))) |
99821988 |
1455 | |
405b4406 |
1456 | #-debug-ref-counting |
1457 | (defmethod print-object ((window window) stream) |
1458 | (if (and |
1459 | (proxy-valid-p window) |
1460 | (slot-boundp window 'title) |
1461 | (not (zerop (length (window-title window))))) |
1462 | (print-unreadable-object (window stream :type t :identity nil) |
1463 | (format stream "~S at 0x~X" |
f957f519 |
1464 | (window-title window) (pointer-address (foreign-location window)))) |
405b4406 |
1465 | (call-next-method))) |
99821988 |
1466 | |
304cfb76 |
1467 | (defbinding window-set-wmclass () nil |
0d07716f |
1468 | (window window) |
1469 | (wmclass-name string) |
1470 | (wmclass-class string)) |
1471 | |
a60bd055 |
1472 | (defbinding window-add-accel-group () nil |
0d07716f |
1473 | (window window) |
1474 | (accel-group accel-group)) |
1475 | |
a60bd055 |
1476 | (defbinding window-remove-accel-group () nil |
0d07716f |
1477 | (window window) |
1478 | (accel-group accel-group)) |
1479 | |
a60bd055 |
1480 | (defbinding window-activate-focus () int |
0d07716f |
1481 | (window window)) |
1482 | |
a60bd055 |
1483 | (defbinding window-activate-default () int |
0d07716f |
1484 | (window window)) |
1485 | |
304cfb76 |
1486 | (defbinding window-set-default-size (window width height) int |
0d07716f |
1487 | (window window) |
304cfb76 |
1488 | ((or width -1) int) |
1489 | ((or height -1) int)) |
0d07716f |
1490 | |
4eed43f1 |
1491 | (defbinding %window-set-geometry-hints () nil |
1492 | (window window) |
d8dd2e76 |
1493 | (widget (or widget null)) |
4eed43f1 |
1494 | (geometry gdk:geometry) |
1495 | (geometry-mask gdk:window-hints)) |
1496 | |
d8dd2e76 |
1497 | (defun window-set-geometry-hints (window &key widget min-width min-height |
4eed43f1 |
1498 | max-width max-height base-width base-height |
d8dd2e76 |
1499 | width-inc height-inc gravity |
1500 | aspect (min-aspect aspect) (max-aspect aspect)) |
4eed43f1 |
1501 | (let ((geometry (make-instance 'gdk:geometry |
1502 | :min-width (or min-width -1) |
1503 | :min-height (or min-height -1) |
1504 | :max-width (or max-width -1) |
1505 | :max-height (or max-height -1) |
1506 | :base-width (or base-width 0) |
1507 | :base-height (or base-height 0) |
1508 | :width-inc (or width-inc 0) |
1509 | :height-inc (or height-inc 0) |
1510 | :min-aspect (or min-aspect 0) |
d8dd2e76 |
1511 | :max-aspect (or max-aspect 0))) |
4eed43f1 |
1512 | (mask ())) |
d8dd2e76 |
1513 | (when (or min-width min-height) |
4eed43f1 |
1514 | (push :min-size mask)) |
d8dd2e76 |
1515 | (when (or max-width max-height) |
4eed43f1 |
1516 | (push :max-size mask)) |
1517 | (when (or base-width base-height) |
1518 | (push :base-size mask)) |
1519 | (when (or width-inc height-inc) |
1520 | (push :resize-inc mask)) |
1521 | (when (or min-aspect max-aspect) |
1522 | (push :aspect mask)) |
d8dd2e76 |
1523 | (when gravity |
1524 | (push :win-gravity mask) |
1525 | (setf (gdk:geometry-gravity geometry) gravity)) |
1526 | (%window-set-geometry-hints window widget geometry mask))) |
0d07716f |
1527 | |
99821988 |
1528 | (defbinding window-list-toplevels () (glist (copy-of window)) |
1529 | "Returns a list of all existing toplevel windows.") |
304cfb76 |
1530 | |
1531 | (defbinding window-add-mnemonic (window key target) nil |
1532 | (window window) |
1533 | ((gdk:keyval-from-name key) unsigned-int) |
1534 | (target widget)) |
1535 | |
1536 | (defbinding window-remove-mnemonic (window key target) nil |
1537 | (window window) |
1538 | ((gdk:keyval-from-name key) unsigned-int) |
1539 | (target widget)) |
1540 | |
1541 | (defbinding window-mnemonic-activate (window key modifier) nil |
1542 | (window window) |
1543 | ((gdk:keyval-from-name key) unsigned-int) |
1544 | (modifier gdk:modifier-type)) |
1545 | |
4eed43f1 |
1546 | (defbinding window-activate-key () boolean |
1547 | (window window) |
1548 | (event gdk:key-event)) |
1549 | |
1550 | (defbinding window-propagate-key-event () boolean |
1551 | (window window) |
1552 | (event gdk:key-event)) |
1553 | |
f957f519 |
1554 | #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
304cfb76 |
1555 | (defbinding window-present () nil |
1556 | (window window)) |
1557 | |
f957f519 |
1558 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
92ba85d4 |
1559 | (progn |
1560 | (defbinding %window-present () nil |
1561 | (window window)) |
1562 | |
12cae344 |
1563 | (defbinding %window-present-with-time () nil |
92ba85d4 |
1564 | (window window) |
1565 | (timespamp unsigned-int)) |
1566 | |
1567 | (defun window-present (window &optional timestamp) |
1568 | (if timestamp |
12cae344 |
1569 | (%window-present-with-time window timestamp) |
92ba85d4 |
1570 | (%window-present window)))) |
1571 | |
304cfb76 |
1572 | (defbinding window-iconify () nil |
1573 | (window window)) |
1574 | |
1575 | (defbinding window-deiconify () nil |
1576 | (window window)) |
1577 | |
1578 | (defbinding window-stick () nil |
1579 | (window window)) |
1580 | |
1581 | (defbinding window-unstick () nil |
1582 | (window window)) |
1583 | |
1584 | (defbinding window-maximize () nil |
1585 | (window window)) |
1586 | |
1587 | (defbinding window-unmaximize () nil |
1588 | (window window)) |
1589 | |
4eed43f1 |
1590 | (defbinding window-fullscreen () nil |
1591 | (window window)) |
1592 | |
1593 | (defbinding window-unfullscreen () nil |
1594 | (window window)) |
1595 | |
1596 | (defbinding window-set-keep-above () nil |
1597 | (window window) |
1598 | (setting boolean)) |
1599 | |
1600 | (defbinding window-set-keep-below () nil |
1601 | (window window) |
1602 | (setting boolean)) |
1603 | |
304cfb76 |
1604 | (defbinding window-begin-resize-drag () nil |
1605 | (window window) |
1606 | (edge gdk:window-edge) |
1607 | (button int) |
1608 | (root-x int) (root-y int) |
6baf860c |
1609 | (timestamp unsigned-int)) |
304cfb76 |
1610 | |
1611 | (defbinding window-begin-move-drag () nil |
1612 | (window window) |
1613 | (edge gdk:window-edge) |
1614 | (button int) |
1615 | (root-x int) (root-y int) |
6baf860c |
1616 | (timestamp unsigned-int)) |
304cfb76 |
1617 | |
1618 | (defbinding window-set-frame-dimensions () nil |
1619 | (window window) |
1620 | (left int) (top int) (rigth int) (bottom int)) |
1621 | |
304cfb76 |
1622 | (defbinding %window-get-default-size () nil |
1623 | (window window) |
1624 | (width int :out) |
1625 | (height int :out)) |
1626 | |
1627 | (defun window-get-default-size (window) |
1628 | (multiple-value-bind (width height) (%window-get-default-size window) |
1629 | (values (unless (= width -1) width) (unless (= height -1) height)))) |
1630 | |
1631 | (defbinding window-get-frame-dimensions () nil |
1632 | (window window) |
1633 | (left int :out) (top int :out) (rigth int :out) (bottom int :out)) |
1634 | |
ad98b596 |
1635 | (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf)) |
304cfb76 |
1636 | (window window)) |
1637 | |
304cfb76 |
1638 | (defbinding window-get-position () nil |
1639 | (window window) |
1640 | (root-x int :out) |
1641 | (root-y int :out)) |
1642 | |
1643 | (defbinding window-get-size () nil |
1644 | (window window) |
1645 | (width int :out) |
1646 | (height int :out)) |
1647 | |
1648 | (defbinding window-move () nil |
1649 | (window window) |
1650 | (x int) |
1651 | (y int)) |
1652 | |
1653 | (defbinding window-parse-geometry () boolean |
1654 | (window window) |
1655 | (geometry string)) |
1656 | |
1657 | (defbinding window-reshow-with-initial-size () nil |
1658 | (window window)) |
1659 | |
1660 | (defbinding window-resize () nil |
1661 | (window window) |
1662 | (width int) |
1663 | (heigth int)) |
1664 | |
4eed43f1 |
1665 | (defbinding (window-default-icon-list "gtk_window_get_default_icon_list") |
1666 | () (glist gdk:pixbuf)) |
1667 | |
1668 | (defun window-default-icon () |
1669 | (first (window-default-icon-list))) |
1670 | |
1671 | (defbinding %window-set-default-icon-list () nil |
1672 | (icons (glist gdk:pixbuf))) |
1673 | |
1674 | (defun (setf window-default-icon-list) (icons) |
1675 | (%window-set-default-icon-list icons) |
1676 | icons) |
1677 | |
1678 | (defbinding %window-set-default-icon () nil |
1679 | (icons (glist gdk:pixbuf))) |
1680 | |
4a8bb854 |
1681 | (defgeneric (setf window-default-icon) (icon)) |
1682 | |
4eed43f1 |
1683 | (defmethod (setf window-default-icon) ((icon gdk:pixbuf)) |
1684 | (%window-set-default-icon icon) |
1685 | icon) |
1686 | |
4a8bb854 |
1687 | (defgeneric (setf window-group) (group window)) |
1688 | |
4eed43f1 |
1689 | (defmethod (setf window-group) ((group window-group) (window window)) |
1690 | (window-group-add-window group window) |
1691 | group) |
1692 | |
1693 | (defbinding %window-set-default-icon-from-file () boolean |
1694 | (filename pathname) |
1695 | (nil null)) |
1696 | |
1697 | (defmethod (setf window-default-icon) ((icon-file pathname)) |
1698 | (%window-set-default-icon-from-file icon-file) |
1699 | icon-file) |
1700 | |
1701 | (defbinding %window-set-icon-from-file () boolean |
1702 | (window window) |
1703 | (filename pathname) |
1704 | (nil null)) |
1705 | |
1706 | (defmethod (setf window-icon) ((icon-file pathname) (window window)) |
1707 | (%window-set-icon-from-file window icon-file) |
1708 | icon-file) |
1709 | |
1710 | (defbinding window-set-auto-startup-notification () nil |
1711 | (setting boolean)) |
1712 | |
1713 | (defbinding decorated-window-init () nil |
1714 | (window window)) |
1715 | |
1716 | (defbinding decorated-window-calculate-frame-size () nil |
1717 | (window window)) |
1718 | |
1719 | (defbinding decorated-window-set-title () nil |
304cfb76 |
1720 | (window window) |
4eed43f1 |
1721 | (title string)) |
304cfb76 |
1722 | |
4eed43f1 |
1723 | (defbinding decorated-window-move-resize-window () nil |
1724 | (window window) |
1725 | (x int) |
1726 | (y int) |
1727 | (width int) |
1728 | (heigth int)) |
304cfb76 |
1729 | |
1730 | |
4eed43f1 |
1731 | ;;; Window group |
0d07716f |
1732 | |
4eed43f1 |
1733 | (defmethod initialize-instance ((window-group window-group) &rest initargs |
1734 | &key window windows) |
1735 | (declare (ignore window windows)) |
1736 | (prog1 |
1737 | (call-next-method) |
1738 | (initial-add window-group #'window-group-add-window |
1739 | initargs :window :windows))) |
0d07716f |
1740 | |
0d07716f |
1741 | |
4eed43f1 |
1742 | (defbinding window-group-add-window () nil |
1743 | (window-group window-group) |
1744 | (window window)) |
0d07716f |
1745 | |
4eed43f1 |
1746 | (defbinding window-group-remove-window () nil |
1747 | (window-group window-group) |
1748 | (window window)) |
0d07716f |
1749 | |
1750 | |
30481825 |
1751 | ;;; Scrolled window |
0d07716f |
1752 | |
0d07716f |
1753 | (defun (setf scrolled-window-scrollbar-policy) (policy window) |
1754 | (setf (scrolled-window-hscrollbar-policy window) policy) |
1755 | (setf (scrolled-window-vscrollbar-policy window) policy)) |
1756 | |
a60bd055 |
1757 | (defbinding scrolled-window-add-with-viewport () nil |
0d07716f |
1758 | (scrolled-window scrolled-window) |
1759 | (child widget)) |
1760 | |
4c308d58 |
1761 | (defmethod shared-initialize ((window scrolled-window) names &key policy) |
1762 | (declare (ignore names)) |
1763 | (when policy |
1764 | (setf (slot-value window 'hscrollbar-policy) policy) |
1765 | (setf (slot-value window 'vscrollbar-policy) policy)) |
1766 | (call-next-method)) |
2afcd8bd |
1767 | |
0d07716f |
1768 | |
30481825 |
1769 | ;;; Statusbar |
0d07716f |
1770 | |
14eaa563 |
1771 | (defbinding statusbar-get-context-id () unsigned-int |
30481825 |
1772 | (statusbar statusbar) |
1773 | (context-description string)) |
0d07716f |
1774 | |
a60bd055 |
1775 | (defbinding statusbar-push () unsigned-int |
30481825 |
1776 | (statusbar statusbar) |
1777 | (context-id unsigned-int) |
1778 | (text string)) |
0d07716f |
1779 | |
a60bd055 |
1780 | (defbinding statusbar-pop () nil |
30481825 |
1781 | (statusbar statusbar) |
1782 | (context-id unsigned-int)) |
0d07716f |
1783 | |
a60bd055 |
1784 | (defbinding statusbar-remove () nil |
30481825 |
1785 | (statusbar statusbar) |
1786 | (context-id unsigned-int) |
1787 | (message-id unsigned-int)) |
0d07716f |
1788 | |
0d07716f |
1789 | |
1790 | |
1791 | ;;; Fixed |
1792 | |
a60bd055 |
1793 | (defbinding fixed-put () nil |
30481825 |
1794 | (fixed fixed) |
1795 | (widget widget) |
378b3c5f |
1796 | (x int) (y int)) |
0d07716f |
1797 | |
a60bd055 |
1798 | (defbinding fixed-move () nil |
30481825 |
1799 | (fixed fixed) |
1800 | (widget widget) |
378b3c5f |
1801 | (x int) (y int)) |
0d07716f |
1802 | |
1803 | |
1804 | |
2afcd8bd |
1805 | ;;; Notebook |
0d07716f |
1806 | |
49043b9a |
1807 | (defun %ensure-notebook-position (notebook page) |
378b3c5f |
1808 | (etypecase page |
49043b9a |
1809 | (position page) |
378b3c5f |
1810 | (widget (notebook-page-num notebook page t)))) |
1811 | |
49043b9a |
1812 | (defun %ensure-notebook-child (notebook position) |
378b3c5f |
1813 | (typecase position |
1814 | (widget position) |
49043b9a |
1815 | (t (notebook-get-nth-page notebook position)))) |
378b3c5f |
1816 | |
1817 | (defbinding (notebook-insert "gtk_notebook_insert_page_menu") |
f957f519 |
1818 | (notebook position child &optional tab-label menu-label) nil |
30481825 |
1819 | (notebook notebook) |
1820 | (child widget) |
1821 | ((if (stringp tab-label) |
378b3c5f |
1822 | (make-instance 'label :label tab-label) |
f957f519 |
1823 | tab-label) (or null widget)) |
30481825 |
1824 | ((if (stringp menu-label) |
378b3c5f |
1825 | (make-instance 'label :label menu-label) |
30481825 |
1826 | menu-label) (or null widget)) |
49043b9a |
1827 | ((%ensure-notebook-position notebook position) position)) |
0d07716f |
1828 | |
f957f519 |
1829 | (defun notebook-append (notebook child &optional tab-label menu-label) |
378b3c5f |
1830 | (notebook-insert notebook :last child tab-label menu-label)) |
0d07716f |
1831 | |
f957f519 |
1832 | (defun notebook-prepend (notebook child &optional tab-label menu-label) |
378b3c5f |
1833 | (notebook-insert notebook :first child tab-label menu-label)) |
0d07716f |
1834 | |
378b3c5f |
1835 | (defbinding notebook-remove-page (notebook page) nil |
30481825 |
1836 | (notebook notebook) |
49043b9a |
1837 | ((%ensure-notebook-position notebook page) position)) |
0d07716f |
1838 | |
a60bd055 |
1839 | (defbinding %notebook-page-num () int |
30481825 |
1840 | (notebook notebook) |
1841 | (child widget)) |
1842 | |
378b3c5f |
1843 | (defun notebook-page-num (notebook child &optional error-p) |
30481825 |
1844 | (let ((page-num (%notebook-page-num notebook child))) |
1845 | (if (= page-num -1) |
378b3c5f |
1846 | (when error-p |
49043b9a |
1847 | (error "~A is not a page in ~A" child notebook)) |
30481825 |
1848 | page-num))) |
1849 | |
a60bd055 |
1850 | (defbinding notebook-next-page () nil |
30481825 |
1851 | (notebook notebook)) |
0d07716f |
1852 | |
a60bd055 |
1853 | (defbinding notebook-prev-page () nil |
30481825 |
1854 | (notebook notebook)) |
1855 | |
378b3c5f |
1856 | (defbinding notebook-reorder-child (notebook child position) nil |
1857 | (notebook notebook) |
1858 | (child widget) |
92ba85d4 |
1859 | ((%ensure-notebook-position notebook position) int)) |
378b3c5f |
1860 | |
a60bd055 |
1861 | (defbinding notebook-popup-enable () nil |
30481825 |
1862 | (notebook notebook)) |
1863 | |
a60bd055 |
1864 | (defbinding notebook-popup-disable () nil |
30481825 |
1865 | (notebook notebook)) |
1866 | |
49043b9a |
1867 | (defbinding notebook-get-nth-page () widget |
378b3c5f |
1868 | (notebook notebook) |
49043b9a |
1869 | (page position)) |
378b3c5f |
1870 | |
49043b9a |
1871 | (defun %notebook-current-page (notebook) |
1872 | (when (slot-boundp notebook 'current-page-num) |
1873 | (notebook-get-nth-page notebook (notebook-current-page-num notebook)))) |
378b3c5f |
1874 | |
1875 | (defun (setf notebook-current-page) (page notebook) |
f957f519 |
1876 | (setf (notebook-current-page-num notebook) (notebook-page-num notebook page))) |
378b3c5f |
1877 | |
eb4f580c |
1878 | (defbinding (notebook-tab-label "gtk_notebook_get_tab_label") |
1879 | (notebook page) widget |
1880 | (notebook notebook) |
49043b9a |
1881 | ((%ensure-notebook-child notebook page) widget)) |
378b3c5f |
1882 | |
eb4f580c |
1883 | (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text") |
84967144 |
1884 | (notebook page) (copy-of string) |
eb4f580c |
1885 | (notebook notebook) |
49043b9a |
1886 | ((%ensure-notebook-child notebook page) widget)) |
378b3c5f |
1887 | |
eb4f580c |
1888 | (defbinding %notebook-set-tab-label () nil |
1889 | (notebook notebook) |
1890 | (page widget) |
1891 | (tab-label widget)) |
1892 | |
1893 | (defun (setf notebook-tab-label) (tab-label notebook page) |
1894 | (let ((widget (if (stringp tab-label) |
1895 | (make-instance 'label :label tab-label) |
1896 | tab-label))) |
49043b9a |
1897 | (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget) |
eb4f580c |
1898 | widget)) |
378b3c5f |
1899 | |
378b3c5f |
1900 | |
eb4f580c |
1901 | (defbinding (notebook-menu-label "gtk_notebook_get_menu_label") |
1902 | (notebook page) widget |
1903 | (notebook notebook) |
49043b9a |
1904 | ((%ensure-notebook-child notebook page) widget)) |
378b3c5f |
1905 | |
eb4f580c |
1906 | (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text") |
84967144 |
1907 | (notebook page) (copy-of string) |
eb4f580c |
1908 | (notebook notebook) |
49043b9a |
1909 | ((%ensure-notebook-child notebook page) widget)) |
378b3c5f |
1910 | |
eb4f580c |
1911 | (defbinding %notebook-set-menu-label () nil |
1912 | (notebook notebook) |
1913 | (page widget) |
1914 | (menu-label widget)) |
1915 | |
1916 | (defun (setf notebook-menu-label) (menu-label notebook page) |
1917 | (let ((widget (if (stringp menu-label) |
1918 | (make-instance 'label :label menu-label) |
1919 | menu-label))) |
49043b9a |
1920 | (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget) |
eb4f580c |
1921 | widget)) |
378b3c5f |
1922 | |
1923 | |
1924 | (defbinding notebook-query-tab-label-packing (notebook page) nil |
30481825 |
1925 | (notebook notebook) |
92ba85d4 |
1926 | ((%ensure-notebook-child notebook page) widget) |
30481825 |
1927 | (expand boolean :out) |
1928 | (fill boolean :out) |
1929 | (pack-type pack-type :out)) |
1930 | |
378b3c5f |
1931 | (defbinding notebook-set-tab-label-packing |
1932 | (notebook page expand fill pack-type) nil |
30481825 |
1933 | (notebook notebook) |
92ba85d4 |
1934 | ((%ensure-notebook-child notebook page) widget) |
30481825 |
1935 | (expand boolean) |
1936 | (fill boolean) |
1937 | (pack-type pack-type)) |
1938 | |
0d07716f |
1939 | |
1940 | |
2afcd8bd |
1941 | ;;; Paned |
0d07716f |
1942 | |
a60bd055 |
1943 | (defbinding paned-pack1 () nil |
2afcd8bd |
1944 | (paned paned) |
1945 | (child widget) |
1946 | (resize boolean) |
1947 | (shrink boolean)) |
0d07716f |
1948 | |
a60bd055 |
1949 | (defbinding paned-pack2 () nil |
2afcd8bd |
1950 | (paned paned) |
1951 | (child widget) |
1952 | (resize boolean) |
1953 | (shrink boolean)) |
0d07716f |
1954 | |
0d07716f |
1955 | |
2afcd8bd |
1956 | ;;; Layout |
0d07716f |
1957 | |
a60bd055 |
1958 | (defbinding layout-put () nil |
2afcd8bd |
1959 | (layout layout) |
49043b9a |
1960 | (child widget) |
2afcd8bd |
1961 | (x int) |
1962 | (y int)) |
0d07716f |
1963 | |
a60bd055 |
1964 | (defbinding layout-move () nil |
2afcd8bd |
1965 | (layout layout) |
49043b9a |
1966 | (child widget) |
2afcd8bd |
1967 | (x int) |
1968 | (y int)) |
0d07716f |
1969 | |
49043b9a |
1970 | (defbinding layout-set-size () nil |
1971 | (layout layout) |
1972 | (width unsigned-int) |
1973 | (height unsigned-int)) |
1974 | |
1975 | (defbinding layout-get-size () nil |
1976 | (layout layout) |
1977 | (width unsigned-int :out) |
1978 | (height unsigned-int :out)) |
0d07716f |
1979 | |
1980 | |
0d07716f |
1981 | ;;; Menu shell |
1982 | |
378b3c5f |
1983 | (defbinding menu-shell-insert (menu-shell menu-item position) nil |
30481825 |
1984 | (menu-shell menu-shell) |
1985 | (menu-item menu-item) |
378b3c5f |
1986 | ((case position |
1987 | (:first 0) |
1988 | (:last -1) |
1989 | (t position)) int)) |
0d07716f |
1990 | |
30481825 |
1991 | (defun menu-shell-append (menu-shell menu-item) |
378b3c5f |
1992 | (menu-shell-insert menu-shell menu-item :last)) |
0d07716f |
1993 | |
30481825 |
1994 | (defun menu-shell-prepend (menu-shell menu-item) |
378b3c5f |
1995 | (menu-shell-insert menu-shell menu-item :fisrt)) |
0d07716f |
1996 | |
a60bd055 |
1997 | (defbinding menu-shell-deactivate () nil |
30481825 |
1998 | (menu-shell menu-shell)) |
0d07716f |
1999 | |
a60bd055 |
2000 | (defbinding menu-shell-select-item () nil |
30481825 |
2001 | (menu-shell menu-shell) |
2002 | (menu-item menu-item)) |
0d07716f |
2003 | |
14eaa563 |
2004 | (defbinding menu-shell-select-first () nil |
2005 | (menu-shell menu-shell) |
2006 | (search-sensitive boolean)) |
2007 | |
a60bd055 |
2008 | (defbinding menu-shell-deselect () nil |
30481825 |
2009 | (menu-shell menu-shell)) |
0d07716f |
2010 | |
a60bd055 |
2011 | (defbinding menu-shell-activate-item () nil |
30481825 |
2012 | (menu-shell menu-shell) |
2013 | (menu-item menu-item) |
2014 | (fore-deactivate boolean)) |
0d07716f |
2015 | |
14eaa563 |
2016 | (defbinding menu-shell-cancel () nil |
2017 | (menu-shell menu-shell)) |
0d07716f |
2018 | |
2019 | |
378b3c5f |
2020 | ;;; Menu |
0d07716f |
2021 | |
378b3c5f |
2022 | (defun %menu-position (menu child) |
2023 | (etypecase child |
2024 | (int child) |
2025 | (keyword (case child |
2026 | (:first 0) |
2027 | (:last -1) |
eb4f580c |
2028 | (t (error "Invalid position keyword: ~A" child)))) |
378b3c5f |
2029 | (widget (menu-child-position menu child)))) |
0d07716f |
2030 | |
2031 | |
378b3c5f |
2032 | (defbinding menu-reorder-child (menu menu-item position) nil |
2033 | (menu menu) |
2034 | (menu-item menu-item) |
2035 | ((%menu-position menu position) int)) |
0d07716f |
2036 | |
14eaa563 |
2037 | (defbinding menu-attach () nil |
2038 | (menu menu) |
2039 | (menu-item menu-item) |
2040 | (left-attach unsigned-int) |
2041 | (right-attach unsigned-int) |
2042 | (top-attach unsigned-int) |
2043 | (bottom-attach unsigned-int)) |
2044 | |
a92553bd |
2045 | (define-callback-marshal %menu-position-callback nil |
2046 | (menu (x int) (y int) (push-in boolean))) |
0d07716f |
2047 | |
378b3c5f |
2048 | (defbinding %menu-popup () nil |
2049 | (menu menu) |
2050 | (parent-menu-shell (or null menu-shell)) |
2051 | (parent-menu-item (or null menu-item)) |
a92553bd |
2052 | (callback (or null callback)) |
378b3c5f |
2053 | (callback-id unsigned-int) |
2054 | (button unsigned-int) |
2055 | (activate-time (unsigned 32))) |
2056 | |
2057 | (defun menu-popup (menu button activate-time &key callback parent-menu-shell |
2058 | parent-menu-item) |
2059 | (if callback |
4886872c |
2060 | (with-callback-function (id callback) |
2061 | (%menu-popup |
2062 | menu parent-menu-shell parent-menu-item |
a92553bd |
2063 | %menu-position-callback id button activate-time)) |
378b3c5f |
2064 | (%menu-popup |
2065 | menu parent-menu-shell parent-menu-item nil 0 button activate-time))) |
2066 | |
2067 | (defbinding menu-set-accel-path () nil |
2068 | (menu menu) |
2069 | (accel-path string)) |
0d07716f |
2070 | |
a60bd055 |
2071 | (defbinding menu-reposition () nil |
30481825 |
2072 | (menu menu)) |
0d07716f |
2073 | |
a60bd055 |
2074 | (defbinding menu-popdown () nil |
30481825 |
2075 | (menu menu)) |
0d07716f |
2076 | |
378b3c5f |
2077 | (defun menu-child-position (menu child) |
2078 | (position child (container-children menu))) |
2079 | |
2080 | (defun menu-active-num (menu) |
2081 | (menu-child-position menu (menu-active menu))) |
2082 | |
a60bd055 |
2083 | (defbinding %menu-set-active () nil |
30481825 |
2084 | (menu menu) |
2085 | (index unsigned-int)) |
0d07716f |
2086 | |
378b3c5f |
2087 | (defun (setf menu-active) (menu child) |
2088 | (%menu-set-active menu (%menu-position menu child)) |
2089 | child) |
2afcd8bd |
2090 | |
a92553bd |
2091 | (define-callback %menu-detach-callback nil ((widget widget) (menu menu)) |
f957f519 |
2092 | (funcall (user-data menu 'detach-func) widget menu)) |
14eaa563 |
2093 | |
405b4406 |
2094 | (defbinding %menu-attach-to-widget (menu widget) nil |
14eaa563 |
2095 | (menu menu) |
2096 | (widget widget) |
a92553bd |
2097 | (%menu-detach-callback callback)) |
14eaa563 |
2098 | |
2099 | (defun menu-attach-to-widget (menu widget function) |
f957f519 |
2100 | (setf (user-data menu 'detach-func) function) |
14eaa563 |
2101 | (%menu-attach-to-widget menu widget)) |
2102 | |
2103 | (defbinding menu-detach () nil |
2104 | (menu menu)) |
2105 | |
f957f519 |
2106 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
14eaa563 |
2107 | (defbinding menu-get-for-attach-widget () (copy-of (glist widget)) |
2108 | (widget widget)) |
2109 | |
2110 | (defbinding menu-set-monitor () nil |
2111 | (menu menu) |
2112 | (monitor-num int)) |
0d07716f |
2113 | |
2114 | |
30481825 |
2115 | ;;; Table |
0d07716f |
2116 | |
a60bd055 |
2117 | (defbinding table-resize () nil |
30481825 |
2118 | (table table) |
2119 | (rows unsigned-int) |
2120 | (columns unsigned-int)) |
0d07716f |
2121 | |
a60bd055 |
2122 | (defbinding table-attach (table child left right top bottom |
362f1795 |
2123 | &key options x-options y-options |
2124 | (x-padding 0) (y-padding 0)) nil |
30481825 |
2125 | (table table) |
2126 | (child widget) |
2127 | (left unsigned-int) |
2128 | (right unsigned-int) |
2129 | (top unsigned-int) |
2130 | (bottom unsigned-int) |
362f1795 |
2131 | ((append (mklist options) (mklist x-options)) attach-options) |
2132 | ((append (mklist options) (mklist y-options)) attach-options) |
30481825 |
2133 | (x-padding unsigned-int) |
2134 | (y-padding unsigned-int)) |
2135 | |
dd392521 |
2136 | |
a60bd055 |
2137 | (defbinding %table-set-row-spacing () nil |
30481825 |
2138 | (table table) |
2139 | (row unsigned-int) |
2140 | (spacing unsigned-int)) |
2141 | |
dd392521 |
2142 | (defbinding %table-set-row-spacings () nil |
2143 | (table table) |
2144 | (spacing unsigned-int)) |
2145 | |
2146 | (defun (setf table-row-spacing) (spacing table &optional row) |
2147 | (if row |
2148 | (%table-set-row-spacing table row spacing) |
2149 | (%table-set-row-spacings table spacing)) |
30481825 |
2150 | spacing) |
2151 | |
dd392521 |
2152 | (defbinding %table-get-row-spacing () unsigned-int |
30481825 |
2153 | (table table) |
dd392521 |
2154 | (row unsigned-int)) |
2155 | |
2156 | (defbinding %table-get-default-row-spacing () unsigned-int |
2157 | (table table)) |
2158 | |
2159 | (defun table-row-spacing (table &optional row) |
2160 | (if row |
2161 | (%table-get-row-spacing table row) |
2162 | (%table-get-default-row-spacing table))) |
2163 | |
30481825 |
2164 | |
a60bd055 |
2165 | (defbinding %table-set-col-spacing () nil |
30481825 |
2166 | (table table) |
2167 | (col unsigned-int) |
2168 | (spacing unsigned-int)) |
2169 | |
dd392521 |
2170 | (defbinding %table-set-col-spacings () nil |
2171 | (table table) |
2172 | (spacing unsigned-int)) |
2173 | |
5233fe44 |
2174 | (defun (setf table-column-spacing) (spacing table &optional column) |
2175 | (if column |
2176 | (%table-set-col-spacing table column spacing) |
dd392521 |
2177 | (%table-set-col-spacings table spacing)) |
30481825 |
2178 | spacing) |
2179 | |
5233fe44 |
2180 | (defun (setf table-col-spacing) (spacing table &optional col) |
2181 | (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead") |
2182 | (setf (table-column-spacing table col) spacing)) |
2183 | |
dd392521 |
2184 | (defbinding %table-get-col-spacing () unsigned-int |
30481825 |
2185 | (table table) |
dd392521 |
2186 | (col unsigned-int)) |
2187 | |
2188 | (defbinding %table-get-default-col-spacing () unsigned-int |
2189 | (table table)) |
2190 | |
5233fe44 |
2191 | (defun table-column-spacing (table &optional column) |
2192 | (if column |
2193 | (%table-get-col-spacing table column) |
dd392521 |
2194 | (%table-get-default-col-spacing table))) |
2195 | |
5233fe44 |
2196 | (defun table-col-spacing (table &optional col) |
2197 | (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead") |
2198 | (table-column-spacing table col)) |
2199 | |
dd392521 |
2200 | |
30481825 |
2201 | |
2202 | ;;; Toolbar |
2203 | |
9617dc95 |
2204 | (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips) |
2205 | (if (eq tooltips t) |
2206 | (apply #'call-next-method toolbar |
2207 | :tooltips (make-instance 'tooltips) initargs) |
2208 | (call-next-method))) |
0d07716f |
2209 | |
9617dc95 |
2210 | (defbinding %toolbar-insert () nil |
378b3c5f |
2211 | (toolbar toolbar) |
9617dc95 |
2212 | (tool-item tool-item) |
2213 | (position position)) |
30481825 |
2214 | |
9617dc95 |
2215 | (defun toolbar-insert (toolbar tool-item &optional (position :end)) |
2216 | (%toolbar-insert toolbar tool-item position) |
2217 | (%tool-item-update-tooltips tool-item)) |
378b3c5f |
2218 | |
9617dc95 |
2219 | (defbinding toolbar-get-item-index () int |
2220 | (toolbar toolbar) |
2221 | (item tool-item)) |
30481825 |
2222 | |
9617dc95 |
2223 | (defbinding toolbar-get-nth-item () tool-item |
2224 | (toolbar toolbar) |
2225 | (n int)) |
30481825 |
2226 | |
9617dc95 |
2227 | (defbinding toolbar-get-drop-index () int |
2228 | (toolbar toolbar) |
2229 | (x int) (y int)) |
30481825 |
2230 | |
9617dc95 |
2231 | (defbinding toolbar-set-drop-highlight-item () nil |
2232 | (toolbar toolbar) |
2233 | (tool-item tool-item) |
2234 | (index int)) |
30481825 |
2235 | |
0d07716f |
2236 | |
9617dc95 |
2237 | ;;; Tool button |
0d07716f |
2238 | |
9617dc95 |
2239 | (defmethod initialize-instance ((button tool-button) &rest initargs &key icon) |
2240 | (if (and icon (not (typep icon 'widget))) |
2241 | (apply #'call-next-method button :icon (create-image-widget icon) initargs) |
2242 | (call-next-method))) |
0d07716f |
2243 | |
2244 | |
9617dc95 |
2245 | ;;; Tool item |
0d07716f |
2246 | |
9617dc95 |
2247 | (defbinding tool-item-set-tooltip () nil |
2248 | (tool-item tool-item) |
2249 | (tooltips tooltips) |
2250 | (tip-text string) |
2251 | (tip-private string)) |
0d07716f |
2252 | |
0d07716f |
2253 | |
9617dc95 |
2254 | (defun %tool-item-update-tooltips (tool-item) |
2255 | (when (and |
2256 | (slot-boundp tool-item 'parent) |
2257 | (or |
2258 | (user-data-p tool-item 'tip-text) |
2259 | (user-data-p tool-item 'tip-private))) |
2260 | (tool-item-set-tooltip |
2261 | tool-item (toolbar-tooltips (widget-parent tool-item)) |
2262 | (or (user-data tool-item 'tip-text) "") |
2263 | (or (user-data tool-item 'tip-private) "")))) |
2264 | |
2265 | (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item)) |
2266 | (setf (user-data tool-item 'tip-text) tip-text) |
2267 | (%tool-item-update-tooltips tool-item) |
2268 | tip-text) |
2269 | |
2270 | (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item)) |
2271 | (setf (user-data tool-item 'tip-private) tip-private) |
2272 | (%tool-item-update-tooltips tool-item) |
2273 | tip-private) |
2274 | |
2275 | (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args) |
2276 | (declare (ignore args)) |
2277 | (prog1 |
2278 | (call-next-method) |
2279 | (%tool-item-update-tooltips tool-item))) |
0d07716f |
2280 | |
14eaa563 |
2281 | |
2282 | (defbinding tool-item-retrieve-proxy-menu-item () widget |
2283 | (tool-item tool-item)) |
2284 | |
2285 | (defbinding (tool-item-proxy-menu-item |
2286 | "gtk_tool_item_get_proxy_menu_item") () menu-item |
2287 | (tool-item tool-item) |
2288 | (menu-item-id string)) |
2289 | |
2290 | (defbinding %tool-item-set-proxy-menu-item () nil |
2291 | (tool-item tool-item) |
2292 | (menu-item-id string) |
2293 | (menu-item menu-item)) |
2294 | |
2295 | (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item) |
2296 | (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item) |
2297 | menu-item) |
2298 | |
f957f519 |
2299 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
14eaa563 |
2300 | (defbinding tool-item-rebuild-menu () nil |
2301 | (tool-item tool-item)) |
2302 | |
2303 | |
a60bd055 |
2304 | ;;; Editable |
eb4f580c |
2305 | |
a60bd055 |
2306 | (defbinding editable-select-region (editable &optional (start 0) end) nil |
30481825 |
2307 | (editable editable) |
2308 | (start int) |
2309 | ((or end -1) int)) |
0d07716f |
2310 | |
eb4f580c |
2311 | (defbinding editable-get-selection-bounds (editable) nil |
2312 | (editable editable) |
2313 | (start int :out) |
2314 | (end int :out)) |
2315 | |
14eaa563 |
2316 | (defbinding editable-insert-text (editable text &optional (position 0)) nil |
30481825 |
2317 | (editable editable) |
2318 | (text string) |
2319 | ((length text) int) |
f957f519 |
2320 | (position position :in/out)) |
0d07716f |
2321 | |
30481825 |
2322 | (defun editable-append-text (editable text) |
2323 | (editable-insert-text editable text nil)) |
0d07716f |
2324 | |
30481825 |
2325 | (defun editable-prepend-text (editable text) |
2326 | (editable-insert-text editable text 0)) |
0d07716f |
2327 | |
a60bd055 |
2328 | (defbinding editable-delete-text (editable &optional (start 0) end) nil |
30481825 |
2329 | (editable editable) |
2330 | (start int) |
2331 | ((or end -1) int)) |
0d07716f |
2332 | |
a60bd055 |
2333 | (defbinding (editable-text "gtk_editable_get_chars") |
30481825 |
2334 | (editable &optional (start 0) end) string |
2335 | (editable editable) |
2336 | (start int) |
2337 | ((or end -1) int)) |
0d07716f |
2338 | |
30481825 |
2339 | (defun (setf editable-text) (text editable) |
2340 | (if text |
2341 | (editable-delete-text |
2342 | editable |
2343 | (editable-insert-text editable text)) |
2344 | (editable-delete-text editable)) |
2345 | text) |
0d07716f |
2346 | |
a60bd055 |
2347 | (defbinding editable-cut-clipboard () nil |
30481825 |
2348 | (editable editable)) |
0d07716f |
2349 | |
a60bd055 |
2350 | (defbinding editable-copy-clipboard () nil |
30481825 |
2351 | (editable editable)) |
0d07716f |
2352 | |
a60bd055 |
2353 | (defbinding editable-paste-clipboard () nil |
30481825 |
2354 | (editable editable)) |
0d07716f |
2355 | |
a60bd055 |
2356 | (defbinding editable-delete-selection () nil |
30481825 |
2357 | (editable editable)) |
0d07716f |
2358 | |
0d07716f |
2359 | |
0d07716f |
2360 | |
30481825 |
2361 | ;;; Spin button |
0d07716f |
2362 | |
14eaa563 |
2363 | (defbinding spin-button-configure () nil |
2364 | (spin-button spin-button) |
2365 | (adjustment adjustment) |
2366 | (climb-rate double-float) |
2367 | (digits unsigned-int)) |
2368 | |
2369 | (defbinding spin-button-set-range () nil |
2370 | (spin-button spin-button) |
2371 | (min double-float) |
2372 | (max double-float)) |
2373 | |
2374 | (defbinding spin-button-get-range () nil |
2375 | (spin-button spin-button) |
2376 | (min double-float :out) |
2377 | (max double-float :out)) |
2378 | |
30481825 |
2379 | (defun spin-button-value-as-int (spin-button) |
2380 | (round (spin-button-value spin-button))) |
0d07716f |
2381 | |
45314d76 |
2382 | (defbinding %spin-button-spin () nil |
30481825 |
2383 | (spin-button spin-button) |
2384 | (direction spin-type) |
45314d76 |
2385 | (increment double-float)) |
2386 | |
2387 | (defun spin-button-spin (spin-button value) |
2388 | (etypecase value |
2389 | (real (%spin-button-spin spin-button :spin-user-defined value)) |
2390 | (spin-type (%spin-button-spin spin-button value 0)))) |
2391 | |
0d07716f |
2392 | |
a60bd055 |
2393 | (defbinding spin-button-update () nil |
30481825 |
2394 | (spin-button spin-button)) |
0d07716f |
2395 | |
2396 | |
2397 | |
2398 | ; ;;; Ruler |
2399 | |
a60bd055 |
2400 | (defbinding ruler-set-range () nil |
30481825 |
2401 | (ruler ruler) |
2402 | (lower single-float) |
2403 | (upper single-float) |
2404 | (position single-float) |
2405 | (max-size single-float)) |
0d07716f |
2406 | |
49043b9a |
2407 | (defbinding ruler-get-range () nil |
2408 | (ruler ruler) |
2409 | (lower single-float :out) |
2410 | (upper single-float :out) |
2411 | (position single-float :out) |
2412 | (max-size single-float :out)) |
0d07716f |
2413 | |
0d07716f |
2414 | |
0d07716f |
2415 | |
2afcd8bd |
2416 | ;;; Range |
0d07716f |
2417 | |
eb4f580c |
2418 | (defun range-lower (range) |
2419 | (adjustment-lower (range-adjustment range))) |
0d07716f |
2420 | |
eb4f580c |
2421 | (defun range-upper (range) |
2422 | (adjustment-upper (range-adjustment range))) |
0d07716f |
2423 | |
eb4f580c |
2424 | (defun (setf range-lower) (value range) |
2425 | (setf (adjustment-lower (range-adjustment range)) value)) |
0d07716f |
2426 | |
eb4f580c |
2427 | (defun (setf range-upper) (value range) |
2428 | (setf (adjustment-upper (range-adjustment range)) value)) |
0d07716f |
2429 | |
eb4f580c |
2430 | (defun range-page-increment (range) |
2431 | (adjustment-page-increment (range-adjustment range))) |
0d07716f |
2432 | |
eb4f580c |
2433 | (defun range-step-increment (range) |
2434 | (adjustment-step-increment (range-adjustment range))) |
0d07716f |
2435 | |
eb4f580c |
2436 | (defun (setf range-page-increment) (value range) |
2437 | (setf (adjustment-page-increment (range-adjustment range)) value)) |
0d07716f |
2438 | |
eb4f580c |
2439 | (defun (setf range-step-increment) (value range) |
2440 | (setf (adjustment-step-increment (range-adjustment range)) value)) |
0d07716f |
2441 | |
eb4f580c |
2442 | (defbinding range-set-range () nil |
2afcd8bd |
2443 | (range range) |
eb4f580c |
2444 | (lower double-float) |
2445 | (upper double-float)) |
0d07716f |
2446 | |
eb4f580c |
2447 | (defbinding range-set-increments () nil |
2afcd8bd |
2448 | (range range) |
eb4f580c |
2449 | (step double-float) |
2450 | (page double-float)) |
0d07716f |
2451 | |
0d07716f |
2452 | |
2afcd8bd |
2453 | ;;; Scale |
0d07716f |
2454 | |
49043b9a |
2455 | (defbinding scale-get-layout-offsets () nil |
2456 | (scale scale) |
2457 | (x int :out) |
2458 | (y int :out)) |
0d07716f |
2459 | |
0d07716f |
2460 | |
2afcd8bd |
2461 | ;;; Progress bar |
0d07716f |
2462 | |
a60bd055 |
2463 | (defbinding progress-bar-pulse () nil |
2afcd8bd |
2464 | (progress-bar progress-bar)) |
0d07716f |
2465 | |
2466 | |
362f1795 |
2467 | ;;; Size group |
2468 | |
2469 | (defmethod initialize-instance ((size-group size-group) &rest initargs |
2470 | &key widget widgets) |
2471 | (declare (ignore widget widgets)) |
2472 | (prog1 |
2473 | (call-next-method) |
2474 | (initial-add size-group #'size-group-add-widget |
2475 | initargs :widget :widgets))) |
2476 | |
2477 | |
2478 | (defbinding size-group-add-widget () nil |
2479 | (size-group size-group) |
2480 | (widget widget)) |
2481 | |
2482 | (defbinding size-group-remove-widget () nil |
2483 | (size-group size-group) |
2484 | (widget widget)) |
2485 | |
0d07716f |
2486 | |
378b3c5f |
2487 | ;;; Stock items |
2488 | |
99821988 |
2489 | (defbinding %stock-item-copy () pointer |
2490 | (location pointer)) |
2491 | |
2492 | (defbinding %stock-item-free () nil |
2493 | (location pointer)) |
378b3c5f |
2494 | |
99821988 |
2495 | (defbinding stock-add (stock-item) nil |
2496 | (stock-item stock-item) |
2497 | (1 unsigned-int)) |
2498 | |
2499 | (defbinding stock-list-ids () (gslist string)) |
2500 | |
2501 | (defbinding %stock-lookup () boolean |
2502 | (stock-id string) |
2503 | (location pointer)) |
2504 | |
2505 | (defun stock-lookup (stock-id) |
f957f519 |
2506 | (with-memory (stock-item (foreign-size (find-class 'stock-item))) |
66984e02 |
2507 | (when (%stock-lookup stock-id stock-item) |
2508 | (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item))))) |
0d07716f |
2509 | |
f957f519 |
2510 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
66984e02 |
2511 | (progn |
2512 | (define-callback-marshal %stock-translate-callback string ((path string))) |
2513 | |
2514 | (defbinding (stock-set-translate-function "gtk_stock_set_translate_func") |
2515 | (domain function) nil |
2516 | (domain string) |
2517 | (%stock-translate-callback callback) |
2518 | ((register-callback-function function) unsigned-int) |
2519 | (user-data-destroy-callback callback))) |
2520 | |
ff1b3ff2 |
2521 | |
2522 | ;;; Tooltip |
2523 | |
2524 | ;; #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0") |
2525 | ;; (progn |
2526 | ;; (defbinding %tooltip-set-markup () nil |
2527 | ;; tooltip |
2528 | ;; (markup string)) |
2529 | |
2530 | ;; (defbinding %tooltip-set-text () nil |
2531 | ;; tooltip |
2532 | ;; (text string)) |
2533 | |
2534 | ;; (defbinding %tooltip-set-icon () nil |
2535 | ;; tooltip |
2536 | ;; (icon gdk:pixbuf)) |
2537 | |
2538 | ;; (defbinding %tooltip-set-from-stock-icon () nil |
2539 | ;; tooltip |
2540 | ;; (stock-id string) |
2541 | ;; icon-size) |
2542 | |
2543 | ;; (defbinding %tooltip-set-custom () nil |
2544 | ;; tooltip |
2545 | ;; widget) |
2546 | |
2547 | ;; (defun tooltip-set (tooltip value &key (markup t) (icon-size :button)) |
2548 | ;; (etypecase value |
2549 | ;; (string (if markup |
2550 | ;; (tooltip-set-markup tooltip value) |
2551 | ;; (tooltip-set-text tooltip value))) |
2552 | ;; (pixbuf (tooltip-set-icon tooltip value)) |
2553 | ;; (keyword (tooltip-set-icon-from-stock tooltip value icon-size)) |
2554 | |
66984e02 |
2555 | |
0d07716f |
2556 | |
ff1b3ff2 |
2557 | ;;; Tooltips |
2558 | |
2559 | ;; GtkTooltips has been deprecated in favor of the new tooltip API |
2560 | ;; introduced in in GTK+ 2.12 |
0d07716f |
2561 | |
a60bd055 |
2562 | (defbinding tooltips-enable () nil |
2afcd8bd |
2563 | (tooltips tooltips)) |
0d07716f |
2564 | |
a60bd055 |
2565 | (defbinding tooltips-disable () nil |
2afcd8bd |
2566 | (tooltips tooltips)) |
0d07716f |
2567 | |
dd392521 |
2568 | (defun (setf tooltips-enabled-p) (enable tooltips) |
2569 | (if enable |
2570 | (tooltips-enable tooltips) |
2571 | (tooltips-disable tooltips))) |
2572 | |
a60bd055 |
2573 | (defbinding tooltips-set-tip () nil |
2afcd8bd |
2574 | (tooltips tooltips) |
2575 | (widget widget) |
2576 | (tip-text string) |
2577 | (tip-private string)) |
0d07716f |
2578 | |
14eaa563 |
2579 | (defbinding tooltips-data-get () tooltips-data |
2580 | (widget widget)) |
2581 | |
a60bd055 |
2582 | (defbinding tooltips-force-window () nil |
2afcd8bd |
2583 | (tooltips tooltips)) |
0d07716f |
2584 | |
14eaa563 |
2585 | (defbinding tooltips-get-info-from-tip-window () boolean |
2586 | (tip-window window) |
2587 | (tooltips tooltips :out) |
2588 | (current-widget widget :out)) |
0d07716f |
2589 | |
2590 | |
e69138cc |
2591 | ;;; Resource Files |
0d07716f |
2592 | |
17163f4e |
2593 | (defbinding rc-get-style () style |
2594 | (widget widget)) |
2595 | |
2596 | (defbinding rc-get-style-by-paths (&key path class-path class) style |
2597 | (path (or null string)) |
2598 | (class-path (or null string)) |
2599 | (class gtype)) |
0d07716f |
2600 | |
17163f4e |
2601 | (defbinding rc-parse () nil |
2602 | (filename pathname)) |
0d07716f |
2603 | |
a60bd055 |
2604 | (defbinding rc-parse-string () nil |
2afcd8bd |
2605 | (rc-string string)) |
0d07716f |
2606 | |
17163f4e |
2607 | (defbinding %rc-reparse-all () boolean) |
0d07716f |
2608 | |
17163f4e |
2609 | (defbinding %rc-reparse-all-for-settings () boolean |
2610 | (settings settings) |
2611 | (force-load-p boolean)) |
2612 | |
2613 | (defun rc-reparse-all (&optional setting force-load-p) |
2614 | (if setting |
2615 | (%rc-reparse-all-for-settings setting force-load-p) |
2616 | (%rc-reparse-all))) |
2617 | |
2618 | (defbinding rc-reset-styles () nil |
2619 | (settings settings)) |
2620 | |
2621 | (defbinding rc-add-default-file () nil |
2622 | (filename pathname)) |
2623 | |
2624 | (defbinding rc-get-default-files () |
2625 | (copy-of (null-terminated-vector (copy-of string)))) |
2626 | |
2627 | (defbinding rc-get-module-dir () string) |
2628 | |
2629 | (defbinding rc-get-im-module-path () string) |
2630 | |
2631 | (defbinding rc-get-im-module-file () string) |
2632 | |
2633 | (defbinding rc-get-theme-dir () string) |
2634 | |
2635 | |
2636 | ;;; Settings |
2637 | |
2638 | (defbinding (settings-get "gtk_settings_get_for_screen") |
2639 | (&optional (screen (gdk:display-get-default-screen))) settings |
2640 | (screen gdk:screen)) |
2641 | |
2642 | |
2643 | ;;; Plug and Socket |
2644 | |
2645 | (defbinding socket-add-id () nil |
2646 | (socket socket) |
2647 | (id gdk:native-window)) |
2648 | |
2649 | (defbinding %plug-new () pointer |
2650 | (id gdk:native-window)) |
2651 | |
2652 | (defmethod allocate-foreign ((plug plug) &key id) |
2653 | (%plug-new (or id 0))) |
14ac49ee |
2654 | |
2655 | |
14ac49ee |
2656 | ;;; Link button |
2657 | |
2658 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0") |
2659 | (progn |
2660 | (define-callback-marshal %link-button-uri-callback nil (link-button (link string))) |
2661 | |
2662 | (defbinding link-button-set-uri-hook (function) pointer |
2663 | (%link-button-uri-callback callback) |
2664 | ((register-callback-function function) unsigned-int) |
2665 | (user-data-destroy-callback callback))) |
ff1b3ff2 |
2666 | |
2667 | |
2668 | ;;; Builder |
2669 | |
2670 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0") |
2671 | (progn |
2672 | (defmethod initialize-instance ((builder builder) &key interface |
2673 | (connect-signals t) (package *package*)) |
2674 | (call-next-method) |
2675 | (etypecase interface |
2676 | (null) |
2677 | (string (builder-add-from-string builder interface)) |
2678 | (pathname (builder-add-from-file builder interface))) |
2679 | (when connect-signals |
2680 | (builder-connect-signals builder package))) |
2681 | |
2682 | |
2683 | (defbinding builder-add-from-file () boolean |
2684 | builder |
2685 | pathname |
2686 | (nil gerror-signal :out)) |
2687 | |
2688 | (defbinding builder-add-from-string () boolean |
2689 | builder |
2690 | (buffer string) |
2691 | (-1 int) ; TODO: add gsize type |
2692 | (nil gerror-signal :out)) |
2693 | |
2694 | (defbinding builder-get-object () gobject |
2695 | builder |
2696 | (name string)) |
2697 | |
2698 | (defbinding builder-get-objects () (gslist gobject) |
2699 | builder) |
2700 | |
2701 | (defun intern-with-package-prefix (name default-package) |
2702 | (let ((pos (position #\: name))) |
2703 | (if pos |
2704 | (intern |
2705 | (string-upcase (subseq name (1+ pos))) |
2706 | (string-upcase (subseq name 0 pos))) |
2707 | (intern (string-upcase name) default-package)))) |
2708 | |
2709 | (define-callback %builder-connect-function nil |
2710 | (builder (object gobject) (signal-name string) (handler-name string) |
2711 | (connect-object gobject) connect-flags (package user-data-id)) |
2712 | (format t "Connect signal ~A for ~A to ~A in default package ~A with flags ~A~%" signal-name object handler-name (find-user-data package) connect-flags) |
2713 | (signal-connect |
2714 | object signal-name |
2715 | (intern-with-package-prefix handler-name (find-user-data package)) |
2716 | :object (or connect-object object) :after (find :after connect-flags))) |
2717 | |
2718 | (defbinding %builder-connect-signals-full (builder package) nil |
2719 | builder |
2720 | (%builder-connect-function callback) |
2721 | (package user-data-id)) |
2722 | |
2723 | (defun builder-connect-signals (builder &optional (package *package*)) |
2724 | (with-user-data (id package) |
2725 | (%builder-connect-signals-full builder id)))) |
2726 | |