560af5c5 |
1 | ;; Common Lisp bindings for GTK+ v2.0 |
bbaeff4b |
2 | ;; Copyright (C) 1999-2001 Espen S. Johnsen <esj@stud.cs.uit.no> |
560af5c5 |
3 | ;; |
4 | ;; This library is free software; you can redistribute it and/or |
5 | ;; modify it under the terms of the GNU Lesser General Public |
6 | ;; License as published by the Free Software Foundation; either |
7 | ;; version 2 of the License, or (at your option) any later version. |
8 | ;; |
9 | ;; This library is distributed in the hope that it will be useful, |
10 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | ;; Lesser General Public License for more details. |
13 | ;; |
14 | ;; You should have received a copy of the GNU Lesser General Public |
15 | ;; License along with this library; if not, write to the Free Software |
16 | ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | |
f45fd227 |
18 | ;; $Id: gtk.lisp,v 1.24 2004-12-20 22:43:26 espen Exp $ |
560af5c5 |
19 | |
20 | |
21 | (in-package "GTK") |
22 | |
23 | ;;; Gtk version |
24 | |
6bb23851 |
25 | (defbinding check-version () (copy-of string) |
560af5c5 |
26 | (required-major unsigned-int) |
27 | (required-minor unsigned-int) |
28 | (required-micro unsigned-int)) |
29 | |
bbaeff4b |
30 | (defbinding query-version () nil |
560af5c5 |
31 | (major unsigned-int :out) |
32 | (minor unsigned-int :out) |
33 | (micro unsigned-int :out)) |
34 | |
35 | (defun gtk-version () |
36 | (multiple-value-bind (major minor micro) |
37 | (query-version) |
38 | (if (zerop micro) |
39 | (format nil "Gtk+ v~A.~A" major minor) |
40 | (format nil "Gtk+ v~A.~A.~A" major minor micro)))) |
41 | |
6bb23851 |
42 | (defbinding get-default-language () (copy-of pango:language)) |
560af5c5 |
43 | |
44 | |
9adccb27 |
45 | ;;;; Initalization |
46 | |
47 | (defbinding (gtk-init "gtk_parse_args") () nil |
48 | "Initializes the library without opening the display." |
49 | (nil null) |
50 | (nil null)) |
51 | |
52 | (defun clg-init (&optional display) |
53 | "Initializes the system and starts the event handling" |
54 | (unless (gdk:display-get-default) |
55 | (gdk:gdk-init) |
56 | (gtk-init) |
57 | (prog1 |
58 | (gdk:display-open display) |
59 | (system:add-fd-handler |
60 | (gdk:display-connection-number) :input #'main-iterate-all) |
61 | (setq lisp::*periodic-polling-function* #'main-iterate-all) |
62 | (setq lisp::*max-event-to-sec* 0) |
63 | (setq lisp::*max-event-to-usec* 1000)))) |
64 | |
65 | |
0f476ab5 |
66 | ;;; Acccel group |
560af5c5 |
67 | |
68 | |
1047e159 |
69 | |
560af5c5 |
70 | ;;; Acccel label |
71 | |
bbaeff4b |
72 | (defbinding accel-label-refetch () boolean |
560af5c5 |
73 | (accel-label accel-label)) |
74 | |
75 | |
0f476ab5 |
76 | ;;; Adjustment |
560af5c5 |
77 | |
1047e159 |
78 | (defmethod shared-initialize ((adjustment adjustment) names &key value) |
79 | (prog1 |
80 | (call-next-method) |
81 | ;; we need to make sure that the value is set last, otherwise it |
82 | ;; may be outside current limits |
83 | (when value |
84 | (setf (slot-value adjustment 'value) value)))) |
85 | |
86 | |
0f476ab5 |
87 | (defbinding adjustment-changed () nil |
88 | (adjustment adjustment)) |
89 | |
90 | (defbinding adjustment-value-changed () nil |
91 | (adjustment adjustment)) |
92 | |
93 | (defbinding adjustment-clamp-page () nil |
94 | (adjustment adjustment) |
95 | (lower single-float) |
96 | (upper single-float)) |
560af5c5 |
97 | |
0f476ab5 |
98 | |
0f476ab5 |
99 | ;;; Arrow -- no functions |
100 | |
101 | |
102 | |
103 | ;;; Aspect frame |
104 | |
105 | |
106 | ;;; Bin |
560af5c5 |
107 | |
108 | (defun (setf bin-child) (child bin) |
0f476ab5 |
109 | (when-bind (current-child (bin-child bin)) |
110 | (container-remove bin current-child)) |
560af5c5 |
111 | (container-add bin child) |
112 | child) |
113 | |
f36ca6af |
114 | |
0f476ab5 |
115 | ;;; Binding |
116 | |
117 | |
118 | |
119 | ;;; Box |
120 | |
121 | (defbinding box-pack-start () nil |
122 | (box box) |
123 | (child widget) |
124 | (expand boolean) |
125 | (fill boolean) |
126 | (padding unsigned-int)) |
127 | |
128 | (defbinding box-pack-end () nil |
129 | (box box) |
130 | (child widget) |
131 | (expand boolean) |
132 | (fill boolean) |
133 | (padding unsigned-int)) |
134 | |
1a1949c7 |
135 | (defun box-pack (box child &key end expand fill (padding 0)) |
136 | (if end |
f5b67f2b |
137 | (box-pack-end box child expand fill padding) |
138 | (box-pack-start box child expand fill padding))) |
0f476ab5 |
139 | |
140 | (defbinding box-reorder-child () nil |
141 | (box box) |
142 | (child widget) |
143 | (position int)) |
144 | |
145 | (defbinding box-query-child-packing () nil |
146 | (box box) |
147 | (child widget) |
148 | (expand boolean :out) |
149 | (fill boolean :out) |
150 | (padding unsigned-int :out) |
151 | (pack-type pack-type :out)) |
152 | |
153 | (defbinding box-set-child-packing () nil |
154 | (box box) |
155 | (child widget) |
156 | (expand boolean) |
157 | (fill boolean) |
158 | (padding unsigned-int) |
159 | (pack-type pack-type)) |
160 | |
161 | |
162 | |
560af5c5 |
163 | ;;; Button |
164 | |
bbaeff4b |
165 | (defbinding button-pressed () nil |
560af5c5 |
166 | (button button)) |
167 | |
0f476ab5 |
168 | (defbinding button-released () nil |
169 | (button button)) |
170 | |
171 | (defbinding button-clicked () nil |
172 | (button button)) |
173 | |
174 | (defbinding button-enter () nil |
175 | (button button)) |
176 | |
177 | (defbinding button-leave () nil |
178 | (button button)) |
179 | |
180 | |
181 | |
182 | ;;; Calendar |
183 | |
184 | (defbinding calendar-select-month () int |
185 | (calendar calendar) |
186 | (month unsigned-int) |
187 | (year unsigned-int)) |
188 | |
189 | (defbinding calendar-select-day () nil |
190 | (calendar calendar) |
191 | (day unsigned-int)) |
192 | |
193 | (defbinding calendar-mark-day () int |
194 | (calendar calendar) |
195 | (day unsigned-int)) |
196 | |
197 | (defbinding calendar-unmark-day () int |
198 | (calendar calendar) |
199 | (day unsigned-int)) |
200 | |
201 | (defbinding calendar-clear-marks () nil |
202 | (calendar calendar)) |
203 | |
204 | (defbinding calendar-display-options () nil |
205 | (calendar calendar) |
206 | (options calendar-display-options)) |
207 | |
208 | (defbinding (calendar-date "gtk_calendar_get_date") () nil |
209 | (calendar calendar) |
210 | (year unsigned-int :out) |
211 | (month unsigned-int :out) |
212 | (day unsigned-int :out)) |
213 | |
214 | (defbinding calendar-freeze () nil |
215 | (calendar calendar)) |
216 | |
217 | (defbinding calendar-thaw () nil |
218 | (calendar calendar)) |
219 | |
220 | |
221 | |
222 | ;;; Cell editable |
223 | |
224 | |
225 | |
226 | ;;; Cell renderer |
227 | |
228 | |
229 | |
230 | ;;; Cell renderer pixbuf -- no functions |
231 | |
232 | |
233 | |
234 | ;;; Cell renderer text |
235 | |
236 | |
237 | |
238 | ;;; Cell renderer toggle -- no functions |
239 | |
240 | |
241 | |
242 | ;;; Check button -- no functions |
243 | |
244 | |
245 | |
246 | ;;; Check menu item |
247 | |
248 | (defbinding check-menu-item-toggled () nil |
249 | (check-menu-item check-menu-item)) |
250 | |
251 | |
252 | |
253 | ;;; Clipboard |
254 | |
255 | |
256 | ;;; Color selection |
257 | |
258 | (defbinding (color-selection-is-adjusting-p |
259 | "gtk_color_selection_is_adjusting") () boolean |
260 | (colorsel color-selection)) |
261 | |
262 | |
263 | |
264 | ;;; Color selection dialog -- no functions |
265 | |
266 | |
267 | |
1a1949c7 |
268 | ;;;; Combo Box |
0f476ab5 |
269 | |
1a1949c7 |
270 | (defmethod shared-initialize ((combo-box combo-box) names &key model content) |
271 | (unless model |
272 | (setf |
273 | (combo-box-model combo-box) |
6bb23851 |
274 | (make-instance 'list-store :column-types '(string))) |
1a1949c7 |
275 | (unless (typep combo-box 'combo-box-entry) |
276 | (let ((cell (make-instance 'cell-renderer-text))) |
277 | (cell-layout-pack combo-box cell :expand t) |
278 | (cell-layout-add-attribute combo-box cell :text 0))) |
279 | (when content |
280 | (map 'nil #'(lambda (text) |
281 | (combo-box-append-text combo-box text)) |
282 | content))) |
283 | (call-next-method)) |
284 | |
285 | ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active) |
286 | ;; (when active |
287 | ;; (signal-emit combo-box 'changed))) |
288 | |
289 | (defbinding combo-box-append-text () nil |
290 | (combo-box combo-box) |
291 | (text string)) |
292 | |
293 | (defbinding combo-box-insert-text () nil |
294 | (combo-box combo-box) |
295 | (position int) |
296 | (text string)) |
297 | |
298 | (defbinding combo-box-prepend-text () nil |
299 | (combo-box combo-box) |
300 | (text string)) |
301 | |
302 | #+gtk2.6 |
303 | (defbinding combo-box-get-active-text () string |
304 | (combo-box combo-box)) |
0f476ab5 |
305 | |
1a1949c7 |
306 | (defbinding combo-box-popup () nil |
307 | (combo-box combo-box)) |
0f476ab5 |
308 | |
1a1949c7 |
309 | (defbinding combo-box-popdown () nil |
310 | (combo-box combo-box)) |
311 | |
312 | |
313 | |
314 | ;;;; Combo Box Entry |
315 | |
316 | (defmethod shared-initialize ((combo-box-entry combo-box-entry) names &key model) |
317 | (call-next-method) |
318 | (unless model |
319 | (setf (combo-box-entry-text-column combo-box-entry) 0))) |
0f476ab5 |
320 | |
321 | |
48da76bf |
322 | ;;;; Dialog |
0f476ab5 |
323 | |
c49be931 |
324 | (defmethod shared-initialize ((dialog dialog) names &rest initargs |
325 | &key button buttons) |
326 | (declare (ignore button buttons)) |
327 | (prog1 |
328 | (call-next-method) |
329 | (initial-apply-add dialog #'dialog-add-button initargs :button :buttons))) |
48da76bf |
330 | |
0f476ab5 |
331 | |
332 | (defvar %*response-id-key* (gensym)) |
333 | |
1047e159 |
334 | (defun %dialog-find-response-id-num (dialog id &optional create-p error-p) |
0f476ab5 |
335 | (or |
1047e159 |
336 | (cadr (assoc id (rest (type-expand-1 'response-type)))) |
337 | (let ((response-ids (object-data dialog %*response-id-key*))) |
0f476ab5 |
338 | (cond |
1047e159 |
339 | ((and response-ids (position id response-ids :test #'equal))) |
340 | (create-p |
341 | (cond |
342 | (response-ids |
343 | (vector-push-extend id response-ids) |
344 | (1- (length response-ids))) |
345 | (t |
346 | (setf |
347 | (object-data dialog %*response-id-key*) |
348 | (make-array 1 :adjustable t :fill-pointer t :initial-element id)) |
349 | 0))) |
350 | (error-p |
351 | (error "Invalid response: ~A" id)))))) |
0f476ab5 |
352 | |
353 | (defun %dialog-find-response-id (dialog response-id-num) |
354 | (if (< response-id-num 0) |
355 | (car |
356 | (rassoc |
357 | (list response-id-num) |
1047e159 |
358 | (rest (type-expand-1 'response-type)) :test #'equal)) |
359 | (aref (object-data dialog %*response-id-key*) response-id-num ))) |
0f476ab5 |
360 | |
361 | |
48da76bf |
362 | (defmethod signal-connect ((dialog dialog) signal function &key object after) |
363 | (let ((response-id-num (%dialog-find-response-id-num dialog signal))) |
364 | (cond |
365 | (response-id-num |
366 | (call-next-method |
367 | dialog 'response |
368 | #'(lambda (dialog id) |
369 | (when (= id response-id-num) |
370 | (cond |
371 | ((eq object t) (funcall function dialog)) |
372 | (object (funcall function object)) |
373 | (t (funcall function))))) |
374 | :object t :after after)) |
1047e159 |
375 | ((call-next-method))))) |
0f476ab5 |
376 | |
377 | |
48da76bf |
378 | (defbinding dialog-run () nil |
379 | (dialog dialog)) |
0f476ab5 |
380 | |
48da76bf |
381 | (defbinding dialog-response (dialog response-id) nil |
0f476ab5 |
382 | (dialog dialog) |
48da76bf |
383 | ((%dialog-find-response-id-num dialog response-id nil t) int)) |
0f476ab5 |
384 | |
385 | |
386 | (defbinding %dialog-add-button () button |
387 | (dialog dialog) |
388 | (text string) |
389 | (response-id-num int)) |
390 | |
1047e159 |
391 | (defun dialog-add-button (dialog label &optional (response label) |
392 | &key default object after) |
393 | "Adds a button to the dialog. If no response is given, then label |
394 | will be used." |
395 | (let* ((id (if (functionp response) |
396 | label |
397 | response)) |
398 | (id-num (%dialog-find-response-id-num dialog id t)) |
399 | (button (%dialog-add-button dialog label id-num))) |
400 | (when (functionp response) |
401 | (signal-connect dialog id response :object object :after after)) |
402 | (when default |
403 | (%dialog-set-default-response dialog id-num)) |
0f476ab5 |
404 | button)) |
405 | |
406 | |
407 | (defbinding %dialog-add-action-widget () button |
408 | (dialog dialog) |
409 | (action-widget widget) |
410 | (response-id-num int)) |
411 | |
1047e159 |
412 | (defun dialog-add-action-widget (dialog widget &optional (response widget) |
413 | &key default object after) |
414 | (let* ((id (if (functionp response) |
415 | widget |
416 | response)) |
417 | (id-num (%dialog-find-response-id-num dialog id t))) |
418 | (%dialog-add-action-widget dialog widget id-num) |
419 | (when (functionp response) |
420 | (signal-connect dialog id response :object object :after after)) |
421 | (when default |
422 | (%dialog-set-default-response dialog id-num)) |
0f476ab5 |
423 | widget)) |
0f476ab5 |
424 | |
0f476ab5 |
425 | |
48da76bf |
426 | (defbinding %dialog-set-default-response () nil |
427 | (dialog dialog) |
428 | (response-id-num int)) |
0f476ab5 |
429 | |
48da76bf |
430 | (defun dialog-set-default-response (dialog response-id) |
431 | (%dialog-set-default-response |
432 | dialog (%dialog-find-response-id-num dialog response-id nil t))) |
0f476ab5 |
433 | |
48da76bf |
434 | (defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil |
435 | (dialog dialog) |
436 | ((%dialog-find-response-id-num dialog response-id nil t) int) |
437 | (sensitive boolean)) |
0f476ab5 |
438 | |
439 | |
48da76bf |
440 | ;; Addition dialog functions |
441 | |
442 | (defmethod container-add ((dialog dialog) (child widget) &rest args) |
1047e159 |
443 | (apply #'container-add (dialog-vbox dialog) child args)) |
48da76bf |
444 | |
445 | (defmethod container-remove ((dialog dialog) (child widget)) |
1047e159 |
446 | (container-remove (dialog-vbox dialog) child)) |
0f476ab5 |
447 | |
48da76bf |
448 | (defmethod container-children ((dialog dialog)) |
1047e159 |
449 | (container-children (dialog-vbox dialog))) |
48da76bf |
450 | |
451 | (defmethod (setf container-children) (children (dialog dialog)) |
1047e159 |
452 | (setf (container-children (dialog-vbox dialog)) children)) |
560af5c5 |
453 | |
560af5c5 |
454 | |
560af5c5 |
455 | |
2e852f7b |
456 | ;;; Drawing area |
457 | |
458 | (defbinding drawing-area-get-size () nil |
459 | (drawing-area drawing-area) |
460 | (width int :out) |
461 | (height int :out)) |
560af5c5 |
462 | |
463 | |
aaa6e6cb |
464 | ;;; Entry |
560af5c5 |
465 | |
60e5d937 |
466 | (defbinding entry-get-layout () pango:layout |
aaa6e6cb |
467 | (entry entry)) |
468 | |
469 | (defbinding entry-get-layout-offsets () nil |
470 | (entry entry) |
471 | (x int :out) |
472 | (y int :out)) |
560af5c5 |
473 | |
560af5c5 |
474 | |
f45fd227 |
475 | ;;; Entry Completion |
476 | |
477 | (def-callback-marshal %entry-completion-match-func |
478 | (boolean entry-completion string (copy-of tree-iter))) |
479 | |
480 | (defbinding entry-completion-set-match-func (completion function) nil |
481 | (completion entry-completion) |
482 | ((callback %entry-completion-match-func) pointer) |
483 | ((register-callback-function function) unsigned-int) |
484 | ((callback %destroy-user-data) pointer)) |
485 | |
486 | (defbinding entry-completion-complete () nil |
487 | (completion entry-completion)) |
488 | |
489 | #+gtk2.6 |
490 | (defbinding entry-completion-insert-prefix () nil |
491 | (completion entry-completion)) |
492 | |
493 | (defbinding entry-completion-insert-action-text () nil |
494 | (completion entry-completion) |
495 | (index int) |
496 | (text string)) |
497 | |
498 | (defbinding entry-completion-insert-action-markup () nil |
499 | (completion entry-completion) |
500 | (index int) |
501 | (markup string)) |
502 | |
503 | (defbinding entry-completion-delete-action () nil |
504 | (completion entry-completion) |
505 | (index int)) |
506 | |
507 | |
1047e159 |
508 | ;;; Image |
509 | |
510 | (defbinding image-set-from-file () nil |
511 | (image image) |
512 | (filename pathname)) |
513 | |
514 | (defbinding image-set-from-pixmap () nil |
515 | (image image) |
516 | (pixmap gdk:pixmap) |
517 | (mask gdk:bitmap)) |
518 | |
519 | (defbinding image-set-from-stock () nil |
520 | (image image) |
521 | (stock-id string) |
522 | (icon-size icon-size)) |
523 | |
524 | (defun image-set-from-pixmap-data (image pixmap-data) |
525 | (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap-data) |
526 | (image-set-from-pixmap image pixmap mask))) |
527 | |
528 | (defun image-set-from-source (image source) |
529 | (etypecase source |
530 | (pathname (image-set-from-file image source)) |
531 | (string (if (stock-lookup source) |
532 | (setf (image-stock image) source) |
533 | (image-set-from-file image source))) |
534 | (vector (image-set-from-pixmap-data image source)))) |
535 | |
536 | |
537 | (defmethod shared-initialize ((image image) names &rest initargs |
538 | &key file pixmap source) |
539 | (prog1 |
540 | (if (vectorp pixmap) |
541 | (progn |
542 | (remf initargs :pixmap) |
543 | (apply #'call-next-method image names initargs)) |
544 | (call-next-method)) |
545 | (cond |
546 | (file (image-set-from-file image file)) |
547 | ((vectorp pixmap) (image-set-from-pixmap-data image pixmap)) |
548 | (source (image-set-from-source image source))))) |
549 | |
560af5c5 |
550 | |
0f476ab5 |
551 | ;;; Label |
560af5c5 |
552 | |
aaa6e6cb |
553 | (defbinding label-get-layout-offsets () nil |
1047e159 |
554 | (label label) |
aaa6e6cb |
555 | (x int :out) |
556 | (y int :out)) |
557 | |
0f476ab5 |
558 | (defbinding label-select-region () nil |
559 | (label label) |
560 | (start int) |
561 | (end int)) |
560af5c5 |
562 | |
1047e159 |
563 | (defbinding label-get-text () string |
aaa6e6cb |
564 | (label label)) |
565 | |
60e5d937 |
566 | (defbinding label-get-layout () pango:layout |
aaa6e6cb |
567 | (label label)) |
568 | |
1047e159 |
569 | (defbinding label-get-selection-bounds () boolean |
aaa6e6cb |
570 | (label label) |
571 | (start int :out) |
572 | (end int :out)) |
f36ca6af |
573 | |
560af5c5 |
574 | |
575 | |
576 | ;;; Radio button |
577 | |
e5b416f0 |
578 | (defbinding %radio-button-get-group () pointer |
d520140e |
579 | (radio-button radio-button)) |
580 | |
bbaeff4b |
581 | (defbinding %radio-button-set-group () nil |
d520140e |
582 | (radio-button radio-button) |
583 | (group pointer)) |
560af5c5 |
584 | |
d520140e |
585 | (defun radio-button-add-to-group (button1 button2) |
586 | "Add BUTTON1 to the group which BUTTON2 belongs to." |
587 | (%radio-button-set-group button1 (%radio-button-get-group button2))) |
588 | |
e5b416f0 |
589 | |
d520140e |
590 | (defmethod initialize-instance ((button radio-button) |
e5b416f0 |
591 | &rest initargs &key group-with) |
592 | (declare (ignore initargs)) |
d520140e |
593 | (call-next-method) |
e5b416f0 |
594 | (when group-with |
f5b67f2b |
595 | (radio-button-add-to-group button group-with))) |
560af5c5 |
596 | |
597 | |
560af5c5 |
598 | ;;; Item |
599 | |
bbaeff4b |
600 | (defbinding item-select () nil |
560af5c5 |
601 | (item item)) |
602 | |
bbaeff4b |
603 | (defbinding item-deselect () nil |
560af5c5 |
604 | (item item)) |
605 | |
bbaeff4b |
606 | (defbinding item-toggle () nil |
560af5c5 |
607 | (item item)) |
608 | |
609 | |
610 | |
611 | ;;; Menu item |
612 | |
f36ca6af |
613 | (defun (setf menu-item-label) (label menu-item) |
614 | (make-instance 'accel-label |
615 | :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item |
616 | :visible t :parent menu-item) |
617 | label) |
560af5c5 |
618 | |
f5b67f2b |
619 | (defun menu-item-label (menu-item) |
620 | (with-slots (child) menu-item |
621 | (when (typep child 'label) |
622 | (label-label child)))) |
623 | |
bbaeff4b |
624 | (defbinding %menu-item-set-submenu () nil |
f36ca6af |
625 | (menu-item menu-item) |
626 | (submenu menu)) |
560af5c5 |
627 | |
bbaeff4b |
628 | (defbinding %menu-item-remove-submenu () nil |
f36ca6af |
629 | (menu-item menu-item)) |
560af5c5 |
630 | |
f36ca6af |
631 | (defun (setf menu-item-submenu) (submenu menu-item) |
632 | (if (not submenu) |
633 | (%menu-item-remove-submenu menu-item) |
634 | (%menu-item-set-submenu menu-item submenu)) |
635 | submenu) |
560af5c5 |
636 | |
f5b67f2b |
637 | (defbinding menu-item-set-accel-path () nil |
638 | (menu-item menu-item) |
639 | (accel-path string)) |
640 | |
bbaeff4b |
641 | (defbinding menu-item-select () nil |
f36ca6af |
642 | (menu-item menu-item)) |
560af5c5 |
643 | |
bbaeff4b |
644 | (defbinding menu-item-deselect () nil |
f36ca6af |
645 | (menu-item menu-item)) |
560af5c5 |
646 | |
bbaeff4b |
647 | (defbinding menu-item-activate () nil |
f36ca6af |
648 | (menu-item menu-item)) |
560af5c5 |
649 | |
f5b67f2b |
650 | (defbinding menu-item-toggle-size-request () nil |
651 | (menu-item menu-item) |
652 | (requisition int :out)) |
653 | |
654 | (defbinding menu-item-toggle-size-allocate () nil |
655 | (menu-item menu-item) |
656 | (allocation int)) |
657 | |
560af5c5 |
658 | |
659 | |
f36ca6af |
660 | ;;; Radio menu item |
560af5c5 |
661 | |
e5b416f0 |
662 | (defbinding %radio-menu-item-get-group () pointer |
d520140e |
663 | (radio-menu-item radio-menu-item)) |
664 | |
bbaeff4b |
665 | (defbinding %radio-menu-item-set-group () nil |
d520140e |
666 | (radio-menu-item radio-menu-item) |
667 | (group pointer)) |
668 | |
d520140e |
669 | (defun radio-menu-item-add-to-group (item1 item2) |
670 | "Add ITEM1 to the group which ITEM2 belongs to." |
671 | (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2))) |
672 | |
673 | (defmethod initialize-instance ((item radio-menu-item) |
e5b416f0 |
674 | &rest initargs &key group-with) |
675 | (declare (ignore initargs)) |
f5b67f2b |
676 | (prog1 |
677 | (call-next-method) |
678 | (when group-with |
679 | (radio-menu-item-add-to-group item group-with)))) |
d520140e |
680 | |
560af5c5 |
681 | |
682 | |
aaa6e6cb |
683 | ;;; Toggle button |
684 | |
685 | (defbinding toggle-button-toggled () nil |
686 | (toggle-button toggle-button)) |
687 | |
688 | |
689 | |
560af5c5 |
690 | ;;; Window |
691 | |
c49be931 |
692 | (defmethod initialize-instance ((window window) &rest initargs |
693 | &key accel-group accel-groups) |
694 | (declare (ignore accel-group accel-groups)) |
695 | (prog1 |
696 | (call-next-method) |
697 | (initial-add window #'window-add-accel-group |
698 | initargs :accel-group :accel-groups))) |
73d58e01 |
699 | |
700 | |
7625ebd8 |
701 | (defbinding window-set-wmclass () nil |
560af5c5 |
702 | (window window) |
703 | (wmclass-name string) |
704 | (wmclass-class string)) |
705 | |
bbaeff4b |
706 | (defbinding window-add-accel-group () nil |
560af5c5 |
707 | (window window) |
708 | (accel-group accel-group)) |
709 | |
bbaeff4b |
710 | (defbinding window-remove-accel-group () nil |
560af5c5 |
711 | (window window) |
712 | (accel-group accel-group)) |
713 | |
bbaeff4b |
714 | (defbinding window-activate-focus () int |
560af5c5 |
715 | (window window)) |
716 | |
bbaeff4b |
717 | (defbinding window-activate-default () int |
560af5c5 |
718 | (window window)) |
719 | |
7625ebd8 |
720 | (defbinding window-set-default-size (window width height) int |
560af5c5 |
721 | (window window) |
7625ebd8 |
722 | ((or width -1) int) |
723 | ((or height -1) int)) |
560af5c5 |
724 | |
bbaeff4b |
725 | ;(defbinding window-set-geometry-hints) |
560af5c5 |
726 | |
73d58e01 |
727 | (defbinding window-list-toplevels () (glist (copy-of window)) |
728 | "Returns a list of all existing toplevel windows.") |
7625ebd8 |
729 | |
730 | (defbinding window-add-mnemonic (window key target) nil |
731 | (window window) |
732 | ((gdk:keyval-from-name key) unsigned-int) |
733 | (target widget)) |
734 | |
735 | (defbinding window-remove-mnemonic (window key target) nil |
736 | (window window) |
737 | ((gdk:keyval-from-name key) unsigned-int) |
738 | (target widget)) |
739 | |
740 | (defbinding window-mnemonic-activate (window key modifier) nil |
741 | (window window) |
742 | ((gdk:keyval-from-name key) unsigned-int) |
743 | (modifier gdk:modifier-type)) |
744 | |
745 | (defbinding window-present () nil |
746 | (window window)) |
747 | |
748 | (defbinding window-iconify () nil |
749 | (window window)) |
750 | |
751 | (defbinding window-deiconify () nil |
752 | (window window)) |
753 | |
754 | (defbinding window-stick () nil |
755 | (window window)) |
756 | |
757 | (defbinding window-unstick () nil |
758 | (window window)) |
759 | |
760 | (defbinding window-maximize () nil |
761 | (window window)) |
762 | |
763 | (defbinding window-unmaximize () nil |
764 | (window window)) |
765 | |
766 | (defbinding window-begin-resize-drag () nil |
767 | (window window) |
768 | (edge gdk:window-edge) |
769 | (button int) |
770 | (root-x int) (root-y int) |
9adccb27 |
771 | (timestamp unsigned-int)) |
7625ebd8 |
772 | |
773 | (defbinding window-begin-move-drag () nil |
774 | (window window) |
775 | (edge gdk:window-edge) |
776 | (button int) |
777 | (root-x int) (root-y int) |
9adccb27 |
778 | (timestamp unsigned-int)) |
7625ebd8 |
779 | |
780 | (defbinding window-set-frame-dimensions () nil |
781 | (window window) |
782 | (left int) (top int) (rigth int) (bottom int)) |
783 | |
784 | (defbinding (window-default-icons "gtk_window_get_default_icon_list") |
785 | () (glist gdk:pixbuf)) |
786 | |
787 | (defbinding %window-get-default-size () nil |
788 | (window window) |
789 | (width int :out) |
790 | (height int :out)) |
791 | |
792 | (defun window-get-default-size (window) |
793 | (multiple-value-bind (width height) (%window-get-default-size window) |
794 | (values (unless (= width -1) width) (unless (= height -1) height)))) |
795 | |
796 | (defbinding window-get-frame-dimensions () nil |
797 | (window window) |
798 | (left int :out) (top int :out) (rigth int :out) (bottom int :out)) |
799 | |
800 | (defbinding %window-get-icon-list () (glist gdk:pixbuf) |
801 | (window window)) |
802 | |
803 | (defmethod window-icon ((window window)) |
804 | (let ((icon-list (%window-get-icon-list window))) |
805 | (if (endp (rest icon-list)) |
806 | (first icon-list) |
807 | icon-list))) |
808 | |
809 | (defbinding window-get-position () nil |
810 | (window window) |
811 | (root-x int :out) |
812 | (root-y int :out)) |
813 | |
814 | (defbinding window-get-size () nil |
815 | (window window) |
816 | (width int :out) |
817 | (height int :out)) |
818 | |
819 | (defbinding window-move () nil |
820 | (window window) |
821 | (x int) |
822 | (y int)) |
823 | |
824 | (defbinding window-parse-geometry () boolean |
825 | (window window) |
826 | (geometry string)) |
827 | |
828 | (defbinding window-reshow-with-initial-size () nil |
829 | (window window)) |
830 | |
831 | (defbinding window-resize () nil |
832 | (window window) |
833 | (width int) |
834 | (heigth int)) |
835 | |
836 | (defbinding %window-set-icon-list () nil |
837 | (window window) |
838 | (icon-list (glist gdk:pixbuf))) |
839 | |
840 | (defmethod (setf window-icon) (icon (window window)) |
841 | (%window-set-icon-list window (mklist icon))) |
842 | |
843 | |
560af5c5 |
844 | |
845 | |
1047e159 |
846 | ;;; File chooser |
560af5c5 |
847 | |
560af5c5 |
848 | |
560af5c5 |
849 | |
850 | |
f36ca6af |
851 | ;;; Scrolled window |
560af5c5 |
852 | |
560af5c5 |
853 | (defun (setf scrolled-window-scrollbar-policy) (policy window) |
854 | (setf (scrolled-window-hscrollbar-policy window) policy) |
855 | (setf (scrolled-window-vscrollbar-policy window) policy)) |
856 | |
bbaeff4b |
857 | (defbinding scrolled-window-add-with-viewport () nil |
560af5c5 |
858 | (scrolled-window scrolled-window) |
859 | (child widget)) |
860 | |
861 | |
862 | |
d520140e |
863 | |
864 | |
865 | |
560af5c5 |
866 | |
f36ca6af |
867 | ;;; Statusbar |
560af5c5 |
868 | |
bbaeff4b |
869 | (defbinding (statusbar-context-id "gtk_statusbar_get_context_id") |
870 | () unsigned-int |
f36ca6af |
871 | (statusbar statusbar) |
872 | (context-description string)) |
560af5c5 |
873 | |
bbaeff4b |
874 | (defbinding statusbar-push () unsigned-int |
f36ca6af |
875 | (statusbar statusbar) |
876 | (context-id unsigned-int) |
877 | (text string)) |
560af5c5 |
878 | |
bbaeff4b |
879 | (defbinding statusbar-pop () nil |
f36ca6af |
880 | (statusbar statusbar) |
881 | (context-id unsigned-int)) |
560af5c5 |
882 | |
bbaeff4b |
883 | (defbinding statusbar-remove () nil |
f36ca6af |
884 | (statusbar statusbar) |
885 | (context-id unsigned-int) |
886 | (message-id unsigned-int)) |
560af5c5 |
887 | |
560af5c5 |
888 | |
889 | |
890 | ;;; Fixed |
891 | |
bbaeff4b |
892 | (defbinding fixed-put () nil |
f36ca6af |
893 | (fixed fixed) |
894 | (widget widget) |
f5b67f2b |
895 | (x int) (y int)) |
560af5c5 |
896 | |
bbaeff4b |
897 | (defbinding fixed-move () nil |
f36ca6af |
898 | (fixed fixed) |
899 | (widget widget) |
f5b67f2b |
900 | (x int) (y int)) |
560af5c5 |
901 | |
902 | |
903 | |
d520140e |
904 | ;;; Notebook |
560af5c5 |
905 | |
f5b67f2b |
906 | (defun %notebook-position (notebook page) |
907 | (etypecase page |
908 | (int page) |
909 | (keyword (case page |
910 | (:first 0) |
911 | (:last -1) |
1047e159 |
912 | (t (error "Invalid position keyword: ~A" page)))) |
f5b67f2b |
913 | (widget (notebook-page-num notebook page t)))) |
914 | |
915 | (defun %notebook-child (notebook position) |
916 | (typecase position |
917 | (widget position) |
918 | (t (notebook-nth-page-child notebook position)))) |
919 | |
920 | |
921 | (defbinding (notebook-insert "gtk_notebook_insert_page_menu") |
f36ca6af |
922 | (notebook position child tab-label &optional menu-label) nil |
923 | (notebook notebook) |
924 | (child widget) |
925 | ((if (stringp tab-label) |
f5b67f2b |
926 | (make-instance 'label :label tab-label) |
f36ca6af |
927 | tab-label) widget) |
928 | ((if (stringp menu-label) |
f5b67f2b |
929 | (make-instance 'label :label menu-label) |
f36ca6af |
930 | menu-label) (or null widget)) |
f5b67f2b |
931 | ((%notebook-position notebook position) int)) |
560af5c5 |
932 | |
f5b67f2b |
933 | (defun notebook-append (notebook child tab-label &optional menu-label) |
934 | (notebook-insert notebook :last child tab-label menu-label)) |
560af5c5 |
935 | |
f5b67f2b |
936 | (defun notebook-prepend (notebook child tab-label &optional menu-label) |
937 | (notebook-insert notebook :first child tab-label menu-label)) |
560af5c5 |
938 | |
f5b67f2b |
939 | (defbinding notebook-remove-page (notebook page) nil |
f36ca6af |
940 | (notebook notebook) |
1047e159 |
941 | ((%notebook-position notebook page) int)) |
560af5c5 |
942 | |
bbaeff4b |
943 | (defbinding %notebook-page-num () int |
f36ca6af |
944 | (notebook notebook) |
945 | (child widget)) |
946 | |
f5b67f2b |
947 | (defun notebook-page-num (notebook child &optional error-p) |
f36ca6af |
948 | (let ((page-num (%notebook-page-num notebook child))) |
949 | (if (= page-num -1) |
f5b67f2b |
950 | (when error-p |
951 | (error "~A is not a child of ~A" child notebook)) |
f36ca6af |
952 | page-num))) |
953 | |
bbaeff4b |
954 | (defbinding notebook-next-page () nil |
f36ca6af |
955 | (notebook notebook)) |
560af5c5 |
956 | |
bbaeff4b |
957 | (defbinding notebook-prev-page () nil |
f36ca6af |
958 | (notebook notebook)) |
959 | |
f5b67f2b |
960 | (defbinding notebook-reorder-child (notebook child position) nil |
961 | (notebook notebook) |
962 | (child widget) |
963 | ((%notebook-position notebook position) int)) |
964 | |
bbaeff4b |
965 | (defbinding notebook-popup-enable () nil |
f36ca6af |
966 | (notebook notebook)) |
967 | |
bbaeff4b |
968 | (defbinding notebook-popup-disable () nil |
f36ca6af |
969 | (notebook notebook)) |
970 | |
f5b67f2b |
971 | (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") |
972 | (notebook page) widget |
973 | (notebook notebook) |
974 | ((case page |
975 | (:first 0) |
976 | (:last -1) |
977 | (t page)) int)) |
978 | |
1047e159 |
979 | |
980 | (defbinding %notebook-get-current-page () int |
f5b67f2b |
981 | (notebook notebook)) |
982 | |
1047e159 |
983 | (defun notebook-current-page-num (notebook) |
984 | (let ((num (%notebook-get-current-page notebook))) |
985 | (when (>= num 0) |
986 | num))) |
987 | |
f5b67f2b |
988 | (defun notebook-current-page (notebook) |
1047e159 |
989 | (let ((page-num (notebook-current-page-num notebook))) |
990 | (when page-num |
991 | (notebook-nth-page-child notebook page-num)))) |
f5b67f2b |
992 | |
993 | (defbinding %notebook-set-current-page () nil |
994 | (notebook notebook) |
995 | (page-num int)) |
996 | |
997 | (defun (setf notebook-current-page) (page notebook) |
998 | (%notebook-set-current-page notebook (%notebook-position notebook page)) |
999 | page) |
1000 | |
1001 | |
1047e159 |
1002 | (defbinding (notebook-tab-label "gtk_notebook_get_tab_label") |
1003 | (notebook page) widget |
1004 | (notebook notebook) |
1005 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
1006 | |
1047e159 |
1007 | (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text") |
6bb23851 |
1008 | (notebook page) (copy-of string) |
1047e159 |
1009 | (notebook notebook) |
1010 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
1011 | |
1047e159 |
1012 | (defbinding %notebook-set-tab-label () nil |
1013 | (notebook notebook) |
1014 | (page widget) |
1015 | (tab-label widget)) |
1016 | |
1017 | (defun (setf notebook-tab-label) (tab-label notebook page) |
1018 | (let ((widget (if (stringp tab-label) |
1019 | (make-instance 'label :label tab-label) |
1020 | tab-label))) |
1021 | (%notebook-set-tab-label notebook (%notebook-child notebook page) widget) |
1022 | widget)) |
f5b67f2b |
1023 | |
f5b67f2b |
1024 | |
1047e159 |
1025 | (defbinding (notebook-menu-label "gtk_notebook_get_menu_label") |
1026 | (notebook page) widget |
1027 | (notebook notebook) |
1028 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
1029 | |
1047e159 |
1030 | (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text") |
6bb23851 |
1031 | (notebook page) (copy-of string) |
1047e159 |
1032 | (notebook notebook) |
1033 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
1034 | |
1047e159 |
1035 | (defbinding %notebook-set-menu-label () nil |
1036 | (notebook notebook) |
1037 | (page widget) |
1038 | (menu-label widget)) |
1039 | |
1040 | (defun (setf notebook-menu-label) (menu-label notebook page) |
1041 | (let ((widget (if (stringp menu-label) |
1042 | (make-instance 'label :label menu-label) |
1043 | menu-label))) |
1044 | (%notebook-set-menu-label notebook (%notebook-child notebook page) widget) |
1045 | widget)) |
f5b67f2b |
1046 | |
1047 | |
1048 | (defbinding notebook-query-tab-label-packing (notebook page) nil |
f36ca6af |
1049 | (notebook notebook) |
f5b67f2b |
1050 | ((%notebook-child notebook page) widget) |
f36ca6af |
1051 | (expand boolean :out) |
1052 | (fill boolean :out) |
1053 | (pack-type pack-type :out)) |
1054 | |
f5b67f2b |
1055 | (defbinding notebook-set-tab-label-packing |
1056 | (notebook page expand fill pack-type) nil |
f36ca6af |
1057 | (notebook notebook) |
f5b67f2b |
1058 | ((%notebook-child notebook page) widget) |
f36ca6af |
1059 | (expand boolean) |
1060 | (fill boolean) |
1061 | (pack-type pack-type)) |
1062 | |
560af5c5 |
1063 | |
1064 | |
d520140e |
1065 | ;;; Paned |
560af5c5 |
1066 | |
bbaeff4b |
1067 | (defbinding paned-pack1 () nil |
d520140e |
1068 | (paned paned) |
1069 | (child widget) |
1070 | (resize boolean) |
1071 | (shrink boolean)) |
560af5c5 |
1072 | |
bbaeff4b |
1073 | (defbinding paned-pack2 () nil |
d520140e |
1074 | (paned paned) |
1075 | (child widget) |
1076 | (resize boolean) |
1077 | (shrink boolean)) |
560af5c5 |
1078 | |
560af5c5 |
1079 | |
d520140e |
1080 | ;;; Layout |
560af5c5 |
1081 | |
bbaeff4b |
1082 | (defbinding layout-put () nil |
d520140e |
1083 | (layout layout) |
1084 | (widget widget) |
1085 | (x int) |
1086 | (y int)) |
560af5c5 |
1087 | |
bbaeff4b |
1088 | (defbinding layout-move () nil |
d520140e |
1089 | (layout layout) |
1090 | (widget widget) |
1091 | (x int) |
1092 | (y int)) |
560af5c5 |
1093 | |
560af5c5 |
1094 | |
1095 | |
560af5c5 |
1096 | ;;; Menu shell |
1097 | |
f5b67f2b |
1098 | (defbinding menu-shell-insert (menu-shell menu-item position) nil |
f36ca6af |
1099 | (menu-shell menu-shell) |
1100 | (menu-item menu-item) |
f5b67f2b |
1101 | ((case position |
1102 | (:first 0) |
1103 | (:last -1) |
1104 | (t position)) int)) |
560af5c5 |
1105 | |
f36ca6af |
1106 | (defun menu-shell-append (menu-shell menu-item) |
f5b67f2b |
1107 | (menu-shell-insert menu-shell menu-item :last)) |
560af5c5 |
1108 | |
f36ca6af |
1109 | (defun menu-shell-prepend (menu-shell menu-item) |
f5b67f2b |
1110 | (menu-shell-insert menu-shell menu-item :fisrt)) |
560af5c5 |
1111 | |
bbaeff4b |
1112 | (defbinding menu-shell-deactivate () nil |
f36ca6af |
1113 | (menu-shell menu-shell)) |
560af5c5 |
1114 | |
bbaeff4b |
1115 | (defbinding menu-shell-select-item () nil |
f36ca6af |
1116 | (menu-shell menu-shell) |
1117 | (menu-item menu-item)) |
560af5c5 |
1118 | |
bbaeff4b |
1119 | (defbinding menu-shell-deselect () nil |
f36ca6af |
1120 | (menu-shell menu-shell)) |
560af5c5 |
1121 | |
bbaeff4b |
1122 | (defbinding menu-shell-activate-item () nil |
f36ca6af |
1123 | (menu-shell menu-shell) |
1124 | (menu-item menu-item) |
1125 | (fore-deactivate boolean)) |
560af5c5 |
1126 | |
1127 | |
1128 | |
f5b67f2b |
1129 | ;;; Menu |
560af5c5 |
1130 | |
f5b67f2b |
1131 | (defun %menu-position (menu child) |
1132 | (etypecase child |
1133 | (int child) |
1134 | (keyword (case child |
1135 | (:first 0) |
1136 | (:last -1) |
1047e159 |
1137 | (t (error "Invalid position keyword: ~A" child)))) |
f5b67f2b |
1138 | (widget (menu-child-position menu child)))) |
560af5c5 |
1139 | |
1140 | |
f5b67f2b |
1141 | (defbinding menu-reorder-child (menu menu-item position) nil |
1142 | (menu menu) |
1143 | (menu-item menu-item) |
1144 | ((%menu-position menu position) int)) |
560af5c5 |
1145 | |
8755b1a5 |
1146 | (def-callback-marshal %menu-popup-callback (nil (x int) (y int) (push-in boolean))) |
560af5c5 |
1147 | |
f5b67f2b |
1148 | (defbinding %menu-popup () nil |
1149 | (menu menu) |
1150 | (parent-menu-shell (or null menu-shell)) |
1151 | (parent-menu-item (or null menu-item)) |
1152 | (callback-func (or null pointer)) |
1153 | (callback-id unsigned-int) |
1154 | (button unsigned-int) |
1155 | (activate-time (unsigned 32))) |
1156 | |
1157 | (defun menu-popup (menu button activate-time &key callback parent-menu-shell |
1158 | parent-menu-item) |
1159 | (if callback |
1a1949c7 |
1160 | (with-callback-function (id callback) |
1161 | (%menu-popup |
1162 | menu parent-menu-shell parent-menu-item |
1163 | (callback %menu-popup-callback) id button activate-time)) |
f5b67f2b |
1164 | (%menu-popup |
1165 | menu parent-menu-shell parent-menu-item nil 0 button activate-time))) |
1166 | |
1167 | (defbinding menu-set-accel-path () nil |
1168 | (menu menu) |
1169 | (accel-path string)) |
560af5c5 |
1170 | |
bbaeff4b |
1171 | (defbinding menu-reposition () nil |
f36ca6af |
1172 | (menu menu)) |
560af5c5 |
1173 | |
bbaeff4b |
1174 | (defbinding menu-popdown () nil |
f36ca6af |
1175 | (menu menu)) |
560af5c5 |
1176 | |
f5b67f2b |
1177 | (defun menu-child-position (menu child) |
1178 | (position child (container-children menu))) |
1179 | |
1180 | (defun menu-active-num (menu) |
1181 | (menu-child-position menu (menu-active menu))) |
1182 | |
bbaeff4b |
1183 | (defbinding %menu-set-active () nil |
f36ca6af |
1184 | (menu menu) |
1185 | (index unsigned-int)) |
560af5c5 |
1186 | |
f5b67f2b |
1187 | (defun (setf menu-active) (menu child) |
1188 | (%menu-set-active menu (%menu-position menu child)) |
1189 | child) |
d520140e |
1190 | |
560af5c5 |
1191 | |
1192 | |
f36ca6af |
1193 | ;;; Table |
560af5c5 |
1194 | |
bbaeff4b |
1195 | (defbinding table-resize () nil |
f36ca6af |
1196 | (table table) |
1197 | (rows unsigned-int) |
1198 | (columns unsigned-int)) |
560af5c5 |
1199 | |
bbaeff4b |
1200 | (defbinding table-attach (table child left right top bottom |
c49be931 |
1201 | &key options x-options y-options |
1202 | (x-padding 0) (y-padding 0)) nil |
f36ca6af |
1203 | (table table) |
1204 | (child widget) |
1205 | (left unsigned-int) |
1206 | (right unsigned-int) |
1207 | (top unsigned-int) |
1208 | (bottom unsigned-int) |
c49be931 |
1209 | ((append (mklist options) (mklist x-options)) attach-options) |
1210 | ((append (mklist options) (mklist y-options)) attach-options) |
f36ca6af |
1211 | (x-padding unsigned-int) |
1212 | (y-padding unsigned-int)) |
1213 | |
e5b416f0 |
1214 | |
bbaeff4b |
1215 | (defbinding %table-set-row-spacing () nil |
f36ca6af |
1216 | (table table) |
1217 | (row unsigned-int) |
1218 | (spacing unsigned-int)) |
1219 | |
e5b416f0 |
1220 | (defbinding %table-set-row-spacings () nil |
1221 | (table table) |
1222 | (spacing unsigned-int)) |
1223 | |
1224 | (defun (setf table-row-spacing) (spacing table &optional row) |
1225 | (if row |
1226 | (%table-set-row-spacing table row spacing) |
1227 | (%table-set-row-spacings table spacing)) |
f36ca6af |
1228 | spacing) |
1229 | |
e5b416f0 |
1230 | (defbinding %table-get-row-spacing () unsigned-int |
f36ca6af |
1231 | (table table) |
e5b416f0 |
1232 | (row unsigned-int)) |
1233 | |
1234 | (defbinding %table-get-default-row-spacing () unsigned-int |
1235 | (table table)) |
1236 | |
1237 | (defun table-row-spacing (table &optional row) |
1238 | (if row |
1239 | (%table-get-row-spacing table row) |
1240 | (%table-get-default-row-spacing table))) |
1241 | |
f36ca6af |
1242 | |
bbaeff4b |
1243 | (defbinding %table-set-col-spacing () nil |
f36ca6af |
1244 | (table table) |
1245 | (col unsigned-int) |
1246 | (spacing unsigned-int)) |
1247 | |
e5b416f0 |
1248 | (defbinding %table-set-col-spacings () nil |
1249 | (table table) |
1250 | (spacing unsigned-int)) |
1251 | |
1252 | (defun (setf table-col-spacing) (spacing table &optional col) |
1253 | (if col |
1254 | (%table-set-col-spacing table col spacing) |
1255 | (%table-set-col-spacings table spacing)) |
f36ca6af |
1256 | spacing) |
1257 | |
e5b416f0 |
1258 | (defbinding %table-get-col-spacing () unsigned-int |
f36ca6af |
1259 | (table table) |
e5b416f0 |
1260 | (col unsigned-int)) |
1261 | |
1262 | (defbinding %table-get-default-col-spacing () unsigned-int |
1263 | (table table)) |
1264 | |
1265 | (defun table-col-spacing (table &optional col) |
1266 | (if col |
1267 | (%table-get-col-spacing table col) |
1268 | (%table-get-default-col-spacing table))) |
1269 | |
1270 | |
f36ca6af |
1271 | |
1272 | ;;; Toolbar |
1273 | |
bbaeff4b |
1274 | (defbinding %toolbar-insert-element () widget |
f36ca6af |
1275 | (toolbar toolbar) |
1276 | (type toolbar-child-type) |
1277 | (widget (or null widget)) |
1278 | (text string) |
1279 | (tooltip-text string) |
1280 | (tooltip-private-text string) |
1281 | (icon (or null widget)) |
1282 | (nil null) |
1283 | (nil null) |
1284 | (position int)) |
560af5c5 |
1285 | |
f5b67f2b |
1286 | (defbinding %toolbar-insert-stock () widget |
1287 | (toolbar toolbar) |
1288 | (stock-id string) |
1289 | (tooltip-text string) |
1290 | (tooltip-private-text string) |
1291 | (nil null) |
1292 | (nil null) |
1293 | (position int)) |
1294 | |
1295 | (defun toolbar-insert (toolbar position element |
1296 | &key tooltip-text tooltip-private-text |
1297 | type icon group callback object) |
1298 | (let* ((numpos (case position |
1047e159 |
1299 | (:first -1) |
1300 | (:last 0) |
f5b67f2b |
1301 | (t position))) |
1302 | (widget |
1303 | (cond |
1304 | ((or |
1305 | (eq type :space) |
1306 | (and (not type) (eq element :space))) |
1307 | (%toolbar-insert-element |
1308 | toolbar :space nil nil |
1309 | tooltip-text tooltip-private-text nil numpos)) |
1310 | ((or |
1311 | (eq type :widget) |
1312 | (and (not type) (typep element 'widget))) |
1313 | (%toolbar-insert-element |
1314 | toolbar :widget element nil |
1315 | tooltip-text tooltip-private-text nil numpos)) |
1316 | ((or |
1317 | (eq type :stock) |
1318 | (and |
1319 | (not type) |
1320 | (typep element 'string) |
1321 | (stock-lookup element))) |
1322 | (%toolbar-insert-stock |
1323 | toolbar element tooltip-text tooltip-private-text numpos)) |
1324 | ((typep element 'string) |
1325 | (%toolbar-insert-element |
1326 | toolbar (or type :button) (when (eq type :radio-button) group) |
1047e159 |
1327 | element tooltip-text tooltip-private-text |
1328 | (etypecase icon |
1329 | (null nil) |
1330 | (widget icon) |
1331 | ((or pathname string vector) |
1332 | (make-instance 'image |
1333 | :source icon ; :icon-size (toolbar-icon-size toolbar) |
1334 | ))) |
1335 | numpos)) |
f5b67f2b |
1336 | ((error "Invalid element type: ~A" element))))) |
f36ca6af |
1337 | (when callback |
f5b67f2b |
1338 | (signal-connect widget 'clicked callback :object object)) |
1339 | widget)) |
f36ca6af |
1340 | |
f5b67f2b |
1341 | (defun toolbar-append (toolbar element &key tooltip-text tooltip-private-text |
1342 | type icon group callback object) |
1343 | (toolbar-insert |
1344 | toolbar :first element :type type :icon icon :group group |
f36ca6af |
1345 | :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text |
f5b67f2b |
1346 | :callback callback :object object)) |
f36ca6af |
1347 | |
f5b67f2b |
1348 | (defun toolbar-prepend (toolbar element &key tooltip-text tooltip-private-text |
1349 | type icon group callback object) |
1350 | (toolbar-insert |
1351 | toolbar :last element :type type :icon icon :group group |
f36ca6af |
1352 | :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text |
f5b67f2b |
1353 | :callback callback :object object)) |
1354 | |
f36ca6af |
1355 | |
1356 | (defun toolbar-insert-space (toolbar position) |
f5b67f2b |
1357 | (toolbar-insert toolbar position :space)) |
f36ca6af |
1358 | |
1359 | (defun toolbar-append-space (toolbar) |
f5b67f2b |
1360 | (toolbar-append toolbar :space)) |
f36ca6af |
1361 | |
1362 | (defun toolbar-prepend-space (toolbar) |
f5b67f2b |
1363 | (toolbar-prepend toolbar :space)) |
f36ca6af |
1364 | |
560af5c5 |
1365 | |
f36ca6af |
1366 | (defun toolbar-enable-tooltips (toolbar) |
1367 | (setf (toolbar-tooltips-p toolbar) t)) |
560af5c5 |
1368 | |
f36ca6af |
1369 | (defun toolbar-disable-tooltips (toolbar) |
1370 | (setf (toolbar-tooltips-p toolbar) nil)) |
560af5c5 |
1371 | |
1372 | |
f5b67f2b |
1373 | (defbinding toolbar-remove-space () nil |
1374 | (toolbar toolbar) |
1375 | (position int)) |
560af5c5 |
1376 | |
f5b67f2b |
1377 | (defbinding toolbar-unset-icon-size () nil |
1378 | (toolbar toolbar)) |
560af5c5 |
1379 | |
f5b67f2b |
1380 | (defbinding toolbar-unset-style () nil |
1381 | (toolbar toolbar)) |
560af5c5 |
1382 | |
1383 | |
bbaeff4b |
1384 | ;;; Editable |
1047e159 |
1385 | |
bbaeff4b |
1386 | (defbinding editable-select-region (editable &optional (start 0) end) nil |
f36ca6af |
1387 | (editable editable) |
1388 | (start int) |
1389 | ((or end -1) int)) |
560af5c5 |
1390 | |
1047e159 |
1391 | (defbinding editable-get-selection-bounds (editable) nil |
1392 | (editable editable) |
1393 | (start int :out) |
1394 | (end int :out)) |
1395 | |
bbaeff4b |
1396 | (defbinding editable-insert-text |
f36ca6af |
1397 | (editable text &optional (position 0)) nil |
1398 | (editable editable) |
1399 | (text string) |
1400 | ((length text) int) |
1401 | ((or position -1) int :in-out)) |
560af5c5 |
1402 | |
f36ca6af |
1403 | (defun editable-append-text (editable text) |
1404 | (editable-insert-text editable text nil)) |
560af5c5 |
1405 | |
f36ca6af |
1406 | (defun editable-prepend-text (editable text) |
1407 | (editable-insert-text editable text 0)) |
560af5c5 |
1408 | |
bbaeff4b |
1409 | (defbinding editable-delete-text (editable &optional (start 0) end) nil |
f36ca6af |
1410 | (editable editable) |
1411 | (start int) |
1412 | ((or end -1) int)) |
560af5c5 |
1413 | |
bbaeff4b |
1414 | (defbinding (editable-text "gtk_editable_get_chars") |
f36ca6af |
1415 | (editable &optional (start 0) end) string |
1416 | (editable editable) |
1417 | (start int) |
1418 | ((or end -1) int)) |
560af5c5 |
1419 | |
f36ca6af |
1420 | (defun (setf editable-text) (text editable) |
1421 | (if text |
1422 | (editable-delete-text |
1423 | editable |
1424 | (editable-insert-text editable text)) |
1425 | (editable-delete-text editable)) |
1426 | text) |
560af5c5 |
1427 | |
bbaeff4b |
1428 | (defbinding editable-cut-clipboard () nil |
f36ca6af |
1429 | (editable editable)) |
560af5c5 |
1430 | |
bbaeff4b |
1431 | (defbinding editable-copy-clipboard () nil |
f36ca6af |
1432 | (editable editable)) |
560af5c5 |
1433 | |
bbaeff4b |
1434 | (defbinding editable-paste-clipboard () nil |
f36ca6af |
1435 | (editable editable)) |
560af5c5 |
1436 | |
bbaeff4b |
1437 | (defbinding editable-delete-selection () nil |
f36ca6af |
1438 | (editable editable)) |
560af5c5 |
1439 | |
560af5c5 |
1440 | |
560af5c5 |
1441 | |
f36ca6af |
1442 | ;;; Spin button |
560af5c5 |
1443 | |
f36ca6af |
1444 | (defun spin-button-value-as-int (spin-button) |
1445 | (round (spin-button-value spin-button))) |
560af5c5 |
1446 | |
bbaeff4b |
1447 | (defbinding spin-button-spin () nil |
f36ca6af |
1448 | (spin-button spin-button) |
1449 | (direction spin-type) |
1450 | (increment single-float)) |
560af5c5 |
1451 | |
bbaeff4b |
1452 | (defbinding spin-button-update () nil |
f36ca6af |
1453 | (spin-button spin-button)) |
560af5c5 |
1454 | |
1455 | |
1456 | |
1457 | ; ;;; Ruler |
1458 | |
bbaeff4b |
1459 | (defbinding ruler-set-range () nil |
f36ca6af |
1460 | (ruler ruler) |
1461 | (lower single-float) |
1462 | (upper single-float) |
1463 | (position single-float) |
1464 | (max-size single-float)) |
560af5c5 |
1465 | |
bbaeff4b |
1466 | (defbinding ruler-draw-ticks () nil |
f36ca6af |
1467 | (ruler ruler)) |
560af5c5 |
1468 | |
bbaeff4b |
1469 | (defbinding ruler-draw-pos () nil |
f36ca6af |
1470 | (ruler ruler)) |
560af5c5 |
1471 | |
560af5c5 |
1472 | |
560af5c5 |
1473 | |
d520140e |
1474 | ;;; Range |
560af5c5 |
1475 | |
1047e159 |
1476 | (defun range-lower (range) |
1477 | (adjustment-lower (range-adjustment range))) |
560af5c5 |
1478 | |
1047e159 |
1479 | (defun range-upper (range) |
1480 | (adjustment-upper (range-adjustment range))) |
560af5c5 |
1481 | |
1047e159 |
1482 | (defun (setf range-lower) (value range) |
1483 | (setf (adjustment-lower (range-adjustment range)) value)) |
560af5c5 |
1484 | |
1047e159 |
1485 | (defun (setf range-upper) (value range) |
1486 | (setf (adjustment-upper (range-adjustment range)) value)) |
560af5c5 |
1487 | |
1047e159 |
1488 | (defun range-page-increment (range) |
1489 | (adjustment-page-increment (range-adjustment range))) |
560af5c5 |
1490 | |
1047e159 |
1491 | (defun range-step-increment (range) |
1492 | (adjustment-step-increment (range-adjustment range))) |
560af5c5 |
1493 | |
1047e159 |
1494 | (defun (setf range-page-increment) (value range) |
1495 | (setf (adjustment-page-increment (range-adjustment range)) value)) |
560af5c5 |
1496 | |
1047e159 |
1497 | (defun (setf range-step-increment) (value range) |
1498 | (setf (adjustment-step-increment (range-adjustment range)) value)) |
560af5c5 |
1499 | |
1047e159 |
1500 | (defbinding range-set-range () nil |
d520140e |
1501 | (range range) |
1047e159 |
1502 | (lower double-float) |
1503 | (upper double-float)) |
560af5c5 |
1504 | |
1047e159 |
1505 | (defbinding range-set-increments () nil |
d520140e |
1506 | (range range) |
1047e159 |
1507 | (step double-float) |
1508 | (page double-float)) |
560af5c5 |
1509 | |
560af5c5 |
1510 | |
d520140e |
1511 | ;;; Scale |
560af5c5 |
1512 | |
e5b416f0 |
1513 | ; (defbinding scale-draw-value () nil |
1514 | ; (scale scale)) |
560af5c5 |
1515 | |
560af5c5 |
1516 | |
560af5c5 |
1517 | |
d520140e |
1518 | ;;; Progress bar |
560af5c5 |
1519 | |
bbaeff4b |
1520 | (defbinding progress-bar-pulse () nil |
d520140e |
1521 | (progress-bar progress-bar)) |
560af5c5 |
1522 | |
1523 | |
c49be931 |
1524 | ;;; Size group |
1525 | |
1526 | (defmethod initialize-instance ((size-group size-group) &rest initargs |
1527 | &key widget widgets) |
1528 | (declare (ignore widget widgets)) |
1529 | (prog1 |
1530 | (call-next-method) |
1531 | (initial-add size-group #'size-group-add-widget |
1532 | initargs :widget :widgets))) |
1533 | |
1534 | |
1535 | (defbinding size-group-add-widget () nil |
1536 | (size-group size-group) |
1537 | (widget widget)) |
1538 | |
1539 | (defbinding size-group-remove-widget () nil |
1540 | (size-group size-group) |
1541 | (widget widget)) |
1542 | |
560af5c5 |
1543 | |
f5b67f2b |
1544 | ;;; Stock items |
1545 | |
73d58e01 |
1546 | (defbinding %stock-item-copy () pointer |
1547 | (location pointer)) |
1548 | |
1549 | (defbinding %stock-item-free () nil |
1550 | (location pointer)) |
f5b67f2b |
1551 | |
73d58e01 |
1552 | (defmethod reference-foreign ((class (eql (find-class 'stock-item))) location) |
1553 | (%stock-item-copy location)) |
1554 | |
1555 | (defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location) |
1556 | (%stock-item-free location)) |
1557 | |
1558 | (defbinding stock-add (stock-item) nil |
1559 | (stock-item stock-item) |
1560 | (1 unsigned-int)) |
1561 | |
1562 | (defbinding stock-list-ids () (gslist string)) |
1563 | |
1564 | (defbinding %stock-lookup () boolean |
1565 | (stock-id string) |
1566 | (location pointer)) |
1567 | |
1568 | (defun stock-lookup (stock-id) |
1569 | (let ((location |
1570 | (allocate-memory (proxy-instance-size (find-class 'stock-item))))) |
1571 | (unwind-protect |
1572 | (when (%stock-lookup stock-id location) |
1573 | (ensure-proxy-instance 'stock-item (%stock-item-copy location))) |
1574 | (deallocate-memory location)))) |
560af5c5 |
1575 | |
1576 | |
1577 | ;;; Tooltips |
1578 | |
bbaeff4b |
1579 | (defbinding tooltips-enable () nil |
d520140e |
1580 | (tooltips tooltips)) |
560af5c5 |
1581 | |
bbaeff4b |
1582 | (defbinding tooltips-disable () nil |
d520140e |
1583 | (tooltips tooltips)) |
560af5c5 |
1584 | |
e5b416f0 |
1585 | (defun (setf tooltips-enabled-p) (enable tooltips) |
1586 | (if enable |
1587 | (tooltips-enable tooltips) |
1588 | (tooltips-disable tooltips))) |
1589 | |
bbaeff4b |
1590 | (defbinding tooltips-set-tip () nil |
d520140e |
1591 | (tooltips tooltips) |
1592 | (widget widget) |
1593 | (tip-text string) |
1594 | (tip-private string)) |
560af5c5 |
1595 | |
bbaeff4b |
1596 | (defbinding tooltips-force-window () nil |
d520140e |
1597 | (tooltips tooltips)) |
560af5c5 |
1598 | |
1599 | |
1600 | |
d520140e |
1601 | ;;; Rc |
560af5c5 |
1602 | |
bbaeff4b |
1603 | (defbinding rc-add-default-file (filename) nil |
d520140e |
1604 | ((namestring (truename filename)) string)) |
560af5c5 |
1605 | |
bbaeff4b |
1606 | (defbinding rc-parse (filename) nil |
d520140e |
1607 | ((namestring (truename filename)) string)) |
560af5c5 |
1608 | |
bbaeff4b |
1609 | (defbinding rc-parse-string () nil |
d520140e |
1610 | (rc-string string)) |
560af5c5 |
1611 | |
bbaeff4b |
1612 | (defbinding rc-reparse-all () nil) |
560af5c5 |
1613 | |
bbaeff4b |
1614 | (defbinding rc-get-style () style |
d520140e |
1615 | (widget widget)) |
560af5c5 |
1616 | |
1617 | |
1618 | |
1619 | ;;; Accelerator Groups |
bbaeff4b |
1620 | #| |
bbaeff4b |
1621 | (defbinding accel-group-activate (accel-group key modifiers) boolean |
560af5c5 |
1622 | (accel-group accel-group) |
1623 | ((gdk:keyval-from-name key) unsigned-int) |
1624 | (modifiers gdk:modifier-type)) |
1625 | |
bbaeff4b |
1626 | (defbinding accel-groups-activate (object key modifiers) boolean |
560af5c5 |
1627 | (object object) |
1628 | ((gdk:keyval-from-name key) unsigned-int) |
1629 | (modifiers gdk:modifier-type)) |
1630 | |
bbaeff4b |
1631 | (defbinding accel-group-attach () nil |
560af5c5 |
1632 | (accel-group accel-group) |
1633 | (object object)) |
1634 | |
bbaeff4b |
1635 | (defbinding accel-group-detach () nil |
560af5c5 |
1636 | (accel-group accel-group) |
1637 | (object object)) |
1638 | |
bbaeff4b |
1639 | (defbinding accel-group-lock () nil |
560af5c5 |
1640 | (accel-group accel-group)) |
1641 | |
bbaeff4b |
1642 | (defbinding accel-group-unlock () nil |
560af5c5 |
1643 | (accel-group accel-group)) |
1644 | |
1645 | |
1646 | ;;; Accelerator Groups Entries |
1647 | |
bbaeff4b |
1648 | (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry |
560af5c5 |
1649 | (accel-group accel-group) |
1650 | ((gdk:keyval-from-name key) unsigned-int) |
1651 | (modifiers gdk:modifier-type)) |
1652 | |
bbaeff4b |
1653 | (defbinding accel-group-lock-entry (accel-group key modifiers) nil |
560af5c5 |
1654 | (accel-group accel-group) |
1655 | ((gdk:keyval-from-name key) unsigned-int) |
1656 | (modifiers gdk:modifier-type)) |
1657 | |
bbaeff4b |
1658 | (defbinding accel-group-unlock-entry (accel-group key modifiers) nil |
560af5c5 |
1659 | (accel-group accel-group) |
1660 | ((gdk:keyval-from-name key) unsigned-int) |
1661 | (modifiers gdk:modifier-type)) |
1662 | |
bbaeff4b |
1663 | (defbinding accel-group-add |
560af5c5 |
1664 | (accel-group key modifiers flags object signal) nil |
1665 | (accel-group accel-group) |
1666 | ((gdk:keyval-from-name key) unsigned-int) |
1667 | (modifiers gdk:modifier-type) |
1668 | (flags accel-flags) |
1669 | (object object) |
1670 | ((name-to-string signal) string)) |
1671 | |
bbaeff4b |
1672 | (defbinding accel-group-add (accel-group key modifiers object) nil |
560af5c5 |
1673 | (accel-group accel-group) |
1674 | ((gdk:keyval-from-name key) unsigned-int) |
1675 | (modifiers gdk:modifier-type) |
1676 | (object object)) |
1677 | |
1678 | |
1679 | ;;; Accelerator Signals |
1680 | |
bbaeff4b |
1681 | (defbinding accel-group-handle-add |
560af5c5 |
1682 | (object signal-id accel-group key modifiers flags) nil |
1683 | (object object) |
1684 | (signal-id unsigned-int) |
1685 | (accel-group accel-group) |
1686 | ((gdk:keyval-from-name key) unsigned-int) |
1687 | (modifiers gdk:modifier-type) |
1688 | (flags accel-flags)) |
1689 | |
bbaeff4b |
1690 | (defbinding accel-group-handle-remove |
560af5c5 |
1691 | (object accel-group key modifiers) nil |
1692 | (object object) |
1693 | (accel-group accel-group) |
1694 | ((gdk:keyval-from-name key) unsigned-int) |
1695 | (modifiers gdk:modifier-type)) |
bbaeff4b |
1696 | |# |