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