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