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 | |
c49be931 |
18 | ;; $Id: gtk.lisp,v 1.21 2004-12-16 23:49:53 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 | |
48da76bf |
456 | ;;; Drawing area -- no functions |
560af5c5 |
457 | |
458 | |
aaa6e6cb |
459 | ;;; Entry |
560af5c5 |
460 | |
60e5d937 |
461 | (defbinding entry-get-layout () pango:layout |
aaa6e6cb |
462 | (entry entry)) |
463 | |
464 | (defbinding entry-get-layout-offsets () nil |
465 | (entry entry) |
466 | (x int :out) |
467 | (y int :out)) |
560af5c5 |
468 | |
560af5c5 |
469 | |
1047e159 |
470 | ;;; Image |
471 | |
472 | (defbinding image-set-from-file () nil |
473 | (image image) |
474 | (filename pathname)) |
475 | |
476 | (defbinding image-set-from-pixmap () nil |
477 | (image image) |
478 | (pixmap gdk:pixmap) |
479 | (mask gdk:bitmap)) |
480 | |
481 | (defbinding image-set-from-stock () nil |
482 | (image image) |
483 | (stock-id string) |
484 | (icon-size icon-size)) |
485 | |
486 | (defun image-set-from-pixmap-data (image pixmap-data) |
487 | (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap-data) |
488 | (image-set-from-pixmap image pixmap mask))) |
489 | |
490 | (defun image-set-from-source (image source) |
491 | (etypecase source |
492 | (pathname (image-set-from-file image source)) |
493 | (string (if (stock-lookup source) |
494 | (setf (image-stock image) source) |
495 | (image-set-from-file image source))) |
496 | (vector (image-set-from-pixmap-data image source)))) |
497 | |
498 | |
499 | (defmethod shared-initialize ((image image) names &rest initargs |
500 | &key file pixmap source) |
501 | (prog1 |
502 | (if (vectorp pixmap) |
503 | (progn |
504 | (remf initargs :pixmap) |
505 | (apply #'call-next-method image names initargs)) |
506 | (call-next-method)) |
507 | (cond |
508 | (file (image-set-from-file image file)) |
509 | ((vectorp pixmap) (image-set-from-pixmap-data image pixmap)) |
510 | (source (image-set-from-source image source))))) |
511 | |
560af5c5 |
512 | |
0f476ab5 |
513 | ;;; Label |
560af5c5 |
514 | |
aaa6e6cb |
515 | (defbinding label-get-layout-offsets () nil |
1047e159 |
516 | (label label) |
aaa6e6cb |
517 | (x int :out) |
518 | (y int :out)) |
519 | |
0f476ab5 |
520 | (defbinding label-select-region () nil |
521 | (label label) |
522 | (start int) |
523 | (end int)) |
560af5c5 |
524 | |
1047e159 |
525 | (defbinding label-get-text () string |
aaa6e6cb |
526 | (label label)) |
527 | |
60e5d937 |
528 | (defbinding label-get-layout () pango:layout |
aaa6e6cb |
529 | (label label)) |
530 | |
1047e159 |
531 | (defbinding label-get-selection-bounds () boolean |
aaa6e6cb |
532 | (label label) |
533 | (start int :out) |
534 | (end int :out)) |
f36ca6af |
535 | |
560af5c5 |
536 | |
537 | |
538 | ;;; Radio button |
539 | |
e5b416f0 |
540 | (defbinding %radio-button-get-group () pointer |
d520140e |
541 | (radio-button radio-button)) |
542 | |
bbaeff4b |
543 | (defbinding %radio-button-set-group () nil |
d520140e |
544 | (radio-button radio-button) |
545 | (group pointer)) |
560af5c5 |
546 | |
d520140e |
547 | (defun radio-button-add-to-group (button1 button2) |
548 | "Add BUTTON1 to the group which BUTTON2 belongs to." |
549 | (%radio-button-set-group button1 (%radio-button-get-group button2))) |
550 | |
e5b416f0 |
551 | |
d520140e |
552 | (defmethod initialize-instance ((button radio-button) |
e5b416f0 |
553 | &rest initargs &key group-with) |
554 | (declare (ignore initargs)) |
d520140e |
555 | (call-next-method) |
e5b416f0 |
556 | (when group-with |
f5b67f2b |
557 | (radio-button-add-to-group button group-with))) |
560af5c5 |
558 | |
559 | |
560af5c5 |
560 | ;;; Item |
561 | |
bbaeff4b |
562 | (defbinding item-select () nil |
560af5c5 |
563 | (item item)) |
564 | |
bbaeff4b |
565 | (defbinding item-deselect () nil |
560af5c5 |
566 | (item item)) |
567 | |
bbaeff4b |
568 | (defbinding item-toggle () nil |
560af5c5 |
569 | (item item)) |
570 | |
571 | |
572 | |
573 | ;;; Menu item |
574 | |
f36ca6af |
575 | (defun (setf menu-item-label) (label menu-item) |
576 | (make-instance 'accel-label |
577 | :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item |
578 | :visible t :parent menu-item) |
579 | label) |
560af5c5 |
580 | |
f5b67f2b |
581 | (defun menu-item-label (menu-item) |
582 | (with-slots (child) menu-item |
583 | (when (typep child 'label) |
584 | (label-label child)))) |
585 | |
bbaeff4b |
586 | (defbinding %menu-item-set-submenu () nil |
f36ca6af |
587 | (menu-item menu-item) |
588 | (submenu menu)) |
560af5c5 |
589 | |
bbaeff4b |
590 | (defbinding %menu-item-remove-submenu () nil |
f36ca6af |
591 | (menu-item menu-item)) |
560af5c5 |
592 | |
f36ca6af |
593 | (defun (setf menu-item-submenu) (submenu menu-item) |
594 | (if (not submenu) |
595 | (%menu-item-remove-submenu menu-item) |
596 | (%menu-item-set-submenu menu-item submenu)) |
597 | submenu) |
560af5c5 |
598 | |
f5b67f2b |
599 | (defbinding menu-item-set-accel-path () nil |
600 | (menu-item menu-item) |
601 | (accel-path string)) |
602 | |
bbaeff4b |
603 | (defbinding menu-item-select () nil |
f36ca6af |
604 | (menu-item menu-item)) |
560af5c5 |
605 | |
bbaeff4b |
606 | (defbinding menu-item-deselect () nil |
f36ca6af |
607 | (menu-item menu-item)) |
560af5c5 |
608 | |
bbaeff4b |
609 | (defbinding menu-item-activate () nil |
f36ca6af |
610 | (menu-item menu-item)) |
560af5c5 |
611 | |
f5b67f2b |
612 | (defbinding menu-item-toggle-size-request () nil |
613 | (menu-item menu-item) |
614 | (requisition int :out)) |
615 | |
616 | (defbinding menu-item-toggle-size-allocate () nil |
617 | (menu-item menu-item) |
618 | (allocation int)) |
619 | |
560af5c5 |
620 | |
621 | |
f36ca6af |
622 | ;;; Radio menu item |
560af5c5 |
623 | |
e5b416f0 |
624 | (defbinding %radio-menu-item-get-group () pointer |
d520140e |
625 | (radio-menu-item radio-menu-item)) |
626 | |
bbaeff4b |
627 | (defbinding %radio-menu-item-set-group () nil |
d520140e |
628 | (radio-menu-item radio-menu-item) |
629 | (group pointer)) |
630 | |
d520140e |
631 | (defun radio-menu-item-add-to-group (item1 item2) |
632 | "Add ITEM1 to the group which ITEM2 belongs to." |
633 | (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2))) |
634 | |
635 | (defmethod initialize-instance ((item radio-menu-item) |
e5b416f0 |
636 | &rest initargs &key group-with) |
637 | (declare (ignore initargs)) |
f5b67f2b |
638 | (prog1 |
639 | (call-next-method) |
640 | (when group-with |
641 | (radio-menu-item-add-to-group item group-with)))) |
d520140e |
642 | |
560af5c5 |
643 | |
644 | |
aaa6e6cb |
645 | ;;; Toggle button |
646 | |
647 | (defbinding toggle-button-toggled () nil |
648 | (toggle-button toggle-button)) |
649 | |
650 | |
651 | |
560af5c5 |
652 | ;;; Window |
653 | |
c49be931 |
654 | (defmethod initialize-instance ((window window) &rest initargs |
655 | &key accel-group accel-groups) |
656 | (declare (ignore accel-group accel-groups)) |
657 | (prog1 |
658 | (call-next-method) |
659 | (initial-add window #'window-add-accel-group |
660 | initargs :accel-group :accel-groups))) |
73d58e01 |
661 | |
662 | |
7625ebd8 |
663 | (defbinding window-set-wmclass () nil |
560af5c5 |
664 | (window window) |
665 | (wmclass-name string) |
666 | (wmclass-class string)) |
667 | |
bbaeff4b |
668 | (defbinding window-add-accel-group () nil |
560af5c5 |
669 | (window window) |
670 | (accel-group accel-group)) |
671 | |
bbaeff4b |
672 | (defbinding window-remove-accel-group () nil |
560af5c5 |
673 | (window window) |
674 | (accel-group accel-group)) |
675 | |
bbaeff4b |
676 | (defbinding window-activate-focus () int |
560af5c5 |
677 | (window window)) |
678 | |
bbaeff4b |
679 | (defbinding window-activate-default () int |
560af5c5 |
680 | (window window)) |
681 | |
7625ebd8 |
682 | (defbinding window-set-default-size (window width height) int |
560af5c5 |
683 | (window window) |
7625ebd8 |
684 | ((or width -1) int) |
685 | ((or height -1) int)) |
560af5c5 |
686 | |
bbaeff4b |
687 | ;(defbinding window-set-geometry-hints) |
560af5c5 |
688 | |
73d58e01 |
689 | (defbinding window-list-toplevels () (glist (copy-of window)) |
690 | "Returns a list of all existing toplevel windows.") |
7625ebd8 |
691 | |
692 | (defbinding window-add-mnemonic (window key target) nil |
693 | (window window) |
694 | ((gdk:keyval-from-name key) unsigned-int) |
695 | (target widget)) |
696 | |
697 | (defbinding window-remove-mnemonic (window key target) nil |
698 | (window window) |
699 | ((gdk:keyval-from-name key) unsigned-int) |
700 | (target widget)) |
701 | |
702 | (defbinding window-mnemonic-activate (window key modifier) nil |
703 | (window window) |
704 | ((gdk:keyval-from-name key) unsigned-int) |
705 | (modifier gdk:modifier-type)) |
706 | |
707 | (defbinding window-present () nil |
708 | (window window)) |
709 | |
710 | (defbinding window-iconify () nil |
711 | (window window)) |
712 | |
713 | (defbinding window-deiconify () nil |
714 | (window window)) |
715 | |
716 | (defbinding window-stick () nil |
717 | (window window)) |
718 | |
719 | (defbinding window-unstick () nil |
720 | (window window)) |
721 | |
722 | (defbinding window-maximize () nil |
723 | (window window)) |
724 | |
725 | (defbinding window-unmaximize () nil |
726 | (window window)) |
727 | |
728 | (defbinding window-begin-resize-drag () nil |
729 | (window window) |
730 | (edge gdk:window-edge) |
731 | (button int) |
732 | (root-x int) (root-y int) |
9adccb27 |
733 | (timestamp unsigned-int)) |
7625ebd8 |
734 | |
735 | (defbinding window-begin-move-drag () nil |
736 | (window window) |
737 | (edge gdk:window-edge) |
738 | (button int) |
739 | (root-x int) (root-y int) |
9adccb27 |
740 | (timestamp unsigned-int)) |
7625ebd8 |
741 | |
742 | (defbinding window-set-frame-dimensions () nil |
743 | (window window) |
744 | (left int) (top int) (rigth int) (bottom int)) |
745 | |
746 | (defbinding (window-default-icons "gtk_window_get_default_icon_list") |
747 | () (glist gdk:pixbuf)) |
748 | |
749 | (defbinding %window-get-default-size () nil |
750 | (window window) |
751 | (width int :out) |
752 | (height int :out)) |
753 | |
754 | (defun window-get-default-size (window) |
755 | (multiple-value-bind (width height) (%window-get-default-size window) |
756 | (values (unless (= width -1) width) (unless (= height -1) height)))) |
757 | |
758 | (defbinding window-get-frame-dimensions () nil |
759 | (window window) |
760 | (left int :out) (top int :out) (rigth int :out) (bottom int :out)) |
761 | |
762 | (defbinding %window-get-icon-list () (glist gdk:pixbuf) |
763 | (window window)) |
764 | |
765 | (defmethod window-icon ((window window)) |
766 | (let ((icon-list (%window-get-icon-list window))) |
767 | (if (endp (rest icon-list)) |
768 | (first icon-list) |
769 | icon-list))) |
770 | |
771 | (defbinding window-get-position () nil |
772 | (window window) |
773 | (root-x int :out) |
774 | (root-y int :out)) |
775 | |
776 | (defbinding window-get-size () nil |
777 | (window window) |
778 | (width int :out) |
779 | (height int :out)) |
780 | |
781 | (defbinding window-move () nil |
782 | (window window) |
783 | (x int) |
784 | (y int)) |
785 | |
786 | (defbinding window-parse-geometry () boolean |
787 | (window window) |
788 | (geometry string)) |
789 | |
790 | (defbinding window-reshow-with-initial-size () nil |
791 | (window window)) |
792 | |
793 | (defbinding window-resize () nil |
794 | (window window) |
795 | (width int) |
796 | (heigth int)) |
797 | |
798 | (defbinding %window-set-icon-list () nil |
799 | (window window) |
800 | (icon-list (glist gdk:pixbuf))) |
801 | |
802 | (defmethod (setf window-icon) (icon (window window)) |
803 | (%window-set-icon-list window (mklist icon))) |
804 | |
805 | |
560af5c5 |
806 | |
807 | |
1047e159 |
808 | ;;; File chooser |
560af5c5 |
809 | |
560af5c5 |
810 | |
560af5c5 |
811 | |
812 | |
f36ca6af |
813 | ;;; Scrolled window |
560af5c5 |
814 | |
560af5c5 |
815 | (defun (setf scrolled-window-scrollbar-policy) (policy window) |
816 | (setf (scrolled-window-hscrollbar-policy window) policy) |
817 | (setf (scrolled-window-vscrollbar-policy window) policy)) |
818 | |
bbaeff4b |
819 | (defbinding scrolled-window-add-with-viewport () nil |
560af5c5 |
820 | (scrolled-window scrolled-window) |
821 | (child widget)) |
822 | |
823 | |
824 | |
d520140e |
825 | |
826 | |
827 | |
560af5c5 |
828 | |
f36ca6af |
829 | ;;; Statusbar |
560af5c5 |
830 | |
bbaeff4b |
831 | (defbinding (statusbar-context-id "gtk_statusbar_get_context_id") |
832 | () unsigned-int |
f36ca6af |
833 | (statusbar statusbar) |
834 | (context-description string)) |
560af5c5 |
835 | |
bbaeff4b |
836 | (defbinding statusbar-push () unsigned-int |
f36ca6af |
837 | (statusbar statusbar) |
838 | (context-id unsigned-int) |
839 | (text string)) |
560af5c5 |
840 | |
bbaeff4b |
841 | (defbinding statusbar-pop () nil |
f36ca6af |
842 | (statusbar statusbar) |
843 | (context-id unsigned-int)) |
560af5c5 |
844 | |
bbaeff4b |
845 | (defbinding statusbar-remove () nil |
f36ca6af |
846 | (statusbar statusbar) |
847 | (context-id unsigned-int) |
848 | (message-id unsigned-int)) |
560af5c5 |
849 | |
560af5c5 |
850 | |
851 | |
852 | ;;; Fixed |
853 | |
bbaeff4b |
854 | (defbinding fixed-put () nil |
f36ca6af |
855 | (fixed fixed) |
856 | (widget widget) |
f5b67f2b |
857 | (x int) (y int)) |
560af5c5 |
858 | |
bbaeff4b |
859 | (defbinding fixed-move () nil |
f36ca6af |
860 | (fixed fixed) |
861 | (widget widget) |
f5b67f2b |
862 | (x int) (y int)) |
560af5c5 |
863 | |
864 | |
865 | |
d520140e |
866 | ;;; Notebook |
560af5c5 |
867 | |
f5b67f2b |
868 | (defun %notebook-position (notebook page) |
869 | (etypecase page |
870 | (int page) |
871 | (keyword (case page |
872 | (:first 0) |
873 | (:last -1) |
1047e159 |
874 | (t (error "Invalid position keyword: ~A" page)))) |
f5b67f2b |
875 | (widget (notebook-page-num notebook page t)))) |
876 | |
877 | (defun %notebook-child (notebook position) |
878 | (typecase position |
879 | (widget position) |
880 | (t (notebook-nth-page-child notebook position)))) |
881 | |
882 | |
883 | (defbinding (notebook-insert "gtk_notebook_insert_page_menu") |
f36ca6af |
884 | (notebook position child tab-label &optional menu-label) nil |
885 | (notebook notebook) |
886 | (child widget) |
887 | ((if (stringp tab-label) |
f5b67f2b |
888 | (make-instance 'label :label tab-label) |
f36ca6af |
889 | tab-label) widget) |
890 | ((if (stringp menu-label) |
f5b67f2b |
891 | (make-instance 'label :label menu-label) |
f36ca6af |
892 | menu-label) (or null widget)) |
f5b67f2b |
893 | ((%notebook-position notebook position) int)) |
560af5c5 |
894 | |
f5b67f2b |
895 | (defun notebook-append (notebook child tab-label &optional menu-label) |
896 | (notebook-insert notebook :last child tab-label menu-label)) |
560af5c5 |
897 | |
f5b67f2b |
898 | (defun notebook-prepend (notebook child tab-label &optional menu-label) |
899 | (notebook-insert notebook :first child tab-label menu-label)) |
560af5c5 |
900 | |
f5b67f2b |
901 | (defbinding notebook-remove-page (notebook page) nil |
f36ca6af |
902 | (notebook notebook) |
1047e159 |
903 | ((%notebook-position notebook page) int)) |
560af5c5 |
904 | |
bbaeff4b |
905 | (defbinding %notebook-page-num () int |
f36ca6af |
906 | (notebook notebook) |
907 | (child widget)) |
908 | |
f5b67f2b |
909 | (defun notebook-page-num (notebook child &optional error-p) |
f36ca6af |
910 | (let ((page-num (%notebook-page-num notebook child))) |
911 | (if (= page-num -1) |
f5b67f2b |
912 | (when error-p |
913 | (error "~A is not a child of ~A" child notebook)) |
f36ca6af |
914 | page-num))) |
915 | |
bbaeff4b |
916 | (defbinding notebook-next-page () nil |
f36ca6af |
917 | (notebook notebook)) |
560af5c5 |
918 | |
bbaeff4b |
919 | (defbinding notebook-prev-page () nil |
f36ca6af |
920 | (notebook notebook)) |
921 | |
f5b67f2b |
922 | (defbinding notebook-reorder-child (notebook child position) nil |
923 | (notebook notebook) |
924 | (child widget) |
925 | ((%notebook-position notebook position) int)) |
926 | |
bbaeff4b |
927 | (defbinding notebook-popup-enable () nil |
f36ca6af |
928 | (notebook notebook)) |
929 | |
bbaeff4b |
930 | (defbinding notebook-popup-disable () nil |
f36ca6af |
931 | (notebook notebook)) |
932 | |
f5b67f2b |
933 | (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") |
934 | (notebook page) widget |
935 | (notebook notebook) |
936 | ((case page |
937 | (:first 0) |
938 | (:last -1) |
939 | (t page)) int)) |
940 | |
1047e159 |
941 | |
942 | (defbinding %notebook-get-current-page () int |
f5b67f2b |
943 | (notebook notebook)) |
944 | |
1047e159 |
945 | (defun notebook-current-page-num (notebook) |
946 | (let ((num (%notebook-get-current-page notebook))) |
947 | (when (>= num 0) |
948 | num))) |
949 | |
f5b67f2b |
950 | (defun notebook-current-page (notebook) |
1047e159 |
951 | (let ((page-num (notebook-current-page-num notebook))) |
952 | (when page-num |
953 | (notebook-nth-page-child notebook page-num)))) |
f5b67f2b |
954 | |
955 | (defbinding %notebook-set-current-page () nil |
956 | (notebook notebook) |
957 | (page-num int)) |
958 | |
959 | (defun (setf notebook-current-page) (page notebook) |
960 | (%notebook-set-current-page notebook (%notebook-position notebook page)) |
961 | page) |
962 | |
963 | |
1047e159 |
964 | (defbinding (notebook-tab-label "gtk_notebook_get_tab_label") |
965 | (notebook page) widget |
966 | (notebook notebook) |
967 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
968 | |
1047e159 |
969 | (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text") |
6bb23851 |
970 | (notebook page) (copy-of string) |
1047e159 |
971 | (notebook notebook) |
972 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
973 | |
1047e159 |
974 | (defbinding %notebook-set-tab-label () nil |
975 | (notebook notebook) |
976 | (page widget) |
977 | (tab-label widget)) |
978 | |
979 | (defun (setf notebook-tab-label) (tab-label notebook page) |
980 | (let ((widget (if (stringp tab-label) |
981 | (make-instance 'label :label tab-label) |
982 | tab-label))) |
983 | (%notebook-set-tab-label notebook (%notebook-child notebook page) widget) |
984 | widget)) |
f5b67f2b |
985 | |
f5b67f2b |
986 | |
1047e159 |
987 | (defbinding (notebook-menu-label "gtk_notebook_get_menu_label") |
988 | (notebook page) widget |
989 | (notebook notebook) |
990 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
991 | |
1047e159 |
992 | (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text") |
6bb23851 |
993 | (notebook page) (copy-of string) |
1047e159 |
994 | (notebook notebook) |
995 | ((%notebook-child notebook page) widget)) |
f5b67f2b |
996 | |
1047e159 |
997 | (defbinding %notebook-set-menu-label () nil |
998 | (notebook notebook) |
999 | (page widget) |
1000 | (menu-label widget)) |
1001 | |
1002 | (defun (setf notebook-menu-label) (menu-label notebook page) |
1003 | (let ((widget (if (stringp menu-label) |
1004 | (make-instance 'label :label menu-label) |
1005 | menu-label))) |
1006 | (%notebook-set-menu-label notebook (%notebook-child notebook page) widget) |
1007 | widget)) |
f5b67f2b |
1008 | |
1009 | |
1010 | (defbinding notebook-query-tab-label-packing (notebook page) nil |
f36ca6af |
1011 | (notebook notebook) |
f5b67f2b |
1012 | ((%notebook-child notebook page) widget) |
f36ca6af |
1013 | (expand boolean :out) |
1014 | (fill boolean :out) |
1015 | (pack-type pack-type :out)) |
1016 | |
f5b67f2b |
1017 | (defbinding notebook-set-tab-label-packing |
1018 | (notebook page expand fill pack-type) nil |
f36ca6af |
1019 | (notebook notebook) |
f5b67f2b |
1020 | ((%notebook-child notebook page) widget) |
f36ca6af |
1021 | (expand boolean) |
1022 | (fill boolean) |
1023 | (pack-type pack-type)) |
1024 | |
560af5c5 |
1025 | |
1026 | |
d520140e |
1027 | ;;; Paned |
560af5c5 |
1028 | |
bbaeff4b |
1029 | (defbinding paned-pack1 () nil |
d520140e |
1030 | (paned paned) |
1031 | (child widget) |
1032 | (resize boolean) |
1033 | (shrink boolean)) |
560af5c5 |
1034 | |
bbaeff4b |
1035 | (defbinding paned-pack2 () nil |
d520140e |
1036 | (paned paned) |
1037 | (child widget) |
1038 | (resize boolean) |
1039 | (shrink boolean)) |
560af5c5 |
1040 | |
f5b67f2b |
1041 | (defun (setf paned-child1) (child paned) |
1042 | (paned-pack1 paned child nil t) |
1043 | child) |
1044 | |
1045 | (defun (setf paned-child2) (child paned) |
1046 | (paned-pack2 paned child t t) |
1047 | child) |
1048 | |
1049 | ;; Defined in gtkglue.c |
bbaeff4b |
1050 | (defbinding paned-child1 () widget |
d520140e |
1051 | (paned paned) |
1052 | (resize boolean :out) |
1053 | (shrink boolean :out)) |
560af5c5 |
1054 | |
f5b67f2b |
1055 | ;; Defined in gtkglue.c |
bbaeff4b |
1056 | (defbinding paned-child2 () widget |
d520140e |
1057 | (paned paned) |
1058 | (resize boolean :out) |
1059 | (shrink boolean :out)) |
560af5c5 |
1060 | |
560af5c5 |
1061 | |
560af5c5 |
1062 | |
d520140e |
1063 | ;;; Layout |
560af5c5 |
1064 | |
bbaeff4b |
1065 | (defbinding layout-put () nil |
d520140e |
1066 | (layout layout) |
1067 | (widget widget) |
1068 | (x int) |
1069 | (y int)) |
560af5c5 |
1070 | |
bbaeff4b |
1071 | (defbinding layout-move () nil |
d520140e |
1072 | (layout layout) |
1073 | (widget widget) |
1074 | (x int) |
1075 | (y int)) |
560af5c5 |
1076 | |
560af5c5 |
1077 | |
1078 | |
560af5c5 |
1079 | ;;; Menu shell |
1080 | |
f5b67f2b |
1081 | (defbinding menu-shell-insert (menu-shell menu-item position) nil |
f36ca6af |
1082 | (menu-shell menu-shell) |
1083 | (menu-item menu-item) |
f5b67f2b |
1084 | ((case position |
1085 | (:first 0) |
1086 | (:last -1) |
1087 | (t position)) int)) |
560af5c5 |
1088 | |
f36ca6af |
1089 | (defun menu-shell-append (menu-shell menu-item) |
f5b67f2b |
1090 | (menu-shell-insert menu-shell menu-item :last)) |
560af5c5 |
1091 | |
f36ca6af |
1092 | (defun menu-shell-prepend (menu-shell menu-item) |
f5b67f2b |
1093 | (menu-shell-insert menu-shell menu-item :fisrt)) |
560af5c5 |
1094 | |
bbaeff4b |
1095 | (defbinding menu-shell-deactivate () nil |
f36ca6af |
1096 | (menu-shell menu-shell)) |
560af5c5 |
1097 | |
bbaeff4b |
1098 | (defbinding menu-shell-select-item () nil |
f36ca6af |
1099 | (menu-shell menu-shell) |
1100 | (menu-item menu-item)) |
560af5c5 |
1101 | |
bbaeff4b |
1102 | (defbinding menu-shell-deselect () nil |
f36ca6af |
1103 | (menu-shell menu-shell)) |
560af5c5 |
1104 | |
bbaeff4b |
1105 | (defbinding menu-shell-activate-item () nil |
f36ca6af |
1106 | (menu-shell menu-shell) |
1107 | (menu-item menu-item) |
1108 | (fore-deactivate boolean)) |
560af5c5 |
1109 | |
1110 | |
1111 | |
f5b67f2b |
1112 | ;;; Menu |
560af5c5 |
1113 | |
f5b67f2b |
1114 | (defun %menu-position (menu child) |
1115 | (etypecase child |
1116 | (int child) |
1117 | (keyword (case child |
1118 | (:first 0) |
1119 | (:last -1) |
1047e159 |
1120 | (t (error "Invalid position keyword: ~A" child)))) |
f5b67f2b |
1121 | (widget (menu-child-position menu child)))) |
560af5c5 |
1122 | |
1123 | |
f5b67f2b |
1124 | (defbinding menu-reorder-child (menu menu-item position) nil |
1125 | (menu menu) |
1126 | (menu-item menu-item) |
1127 | ((%menu-position menu position) int)) |
560af5c5 |
1128 | |
8755b1a5 |
1129 | (def-callback-marshal %menu-popup-callback (nil (x int) (y int) (push-in boolean))) |
560af5c5 |
1130 | |
f5b67f2b |
1131 | (defbinding %menu-popup () nil |
1132 | (menu menu) |
1133 | (parent-menu-shell (or null menu-shell)) |
1134 | (parent-menu-item (or null menu-item)) |
1135 | (callback-func (or null pointer)) |
1136 | (callback-id unsigned-int) |
1137 | (button unsigned-int) |
1138 | (activate-time (unsigned 32))) |
1139 | |
1140 | (defun menu-popup (menu button activate-time &key callback parent-menu-shell |
1141 | parent-menu-item) |
1142 | (if callback |
1a1949c7 |
1143 | (with-callback-function (id callback) |
1144 | (%menu-popup |
1145 | menu parent-menu-shell parent-menu-item |
1146 | (callback %menu-popup-callback) id button activate-time)) |
f5b67f2b |
1147 | (%menu-popup |
1148 | menu parent-menu-shell parent-menu-item nil 0 button activate-time))) |
1149 | |
1150 | (defbinding menu-set-accel-path () nil |
1151 | (menu menu) |
1152 | (accel-path string)) |
560af5c5 |
1153 | |
bbaeff4b |
1154 | (defbinding menu-reposition () nil |
f36ca6af |
1155 | (menu menu)) |
560af5c5 |
1156 | |
bbaeff4b |
1157 | (defbinding menu-popdown () nil |
f36ca6af |
1158 | (menu menu)) |
560af5c5 |
1159 | |
f5b67f2b |
1160 | (defun menu-child-position (menu child) |
1161 | (position child (container-children menu))) |
1162 | |
1163 | (defun menu-active-num (menu) |
1164 | (menu-child-position menu (menu-active menu))) |
1165 | |
bbaeff4b |
1166 | (defbinding %menu-set-active () nil |
f36ca6af |
1167 | (menu menu) |
1168 | (index unsigned-int)) |
560af5c5 |
1169 | |
f5b67f2b |
1170 | (defun (setf menu-active) (menu child) |
1171 | (%menu-set-active menu (%menu-position menu child)) |
1172 | child) |
d520140e |
1173 | |
560af5c5 |
1174 | |
1175 | |
f36ca6af |
1176 | ;;; Table |
560af5c5 |
1177 | |
bbaeff4b |
1178 | (defbinding table-resize () nil |
f36ca6af |
1179 | (table table) |
1180 | (rows unsigned-int) |
1181 | (columns unsigned-int)) |
560af5c5 |
1182 | |
bbaeff4b |
1183 | (defbinding table-attach (table child left right top bottom |
c49be931 |
1184 | &key options x-options y-options |
1185 | (x-padding 0) (y-padding 0)) nil |
f36ca6af |
1186 | (table table) |
1187 | (child widget) |
1188 | (left unsigned-int) |
1189 | (right unsigned-int) |
1190 | (top unsigned-int) |
1191 | (bottom unsigned-int) |
c49be931 |
1192 | ((append (mklist options) (mklist x-options)) attach-options) |
1193 | ((append (mklist options) (mklist y-options)) attach-options) |
f36ca6af |
1194 | (x-padding unsigned-int) |
1195 | (y-padding unsigned-int)) |
1196 | |
e5b416f0 |
1197 | |
bbaeff4b |
1198 | (defbinding %table-set-row-spacing () nil |
f36ca6af |
1199 | (table table) |
1200 | (row unsigned-int) |
1201 | (spacing unsigned-int)) |
1202 | |
e5b416f0 |
1203 | (defbinding %table-set-row-spacings () nil |
1204 | (table table) |
1205 | (spacing unsigned-int)) |
1206 | |
1207 | (defun (setf table-row-spacing) (spacing table &optional row) |
1208 | (if row |
1209 | (%table-set-row-spacing table row spacing) |
1210 | (%table-set-row-spacings table spacing)) |
f36ca6af |
1211 | spacing) |
1212 | |
e5b416f0 |
1213 | (defbinding %table-get-row-spacing () unsigned-int |
f36ca6af |
1214 | (table table) |
e5b416f0 |
1215 | (row unsigned-int)) |
1216 | |
1217 | (defbinding %table-get-default-row-spacing () unsigned-int |
1218 | (table table)) |
1219 | |
1220 | (defun table-row-spacing (table &optional row) |
1221 | (if row |
1222 | (%table-get-row-spacing table row) |
1223 | (%table-get-default-row-spacing table))) |
1224 | |
f36ca6af |
1225 | |
bbaeff4b |
1226 | (defbinding %table-set-col-spacing () nil |
f36ca6af |
1227 | (table table) |
1228 | (col unsigned-int) |
1229 | (spacing unsigned-int)) |
1230 | |
e5b416f0 |
1231 | (defbinding %table-set-col-spacings () nil |
1232 | (table table) |
1233 | (spacing unsigned-int)) |
1234 | |
1235 | (defun (setf table-col-spacing) (spacing table &optional col) |
1236 | (if col |
1237 | (%table-set-col-spacing table col spacing) |
1238 | (%table-set-col-spacings table spacing)) |
f36ca6af |
1239 | spacing) |
1240 | |
e5b416f0 |
1241 | (defbinding %table-get-col-spacing () unsigned-int |
f36ca6af |
1242 | (table table) |
e5b416f0 |
1243 | (col unsigned-int)) |
1244 | |
1245 | (defbinding %table-get-default-col-spacing () unsigned-int |
1246 | (table table)) |
1247 | |
1248 | (defun table-col-spacing (table &optional col) |
1249 | (if col |
1250 | (%table-get-col-spacing table col) |
1251 | (%table-get-default-col-spacing table))) |
1252 | |
1253 | |
f36ca6af |
1254 | |
1255 | ;;; Toolbar |
1256 | |
bbaeff4b |
1257 | (defbinding %toolbar-insert-element () widget |
f36ca6af |
1258 | (toolbar toolbar) |
1259 | (type toolbar-child-type) |
1260 | (widget (or null widget)) |
1261 | (text string) |
1262 | (tooltip-text string) |
1263 | (tooltip-private-text string) |
1264 | (icon (or null widget)) |
1265 | (nil null) |
1266 | (nil null) |
1267 | (position int)) |
560af5c5 |
1268 | |
f5b67f2b |
1269 | (defbinding %toolbar-insert-stock () widget |
1270 | (toolbar toolbar) |
1271 | (stock-id string) |
1272 | (tooltip-text string) |
1273 | (tooltip-private-text string) |
1274 | (nil null) |
1275 | (nil null) |
1276 | (position int)) |
1277 | |
1278 | (defun toolbar-insert (toolbar position element |
1279 | &key tooltip-text tooltip-private-text |
1280 | type icon group callback object) |
1281 | (let* ((numpos (case position |
1047e159 |
1282 | (:first -1) |
1283 | (:last 0) |
f5b67f2b |
1284 | (t position))) |
1285 | (widget |
1286 | (cond |
1287 | ((or |
1288 | (eq type :space) |
1289 | (and (not type) (eq element :space))) |
1290 | (%toolbar-insert-element |
1291 | toolbar :space nil nil |
1292 | tooltip-text tooltip-private-text nil numpos)) |
1293 | ((or |
1294 | (eq type :widget) |
1295 | (and (not type) (typep element 'widget))) |
1296 | (%toolbar-insert-element |
1297 | toolbar :widget element nil |
1298 | tooltip-text tooltip-private-text nil numpos)) |
1299 | ((or |
1300 | (eq type :stock) |
1301 | (and |
1302 | (not type) |
1303 | (typep element 'string) |
1304 | (stock-lookup element))) |
1305 | (%toolbar-insert-stock |
1306 | toolbar element tooltip-text tooltip-private-text numpos)) |
1307 | ((typep element 'string) |
1308 | (%toolbar-insert-element |
1309 | toolbar (or type :button) (when (eq type :radio-button) group) |
1047e159 |
1310 | element tooltip-text tooltip-private-text |
1311 | (etypecase icon |
1312 | (null nil) |
1313 | (widget icon) |
1314 | ((or pathname string vector) |
1315 | (make-instance 'image |
1316 | :source icon ; :icon-size (toolbar-icon-size toolbar) |
1317 | ))) |
1318 | numpos)) |
f5b67f2b |
1319 | ((error "Invalid element type: ~A" element))))) |
f36ca6af |
1320 | (when callback |
f5b67f2b |
1321 | (signal-connect widget 'clicked callback :object object)) |
1322 | widget)) |
f36ca6af |
1323 | |
f5b67f2b |
1324 | (defun toolbar-append (toolbar element &key tooltip-text tooltip-private-text |
1325 | type icon group callback object) |
1326 | (toolbar-insert |
1327 | toolbar :first element :type type :icon icon :group group |
f36ca6af |
1328 | :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text |
f5b67f2b |
1329 | :callback callback :object object)) |
f36ca6af |
1330 | |
f5b67f2b |
1331 | (defun toolbar-prepend (toolbar element &key tooltip-text tooltip-private-text |
1332 | type icon group callback object) |
1333 | (toolbar-insert |
1334 | toolbar :last element :type type :icon icon :group group |
f36ca6af |
1335 | :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text |
f5b67f2b |
1336 | :callback callback :object object)) |
1337 | |
f36ca6af |
1338 | |
1339 | (defun toolbar-insert-space (toolbar position) |
f5b67f2b |
1340 | (toolbar-insert toolbar position :space)) |
f36ca6af |
1341 | |
1342 | (defun toolbar-append-space (toolbar) |
f5b67f2b |
1343 | (toolbar-append toolbar :space)) |
f36ca6af |
1344 | |
1345 | (defun toolbar-prepend-space (toolbar) |
f5b67f2b |
1346 | (toolbar-prepend toolbar :space)) |
f36ca6af |
1347 | |
560af5c5 |
1348 | |
f36ca6af |
1349 | (defun toolbar-enable-tooltips (toolbar) |
1350 | (setf (toolbar-tooltips-p toolbar) t)) |
560af5c5 |
1351 | |
f36ca6af |
1352 | (defun toolbar-disable-tooltips (toolbar) |
1353 | (setf (toolbar-tooltips-p toolbar) nil)) |
560af5c5 |
1354 | |
1355 | |
f5b67f2b |
1356 | (defbinding toolbar-remove-space () nil |
1357 | (toolbar toolbar) |
1358 | (position int)) |
560af5c5 |
1359 | |
f5b67f2b |
1360 | (defbinding toolbar-unset-icon-size () nil |
1361 | (toolbar toolbar)) |
560af5c5 |
1362 | |
f5b67f2b |
1363 | (defbinding toolbar-unset-style () nil |
1364 | (toolbar toolbar)) |
560af5c5 |
1365 | |
1366 | |
bbaeff4b |
1367 | ;;; Editable |
1047e159 |
1368 | |
bbaeff4b |
1369 | (defbinding editable-select-region (editable &optional (start 0) end) nil |
f36ca6af |
1370 | (editable editable) |
1371 | (start int) |
1372 | ((or end -1) int)) |
560af5c5 |
1373 | |
1047e159 |
1374 | (defbinding editable-get-selection-bounds (editable) nil |
1375 | (editable editable) |
1376 | (start int :out) |
1377 | (end int :out)) |
1378 | |
bbaeff4b |
1379 | (defbinding editable-insert-text |
f36ca6af |
1380 | (editable text &optional (position 0)) nil |
1381 | (editable editable) |
1382 | (text string) |
1383 | ((length text) int) |
1384 | ((or position -1) int :in-out)) |
560af5c5 |
1385 | |
f36ca6af |
1386 | (defun editable-append-text (editable text) |
1387 | (editable-insert-text editable text nil)) |
560af5c5 |
1388 | |
f36ca6af |
1389 | (defun editable-prepend-text (editable text) |
1390 | (editable-insert-text editable text 0)) |
560af5c5 |
1391 | |
bbaeff4b |
1392 | (defbinding editable-delete-text (editable &optional (start 0) end) nil |
f36ca6af |
1393 | (editable editable) |
1394 | (start int) |
1395 | ((or end -1) int)) |
560af5c5 |
1396 | |
bbaeff4b |
1397 | (defbinding (editable-text "gtk_editable_get_chars") |
f36ca6af |
1398 | (editable &optional (start 0) end) string |
1399 | (editable editable) |
1400 | (start int) |
1401 | ((or end -1) int)) |
560af5c5 |
1402 | |
f36ca6af |
1403 | (defun (setf editable-text) (text editable) |
1404 | (if text |
1405 | (editable-delete-text |
1406 | editable |
1407 | (editable-insert-text editable text)) |
1408 | (editable-delete-text editable)) |
1409 | text) |
560af5c5 |
1410 | |
bbaeff4b |
1411 | (defbinding editable-cut-clipboard () nil |
f36ca6af |
1412 | (editable editable)) |
560af5c5 |
1413 | |
bbaeff4b |
1414 | (defbinding editable-copy-clipboard () nil |
f36ca6af |
1415 | (editable editable)) |
560af5c5 |
1416 | |
bbaeff4b |
1417 | (defbinding editable-paste-clipboard () nil |
f36ca6af |
1418 | (editable editable)) |
560af5c5 |
1419 | |
bbaeff4b |
1420 | (defbinding editable-delete-selection () nil |
f36ca6af |
1421 | (editable editable)) |
560af5c5 |
1422 | |
560af5c5 |
1423 | |
560af5c5 |
1424 | |
f36ca6af |
1425 | ;;; Spin button |
560af5c5 |
1426 | |
f36ca6af |
1427 | (defun spin-button-value-as-int (spin-button) |
1428 | (round (spin-button-value spin-button))) |
560af5c5 |
1429 | |
bbaeff4b |
1430 | (defbinding spin-button-spin () nil |
f36ca6af |
1431 | (spin-button spin-button) |
1432 | (direction spin-type) |
1433 | (increment single-float)) |
560af5c5 |
1434 | |
bbaeff4b |
1435 | (defbinding spin-button-update () nil |
f36ca6af |
1436 | (spin-button spin-button)) |
560af5c5 |
1437 | |
1438 | |
1439 | |
1440 | ; ;;; Ruler |
1441 | |
bbaeff4b |
1442 | (defbinding ruler-set-range () nil |
f36ca6af |
1443 | (ruler ruler) |
1444 | (lower single-float) |
1445 | (upper single-float) |
1446 | (position single-float) |
1447 | (max-size single-float)) |
560af5c5 |
1448 | |
bbaeff4b |
1449 | (defbinding ruler-draw-ticks () nil |
f36ca6af |
1450 | (ruler ruler)) |
560af5c5 |
1451 | |
bbaeff4b |
1452 | (defbinding ruler-draw-pos () nil |
f36ca6af |
1453 | (ruler ruler)) |
560af5c5 |
1454 | |
560af5c5 |
1455 | |
560af5c5 |
1456 | |
d520140e |
1457 | ;;; Range |
560af5c5 |
1458 | |
1047e159 |
1459 | (defun range-lower (range) |
1460 | (adjustment-lower (range-adjustment range))) |
560af5c5 |
1461 | |
1047e159 |
1462 | (defun range-upper (range) |
1463 | (adjustment-upper (range-adjustment range))) |
560af5c5 |
1464 | |
1047e159 |
1465 | (defun (setf range-lower) (value range) |
1466 | (setf (adjustment-lower (range-adjustment range)) value)) |
560af5c5 |
1467 | |
1047e159 |
1468 | (defun (setf range-upper) (value range) |
1469 | (setf (adjustment-upper (range-adjustment range)) value)) |
560af5c5 |
1470 | |
1047e159 |
1471 | (defun range-page-increment (range) |
1472 | (adjustment-page-increment (range-adjustment range))) |
560af5c5 |
1473 | |
1047e159 |
1474 | (defun range-step-increment (range) |
1475 | (adjustment-step-increment (range-adjustment range))) |
560af5c5 |
1476 | |
1047e159 |
1477 | (defun (setf range-page-increment) (value range) |
1478 | (setf (adjustment-page-increment (range-adjustment range)) value)) |
560af5c5 |
1479 | |
1047e159 |
1480 | (defun (setf range-step-increment) (value range) |
1481 | (setf (adjustment-step-increment (range-adjustment range)) value)) |
560af5c5 |
1482 | |
1047e159 |
1483 | (defbinding range-set-range () nil |
d520140e |
1484 | (range range) |
1047e159 |
1485 | (lower double-float) |
1486 | (upper double-float)) |
560af5c5 |
1487 | |
1047e159 |
1488 | (defbinding range-set-increments () nil |
d520140e |
1489 | (range range) |
1047e159 |
1490 | (step double-float) |
1491 | (page double-float)) |
560af5c5 |
1492 | |
560af5c5 |
1493 | |
d520140e |
1494 | ;;; Scale |
560af5c5 |
1495 | |
e5b416f0 |
1496 | ; (defbinding scale-draw-value () nil |
1497 | ; (scale scale)) |
560af5c5 |
1498 | |
560af5c5 |
1499 | |
560af5c5 |
1500 | |
d520140e |
1501 | ;;; Progress bar |
560af5c5 |
1502 | |
bbaeff4b |
1503 | (defbinding progress-bar-pulse () nil |
d520140e |
1504 | (progress-bar progress-bar)) |
560af5c5 |
1505 | |
1506 | |
c49be931 |
1507 | ;;; Size group |
1508 | |
1509 | (defmethod initialize-instance ((size-group size-group) &rest initargs |
1510 | &key widget widgets) |
1511 | (declare (ignore widget widgets)) |
1512 | (prog1 |
1513 | (call-next-method) |
1514 | (initial-add size-group #'size-group-add-widget |
1515 | initargs :widget :widgets))) |
1516 | |
1517 | |
1518 | (defbinding size-group-add-widget () nil |
1519 | (size-group size-group) |
1520 | (widget widget)) |
1521 | |
1522 | (defbinding size-group-remove-widget () nil |
1523 | (size-group size-group) |
1524 | (widget widget)) |
1525 | |
560af5c5 |
1526 | |
f5b67f2b |
1527 | ;;; Stock items |
1528 | |
73d58e01 |
1529 | (defbinding %stock-item-copy () pointer |
1530 | (location pointer)) |
1531 | |
1532 | (defbinding %stock-item-free () nil |
1533 | (location pointer)) |
f5b67f2b |
1534 | |
73d58e01 |
1535 | (defmethod reference-foreign ((class (eql (find-class 'stock-item))) location) |
1536 | (%stock-item-copy location)) |
1537 | |
1538 | (defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location) |
1539 | (%stock-item-free location)) |
1540 | |
1541 | (defbinding stock-add (stock-item) nil |
1542 | (stock-item stock-item) |
1543 | (1 unsigned-int)) |
1544 | |
1545 | (defbinding stock-list-ids () (gslist string)) |
1546 | |
1547 | (defbinding %stock-lookup () boolean |
1548 | (stock-id string) |
1549 | (location pointer)) |
1550 | |
1551 | (defun stock-lookup (stock-id) |
1552 | (let ((location |
1553 | (allocate-memory (proxy-instance-size (find-class 'stock-item))))) |
1554 | (unwind-protect |
1555 | (when (%stock-lookup stock-id location) |
1556 | (ensure-proxy-instance 'stock-item (%stock-item-copy location))) |
1557 | (deallocate-memory location)))) |
560af5c5 |
1558 | |
1559 | |
1560 | ;;; Tooltips |
1561 | |
bbaeff4b |
1562 | (defbinding tooltips-enable () nil |
d520140e |
1563 | (tooltips tooltips)) |
560af5c5 |
1564 | |
bbaeff4b |
1565 | (defbinding tooltips-disable () nil |
d520140e |
1566 | (tooltips tooltips)) |
560af5c5 |
1567 | |
e5b416f0 |
1568 | (defun (setf tooltips-enabled-p) (enable tooltips) |
1569 | (if enable |
1570 | (tooltips-enable tooltips) |
1571 | (tooltips-disable tooltips))) |
1572 | |
bbaeff4b |
1573 | (defbinding tooltips-set-tip () nil |
d520140e |
1574 | (tooltips tooltips) |
1575 | (widget widget) |
1576 | (tip-text string) |
1577 | (tip-private string)) |
560af5c5 |
1578 | |
bbaeff4b |
1579 | (defbinding tooltips-force-window () nil |
d520140e |
1580 | (tooltips tooltips)) |
560af5c5 |
1581 | |
1582 | |
1583 | |
d520140e |
1584 | ;;; Rc |
560af5c5 |
1585 | |
bbaeff4b |
1586 | (defbinding rc-add-default-file (filename) nil |
d520140e |
1587 | ((namestring (truename filename)) string)) |
560af5c5 |
1588 | |
bbaeff4b |
1589 | (defbinding rc-parse (filename) nil |
d520140e |
1590 | ((namestring (truename filename)) string)) |
560af5c5 |
1591 | |
bbaeff4b |
1592 | (defbinding rc-parse-string () nil |
d520140e |
1593 | (rc-string string)) |
560af5c5 |
1594 | |
bbaeff4b |
1595 | (defbinding rc-reparse-all () nil) |
560af5c5 |
1596 | |
bbaeff4b |
1597 | (defbinding rc-get-style () style |
d520140e |
1598 | (widget widget)) |
560af5c5 |
1599 | |
1600 | |
1601 | |
1602 | ;;; Accelerator Groups |
bbaeff4b |
1603 | #| |
bbaeff4b |
1604 | (defbinding accel-group-activate (accel-group key modifiers) boolean |
560af5c5 |
1605 | (accel-group accel-group) |
1606 | ((gdk:keyval-from-name key) unsigned-int) |
1607 | (modifiers gdk:modifier-type)) |
1608 | |
bbaeff4b |
1609 | (defbinding accel-groups-activate (object key modifiers) boolean |
560af5c5 |
1610 | (object object) |
1611 | ((gdk:keyval-from-name key) unsigned-int) |
1612 | (modifiers gdk:modifier-type)) |
1613 | |
bbaeff4b |
1614 | (defbinding accel-group-attach () nil |
560af5c5 |
1615 | (accel-group accel-group) |
1616 | (object object)) |
1617 | |
bbaeff4b |
1618 | (defbinding accel-group-detach () nil |
560af5c5 |
1619 | (accel-group accel-group) |
1620 | (object object)) |
1621 | |
bbaeff4b |
1622 | (defbinding accel-group-lock () nil |
560af5c5 |
1623 | (accel-group accel-group)) |
1624 | |
bbaeff4b |
1625 | (defbinding accel-group-unlock () nil |
560af5c5 |
1626 | (accel-group accel-group)) |
1627 | |
1628 | |
1629 | ;;; Accelerator Groups Entries |
1630 | |
bbaeff4b |
1631 | (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry |
560af5c5 |
1632 | (accel-group accel-group) |
1633 | ((gdk:keyval-from-name key) unsigned-int) |
1634 | (modifiers gdk:modifier-type)) |
1635 | |
bbaeff4b |
1636 | (defbinding accel-group-lock-entry (accel-group key modifiers) nil |
560af5c5 |
1637 | (accel-group accel-group) |
1638 | ((gdk:keyval-from-name key) unsigned-int) |
1639 | (modifiers gdk:modifier-type)) |
1640 | |
bbaeff4b |
1641 | (defbinding accel-group-unlock-entry (accel-group key modifiers) nil |
560af5c5 |
1642 | (accel-group accel-group) |
1643 | ((gdk:keyval-from-name key) unsigned-int) |
1644 | (modifiers gdk:modifier-type)) |
1645 | |
bbaeff4b |
1646 | (defbinding accel-group-add |
560af5c5 |
1647 | (accel-group key modifiers flags object signal) nil |
1648 | (accel-group accel-group) |
1649 | ((gdk:keyval-from-name key) unsigned-int) |
1650 | (modifiers gdk:modifier-type) |
1651 | (flags accel-flags) |
1652 | (object object) |
1653 | ((name-to-string signal) string)) |
1654 | |
bbaeff4b |
1655 | (defbinding accel-group-add (accel-group key modifiers object) nil |
560af5c5 |
1656 | (accel-group accel-group) |
1657 | ((gdk:keyval-from-name key) unsigned-int) |
1658 | (modifiers gdk:modifier-type) |
1659 | (object object)) |
1660 | |
1661 | |
1662 | ;;; Accelerator Signals |
1663 | |
bbaeff4b |
1664 | (defbinding accel-group-handle-add |
560af5c5 |
1665 | (object signal-id accel-group key modifiers flags) nil |
1666 | (object object) |
1667 | (signal-id unsigned-int) |
1668 | (accel-group accel-group) |
1669 | ((gdk:keyval-from-name key) unsigned-int) |
1670 | (modifiers gdk:modifier-type) |
1671 | (flags accel-flags)) |
1672 | |
bbaeff4b |
1673 | (defbinding accel-group-handle-remove |
560af5c5 |
1674 | (object accel-group key modifiers) nil |
1675 | (object object) |
1676 | (accel-group accel-group) |
1677 | ((gdk:keyval-from-name key) unsigned-int) |
1678 | (modifiers gdk:modifier-type)) |
bbaeff4b |
1679 | |# |