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