chiark / gitweb /
Updated dialog class
[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.9 2002-03-24 15:40:50 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 (defun (setf window-wmclass) (wmclass window)
522   (%window-set-wmclass window (svref wmclass 0) (svref wmclass 1))
523   (values (svref wmclass 0) (svref wmclass 1)))
524
525 ;; gtkglue.c
526 (defbinding window-wmclass () nil
527   (window window)
528   (wmclass-name string :out)
529   (wmclass-class string :out))
530
531 (defbinding window-add-accel-group () nil
532   (window window)
533   (accel-group accel-group))
534
535 (defbinding window-remove-accel-group () nil
536   (window window)
537   (accel-group accel-group))
538
539 (defbinding window-activate-focus () int
540   (window window))
541
542 (defbinding window-activate-default () int
543   (window window))
544
545 (defbinding window-set-transient-for () nil
546   (window window)
547   (parent window))
548
549 ;(defbinding window-set-geometry-hints)
550
551
552
553 ;;; File selection
554
555 (defbinding file-selection-complete () nil
556   (file-selection file-selection)
557   (pattern string))
558
559
560
561 ;;; Scrolled window
562
563 (defun (setf scrolled-window-scrollbar-policy) (policy window)
564   (setf (scrolled-window-hscrollbar-policy window) policy)
565   (setf (scrolled-window-vscrollbar-policy window) policy))
566
567 (defbinding scrolled-window-add-with-viewport () nil
568    (scrolled-window scrolled-window)
569    (child widget))
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584 ;;; Statusbar
585
586 (defbinding (statusbar-context-id "gtk_statusbar_get_context_id")
587     () unsigned-int
588   (statusbar statusbar)
589   (context-description string))
590
591 (defbinding statusbar-push () unsigned-int
592   (statusbar statusbar)
593   (context-id unsigned-int)  
594   (text string))
595
596 (defbinding statusbar-pop () nil
597   (statusbar statusbar)
598   (context-id unsigned-int))
599
600 (defbinding statusbar-remove () nil
601   (statusbar statusbar)
602   (context-id unsigned-int)
603   (message-id unsigned-int))
604
605
606
607 ;;; Fixed
608
609 (defbinding fixed-put () nil
610   (fixed fixed)
611   (widget widget)
612   (x (signed 16))
613   (y (signed 16)))
614
615 (defbinding fixed-move () nil
616   (fixed fixed)
617   (widget widget)
618   (x (signed 16))
619   (y (signed 16)))
620
621
622
623 ;;; Notebook
624
625 (defbinding (notebook-insert-page "gtk_notebook_insert_page_menu")
626     (notebook position child tab-label &optional menu-label) nil
627   (notebook notebook)
628   (child widget)
629   ((if (stringp tab-label)
630        (label-new tab-label)
631      tab-label) widget)
632   ((if (stringp menu-label)
633        (label-new menu-label)
634      menu-label) (or null widget))
635   (position int))
636
637 (defun notebook-append-page (notebook child tab-label &optional menu-label)
638   (notebook-insert-page notebook -1 child tab-label menu-label))
639
640 (defun notebook-prepend-page (notebook child tab-label &optional menu-label)
641   (notebook-insert-page notebook 0 child tab-label menu-label))
642   
643 (defbinding notebook-remove-page () nil
644   (notebook notebook)
645   (page-num int))
646
647 ; (defun notebook-current-page-num (notebook)
648 ;   (let ((page-num (notebook-current-page notebook)))
649 ;     (if (= page-num -1)
650 ;       nil
651 ;       page-num)))
652
653 (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") () widget
654   (notebook notebook)
655   (page-num int))
656
657 (defun notebook-page-child (notebook)
658   (notebook-nth-page-child notebook (notebook-page notebook)))
659
660 (defbinding %notebook-page-num () int
661   (notebook notebook)
662   (child widget))
663
664 (defun notebook-child-num (notebook child)
665   (let ((page-num (%notebook-page-num notebook child)))
666     (if (= page-num -1)
667         nil
668       page-num)))
669
670 (defbinding notebook-next-page () nil
671   (notebook notebook))
672
673 (defbinding notebook-prev-page () nil
674   (notebook notebook))
675
676 (defbinding notebook-popup-enable () nil
677   (notebook notebook))
678
679 (defbinding notebook-popup-disable () nil
680   (notebook notebook))
681
682 ; (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
683 ;     (notebook ref) widget
684 ;   (notebook notebook)
685 ;   ((if (typep ref 'widget)
686 ;        ref
687 ;      (notebook-nth-page-child notebook ref))
688 ;    widget))
689
690 ; (defbinding %notebook-set-tab-label () nil
691 ;   (notebook notebook)
692 ;   (reference widget)
693 ;   (tab-label widget))
694
695 ; (defun (setf notebook-tab-label) (tab-label notebook reference)
696 ;   (let ((tab-label-widget (if (stringp tab-label)
697 ;                             (label-new tab-label)
698 ;                           tab-label)))
699 ;     (%notebook-set-tab-label
700 ;      notebook
701 ;      (if (typep reference 'widget)
702 ;        reference
703 ;        (notebook-nth-page-child notebook reference))
704 ;      tab-label-widget)
705 ;     tab-label-widget))
706    
707 ; (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
708 ;     (notebook ref) widget
709 ;   (notebook notebook)
710 ;   ((if (typep ref 'widget)
711 ;        ref
712 ;      (notebook-nth-page-child notebook ref))
713 ;    widget))
714
715 ; (defbinding %notebook-set-menu-label () nil
716 ;   (notebook notebook)
717 ;   (reference widget)
718 ;   (menu-label widget))
719
720 ; (defun (setf notebook-menu-label) (menu-label notebook reference)
721 ;   (let ((menu-label-widget (if (stringp menu-label)
722 ;                             (label-new menu-label)
723 ;                           menu-label)))
724 ;     (%notebook-set-menu-label
725 ;      notebook
726 ;      (if (typep reference 'widget)
727 ;        reference
728 ;        (notebook-nth-page-child notebook reference))
729 ;      menu-label-widget)
730 ;     menu-label-widget))
731
732 (defbinding notebook-query-tab-label-packing (notebook ref) nil
733   (notebook notebook)
734   ((if (typep ref 'widget)
735        ref
736      (notebook-nth-page-child notebook ref))
737    widget)
738   (expand boolean :out)
739   (fill boolean :out)
740   (pack-type pack-type :out))
741
742 (defbinding
743     notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil
744   (notebook notebook)
745   ((if (typep ref 'widget)
746        ref
747      (notebook-nth-page-child notebook ref))
748    widget)
749   (expand boolean)
750   (fill boolean)
751   (pack-type pack-type))
752
753 (defbinding notebook-reorder-child () nil
754   (notebook notebook)
755   (child widget)
756   (position int))
757
758
759
760 ;;; Paned
761
762 (defbinding paned-pack1 () nil
763   (paned paned)
764   (child widget)
765   (resize boolean)
766   (shrink boolean))
767
768 (defbinding paned-pack2 () nil
769   (paned paned)
770   (child widget)
771   (resize boolean)
772   (shrink boolean))
773
774 ;; gtkglue.c
775 (defbinding paned-child1 () widget
776   (paned paned)
777   (resize boolean :out)
778   (shrink boolean :out))
779
780 ;; gtkglue.c
781 (defbinding paned-child2 () widget
782   (paned paned)
783   (resize boolean :out)
784   (shrink boolean :out))
785
786 (defun (setf paned-child1) (child paned)
787   (paned-pack1 paned child nil t))
788
789 (defun (setf paned-child2) (child paned)
790   (paned-pack2 paned child t t))
791
792
793
794 ;;; Layout
795
796 (defbinding layout-put () nil
797   (layout layout)
798   (widget widget)
799   (x int)
800   (y int))
801
802 (defbinding layout-move () nil
803   (layout layout)
804   (widget widget)
805   (x int)
806   (y int))
807
808 (defbinding layout-set-size () nil
809   (layout layout)
810   (width int)
811   (height int))
812
813 (defbinding layout-get-size () nil
814   (layout layout)
815   (width int :out)
816   (height int :out))
817
818
819
820 ;;; Menu shell
821
822 (defbinding menu-shell-insert () nil
823   (menu-shell menu-shell)
824   (menu-item menu-item)
825   (position int))
826
827 (defun menu-shell-append (menu-shell menu-item)
828   (menu-shell-insert menu-shell menu-item -1))
829
830 (defun menu-shell-prepend (menu-shell menu-item)
831   (menu-shell-insert menu-shell menu-item 0))
832
833 (defbinding menu-shell-deactivate () nil
834   (menu-shell menu-shell))
835
836 (defbinding menu-shell-select-item () nil
837   (menu-shell menu-shell)
838   (menu-item menu-item))
839
840 (defbinding menu-shell-deselect () nil
841   (menu-shell menu-shell))
842
843 (defbinding menu-shell-activate-item () nil
844   (menu-shell menu-shell)
845   (menu-item menu-item)
846   (fore-deactivate boolean))
847
848
849
850 ; ;;; Menu bar
851
852 ; (defbinding menu-bar-insert () nil
853 ;   (menu-bar menu-bar)
854 ;   (menu menu)
855 ;   (position int))
856
857 ; (defun menu-bar-append (menu-bar menu)
858 ;   (menu-bar-insert menu-bar menu -1))
859
860 ; (defun menu-bar-prepend (menu-bar menu)
861 ;   (menu-bar-insert menu-bar menu 0))
862
863
864
865 ; ;;; Menu
866
867 ;(defun menu-popup ...)
868
869 (defbinding menu-reposition () nil
870   (menu menu))
871
872 (defbinding menu-popdown () nil
873   (menu menu))
874
875 (defbinding %menu-set-active () nil
876   (menu menu)
877   (index unsigned-int))
878
879 (defun (setf menu-active) (menu index)
880   (%menu-set-active menu index))
881   
882 (defbinding menu-reorder-child () nil
883   (menu menu)
884   (menu-item menu-item)
885   (position int))
886
887
888 ;;; Table
889
890 (defbinding table-resize () nil
891   (table table)
892   (rows unsigned-int)
893   (columns unsigned-int))
894
895 (defbinding table-attach (table child left right top bottom
896                                &key (x-options '(:expand :fill))
897                                     (y-options '(:expand :fill))
898                                     (x-padding 0) (y-padding 0)) nil
899   (table table)
900   (child widget)
901   (left unsigned-int)
902   (right unsigned-int)
903   (top unsigned-int)
904   (bottom unsigned-int)
905   (x-options attach-options)
906   (y-options attach-options)
907   (x-padding unsigned-int)
908   (y-padding unsigned-int))
909
910
911 (defbinding %table-set-row-spacing () nil
912   (table table)
913   (row unsigned-int)
914   (spacing unsigned-int))
915
916 (defbinding %table-set-row-spacings () nil
917   (table table)
918   (spacing unsigned-int))
919
920 (defun (setf table-row-spacing) (spacing table &optional row)
921   (if row
922       (%table-set-row-spacing table row spacing)
923     (%table-set-row-spacings table spacing))
924   spacing)
925
926 (defbinding %table-get-row-spacing () unsigned-int
927   (table table)
928   (row unsigned-int))
929
930 (defbinding %table-get-default-row-spacing () unsigned-int
931   (table table))
932
933 (defun table-row-spacing (table &optional row)
934   (if row
935       (%table-get-row-spacing table row)
936     (%table-get-default-row-spacing table)))
937
938
939 (defbinding %table-set-col-spacing () nil
940   (table table)
941   (col unsigned-int)
942   (spacing unsigned-int))
943
944 (defbinding %table-set-col-spacings () nil
945   (table table)
946   (spacing unsigned-int))
947
948 (defun (setf table-col-spacing) (spacing table &optional col)
949   (if col
950       (%table-set-col-spacing table col spacing)
951     (%table-set-col-spacings table spacing))
952   spacing)
953
954 (defbinding %table-get-col-spacing () unsigned-int
955   (table table)
956   (col unsigned-int))
957
958 (defbinding %table-get-default-col-spacing () unsigned-int
959   (table table))
960
961 (defun table-col-spacing (table &optional col)
962   (if col
963       (%table-get-col-spacing table col)
964     (%table-get-default-col-spacing table)))
965   
966
967
968 ;;; Toolbar
969
970 ;; gtkglue.c
971 (defbinding toolbar-num-children () int
972   (toolbar toolbar))
973
974 (defun %toolbar-position-num (toolbar position)
975   (case position
976     (:prepend 0)
977     (:append (toolbar-num-children toolbar))
978     (t
979      (assert (and (>= position 0) (< position (toolbar-num-children toolbar))))
980      position)))
981
982 (defbinding %toolbar-insert-element () widget
983   (toolbar toolbar)
984   (type toolbar-child-type)
985   (widget (or null widget))
986   (text string)
987   (tooltip-text string)
988   (tooltip-private-text string)
989   (icon (or null widget))
990   (nil null)
991   (nil null)
992   (position int))
993
994 (defun toolbar-insert-element (toolbar position
995                                &key tooltip-text tooltip-private-text
996                                type widget icon text callback)
997   (let* ((icon-widget (typecase icon
998                        ((or null widget) icon)
999                        (t (pixmap-new icon))))
1000          (toolbar-child
1001           (%toolbar-insert-element
1002            toolbar (or type (and widget :widget) :button)
1003            widget text tooltip-text tooltip-private-text icon-widget
1004            (%toolbar-position-num toolbar position))))
1005     (when callback
1006       (signal-connect toolbar-child 'clicked callback))
1007     toolbar-child))
1008
1009 (defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text
1010                                type widget icon text callback)
1011   (toolbar-insert-element
1012    toolbar :append :type type :widget widget :icon icon :text text
1013    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1014    :callback callback))
1015
1016 (defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text
1017                                 type widget icon text callback)
1018   (toolbar-insert-element
1019    toolbar :prepend :type type :widget widget :icon icon :text text
1020    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1021    :callback callback))
1022
1023 (defun toolbar-insert-space (toolbar position)
1024   (toolbar-insert-element toolbar position :type :space))
1025
1026 (defun toolbar-append-space (toolbar)
1027   (toolbar-insert-space toolbar :append))
1028
1029 (defun toolbar-prepend-space (toolbar)
1030   (toolbar-insert-space toolbar :prepend))
1031
1032 (defun toolbar-insert-widget (toolbar widget position &key tooltip-text
1033                               tooltip-private-text callback)
1034   (toolbar-insert-element
1035    toolbar position :widget widget :tooltip-text tooltip-text
1036    :tooltip-private-text tooltip-private-text :callback callback))
1037  
1038 (defun toolbar-append-widget (toolbar widget &key tooltip-text
1039                               tooltip-private-text callback)
1040   (toolbar-insert-widget
1041    toolbar widget :append :tooltip-text tooltip-text
1042    :tooltip-private-text tooltip-private-text :callback callback))
1043
1044 (defun toolbar-prepend-widget (toolbar widget &key tooltip-text
1045                                tooltip-private-text callback)
1046   (toolbar-insert-widget
1047    toolbar widget :prepend :tooltip-text tooltip-text
1048    :tooltip-private-text tooltip-private-text :callback callback))
1049
1050 (defun toolbar-insert-item (toolbar text icon position &key tooltip-text
1051                             tooltip-private-text callback)
1052   (toolbar-insert-element
1053    toolbar position :text text :icon icon :callback callback
1054    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1055
1056 (defun toolbar-append-item (toolbar text icon &key tooltip-text
1057                             tooltip-private-text callback)
1058   (toolbar-insert-item
1059    toolbar text icon :append :callback callback
1060    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1061
1062                        
1063 (defun toolbar-prepend-item (toolbar text icon &key tooltip-text
1064                              tooltip-private-text callback)
1065   (toolbar-insert-item
1066    toolbar text icon :prepend :callback callback
1067    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1068
1069 (defun toolbar-enable-tooltips (toolbar)
1070   (setf (toolbar-tooltips-p toolbar) t))
1071
1072 (defun toolbar-disable-tooltips (toolbar)
1073   (setf (toolbar-tooltips-p toolbar) nil))
1074
1075
1076
1077
1078
1079
1080
1081
1082 ;;; Editable
1083 #|
1084 (defbinding editable-select-region (editable &optional (start 0) end) nil
1085   (editable editable)
1086   (start int)
1087   ((or end -1) int))
1088
1089 (defbinding editable-insert-text
1090     (editable text &optional (position 0)) nil
1091   (editable editable)
1092   (text string)
1093   ((length text) int)
1094   ((or position -1) int :in-out))
1095
1096 (defun editable-append-text (editable text)
1097   (editable-insert-text editable text nil))
1098
1099 (defun editable-prepend-text (editable text)
1100   (editable-insert-text editable text 0))
1101
1102 (defbinding editable-delete-text (editable &optional (start 0) end) nil
1103   (editable editable)
1104   (start int)
1105   ((or end -1) int))
1106
1107 (defbinding (editable-text "gtk_editable_get_chars")
1108     (editable &optional (start 0) end) string
1109   (editable editable)
1110   (start int)
1111   ((or end -1) int))
1112
1113 (defun (setf editable-text) (text editable)
1114   (if text
1115       (editable-delete-text
1116        editable
1117        (editable-insert-text editable text))
1118     (editable-delete-text editable))
1119   text)
1120
1121 (defbinding editable-cut-clipboard () nil
1122   (editable editable))
1123
1124 (defbinding editable-copy-clipboard () nil
1125   (editable editable))
1126
1127 (defbinding editable-paste-clipboard () nil
1128   (editable editable))
1129
1130 ; (defbinding editable-claim-selection () nil
1131 ;   (editable editable)
1132 ;   (claim boolean)
1133 ;   (time unsigned-int))
1134
1135 (defbinding editable-delete-selection () nil
1136   (editable editable))
1137
1138 ; (defbinding editable-changed () nil
1139 ;   (editable editable))
1140 |#
1141
1142
1143 ;;; Spin button
1144
1145 (defun spin-button-value-as-int (spin-button)
1146   (round (spin-button-value spin-button)))
1147
1148 (defbinding spin-button-spin () nil
1149   (spin-button spin-button)
1150   (direction spin-type)
1151   (increment single-float))
1152
1153 (defbinding spin-button-update () nil
1154   (spin-button spin-button))
1155
1156
1157
1158 ; ;;; Ruler
1159
1160 (defbinding ruler-set-range () nil
1161   (ruler ruler)
1162   (lower single-float)
1163   (upper single-float)
1164   (position single-float)
1165   (max-size single-float))
1166
1167 (defbinding ruler-draw-ticks () nil
1168   (ruler ruler))
1169
1170 (defbinding ruler-draw-pos () nil
1171   (ruler ruler))
1172
1173
1174
1175 ;;; Range
1176 #|
1177 (defbinding range-draw-background () nil
1178   (range range))
1179
1180 (defbinding range-clear-background () nil
1181   (range range))
1182
1183 (defbinding range-draw-trough () nil
1184   (range range))
1185
1186 (defbinding range-draw-slider () nil
1187   (range range))
1188
1189 (defbinding range-draw-step-forw () nil
1190   (range range))
1191
1192 (defbinding range-slider-update () nil
1193   (range range))
1194
1195 (defbinding range-trough-click () int
1196   (range range)
1197   (x int)
1198   (y int)
1199   (jump-perc single-float :out))
1200
1201 (defbinding range-default-hslider-update () nil
1202   (range range))
1203
1204 (defbinding range-default-vslider-update () nil
1205   (range range))
1206
1207 (defbinding range-default-htrough-click () int
1208   (range range)
1209   (x int)
1210   (y int)
1211   (jump-perc single-float :out))
1212
1213 (defbinding range-default-vtrough-click () int
1214   (range range)
1215   (x int)
1216   (y int)
1217   (jump-perc single-float :out))
1218
1219 (defbinding range-default-hmotion () int
1220   (range range)
1221   (x-delta int)
1222   (y-delta int))
1223
1224 (defbinding range-default-vmotion () int
1225   (range range)
1226   (x-delta int)
1227   (y-delta int))
1228 |#
1229
1230
1231 ;;; Scale
1232
1233 ; (defbinding scale-draw-value () nil
1234 ;   (scale scale))
1235
1236
1237
1238 ;;; Progress bar
1239
1240 (defbinding progress-bar-pulse () nil
1241   (progress-bar progress-bar))
1242
1243
1244
1245
1246
1247 ;;; Tooltips
1248
1249 (defbinding tooltips-enable () nil
1250   (tooltips tooltips))
1251
1252 (defbinding tooltips-disable () nil
1253   (tooltips tooltips))
1254
1255 (defun (setf tooltips-enabled-p) (enable tooltips)
1256   (if enable
1257       (tooltips-enable tooltips)
1258     (tooltips-disable tooltips)))
1259
1260 (defbinding tooltips-set-tip () nil
1261   (tooltips tooltips)
1262   (widget widget)
1263   (tip-text string)
1264   (tip-private string))
1265
1266 (defbinding tooltips-force-window () nil
1267   (tooltips tooltips))
1268
1269
1270
1271 ;;; Rc
1272
1273 (defbinding rc-add-default-file (filename) nil
1274   ((namestring (truename filename)) string))
1275
1276 (defbinding rc-parse (filename) nil
1277   ((namestring (truename filename)) string))
1278
1279 (defbinding rc-parse-string () nil
1280   (rc-string string))
1281
1282 (defbinding rc-reparse-all () nil)
1283
1284 (defbinding rc-get-style () style
1285   (widget widget))
1286
1287
1288
1289 ;;; Accelerator Groups
1290 #|
1291 (defbinding accel-group-get-default () accel-group)
1292
1293 (deftype-method alien-ref accel-group (type-spec)
1294   (declare (ignore type-spec))
1295   '%accel-group-ref)
1296
1297 (deftype-method alien-unref accel-group (type-spec)
1298   (declare (ignore type-spec))
1299   '%accel-group-unref)
1300
1301 (defbinding %accel-group-ref () accel-group
1302   (accel-group (or accel-group pointer)))
1303
1304 (defbinding %accel-group-unref () nil
1305   (accel-group (or accel-group pointer)))
1306
1307 (defbinding accel-group-activate (accel-group key modifiers) boolean
1308   (accel-group accel-group)
1309   ((gdk:keyval-from-name key) unsigned-int)
1310   (modifiers gdk:modifier-type))
1311
1312 (defbinding accel-groups-activate (object key modifiers) boolean
1313   (object object)
1314   ((gdk:keyval-from-name key) unsigned-int)
1315   (modifiers gdk:modifier-type))
1316
1317 (defbinding accel-group-attach () nil
1318   (accel-group accel-group)
1319   (object object))
1320
1321 (defbinding accel-group-detach () nil
1322   (accel-group accel-group)
1323   (object object))
1324
1325 (defbinding accel-group-lock () nil
1326   (accel-group accel-group))
1327
1328 (defbinding accel-group-unlock () nil
1329   (accel-group accel-group))
1330
1331
1332 ;;; Accelerator Groups Entries
1333
1334 (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry
1335   (accel-group accel-group)
1336   ((gdk:keyval-from-name key) unsigned-int)
1337   (modifiers gdk:modifier-type))
1338
1339 (defbinding accel-group-lock-entry (accel-group key modifiers) nil
1340   (accel-group accel-group)
1341   ((gdk:keyval-from-name key) unsigned-int)
1342   (modifiers gdk:modifier-type))
1343
1344 (defbinding accel-group-unlock-entry (accel-group key modifiers) nil
1345   (accel-group accel-group)
1346   ((gdk:keyval-from-name key) unsigned-int)
1347   (modifiers gdk:modifier-type))
1348
1349 (defbinding accel-group-add
1350     (accel-group key modifiers flags object signal) nil
1351   (accel-group accel-group)
1352   ((gdk:keyval-from-name key) unsigned-int)
1353   (modifiers gdk:modifier-type)
1354   (flags accel-flags)
1355   (object object)
1356   ((name-to-string signal) string))
1357
1358 (defbinding accel-group-add (accel-group key modifiers object) nil
1359   (accel-group accel-group)
1360   ((gdk:keyval-from-name key) unsigned-int)
1361   (modifiers gdk:modifier-type)
1362   (object object))
1363
1364
1365 ;;; Accelerator Signals
1366
1367 (defbinding accel-group-handle-add
1368     (object signal-id accel-group key modifiers flags) nil
1369   (object object)
1370   (signal-id unsigned-int)
1371   (accel-group accel-group)
1372   ((gdk:keyval-from-name key) unsigned-int)
1373   (modifiers gdk:modifier-type)
1374   (flags accel-flags))
1375
1376 (defbinding accel-group-handle-remove
1377     (object accel-group key modifiers) nil
1378   (object object)
1379   (accel-group accel-group)
1380   ((gdk:keyval-from-name key) unsigned-int)
1381   (modifiers gdk:modifier-type))
1382 |#