chiark / gitweb /
Changed CONTAINER-ADD and CONTAINER-REMOVE into generic functions
[clg] / gtk / gtk.lisp
1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 1999-2001 Espen S. Johnsen <esj@stud.cs.uit.no>
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
18 ;; $Id: gtk.lisp,v 1.10 2002-03-24 21:54:06 espen Exp $
19
20
21 (in-package "GTK")
22
23 ;;; Gtk version
24
25 (defbinding check-version () string
26   (required-major unsigned-int)
27   (required-minor unsigned-int)
28   (required-micro unsigned-int))
29
30 (defbinding query-version () nil
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
42 (defbinding get-default-language () string)
43
44
45 ;;; Acccel group
46
47
48 ;;; Acccel label
49
50 (defbinding accel-label-refetch () boolean
51   (accel-label accel-label))
52
53
54 ;;; Adjustment
55
56 (defbinding adjustment-changed () nil
57   (adjustment adjustment))
58
59 (defbinding adjustment-value-changed () nil
60   (adjustment adjustment))
61
62 (defbinding adjustment-clamp-page () nil
63   (adjustment adjustment)
64   (lower single-float)
65   (upper single-float))
66
67
68
69 ;;; Alignment -- no functions
70 ;;; Arrow -- no functions
71
72
73
74 ;;; Aspect frame
75
76
77 ;;; Bin
78
79 (defun (setf bin-child) (child bin)
80   (when-bind (current-child (bin-child bin))
81     (container-remove bin current-child))
82   (container-add bin child)
83   child)
84
85
86
87 ;;; Button box -- no functions
88
89
90 ;;; Binding
91
92
93
94 ;;; Box
95
96 (defbinding box-pack-start () nil
97   (box box)
98   (child widget)
99   (expand boolean)
100   (fill boolean)
101   (padding unsigned-int))
102
103 (defbinding box-pack-end () nil
104   (box box)
105   (child widget)
106   (expand boolean)
107   (fill boolean)
108   (padding unsigned-int))
109
110 (defun box-pack (box child &key (pack :start) (expand t) (fill t) (padding 0))
111   (if (eq pack :start)
112       (box-pack-start box child expand fill padding)
113     (box-pack-end box child expand fill padding)))
114
115 (defbinding box-reorder-child () nil
116   (box box)
117   (child widget)
118   (position int))
119
120 (defbinding box-query-child-packing () nil
121   (box box)
122   (child widget)
123   (expand boolean :out)
124   (fill boolean :out)
125   (padding unsigned-int :out)
126   (pack-type pack-type :out))
127
128 (defbinding box-set-child-packing () nil
129   (box box)
130   (child widget)
131   (expand boolean)
132   (fill boolean)
133   (padding unsigned-int)
134   (pack-type pack-type))
135
136
137
138 ;;; Button
139
140 (defbinding button-pressed () nil
141   (button button))
142
143 (defbinding button-released () nil
144   (button button))
145
146 (defbinding button-clicked () nil
147   (button button))
148
149 (defbinding button-enter () nil
150   (button button))
151
152 (defbinding button-leave () nil
153   (button button))
154
155
156
157 ;;; Calendar
158
159 (defbinding calendar-select-month () int
160   (calendar calendar)
161   (month unsigned-int)
162   (year unsigned-int))
163
164 (defbinding calendar-select-day () nil
165   (calendar calendar)
166   (day unsigned-int))
167
168 (defbinding calendar-mark-day () int
169   (calendar calendar)
170   (day unsigned-int))
171
172 (defbinding calendar-unmark-day () int
173   (calendar calendar)
174   (day unsigned-int))
175
176 (defbinding calendar-clear-marks () nil
177   (calendar calendar))
178
179 (defbinding calendar-display-options () nil
180   (calendar calendar)
181   (options calendar-display-options))
182
183 (defbinding (calendar-date "gtk_calendar_get_date") () nil
184   (calendar calendar)
185   (year unsigned-int :out)
186   (month unsigned-int :out)
187   (day unsigned-int :out))
188
189 (defbinding calendar-freeze () nil
190   (calendar calendar))
191
192 (defbinding calendar-thaw () nil
193   (calendar calendar))
194
195
196
197 ;;; Cell editable
198
199
200
201 ;;; Cell renderer
202
203
204
205 ;;; Cell renderer pixbuf -- no functions
206
207
208
209 ;;; Cell renderer text
210
211
212
213 ;;; Cell renderer toggle -- no functions
214
215
216
217 ;;; Check button -- no functions
218
219
220
221 ;;; Check menu item
222
223 (defbinding check-menu-item-toggled () nil
224   (check-menu-item check-menu-item))
225
226
227
228 ;;; Clipboard
229
230
231 ;;; Color selection
232
233 (defbinding (color-selection-is-adjusting-p
234              "gtk_color_selection_is_adjusting") () boolean
235   (colorsel color-selection))
236
237
238
239 ;;; Color selection dialog -- no functions
240
241
242
243 ;;; Combo
244
245 (defbinding combo-set-value-in-list () nil
246   (combo combo)
247   (value boolean)
248   (ok-if-empty boolean))
249
250 (defbinding combo-set-item-string () nil
251   (combo combo)
252   (item item)
253   (item-value string))
254
255 (defbinding combo-set-popdown-strings () nil
256   (combo combo)
257   (strings (glist string)))
258
259 (defbinding combo-disable-activate () nil
260   (combo combo))
261
262
263
264 ;;;; Dialog
265
266 (defmethod shared-initialize ((dialog dialog) names &rest initargs)
267   (call-next-method)
268   (dolist (button-definition (get-all initargs :button))
269     (apply #'dialog-add-button dialog button-definition)))
270   
271
272 (defvar %*response-id-key* (gensym))
273
274 (defun %dialog-find-response-id-num (dialog response-id &optional create-p error-p)
275   (or
276    (cadr (assoc response-id (rest (type-expand-1 'response-type))))
277    (let* ((response-ids (object-data dialog %*response-id-key*))
278           (response-id-num (position response-id response-ids)))
279     (cond
280      (response-id-num)
281      (create-p
282       (cond
283        (response-ids
284         (setf (cdr (last response-ids)) (list response-id))
285         (1- (length response-ids)))
286        (t
287         (setf (object-data dialog %*response-id-key*) (list response-id))
288         0)))
289      (error-p
290       (error "Invalid response: ~A" response-id))))))
291
292 (defun %dialog-find-response-id (dialog response-id-num)
293   (if (< response-id-num 0)
294       (car
295        (rassoc
296         (list response-id-num)
297         (rest (type-expand-1 'response-type)) :test #'equalp))
298     (nth response-id-num (object-data dialog %*response-id-key*))))
299
300
301 (defmethod signal-connect ((dialog dialog) signal function &key object after)
302   (let ((response-id-num (%dialog-find-response-id-num dialog signal)))
303     (cond
304      (response-id-num
305       (call-next-method
306        dialog 'response
307        #'(lambda (dialog id)
308            (when (= id response-id-num)
309              (cond
310               ((eq object t) (funcall function dialog))
311               (object (funcall function object))
312               (t (funcall function)))))
313        :object t :after after))
314     (t
315      (call-next-method)))))
316
317
318 (defbinding dialog-run () nil
319   (dialog dialog))
320
321 (defbinding dialog-response (dialog response-id) nil
322   (dialog dialog)
323   ((%dialog-find-response-id-num dialog response-id nil t) int))
324
325
326 (defbinding %dialog-add-button () button
327   (dialog dialog)
328   (text string)
329   (response-id-num int))
330
331 (defun dialog-add-button (dialog label &optional response-id default-p)
332   (let* ((response-id-num
333           (if response-id
334               (%dialog-find-response-id-num dialog response-id t)
335             (length (object-data dialog %*response-id-key*))))
336          (button (%dialog-add-button dialog label response-id-num)))
337     (unless response-id
338       (%dialog-find-response-id-num dialog button t))
339     (when default-p
340       (%dialog-set-default-response dialog response-id-num))
341     button))
342
343
344 (defbinding %dialog-add-action-widget () button
345   (dialog dialog)
346   (action-widget widget)
347   (response-id-num int))
348
349 (defun dialog-add-action-widget (dialog widget &optional (response-id widget)
350                                  default-p)
351   (let ((response-id-num (%dialog-find-response-id-num dialog response-id t)))
352     (%dialog-add-action-widget dialog widget response-id-num)
353     (when default-p
354       (%dialog-set-default-response dialog response-id-num))
355     widget))
356
357
358 (defbinding %dialog-set-default-response () nil
359   (dialog dialog)
360   (response-id-num int))
361
362 (defun dialog-set-default-response (dialog response-id)
363   (%dialog-set-default-response
364    dialog (%dialog-find-response-id-num dialog response-id nil t)))
365
366 (defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil
367   (dialog dialog)
368   ((%dialog-find-response-id-num dialog response-id nil t) int)
369   (sensitive boolean))
370
371
372 ;; Addition dialog functions
373
374 (defmethod container-add ((dialog dialog) (child widget) &rest args)
375   (apply #'container-add (slot-value dialog 'main-area) child args))
376
377 (defmethod container-remove ((dialog dialog) (child widget))
378   (container-remove (slot-value dialog 'main-area) child))
379
380 (defmethod container-children ((dialog dialog))
381   (container-children (dialog-main-area dialog)))
382
383 (defmethod (setf container-children) (children (dialog dialog))
384   (setf (container-children (dialog-main-area dialog)) children))
385
386
387
388 ;;; Drawing area -- no functions
389
390
391
392 ;;; Toggle button
393
394 (defbinding toggle-button-toggled () nil
395   (toggle-button toggle-button))
396
397
398 ;;; Label
399
400 (defbinding label-select-region () nil
401   (label label)
402   (start int)
403   (end int))
404
405
406
407
408 ;;; Radio button
409
410 (defbinding %radio-button-get-group () pointer
411   (radio-button radio-button))
412
413 (defbinding %radio-button-set-group () nil
414   (radio-button radio-button)
415   (group pointer))
416
417 (defun radio-button-add-to-group (button1 button2)
418   "Add BUTTON1 to the group which BUTTON2 belongs to."
419   (%radio-button-set-group button1 (%radio-button-get-group button2)))
420
421
422 (defmethod initialize-instance ((button radio-button)
423                                 &rest initargs &key group-with)
424   (declare (ignore initargs))
425   (call-next-method)
426   (when group-with
427     (radio-button-add-to-group item group-with)))
428
429
430 ;;; Option menu
431
432 (defbinding %option-menu-set-menu () nil
433   (option-menu option-menu)
434   (menu widget))
435
436 (defbinding %option-menu-remove-menu () nil
437   (option-menu option-menu))
438
439 (defun (setf option-menu-menu) (menu option-menu)
440   (if (not menu)
441       (%option-menu-remove-menu option-menu)
442     (%option-menu-set-menu option-menu menu))
443   menu)
444     
445
446
447 ;;; Item
448
449 (defbinding item-select () nil
450   (item item))
451
452 (defbinding item-deselect () nil
453   (item item))
454
455 (defbinding item-toggle () nil
456   (item item))
457
458
459
460 ;;; Menu item
461
462 (defun (setf menu-item-label) (label menu-item)
463   (make-instance 'accel-label
464    :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
465    :visible t :parent menu-item)
466   label)
467
468 (defbinding %menu-item-set-submenu () nil
469   (menu-item menu-item)
470   (submenu menu))
471
472 (defbinding %menu-item-remove-submenu () nil
473   (menu-item menu-item))
474
475 (defun (setf menu-item-submenu) (submenu menu-item)
476   (if (not submenu)
477       (%menu-item-remove-submenu menu-item)
478     (%menu-item-set-submenu menu-item submenu))
479   submenu)
480
481 (defbinding menu-item-select () nil
482   (menu-item menu-item))
483
484 (defbinding menu-item-deselect () nil
485   (menu-item menu-item))
486
487 (defbinding menu-item-activate () nil
488   (menu-item menu-item))
489
490
491
492 ;;; Radio menu item
493
494 (defbinding %radio-menu-item-get-group () pointer
495   (radio-menu-item radio-menu-item))
496
497 (defbinding %radio-menu-item-set-group () nil
498   (radio-menu-item radio-menu-item)
499   (group pointer))
500
501 (defun radio-menu-item-add-to-group (item1 item2)
502   "Add ITEM1 to the group which ITEM2 belongs to."
503   (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
504
505 (defmethod initialize-instance ((item radio-menu-item)
506                                 &rest initargs &key group-with)
507   (declare (ignore initargs))
508   (call-next-method)
509   (when group-with
510     (radio-menu-item-add-to-group item group-with)))
511   
512
513
514 ;;; Window
515
516 (defbinding window-set-wmclass () nil
517   (window window)
518   (wmclass-name string)
519   (wmclass-class string))
520
521 (defbinding window-add-accel-group () nil
522   (window window)
523   (accel-group accel-group))
524
525 (defbinding window-remove-accel-group () nil
526   (window window)
527   (accel-group accel-group))
528
529 (defbinding window-activate-focus () int
530   (window window))
531
532 (defbinding window-activate-default () int
533   (window window))
534
535 (defbinding window-set-default-size (window width height) int
536   (window window)
537   ((or width -1) int)
538   ((or height -1) int))
539
540 ;(defbinding window-set-geometry-hints)
541
542 (defbinding window-list-toplevels () (glist window))
543
544 (defbinding window-add-mnemonic (window key target) nil
545   (window window)
546   ((gdk:keyval-from-name key) unsigned-int)
547   (target widget))
548
549 (defbinding window-remove-mnemonic (window key target) nil
550   (window window)
551   ((gdk:keyval-from-name key) unsigned-int)
552   (target widget))
553
554 (defbinding window-mnemonic-activate (window key modifier) nil
555   (window window)
556   ((gdk:keyval-from-name key) unsigned-int)
557   (modifier gdk:modifier-type))
558
559 (defbinding window-present () nil
560   (window window))
561
562 (defbinding window-iconify () nil
563   (window window))
564
565 (defbinding window-deiconify () nil
566   (window window))
567
568 (defbinding window-stick () nil
569   (window window))
570
571 (defbinding window-unstick () nil
572   (window window))
573
574 (defbinding window-maximize () nil
575   (window window))
576
577 (defbinding window-unmaximize () nil
578   (window window))
579
580 (defbinding window-begin-resize-drag () nil
581   (window window)
582   (edge gdk:window-edge)
583   (button int)
584   (root-x int) (root-y int)
585   (timestamp (unsigned-int 32)))
586
587 (defbinding window-begin-move-drag () nil
588   (window window)
589   (edge gdk:window-edge)
590   (button int)
591   (root-x int) (root-y int)
592   (timestamp (unsigned-int 32)))
593
594 (defbinding window-set-frame-dimensions () nil
595   (window window)
596   (left int) (top int) (rigth int) (bottom int))
597
598 (defbinding (window-default-icons "gtk_window_get_default_icon_list")
599     () (glist gdk:pixbuf))
600
601 (defbinding %window-get-default-size () nil
602   (window window)
603   (width int :out)
604   (height int :out))
605
606 (defun window-get-default-size (window)
607   (multiple-value-bind (width height) (%window-get-default-size window)
608     (values (unless (= width -1) width) (unless (= height -1) height))))
609
610 (defbinding window-get-frame-dimensions () nil
611   (window window)
612   (left int :out) (top int :out) (rigth int :out) (bottom int :out))
613
614 (defbinding %window-get-icon-list () (glist gdk:pixbuf)
615   (window window))
616
617 (defmethod window-icon ((window window))
618   (let ((icon-list (%window-get-icon-list window)))
619     (if (endp (rest icon-list))
620         (first icon-list)
621       icon-list)))
622
623 (defbinding window-get-position () nil
624   (window window)
625   (root-x int :out)
626   (root-y int :out))
627
628 (defbinding window-get-size () nil
629   (window window)
630   (width int :out)
631   (height int :out))
632
633 (defbinding window-move () nil
634   (window window)
635   (x int)
636   (y int))
637
638 (defbinding window-parse-geometry () boolean
639   (window window)
640   (geometry string))
641
642 (defbinding window-reshow-with-initial-size () nil
643   (window window))
644
645 (defbinding window-resize () nil
646   (window window)
647   (width int)
648   (heigth int))
649
650 (defbinding %window-set-icon-list () nil
651   (window window)
652   (icon-list (glist gdk:pixbuf)))
653
654 (defmethod (setf window-icon) (icon (window window))
655   (%window-set-icon-list window (mklist icon)))
656
657
658
659
660 ;;; File selection
661
662 (defbinding file-selection-complete () nil
663   (file-selection file-selection)
664   (pattern string))
665
666
667
668 ;;; Scrolled window
669
670 (defun (setf scrolled-window-scrollbar-policy) (policy window)
671   (setf (scrolled-window-hscrollbar-policy window) policy)
672   (setf (scrolled-window-vscrollbar-policy window) policy))
673
674 (defbinding scrolled-window-add-with-viewport () nil
675    (scrolled-window scrolled-window)
676    (child widget))
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691 ;;; Statusbar
692
693 (defbinding (statusbar-context-id "gtk_statusbar_get_context_id")
694     () unsigned-int
695   (statusbar statusbar)
696   (context-description string))
697
698 (defbinding statusbar-push () unsigned-int
699   (statusbar statusbar)
700   (context-id unsigned-int)  
701   (text string))
702
703 (defbinding statusbar-pop () nil
704   (statusbar statusbar)
705   (context-id unsigned-int))
706
707 (defbinding statusbar-remove () nil
708   (statusbar statusbar)
709   (context-id unsigned-int)
710   (message-id unsigned-int))
711
712
713
714 ;;; Fixed
715
716 (defbinding fixed-put () nil
717   (fixed fixed)
718   (widget widget)
719   (x (signed 16))
720   (y (signed 16)))
721
722 (defbinding fixed-move () nil
723   (fixed fixed)
724   (widget widget)
725   (x (signed 16))
726   (y (signed 16)))
727
728
729
730 ;;; Notebook
731
732 (defbinding (notebook-insert-page "gtk_notebook_insert_page_menu")
733     (notebook position child tab-label &optional menu-label) nil
734   (notebook notebook)
735   (child widget)
736   ((if (stringp tab-label)
737        (label-new tab-label)
738      tab-label) widget)
739   ((if (stringp menu-label)
740        (label-new menu-label)
741      menu-label) (or null widget))
742   (position int))
743
744 (defun notebook-append-page (notebook child tab-label &optional menu-label)
745   (notebook-insert-page notebook -1 child tab-label menu-label))
746
747 (defun notebook-prepend-page (notebook child tab-label &optional menu-label)
748   (notebook-insert-page notebook 0 child tab-label menu-label))
749   
750 (defbinding notebook-remove-page () nil
751   (notebook notebook)
752   (page-num int))
753
754 ; (defun notebook-current-page-num (notebook)
755 ;   (let ((page-num (notebook-current-page notebook)))
756 ;     (if (= page-num -1)
757 ;       nil
758 ;       page-num)))
759
760 (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") () widget
761   (notebook notebook)
762   (page-num int))
763
764 (defun notebook-page-child (notebook)
765   (notebook-nth-page-child notebook (notebook-page notebook)))
766
767 (defbinding %notebook-page-num () int
768   (notebook notebook)
769   (child widget))
770
771 (defun notebook-child-num (notebook child)
772   (let ((page-num (%notebook-page-num notebook child)))
773     (if (= page-num -1)
774         nil
775       page-num)))
776
777 (defbinding notebook-next-page () nil
778   (notebook notebook))
779
780 (defbinding notebook-prev-page () nil
781   (notebook notebook))
782
783 (defbinding notebook-popup-enable () nil
784   (notebook notebook))
785
786 (defbinding notebook-popup-disable () nil
787   (notebook notebook))
788
789 ; (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
790 ;     (notebook ref) widget
791 ;   (notebook notebook)
792 ;   ((if (typep ref 'widget)
793 ;        ref
794 ;      (notebook-nth-page-child notebook ref))
795 ;    widget))
796
797 ; (defbinding %notebook-set-tab-label () nil
798 ;   (notebook notebook)
799 ;   (reference widget)
800 ;   (tab-label widget))
801
802 ; (defun (setf notebook-tab-label) (tab-label notebook reference)
803 ;   (let ((tab-label-widget (if (stringp tab-label)
804 ;                             (label-new tab-label)
805 ;                           tab-label)))
806 ;     (%notebook-set-tab-label
807 ;      notebook
808 ;      (if (typep reference 'widget)
809 ;        reference
810 ;        (notebook-nth-page-child notebook reference))
811 ;      tab-label-widget)
812 ;     tab-label-widget))
813    
814 ; (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
815 ;     (notebook ref) widget
816 ;   (notebook notebook)
817 ;   ((if (typep ref 'widget)
818 ;        ref
819 ;      (notebook-nth-page-child notebook ref))
820 ;    widget))
821
822 ; (defbinding %notebook-set-menu-label () nil
823 ;   (notebook notebook)
824 ;   (reference widget)
825 ;   (menu-label widget))
826
827 ; (defun (setf notebook-menu-label) (menu-label notebook reference)
828 ;   (let ((menu-label-widget (if (stringp menu-label)
829 ;                             (label-new menu-label)
830 ;                           menu-label)))
831 ;     (%notebook-set-menu-label
832 ;      notebook
833 ;      (if (typep reference 'widget)
834 ;        reference
835 ;        (notebook-nth-page-child notebook reference))
836 ;      menu-label-widget)
837 ;     menu-label-widget))
838
839 (defbinding notebook-query-tab-label-packing (notebook ref) nil
840   (notebook notebook)
841   ((if (typep ref 'widget)
842        ref
843      (notebook-nth-page-child notebook ref))
844    widget)
845   (expand boolean :out)
846   (fill boolean :out)
847   (pack-type pack-type :out))
848
849 (defbinding
850     notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil
851   (notebook notebook)
852   ((if (typep ref 'widget)
853        ref
854      (notebook-nth-page-child notebook ref))
855    widget)
856   (expand boolean)
857   (fill boolean)
858   (pack-type pack-type))
859
860 (defbinding notebook-reorder-child () nil
861   (notebook notebook)
862   (child widget)
863   (position int))
864
865
866
867 ;;; Paned
868
869 (defbinding paned-pack1 () nil
870   (paned paned)
871   (child widget)
872   (resize boolean)
873   (shrink boolean))
874
875 (defbinding paned-pack2 () nil
876   (paned paned)
877   (child widget)
878   (resize boolean)
879   (shrink boolean))
880
881 ;; gtkglue.c
882 (defbinding paned-child1 () widget
883   (paned paned)
884   (resize boolean :out)
885   (shrink boolean :out))
886
887 ;; gtkglue.c
888 (defbinding paned-child2 () widget
889   (paned paned)
890   (resize boolean :out)
891   (shrink boolean :out))
892
893 (defun (setf paned-child1) (child paned)
894   (paned-pack1 paned child nil t))
895
896 (defun (setf paned-child2) (child paned)
897   (paned-pack2 paned child t t))
898
899
900
901 ;;; Layout
902
903 (defbinding layout-put () nil
904   (layout layout)
905   (widget widget)
906   (x int)
907   (y int))
908
909 (defbinding layout-move () nil
910   (layout layout)
911   (widget widget)
912   (x int)
913   (y int))
914
915 (defbinding layout-set-size () nil
916   (layout layout)
917   (width int)
918   (height int))
919
920 (defbinding layout-get-size () nil
921   (layout layout)
922   (width int :out)
923   (height int :out))
924
925
926
927 ;;; Menu shell
928
929 (defbinding menu-shell-insert () nil
930   (menu-shell menu-shell)
931   (menu-item menu-item)
932   (position int))
933
934 (defun menu-shell-append (menu-shell menu-item)
935   (menu-shell-insert menu-shell menu-item -1))
936
937 (defun menu-shell-prepend (menu-shell menu-item)
938   (menu-shell-insert menu-shell menu-item 0))
939
940 (defbinding menu-shell-deactivate () nil
941   (menu-shell menu-shell))
942
943 (defbinding menu-shell-select-item () nil
944   (menu-shell menu-shell)
945   (menu-item menu-item))
946
947 (defbinding menu-shell-deselect () nil
948   (menu-shell menu-shell))
949
950 (defbinding menu-shell-activate-item () nil
951   (menu-shell menu-shell)
952   (menu-item menu-item)
953   (fore-deactivate boolean))
954
955
956
957 ; ;;; Menu bar
958
959 ; (defbinding menu-bar-insert () nil
960 ;   (menu-bar menu-bar)
961 ;   (menu menu)
962 ;   (position int))
963
964 ; (defun menu-bar-append (menu-bar menu)
965 ;   (menu-bar-insert menu-bar menu -1))
966
967 ; (defun menu-bar-prepend (menu-bar menu)
968 ;   (menu-bar-insert menu-bar menu 0))
969
970
971
972 ; ;;; Menu
973
974 ;(defun menu-popup ...)
975
976 (defbinding menu-reposition () nil
977   (menu menu))
978
979 (defbinding menu-popdown () nil
980   (menu menu))
981
982 (defbinding %menu-set-active () nil
983   (menu menu)
984   (index unsigned-int))
985
986 (defun (setf menu-active) (menu index)
987   (%menu-set-active menu index))
988   
989 (defbinding menu-reorder-child () nil
990   (menu menu)
991   (menu-item menu-item)
992   (position int))
993
994
995 ;;; Table
996
997 (defbinding table-resize () nil
998   (table table)
999   (rows unsigned-int)
1000   (columns unsigned-int))
1001
1002 (defbinding table-attach (table child left right top bottom
1003                                &key (x-options '(:expand :fill))
1004                                     (y-options '(:expand :fill))
1005                                     (x-padding 0) (y-padding 0)) nil
1006   (table table)
1007   (child widget)
1008   (left unsigned-int)
1009   (right unsigned-int)
1010   (top unsigned-int)
1011   (bottom unsigned-int)
1012   (x-options attach-options)
1013   (y-options attach-options)
1014   (x-padding unsigned-int)
1015   (y-padding unsigned-int))
1016
1017
1018 (defbinding %table-set-row-spacing () nil
1019   (table table)
1020   (row unsigned-int)
1021   (spacing unsigned-int))
1022
1023 (defbinding %table-set-row-spacings () nil
1024   (table table)
1025   (spacing unsigned-int))
1026
1027 (defun (setf table-row-spacing) (spacing table &optional row)
1028   (if row
1029       (%table-set-row-spacing table row spacing)
1030     (%table-set-row-spacings table spacing))
1031   spacing)
1032
1033 (defbinding %table-get-row-spacing () unsigned-int
1034   (table table)
1035   (row unsigned-int))
1036
1037 (defbinding %table-get-default-row-spacing () unsigned-int
1038   (table table))
1039
1040 (defun table-row-spacing (table &optional row)
1041   (if row
1042       (%table-get-row-spacing table row)
1043     (%table-get-default-row-spacing table)))
1044
1045
1046 (defbinding %table-set-col-spacing () nil
1047   (table table)
1048   (col unsigned-int)
1049   (spacing unsigned-int))
1050
1051 (defbinding %table-set-col-spacings () nil
1052   (table table)
1053   (spacing unsigned-int))
1054
1055 (defun (setf table-col-spacing) (spacing table &optional col)
1056   (if col
1057       (%table-set-col-spacing table col spacing)
1058     (%table-set-col-spacings table spacing))
1059   spacing)
1060
1061 (defbinding %table-get-col-spacing () unsigned-int
1062   (table table)
1063   (col unsigned-int))
1064
1065 (defbinding %table-get-default-col-spacing () unsigned-int
1066   (table table))
1067
1068 (defun table-col-spacing (table &optional col)
1069   (if col
1070       (%table-get-col-spacing table col)
1071     (%table-get-default-col-spacing table)))
1072   
1073
1074
1075 ;;; Toolbar
1076
1077 ;; gtkglue.c
1078 (defbinding toolbar-num-children () int
1079   (toolbar toolbar))
1080
1081 (defun %toolbar-position-num (toolbar position)
1082   (case position
1083     (:prepend 0)
1084     (:append (toolbar-num-children toolbar))
1085     (t
1086      (assert (and (>= position 0) (< position (toolbar-num-children toolbar))))
1087      position)))
1088
1089 (defbinding %toolbar-insert-element () widget
1090   (toolbar toolbar)
1091   (type toolbar-child-type)
1092   (widget (or null widget))
1093   (text string)
1094   (tooltip-text string)
1095   (tooltip-private-text string)
1096   (icon (or null widget))
1097   (nil null)
1098   (nil null)
1099   (position int))
1100
1101 (defun toolbar-insert-element (toolbar position
1102                                &key tooltip-text tooltip-private-text
1103                                type widget icon text callback)
1104   (let* ((icon-widget (typecase icon
1105                        ((or null widget) icon)
1106                        (t (pixmap-new icon))))
1107          (toolbar-child
1108           (%toolbar-insert-element
1109            toolbar (or type (and widget :widget) :button)
1110            widget text tooltip-text tooltip-private-text icon-widget
1111            (%toolbar-position-num toolbar position))))
1112     (when callback
1113       (signal-connect toolbar-child 'clicked callback))
1114     toolbar-child))
1115
1116 (defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text
1117                                type widget icon text callback)
1118   (toolbar-insert-element
1119    toolbar :append :type type :widget widget :icon icon :text text
1120    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1121    :callback callback))
1122
1123 (defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text
1124                                 type widget icon text callback)
1125   (toolbar-insert-element
1126    toolbar :prepend :type type :widget widget :icon icon :text text
1127    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1128    :callback callback))
1129
1130 (defun toolbar-insert-space (toolbar position)
1131   (toolbar-insert-element toolbar position :type :space))
1132
1133 (defun toolbar-append-space (toolbar)
1134   (toolbar-insert-space toolbar :append))
1135
1136 (defun toolbar-prepend-space (toolbar)
1137   (toolbar-insert-space toolbar :prepend))
1138
1139 (defun toolbar-insert-widget (toolbar widget position &key tooltip-text
1140                               tooltip-private-text callback)
1141   (toolbar-insert-element
1142    toolbar position :widget widget :tooltip-text tooltip-text
1143    :tooltip-private-text tooltip-private-text :callback callback))
1144  
1145 (defun toolbar-append-widget (toolbar widget &key tooltip-text
1146                               tooltip-private-text callback)
1147   (toolbar-insert-widget
1148    toolbar widget :append :tooltip-text tooltip-text
1149    :tooltip-private-text tooltip-private-text :callback callback))
1150
1151 (defun toolbar-prepend-widget (toolbar widget &key tooltip-text
1152                                tooltip-private-text callback)
1153   (toolbar-insert-widget
1154    toolbar widget :prepend :tooltip-text tooltip-text
1155    :tooltip-private-text tooltip-private-text :callback callback))
1156
1157 (defun toolbar-insert-item (toolbar text icon position &key tooltip-text
1158                             tooltip-private-text callback)
1159   (toolbar-insert-element
1160    toolbar position :text text :icon icon :callback callback
1161    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1162
1163 (defun toolbar-append-item (toolbar text icon &key tooltip-text
1164                             tooltip-private-text callback)
1165   (toolbar-insert-item
1166    toolbar text icon :append :callback callback
1167    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1168
1169                        
1170 (defun toolbar-prepend-item (toolbar text icon &key tooltip-text
1171                              tooltip-private-text callback)
1172   (toolbar-insert-item
1173    toolbar text icon :prepend :callback callback
1174    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1175
1176 (defun toolbar-enable-tooltips (toolbar)
1177   (setf (toolbar-tooltips-p toolbar) t))
1178
1179 (defun toolbar-disable-tooltips (toolbar)
1180   (setf (toolbar-tooltips-p toolbar) nil))
1181
1182
1183
1184
1185
1186
1187
1188
1189 ;;; Editable
1190 #|
1191 (defbinding editable-select-region (editable &optional (start 0) end) nil
1192   (editable editable)
1193   (start int)
1194   ((or end -1) int))
1195
1196 (defbinding editable-insert-text
1197     (editable text &optional (position 0)) nil
1198   (editable editable)
1199   (text string)
1200   ((length text) int)
1201   ((or position -1) int :in-out))
1202
1203 (defun editable-append-text (editable text)
1204   (editable-insert-text editable text nil))
1205
1206 (defun editable-prepend-text (editable text)
1207   (editable-insert-text editable text 0))
1208
1209 (defbinding editable-delete-text (editable &optional (start 0) end) nil
1210   (editable editable)
1211   (start int)
1212   ((or end -1) int))
1213
1214 (defbinding (editable-text "gtk_editable_get_chars")
1215     (editable &optional (start 0) end) string
1216   (editable editable)
1217   (start int)
1218   ((or end -1) int))
1219
1220 (defun (setf editable-text) (text editable)
1221   (if text
1222       (editable-delete-text
1223        editable
1224        (editable-insert-text editable text))
1225     (editable-delete-text editable))
1226   text)
1227
1228 (defbinding editable-cut-clipboard () nil
1229   (editable editable))
1230
1231 (defbinding editable-copy-clipboard () nil
1232   (editable editable))
1233
1234 (defbinding editable-paste-clipboard () nil
1235   (editable editable))
1236
1237 ; (defbinding editable-claim-selection () nil
1238 ;   (editable editable)
1239 ;   (claim boolean)
1240 ;   (time unsigned-int))
1241
1242 (defbinding editable-delete-selection () nil
1243   (editable editable))
1244
1245 ; (defbinding editable-changed () nil
1246 ;   (editable editable))
1247 |#
1248
1249
1250 ;;; Spin button
1251
1252 (defun spin-button-value-as-int (spin-button)
1253   (round (spin-button-value spin-button)))
1254
1255 (defbinding spin-button-spin () nil
1256   (spin-button spin-button)
1257   (direction spin-type)
1258   (increment single-float))
1259
1260 (defbinding spin-button-update () nil
1261   (spin-button spin-button))
1262
1263
1264
1265 ; ;;; Ruler
1266
1267 (defbinding ruler-set-range () nil
1268   (ruler ruler)
1269   (lower single-float)
1270   (upper single-float)
1271   (position single-float)
1272   (max-size single-float))
1273
1274 (defbinding ruler-draw-ticks () nil
1275   (ruler ruler))
1276
1277 (defbinding ruler-draw-pos () nil
1278   (ruler ruler))
1279
1280
1281
1282 ;;; Range
1283 #|
1284 (defbinding range-draw-background () nil
1285   (range range))
1286
1287 (defbinding range-clear-background () nil
1288   (range range))
1289
1290 (defbinding range-draw-trough () nil
1291   (range range))
1292
1293 (defbinding range-draw-slider () nil
1294   (range range))
1295
1296 (defbinding range-draw-step-forw () nil
1297   (range range))
1298
1299 (defbinding range-slider-update () nil
1300   (range range))
1301
1302 (defbinding range-trough-click () int
1303   (range range)
1304   (x int)
1305   (y int)
1306   (jump-perc single-float :out))
1307
1308 (defbinding range-default-hslider-update () nil
1309   (range range))
1310
1311 (defbinding range-default-vslider-update () nil
1312   (range range))
1313
1314 (defbinding range-default-htrough-click () int
1315   (range range)
1316   (x int)
1317   (y int)
1318   (jump-perc single-float :out))
1319
1320 (defbinding range-default-vtrough-click () int
1321   (range range)
1322   (x int)
1323   (y int)
1324   (jump-perc single-float :out))
1325
1326 (defbinding range-default-hmotion () int
1327   (range range)
1328   (x-delta int)
1329   (y-delta int))
1330
1331 (defbinding range-default-vmotion () int
1332   (range range)
1333   (x-delta int)
1334   (y-delta int))
1335 |#
1336
1337
1338 ;;; Scale
1339
1340 ; (defbinding scale-draw-value () nil
1341 ;   (scale scale))
1342
1343
1344
1345 ;;; Progress bar
1346
1347 (defbinding progress-bar-pulse () nil
1348   (progress-bar progress-bar))
1349
1350
1351
1352
1353
1354 ;;; Tooltips
1355
1356 (defbinding tooltips-enable () nil
1357   (tooltips tooltips))
1358
1359 (defbinding tooltips-disable () nil
1360   (tooltips tooltips))
1361
1362 (defun (setf tooltips-enabled-p) (enable tooltips)
1363   (if enable
1364       (tooltips-enable tooltips)
1365     (tooltips-disable tooltips)))
1366
1367 (defbinding tooltips-set-tip () nil
1368   (tooltips tooltips)
1369   (widget widget)
1370   (tip-text string)
1371   (tip-private string))
1372
1373 (defbinding tooltips-force-window () nil
1374   (tooltips tooltips))
1375
1376
1377
1378 ;;; Rc
1379
1380 (defbinding rc-add-default-file (filename) nil
1381   ((namestring (truename filename)) string))
1382
1383 (defbinding rc-parse (filename) nil
1384   ((namestring (truename filename)) string))
1385
1386 (defbinding rc-parse-string () nil
1387   (rc-string string))
1388
1389 (defbinding rc-reparse-all () nil)
1390
1391 (defbinding rc-get-style () style
1392   (widget widget))
1393
1394
1395
1396 ;;; Accelerator Groups
1397 #|
1398 (defbinding accel-group-get-default () accel-group)
1399
1400 (deftype-method alien-ref accel-group (type-spec)
1401   (declare (ignore type-spec))
1402   '%accel-group-ref)
1403
1404 (deftype-method alien-unref accel-group (type-spec)
1405   (declare (ignore type-spec))
1406   '%accel-group-unref)
1407
1408 (defbinding %accel-group-ref () accel-group
1409   (accel-group (or accel-group pointer)))
1410
1411 (defbinding %accel-group-unref () nil
1412   (accel-group (or accel-group pointer)))
1413
1414 (defbinding accel-group-activate (accel-group key modifiers) boolean
1415   (accel-group accel-group)
1416   ((gdk:keyval-from-name key) unsigned-int)
1417   (modifiers gdk:modifier-type))
1418
1419 (defbinding accel-groups-activate (object key modifiers) boolean
1420   (object object)
1421   ((gdk:keyval-from-name key) unsigned-int)
1422   (modifiers gdk:modifier-type))
1423
1424 (defbinding accel-group-attach () nil
1425   (accel-group accel-group)
1426   (object object))
1427
1428 (defbinding accel-group-detach () nil
1429   (accel-group accel-group)
1430   (object object))
1431
1432 (defbinding accel-group-lock () nil
1433   (accel-group accel-group))
1434
1435 (defbinding accel-group-unlock () nil
1436   (accel-group accel-group))
1437
1438
1439 ;;; Accelerator Groups Entries
1440
1441 (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry
1442   (accel-group accel-group)
1443   ((gdk:keyval-from-name key) unsigned-int)
1444   (modifiers gdk:modifier-type))
1445
1446 (defbinding accel-group-lock-entry (accel-group key modifiers) nil
1447   (accel-group accel-group)
1448   ((gdk:keyval-from-name key) unsigned-int)
1449   (modifiers gdk:modifier-type))
1450
1451 (defbinding accel-group-unlock-entry (accel-group key modifiers) nil
1452   (accel-group accel-group)
1453   ((gdk:keyval-from-name key) unsigned-int)
1454   (modifiers gdk:modifier-type))
1455
1456 (defbinding accel-group-add
1457     (accel-group key modifiers flags object signal) nil
1458   (accel-group accel-group)
1459   ((gdk:keyval-from-name key) unsigned-int)
1460   (modifiers gdk:modifier-type)
1461   (flags accel-flags)
1462   (object object)
1463   ((name-to-string signal) string))
1464
1465 (defbinding accel-group-add (accel-group key modifiers object) nil
1466   (accel-group accel-group)
1467   ((gdk:keyval-from-name key) unsigned-int)
1468   (modifiers gdk:modifier-type)
1469   (object object))
1470
1471
1472 ;;; Accelerator Signals
1473
1474 (defbinding accel-group-handle-add
1475     (object signal-id accel-group key modifiers flags) nil
1476   (object object)
1477   (signal-id unsigned-int)
1478   (accel-group accel-group)
1479   ((gdk:keyval-from-name key) unsigned-int)
1480   (modifiers gdk:modifier-type)
1481   (flags accel-flags))
1482
1483 (defbinding accel-group-handle-remove
1484     (object accel-group key modifiers) nil
1485   (object object)
1486   (accel-group accel-group)
1487   ((gdk:keyval-from-name key) unsigned-int)
1488   (modifiers gdk:modifier-type))
1489 |#