chiark / gitweb /
Workaround for wrong topological sorting of auto defined types
[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.11 2002-03-25 09:24:55 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 ;;; Entry
392
393 (defbinding  entry-get-layout () pango:layout
394   (entry entry))
395
396 (defbinding entry-get-layout-offsets () nil
397   (entry entry)
398   (x int :out)
399   (y int :out))
400
401
402
403 ;;; Label
404
405 (defbinding label-get-layout-offsets () nil
406   (labe label)
407   (x int :out)
408   (y int :out))
409
410 (defbinding label-select-region () nil
411   (label label)
412   (start int)
413   (end int))
414
415 (defbinding  label-get-text () string
416   (label label))
417
418 (defbinding label-get-layout () pango:layout
419   (label label))
420
421 (defbinding  label-get-selection-bounds () boolean
422   (label label)
423   (start int :out)
424   (end int :out))
425
426
427
428 ;;; Radio button
429
430 (defbinding %radio-button-get-group () pointer
431   (radio-button radio-button))
432
433 (defbinding %radio-button-set-group () nil
434   (radio-button radio-button)
435   (group pointer))
436
437 (defun radio-button-add-to-group (button1 button2)
438   "Add BUTTON1 to the group which BUTTON2 belongs to."
439   (%radio-button-set-group button1 (%radio-button-get-group button2)))
440
441
442 (defmethod initialize-instance ((button radio-button)
443                                 &rest initargs &key group-with)
444   (declare (ignore initargs))
445   (call-next-method)
446   (when group-with
447     (radio-button-add-to-group item group-with)))
448
449
450 ;;; Option menu
451
452 (defbinding %option-menu-set-menu () nil
453   (option-menu option-menu)
454   (menu widget))
455
456 (defbinding %option-menu-remove-menu () nil
457   (option-menu option-menu))
458
459 (defun (setf option-menu-menu) (menu option-menu)
460   (if (not menu)
461       (%option-menu-remove-menu option-menu)
462     (%option-menu-set-menu option-menu menu))
463   menu)
464     
465
466
467 ;;; Item
468
469 (defbinding item-select () nil
470   (item item))
471
472 (defbinding item-deselect () nil
473   (item item))
474
475 (defbinding item-toggle () nil
476   (item item))
477
478
479
480 ;;; Menu item
481
482 (defun (setf menu-item-label) (label menu-item)
483   (make-instance 'accel-label
484    :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
485    :visible t :parent menu-item)
486   label)
487
488 (defbinding %menu-item-set-submenu () nil
489   (menu-item menu-item)
490   (submenu menu))
491
492 (defbinding %menu-item-remove-submenu () nil
493   (menu-item menu-item))
494
495 (defun (setf menu-item-submenu) (submenu menu-item)
496   (if (not submenu)
497       (%menu-item-remove-submenu menu-item)
498     (%menu-item-set-submenu menu-item submenu))
499   submenu)
500
501 (defbinding menu-item-select () nil
502   (menu-item menu-item))
503
504 (defbinding menu-item-deselect () nil
505   (menu-item menu-item))
506
507 (defbinding menu-item-activate () nil
508   (menu-item menu-item))
509
510
511
512 ;;; Radio menu item
513
514 (defbinding %radio-menu-item-get-group () pointer
515   (radio-menu-item radio-menu-item))
516
517 (defbinding %radio-menu-item-set-group () nil
518   (radio-menu-item radio-menu-item)
519   (group pointer))
520
521 (defun radio-menu-item-add-to-group (item1 item2)
522   "Add ITEM1 to the group which ITEM2 belongs to."
523   (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
524
525 (defmethod initialize-instance ((item radio-menu-item)
526                                 &rest initargs &key group-with)
527   (declare (ignore initargs))
528   (call-next-method)
529   (when group-with
530     (radio-menu-item-add-to-group item group-with)))
531   
532
533
534 ;;; Toggle button
535
536 (defbinding toggle-button-toggled () nil
537   (toggle-button toggle-button))
538
539
540
541 ;;; Window
542
543 (defbinding window-set-wmclass () nil
544   (window window)
545   (wmclass-name string)
546   (wmclass-class string))
547
548 (defbinding window-add-accel-group () nil
549   (window window)
550   (accel-group accel-group))
551
552 (defbinding window-remove-accel-group () nil
553   (window window)
554   (accel-group accel-group))
555
556 (defbinding window-activate-focus () int
557   (window window))
558
559 (defbinding window-activate-default () int
560   (window window))
561
562 (defbinding window-set-default-size (window width height) int
563   (window window)
564   ((or width -1) int)
565   ((or height -1) int))
566
567 ;(defbinding window-set-geometry-hints)
568
569 (defbinding window-list-toplevels () (glist window))
570
571 (defbinding window-add-mnemonic (window key target) nil
572   (window window)
573   ((gdk:keyval-from-name key) unsigned-int)
574   (target widget))
575
576 (defbinding window-remove-mnemonic (window key target) nil
577   (window window)
578   ((gdk:keyval-from-name key) unsigned-int)
579   (target widget))
580
581 (defbinding window-mnemonic-activate (window key modifier) nil
582   (window window)
583   ((gdk:keyval-from-name key) unsigned-int)
584   (modifier gdk:modifier-type))
585
586 (defbinding window-present () nil
587   (window window))
588
589 (defbinding window-iconify () nil
590   (window window))
591
592 (defbinding window-deiconify () nil
593   (window window))
594
595 (defbinding window-stick () nil
596   (window window))
597
598 (defbinding window-unstick () nil
599   (window window))
600
601 (defbinding window-maximize () nil
602   (window window))
603
604 (defbinding window-unmaximize () nil
605   (window window))
606
607 (defbinding window-begin-resize-drag () nil
608   (window window)
609   (edge gdk:window-edge)
610   (button int)
611   (root-x int) (root-y int)
612   (timestamp (unsigned-int 32)))
613
614 (defbinding window-begin-move-drag () nil
615   (window window)
616   (edge gdk:window-edge)
617   (button int)
618   (root-x int) (root-y int)
619   (timestamp (unsigned-int 32)))
620
621 (defbinding window-set-frame-dimensions () nil
622   (window window)
623   (left int) (top int) (rigth int) (bottom int))
624
625 (defbinding (window-default-icons "gtk_window_get_default_icon_list")
626     () (glist gdk:pixbuf))
627
628 (defbinding %window-get-default-size () nil
629   (window window)
630   (width int :out)
631   (height int :out))
632
633 (defun window-get-default-size (window)
634   (multiple-value-bind (width height) (%window-get-default-size window)
635     (values (unless (= width -1) width) (unless (= height -1) height))))
636
637 (defbinding window-get-frame-dimensions () nil
638   (window window)
639   (left int :out) (top int :out) (rigth int :out) (bottom int :out))
640
641 (defbinding %window-get-icon-list () (glist gdk:pixbuf)
642   (window window))
643
644 (defmethod window-icon ((window window))
645   (let ((icon-list (%window-get-icon-list window)))
646     (if (endp (rest icon-list))
647         (first icon-list)
648       icon-list)))
649
650 (defbinding window-get-position () nil
651   (window window)
652   (root-x int :out)
653   (root-y int :out))
654
655 (defbinding window-get-size () nil
656   (window window)
657   (width int :out)
658   (height int :out))
659
660 (defbinding window-move () nil
661   (window window)
662   (x int)
663   (y int))
664
665 (defbinding window-parse-geometry () boolean
666   (window window)
667   (geometry string))
668
669 (defbinding window-reshow-with-initial-size () nil
670   (window window))
671
672 (defbinding window-resize () nil
673   (window window)
674   (width int)
675   (heigth int))
676
677 (defbinding %window-set-icon-list () nil
678   (window window)
679   (icon-list (glist gdk:pixbuf)))
680
681 (defmethod (setf window-icon) (icon (window window))
682   (%window-set-icon-list window (mklist icon)))
683
684
685
686
687 ;;; File selection
688
689 (defbinding file-selection-complete () nil
690   (file-selection file-selection)
691   (pattern string))
692
693
694
695 ;;; Scrolled window
696
697 (defun (setf scrolled-window-scrollbar-policy) (policy window)
698   (setf (scrolled-window-hscrollbar-policy window) policy)
699   (setf (scrolled-window-vscrollbar-policy window) policy))
700
701 (defbinding scrolled-window-add-with-viewport () nil
702    (scrolled-window scrolled-window)
703    (child widget))
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718 ;;; Statusbar
719
720 (defbinding (statusbar-context-id "gtk_statusbar_get_context_id")
721     () unsigned-int
722   (statusbar statusbar)
723   (context-description string))
724
725 (defbinding statusbar-push () unsigned-int
726   (statusbar statusbar)
727   (context-id unsigned-int)  
728   (text string))
729
730 (defbinding statusbar-pop () nil
731   (statusbar statusbar)
732   (context-id unsigned-int))
733
734 (defbinding statusbar-remove () nil
735   (statusbar statusbar)
736   (context-id unsigned-int)
737   (message-id unsigned-int))
738
739
740
741 ;;; Fixed
742
743 (defbinding fixed-put () nil
744   (fixed fixed)
745   (widget widget)
746   (x (signed 16))
747   (y (signed 16)))
748
749 (defbinding fixed-move () nil
750   (fixed fixed)
751   (widget widget)
752   (x (signed 16))
753   (y (signed 16)))
754
755
756
757 ;;; Notebook
758
759 (defbinding (notebook-insert-page "gtk_notebook_insert_page_menu")
760     (notebook position child tab-label &optional menu-label) nil
761   (notebook notebook)
762   (child widget)
763   ((if (stringp tab-label)
764        (label-new tab-label)
765      tab-label) widget)
766   ((if (stringp menu-label)
767        (label-new menu-label)
768      menu-label) (or null widget))
769   (position int))
770
771 (defun notebook-append-page (notebook child tab-label &optional menu-label)
772   (notebook-insert-page notebook -1 child tab-label menu-label))
773
774 (defun notebook-prepend-page (notebook child tab-label &optional menu-label)
775   (notebook-insert-page notebook 0 child tab-label menu-label))
776   
777 (defbinding notebook-remove-page () nil
778   (notebook notebook)
779   (page-num int))
780
781 ; (defun notebook-current-page-num (notebook)
782 ;   (let ((page-num (notebook-current-page notebook)))
783 ;     (if (= page-num -1)
784 ;       nil
785 ;       page-num)))
786
787 (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") () widget
788   (notebook notebook)
789   (page-num int))
790
791 (defun notebook-page-child (notebook)
792   (notebook-nth-page-child notebook (notebook-page notebook)))
793
794 (defbinding %notebook-page-num () int
795   (notebook notebook)
796   (child widget))
797
798 (defun notebook-child-num (notebook child)
799   (let ((page-num (%notebook-page-num notebook child)))
800     (if (= page-num -1)
801         nil
802       page-num)))
803
804 (defbinding notebook-next-page () nil
805   (notebook notebook))
806
807 (defbinding notebook-prev-page () nil
808   (notebook notebook))
809
810 (defbinding notebook-popup-enable () nil
811   (notebook notebook))
812
813 (defbinding notebook-popup-disable () nil
814   (notebook notebook))
815
816 ; (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
817 ;     (notebook ref) widget
818 ;   (notebook notebook)
819 ;   ((if (typep ref 'widget)
820 ;        ref
821 ;      (notebook-nth-page-child notebook ref))
822 ;    widget))
823
824 ; (defbinding %notebook-set-tab-label () nil
825 ;   (notebook notebook)
826 ;   (reference widget)
827 ;   (tab-label widget))
828
829 ; (defun (setf notebook-tab-label) (tab-label notebook reference)
830 ;   (let ((tab-label-widget (if (stringp tab-label)
831 ;                             (label-new tab-label)
832 ;                           tab-label)))
833 ;     (%notebook-set-tab-label
834 ;      notebook
835 ;      (if (typep reference 'widget)
836 ;        reference
837 ;        (notebook-nth-page-child notebook reference))
838 ;      tab-label-widget)
839 ;     tab-label-widget))
840    
841 ; (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
842 ;     (notebook ref) widget
843 ;   (notebook notebook)
844 ;   ((if (typep ref 'widget)
845 ;        ref
846 ;      (notebook-nth-page-child notebook ref))
847 ;    widget))
848
849 ; (defbinding %notebook-set-menu-label () nil
850 ;   (notebook notebook)
851 ;   (reference widget)
852 ;   (menu-label widget))
853
854 ; (defun (setf notebook-menu-label) (menu-label notebook reference)
855 ;   (let ((menu-label-widget (if (stringp menu-label)
856 ;                             (label-new menu-label)
857 ;                           menu-label)))
858 ;     (%notebook-set-menu-label
859 ;      notebook
860 ;      (if (typep reference 'widget)
861 ;        reference
862 ;        (notebook-nth-page-child notebook reference))
863 ;      menu-label-widget)
864 ;     menu-label-widget))
865
866 (defbinding notebook-query-tab-label-packing (notebook ref) nil
867   (notebook notebook)
868   ((if (typep ref 'widget)
869        ref
870      (notebook-nth-page-child notebook ref))
871    widget)
872   (expand boolean :out)
873   (fill boolean :out)
874   (pack-type pack-type :out))
875
876 (defbinding
877     notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil
878   (notebook notebook)
879   ((if (typep ref 'widget)
880        ref
881      (notebook-nth-page-child notebook ref))
882    widget)
883   (expand boolean)
884   (fill boolean)
885   (pack-type pack-type))
886
887 (defbinding notebook-reorder-child () nil
888   (notebook notebook)
889   (child widget)
890   (position int))
891
892
893
894 ;;; Paned
895
896 (defbinding paned-pack1 () nil
897   (paned paned)
898   (child widget)
899   (resize boolean)
900   (shrink boolean))
901
902 (defbinding paned-pack2 () nil
903   (paned paned)
904   (child widget)
905   (resize boolean)
906   (shrink boolean))
907
908 ;; gtkglue.c
909 (defbinding paned-child1 () widget
910   (paned paned)
911   (resize boolean :out)
912   (shrink boolean :out))
913
914 ;; gtkglue.c
915 (defbinding paned-child2 () widget
916   (paned paned)
917   (resize boolean :out)
918   (shrink boolean :out))
919
920 (defun (setf paned-child1) (child paned)
921   (paned-pack1 paned child nil t))
922
923 (defun (setf paned-child2) (child paned)
924   (paned-pack2 paned child t t))
925
926
927
928 ;;; Layout
929
930 (defbinding layout-put () nil
931   (layout layout)
932   (widget widget)
933   (x int)
934   (y int))
935
936 (defbinding layout-move () nil
937   (layout layout)
938   (widget widget)
939   (x int)
940   (y int))
941
942 (defbinding layout-set-size () nil
943   (layout layout)
944   (width int)
945   (height int))
946
947 (defbinding layout-get-size () nil
948   (layout layout)
949   (width int :out)
950   (height int :out))
951
952
953
954 ;;; Menu shell
955
956 (defbinding menu-shell-insert () nil
957   (menu-shell menu-shell)
958   (menu-item menu-item)
959   (position int))
960
961 (defun menu-shell-append (menu-shell menu-item)
962   (menu-shell-insert menu-shell menu-item -1))
963
964 (defun menu-shell-prepend (menu-shell menu-item)
965   (menu-shell-insert menu-shell menu-item 0))
966
967 (defbinding menu-shell-deactivate () nil
968   (menu-shell menu-shell))
969
970 (defbinding menu-shell-select-item () nil
971   (menu-shell menu-shell)
972   (menu-item menu-item))
973
974 (defbinding menu-shell-deselect () nil
975   (menu-shell menu-shell))
976
977 (defbinding menu-shell-activate-item () nil
978   (menu-shell menu-shell)
979   (menu-item menu-item)
980   (fore-deactivate boolean))
981
982
983
984 ; ;;; Menu bar
985
986 ; (defbinding menu-bar-insert () nil
987 ;   (menu-bar menu-bar)
988 ;   (menu menu)
989 ;   (position int))
990
991 ; (defun menu-bar-append (menu-bar menu)
992 ;   (menu-bar-insert menu-bar menu -1))
993
994 ; (defun menu-bar-prepend (menu-bar menu)
995 ;   (menu-bar-insert menu-bar menu 0))
996
997
998
999 ; ;;; Menu
1000
1001 ;(defun menu-popup ...)
1002
1003 (defbinding menu-reposition () nil
1004   (menu menu))
1005
1006 (defbinding menu-popdown () nil
1007   (menu menu))
1008
1009 (defbinding %menu-set-active () nil
1010   (menu menu)
1011   (index unsigned-int))
1012
1013 (defun (setf menu-active) (menu index)
1014   (%menu-set-active menu index))
1015   
1016 (defbinding menu-reorder-child () nil
1017   (menu menu)
1018   (menu-item menu-item)
1019   (position int))
1020
1021
1022 ;;; Table
1023
1024 (defbinding table-resize () nil
1025   (table table)
1026   (rows unsigned-int)
1027   (columns unsigned-int))
1028
1029 (defbinding table-attach (table child left right top bottom
1030                                &key (x-options '(:expand :fill))
1031                                     (y-options '(:expand :fill))
1032                                     (x-padding 0) (y-padding 0)) nil
1033   (table table)
1034   (child widget)
1035   (left unsigned-int)
1036   (right unsigned-int)
1037   (top unsigned-int)
1038   (bottom unsigned-int)
1039   (x-options attach-options)
1040   (y-options attach-options)
1041   (x-padding unsigned-int)
1042   (y-padding unsigned-int))
1043
1044
1045 (defbinding %table-set-row-spacing () nil
1046   (table table)
1047   (row unsigned-int)
1048   (spacing unsigned-int))
1049
1050 (defbinding %table-set-row-spacings () nil
1051   (table table)
1052   (spacing unsigned-int))
1053
1054 (defun (setf table-row-spacing) (spacing table &optional row)
1055   (if row
1056       (%table-set-row-spacing table row spacing)
1057     (%table-set-row-spacings table spacing))
1058   spacing)
1059
1060 (defbinding %table-get-row-spacing () unsigned-int
1061   (table table)
1062   (row unsigned-int))
1063
1064 (defbinding %table-get-default-row-spacing () unsigned-int
1065   (table table))
1066
1067 (defun table-row-spacing (table &optional row)
1068   (if row
1069       (%table-get-row-spacing table row)
1070     (%table-get-default-row-spacing table)))
1071
1072
1073 (defbinding %table-set-col-spacing () nil
1074   (table table)
1075   (col unsigned-int)
1076   (spacing unsigned-int))
1077
1078 (defbinding %table-set-col-spacings () nil
1079   (table table)
1080   (spacing unsigned-int))
1081
1082 (defun (setf table-col-spacing) (spacing table &optional col)
1083   (if col
1084       (%table-set-col-spacing table col spacing)
1085     (%table-set-col-spacings table spacing))
1086   spacing)
1087
1088 (defbinding %table-get-col-spacing () unsigned-int
1089   (table table)
1090   (col unsigned-int))
1091
1092 (defbinding %table-get-default-col-spacing () unsigned-int
1093   (table table))
1094
1095 (defun table-col-spacing (table &optional col)
1096   (if col
1097       (%table-get-col-spacing table col)
1098     (%table-get-default-col-spacing table)))
1099   
1100
1101
1102 ;;; Toolbar
1103
1104 ;; gtkglue.c
1105 (defbinding toolbar-num-children () int
1106   (toolbar toolbar))
1107
1108 (defun %toolbar-position-num (toolbar position)
1109   (case position
1110     (:prepend 0)
1111     (:append (toolbar-num-children toolbar))
1112     (t
1113      (assert (and (>= position 0) (< position (toolbar-num-children toolbar))))
1114      position)))
1115
1116 (defbinding %toolbar-insert-element () widget
1117   (toolbar toolbar)
1118   (type toolbar-child-type)
1119   (widget (or null widget))
1120   (text string)
1121   (tooltip-text string)
1122   (tooltip-private-text string)
1123   (icon (or null widget))
1124   (nil null)
1125   (nil null)
1126   (position int))
1127
1128 (defun toolbar-insert-element (toolbar position
1129                                &key tooltip-text tooltip-private-text
1130                                type widget icon text callback)
1131   (let* ((icon-widget (typecase icon
1132                        ((or null widget) icon)
1133                        (t (pixmap-new icon))))
1134          (toolbar-child
1135           (%toolbar-insert-element
1136            toolbar (or type (and widget :widget) :button)
1137            widget text tooltip-text tooltip-private-text icon-widget
1138            (%toolbar-position-num toolbar position))))
1139     (when callback
1140       (signal-connect toolbar-child 'clicked callback))
1141     toolbar-child))
1142
1143 (defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text
1144                                type widget icon text callback)
1145   (toolbar-insert-element
1146    toolbar :append :type type :widget widget :icon icon :text text
1147    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1148    :callback callback))
1149
1150 (defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text
1151                                 type widget icon text callback)
1152   (toolbar-insert-element
1153    toolbar :prepend :type type :widget widget :icon icon :text text
1154    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1155    :callback callback))
1156
1157 (defun toolbar-insert-space (toolbar position)
1158   (toolbar-insert-element toolbar position :type :space))
1159
1160 (defun toolbar-append-space (toolbar)
1161   (toolbar-insert-space toolbar :append))
1162
1163 (defun toolbar-prepend-space (toolbar)
1164   (toolbar-insert-space toolbar :prepend))
1165
1166 (defun toolbar-insert-widget (toolbar widget position &key tooltip-text
1167                               tooltip-private-text callback)
1168   (toolbar-insert-element
1169    toolbar position :widget widget :tooltip-text tooltip-text
1170    :tooltip-private-text tooltip-private-text :callback callback))
1171  
1172 (defun toolbar-append-widget (toolbar widget &key tooltip-text
1173                               tooltip-private-text callback)
1174   (toolbar-insert-widget
1175    toolbar widget :append :tooltip-text tooltip-text
1176    :tooltip-private-text tooltip-private-text :callback callback))
1177
1178 (defun toolbar-prepend-widget (toolbar widget &key tooltip-text
1179                                tooltip-private-text callback)
1180   (toolbar-insert-widget
1181    toolbar widget :prepend :tooltip-text tooltip-text
1182    :tooltip-private-text tooltip-private-text :callback callback))
1183
1184 (defun toolbar-insert-item (toolbar text icon position &key tooltip-text
1185                             tooltip-private-text callback)
1186   (toolbar-insert-element
1187    toolbar position :text text :icon icon :callback callback
1188    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1189
1190 (defun toolbar-append-item (toolbar text icon &key tooltip-text
1191                             tooltip-private-text callback)
1192   (toolbar-insert-item
1193    toolbar text icon :append :callback callback
1194    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1195
1196                        
1197 (defun toolbar-prepend-item (toolbar text icon &key tooltip-text
1198                              tooltip-private-text callback)
1199   (toolbar-insert-item
1200    toolbar text icon :prepend :callback callback
1201    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1202
1203 (defun toolbar-enable-tooltips (toolbar)
1204   (setf (toolbar-tooltips-p toolbar) t))
1205
1206 (defun toolbar-disable-tooltips (toolbar)
1207   (setf (toolbar-tooltips-p toolbar) nil))
1208
1209
1210
1211
1212
1213
1214
1215
1216 ;;; Editable
1217 #|
1218 (defbinding editable-select-region (editable &optional (start 0) end) nil
1219   (editable editable)
1220   (start int)
1221   ((or end -1) int))
1222
1223 (defbinding editable-insert-text
1224     (editable text &optional (position 0)) nil
1225   (editable editable)
1226   (text string)
1227   ((length text) int)
1228   ((or position -1) int :in-out))
1229
1230 (defun editable-append-text (editable text)
1231   (editable-insert-text editable text nil))
1232
1233 (defun editable-prepend-text (editable text)
1234   (editable-insert-text editable text 0))
1235
1236 (defbinding editable-delete-text (editable &optional (start 0) end) nil
1237   (editable editable)
1238   (start int)
1239   ((or end -1) int))
1240
1241 (defbinding (editable-text "gtk_editable_get_chars")
1242     (editable &optional (start 0) end) string
1243   (editable editable)
1244   (start int)
1245   ((or end -1) int))
1246
1247 (defun (setf editable-text) (text editable)
1248   (if text
1249       (editable-delete-text
1250        editable
1251        (editable-insert-text editable text))
1252     (editable-delete-text editable))
1253   text)
1254
1255 (defbinding editable-cut-clipboard () nil
1256   (editable editable))
1257
1258 (defbinding editable-copy-clipboard () nil
1259   (editable editable))
1260
1261 (defbinding editable-paste-clipboard () nil
1262   (editable editable))
1263
1264 ; (defbinding editable-claim-selection () nil
1265 ;   (editable editable)
1266 ;   (claim boolean)
1267 ;   (time unsigned-int))
1268
1269 (defbinding editable-delete-selection () nil
1270   (editable editable))
1271
1272 ; (defbinding editable-changed () nil
1273 ;   (editable editable))
1274 |#
1275
1276
1277 ;;; Spin button
1278
1279 (defun spin-button-value-as-int (spin-button)
1280   (round (spin-button-value spin-button)))
1281
1282 (defbinding spin-button-spin () nil
1283   (spin-button spin-button)
1284   (direction spin-type)
1285   (increment single-float))
1286
1287 (defbinding spin-button-update () nil
1288   (spin-button spin-button))
1289
1290
1291
1292 ; ;;; Ruler
1293
1294 (defbinding ruler-set-range () nil
1295   (ruler ruler)
1296   (lower single-float)
1297   (upper single-float)
1298   (position single-float)
1299   (max-size single-float))
1300
1301 (defbinding ruler-draw-ticks () nil
1302   (ruler ruler))
1303
1304 (defbinding ruler-draw-pos () nil
1305   (ruler ruler))
1306
1307
1308
1309 ;;; Range
1310 #|
1311 (defbinding range-draw-background () nil
1312   (range range))
1313
1314 (defbinding range-clear-background () nil
1315   (range range))
1316
1317 (defbinding range-draw-trough () nil
1318   (range range))
1319
1320 (defbinding range-draw-slider () nil
1321   (range range))
1322
1323 (defbinding range-draw-step-forw () nil
1324   (range range))
1325
1326 (defbinding range-slider-update () nil
1327   (range range))
1328
1329 (defbinding range-trough-click () int
1330   (range range)
1331   (x int)
1332   (y int)
1333   (jump-perc single-float :out))
1334
1335 (defbinding range-default-hslider-update () nil
1336   (range range))
1337
1338 (defbinding range-default-vslider-update () nil
1339   (range range))
1340
1341 (defbinding range-default-htrough-click () int
1342   (range range)
1343   (x int)
1344   (y int)
1345   (jump-perc single-float :out))
1346
1347 (defbinding range-default-vtrough-click () int
1348   (range range)
1349   (x int)
1350   (y int)
1351   (jump-perc single-float :out))
1352
1353 (defbinding range-default-hmotion () int
1354   (range range)
1355   (x-delta int)
1356   (y-delta int))
1357
1358 (defbinding range-default-vmotion () int
1359   (range range)
1360   (x-delta int)
1361   (y-delta int))
1362 |#
1363
1364
1365 ;;; Scale
1366
1367 ; (defbinding scale-draw-value () nil
1368 ;   (scale scale))
1369
1370
1371
1372 ;;; Progress bar
1373
1374 (defbinding progress-bar-pulse () nil
1375   (progress-bar progress-bar))
1376
1377
1378
1379
1380
1381 ;;; Tooltips
1382
1383 (defbinding tooltips-enable () nil
1384   (tooltips tooltips))
1385
1386 (defbinding tooltips-disable () nil
1387   (tooltips tooltips))
1388
1389 (defun (setf tooltips-enabled-p) (enable tooltips)
1390   (if enable
1391       (tooltips-enable tooltips)
1392     (tooltips-disable tooltips)))
1393
1394 (defbinding tooltips-set-tip () nil
1395   (tooltips tooltips)
1396   (widget widget)
1397   (tip-text string)
1398   (tip-private string))
1399
1400 (defbinding tooltips-force-window () nil
1401   (tooltips tooltips))
1402
1403
1404
1405 ;;; Rc
1406
1407 (defbinding rc-add-default-file (filename) nil
1408   ((namestring (truename filename)) string))
1409
1410 (defbinding rc-parse (filename) nil
1411   ((namestring (truename filename)) string))
1412
1413 (defbinding rc-parse-string () nil
1414   (rc-string string))
1415
1416 (defbinding rc-reparse-all () nil)
1417
1418 (defbinding rc-get-style () style
1419   (widget widget))
1420
1421
1422
1423 ;;; Accelerator Groups
1424 #|
1425 (defbinding accel-group-get-default () accel-group)
1426
1427 (deftype-method alien-ref accel-group (type-spec)
1428   (declare (ignore type-spec))
1429   '%accel-group-ref)
1430
1431 (deftype-method alien-unref accel-group (type-spec)
1432   (declare (ignore type-spec))
1433   '%accel-group-unref)
1434
1435 (defbinding %accel-group-ref () accel-group
1436   (accel-group (or accel-group pointer)))
1437
1438 (defbinding %accel-group-unref () nil
1439   (accel-group (or accel-group pointer)))
1440
1441 (defbinding accel-group-activate (accel-group key modifiers) boolean
1442   (accel-group accel-group)
1443   ((gdk:keyval-from-name key) unsigned-int)
1444   (modifiers gdk:modifier-type))
1445
1446 (defbinding accel-groups-activate (object key modifiers) boolean
1447   (object object)
1448   ((gdk:keyval-from-name key) unsigned-int)
1449   (modifiers gdk:modifier-type))
1450
1451 (defbinding accel-group-attach () nil
1452   (accel-group accel-group)
1453   (object object))
1454
1455 (defbinding accel-group-detach () nil
1456   (accel-group accel-group)
1457   (object object))
1458
1459 (defbinding accel-group-lock () nil
1460   (accel-group accel-group))
1461
1462 (defbinding accel-group-unlock () nil
1463   (accel-group accel-group))
1464
1465
1466 ;;; Accelerator Groups Entries
1467
1468 (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry
1469   (accel-group accel-group)
1470   ((gdk:keyval-from-name key) unsigned-int)
1471   (modifiers gdk:modifier-type))
1472
1473 (defbinding accel-group-lock-entry (accel-group key modifiers) nil
1474   (accel-group accel-group)
1475   ((gdk:keyval-from-name key) unsigned-int)
1476   (modifiers gdk:modifier-type))
1477
1478 (defbinding accel-group-unlock-entry (accel-group key modifiers) nil
1479   (accel-group accel-group)
1480   ((gdk:keyval-from-name key) unsigned-int)
1481   (modifiers gdk:modifier-type))
1482
1483 (defbinding accel-group-add
1484     (accel-group key modifiers flags object signal) nil
1485   (accel-group accel-group)
1486   ((gdk:keyval-from-name key) unsigned-int)
1487   (modifiers gdk:modifier-type)
1488   (flags accel-flags)
1489   (object object)
1490   ((name-to-string signal) string))
1491
1492 (defbinding accel-group-add (accel-group key modifiers object) nil
1493   (accel-group accel-group)
1494   ((gdk:keyval-from-name key) unsigned-int)
1495   (modifiers gdk:modifier-type)
1496   (object object))
1497
1498
1499 ;;; Accelerator Signals
1500
1501 (defbinding accel-group-handle-add
1502     (object signal-id accel-group key modifiers flags) nil
1503   (object object)
1504   (signal-id unsigned-int)
1505   (accel-group accel-group)
1506   ((gdk:keyval-from-name key) unsigned-int)
1507   (modifiers gdk:modifier-type)
1508   (flags accel-flags))
1509
1510 (defbinding accel-group-handle-remove
1511     (object accel-group key modifiers) nil
1512   (object object)
1513   (accel-group accel-group)
1514   ((gdk:keyval-from-name key) unsigned-int)
1515   (modifiers gdk:modifier-type))
1516 |#