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