chiark / gitweb /
Widget class updated for gtk 2.0
[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.7 2001-11-12 22:34:28 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 initialize-instance ((dialog dialog) &rest initargs)
267   (apply #'call-next-method dialog (plist-remove initargs :child))
268   (dolist (button-definition (get-all initargs :button))
269     (apply #'dialog-add-button dialog button-definition))
270   (dolist (child (get-all initargs :child))
271     (apply #'dialog-add-child dialog (mklist child))))
272
273
274 (defvar %*response-id-key* (gensym))
275
276 (defun %dialog-find-response-id-num (dialog response-id create-p)
277   (or
278    (cadr (assoc response-id (rest (type-expand-1 'response-type))))
279    (let* ((response-ids (object-data dialog %*response-id-key*))
280           (response-id-num (position response-id response-ids)))
281     (cond
282      (response-id-num)
283      (create-p
284       (cond
285        (response-ids
286         (setf (cdr (last response-ids)) (list response-id))
287         (1- (length response-ids)))
288        (t
289         (setf (object-data dialog %*response-id-key*) (list response-id))
290         0)))
291      (t
292       (error "Invalid response id: ~A" response-id))))))
293
294 (defun %dialog-find-response-id (dialog response-id-num)
295   (if (< response-id-num 0)
296       (car
297        (rassoc
298         (list response-id-num)
299         (rest (type-expand-1 'response-type)) :test #'equalp))
300     (nth response-id-num (object-data dialog %*response-id-key*))))
301
302
303 (defmethod signal-connect ((dialog dialog) signal function &key object)
304   (case signal
305     (response
306      #'(lambda (dialog response-id-num)
307          (let ((response-id (%dialog-find-response-id dialog response-id-num)))
308            (cond
309             ((eq object t)  (funcall function dialog response-id))
310             (object (funcall function object response-id))
311             (t (funcall function response-id))))))
312     (t
313      (call-next-method))))
314
315
316 (defbinding dialog-response (dialog response-id) nil
317   (dialog dialog)
318   ((%dialog-find-response-id-num dialog response-id nil) int))
319   
320 (defbinding %dialog-set-default-response () nil
321   (dialog dialog)
322   (response-id-num int))
323
324 (defun dialog-set-default-response (dialog response-id)
325   (%dialog-set-default-response
326    dialog (%dialog-find-response-id-num dialog response-id nil)))
327
328 (defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil
329   (dialog dialog)
330   ((%dialog-find-response-id-num dialog response-id nil) int)
331   (sensitive boolean))
332
333
334 (defbinding %dialog-add-button () button
335   (dialog dialog)
336   (text string)
337   (response-id-num int))
338
339 (defun dialog-add-button (dialog label &optional response-id default-p)
340   (let* ((response-id-num
341           (if response-id
342               (%dialog-find-response-id-num dialog response-id t)
343             (length (object-data dialog %*response-id-key*))))
344          (button (%dialog-add-button dialog label response-id-num)))
345     (unless response-id
346       (%dialog-find-response-id-num dialog button t))
347     (when default-p
348       (%dialog-set-default-response dialog response-id-num))
349     button))
350
351
352 (defbinding %dialog-add-action-widget () button
353   (dialog dialog)
354   (action-widget widget)
355   (response-id-num int))
356
357 (defun dialog-add-action-widget (dialog widget &optional (response-id widget)
358                                  default-p)
359   (let ((response-id-num (%dialog-find-response-id-num dialog response-id t)))
360     (%dialog-add-action-widget dialog widget response-id-num)
361     (when default-p
362       (%dialog-set-default-response dialog response-id-num))
363     widget))
364   
365
366 (defun dialog-add-child (dialog child &rest args)
367   (apply #'container-add (slot-value dialog 'vbox) child args))
368
369 (defmethod container-children ((dialog dialog))
370   (container-children (dialog-vbox dialog)))
371
372 (defmethod (setf container-children) (children (dialog dialog))
373   (setf (container-children (dialog-vbox dialog)) children))
374
375
376
377 ;;; Drawing area -- no functions
378
379
380
381
382
383
384
385 ;;; Toggle button
386
387 (defbinding toggle-button-toggled () nil
388   (toggle-button toggle-button))
389
390
391 ;;; Label
392
393 (defbinding label-select-region () nil
394   (label label)
395   (start int)
396   (end int))
397
398
399
400
401 ;;; Radio button
402
403 (defbinding %radio-button-get-group () pointer
404   (radio-button radio-button))
405
406 (defbinding %radio-button-set-group () nil
407   (radio-button radio-button)
408   (group pointer))
409
410 (defun radio-button-add-to-group (button1 button2)
411   "Add BUTTON1 to the group which BUTTON2 belongs to."
412   (%radio-button-set-group button1 (%radio-button-get-group button2)))
413
414
415 (defmethod initialize-instance ((button radio-button)
416                                 &rest initargs &key group-with)
417   (declare (ignore initargs))
418   (call-next-method)
419   (when group-with
420     (radio-button-add-to-group item group-with)))
421
422
423 ;;; Option menu
424
425 (defbinding %option-menu-set-menu () nil
426   (option-menu option-menu)
427   (menu widget))
428
429 (defbinding %option-menu-remove-menu () nil
430   (option-menu option-menu))
431
432 (defun (setf option-menu-menu) (menu option-menu)
433   (if (not menu)
434       (%option-menu-remove-menu option-menu)
435     (%option-menu-set-menu option-menu menu))
436   menu)
437     
438
439
440 ;;; Item
441
442 (defbinding item-select () nil
443   (item item))
444
445 (defbinding item-deselect () nil
446   (item item))
447
448 (defbinding item-toggle () nil
449   (item item))
450
451
452
453 ;;; Menu item
454
455 (defun (setf menu-item-label) (label menu-item)
456   (make-instance 'accel-label
457    :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
458    :visible t :parent menu-item)
459   label)
460
461 (defbinding %menu-item-set-submenu () nil
462   (menu-item menu-item)
463   (submenu menu))
464
465 (defbinding %menu-item-remove-submenu () nil
466   (menu-item menu-item))
467
468 (defun (setf menu-item-submenu) (submenu menu-item)
469   (if (not submenu)
470       (%menu-item-remove-submenu menu-item)
471     (%menu-item-set-submenu menu-item submenu))
472   submenu)
473
474 (defbinding menu-item-select () nil
475   (menu-item menu-item))
476
477 (defbinding menu-item-deselect () nil
478   (menu-item menu-item))
479
480 (defbinding menu-item-activate () nil
481   (menu-item menu-item))
482
483
484
485 ;;; Radio menu item
486
487 (defbinding %radio-menu-item-get-group () pointer
488   (radio-menu-item radio-menu-item))
489
490 (defbinding %radio-menu-item-set-group () nil
491   (radio-menu-item radio-menu-item)
492   (group pointer))
493
494 (defun radio-menu-item-add-to-group (item1 item2)
495   "Add ITEM1 to the group which ITEM2 belongs to."
496   (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
497
498 (defmethod initialize-instance ((item radio-menu-item)
499                                 &rest initargs &key group-with)
500   (declare (ignore initargs))
501   (call-next-method)
502   (when group-with
503     (radio-menu-item-add-to-group item group-with)))
504   
505
506
507 ;;; Window
508
509 (defbinding %window-set-wmclass () nil
510   (window window)
511   (wmclass-name string)
512   (wmclass-class string))
513
514 (defun (setf window-wmclass) (wmclass window)
515   (%window-set-wmclass window (svref wmclass 0) (svref wmclass 1))
516   (values (svref wmclass 0) (svref wmclass 1)))
517
518 ;; gtkglue.c
519 (defbinding window-wmclass () nil
520   (window window)
521   (wmclass-name string :out)
522   (wmclass-class string :out))
523
524 (defbinding window-add-accel-group () nil
525   (window window)
526   (accel-group accel-group))
527
528 (defbinding window-remove-accel-group () nil
529   (window window)
530   (accel-group accel-group))
531
532 (defbinding window-activate-focus () int
533   (window window))
534
535 (defbinding window-activate-default () int
536   (window window))
537
538 (defbinding window-set-transient-for () nil
539   (window window)
540   (parent window))
541
542 ;(defbinding window-set-geometry-hints)
543
544
545
546 ;;; File selection
547
548 (defbinding file-selection-complete () nil
549   (file-selection file-selection)
550   (pattern string))
551
552
553
554 ;;; Scrolled window
555
556 (defun (setf scrolled-window-scrollbar-policy) (policy window)
557   (setf (scrolled-window-hscrollbar-policy window) policy)
558   (setf (scrolled-window-vscrollbar-policy window) policy))
559
560 (defbinding scrolled-window-add-with-viewport () nil
561    (scrolled-window scrolled-window)
562    (child widget))
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577 ;;; Statusbar
578
579 (defbinding (statusbar-context-id "gtk_statusbar_get_context_id")
580     () unsigned-int
581   (statusbar statusbar)
582   (context-description string))
583
584 (defbinding statusbar-push () unsigned-int
585   (statusbar statusbar)
586   (context-id unsigned-int)  
587   (text string))
588
589 (defbinding statusbar-pop () nil
590   (statusbar statusbar)
591   (context-id unsigned-int))
592
593 (defbinding statusbar-remove () nil
594   (statusbar statusbar)
595   (context-id unsigned-int)
596   (message-id unsigned-int))
597
598
599
600 ;;; Fixed
601
602 (defbinding fixed-put () nil
603   (fixed fixed)
604   (widget widget)
605   (x (signed 16))
606   (y (signed 16)))
607
608 (defbinding fixed-move () nil
609   (fixed fixed)
610   (widget widget)
611   (x (signed 16))
612   (y (signed 16)))
613
614
615
616 ;;; Notebook
617
618 (defbinding (notebook-insert-page "gtk_notebook_insert_page_menu")
619     (notebook position child tab-label &optional menu-label) nil
620   (notebook notebook)
621   (child widget)
622   ((if (stringp tab-label)
623        (label-new tab-label)
624      tab-label) widget)
625   ((if (stringp menu-label)
626        (label-new menu-label)
627      menu-label) (or null widget))
628   (position int))
629
630 (defun notebook-append-page (notebook child tab-label &optional menu-label)
631   (notebook-insert-page notebook -1 child tab-label menu-label))
632
633 (defun notebook-prepend-page (notebook child tab-label &optional menu-label)
634   (notebook-insert-page notebook 0 child tab-label menu-label))
635   
636 (defbinding notebook-remove-page () nil
637   (notebook notebook)
638   (page-num int))
639
640 ; (defun notebook-current-page-num (notebook)
641 ;   (let ((page-num (notebook-current-page notebook)))
642 ;     (if (= page-num -1)
643 ;       nil
644 ;       page-num)))
645
646 (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") () widget
647   (notebook notebook)
648   (page-num int))
649
650 (defun notebook-page-child (notebook)
651   (notebook-nth-page-child notebook (notebook-page notebook)))
652
653 (defbinding %notebook-page-num () int
654   (notebook notebook)
655   (child widget))
656
657 (defun notebook-child-num (notebook child)
658   (let ((page-num (%notebook-page-num notebook child)))
659     (if (= page-num -1)
660         nil
661       page-num)))
662
663 (defbinding notebook-next-page () nil
664   (notebook notebook))
665
666 (defbinding notebook-prev-page () nil
667   (notebook notebook))
668
669 (defbinding notebook-popup-enable () nil
670   (notebook notebook))
671
672 (defbinding notebook-popup-disable () nil
673   (notebook notebook))
674
675 ; (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
676 ;     (notebook ref) widget
677 ;   (notebook notebook)
678 ;   ((if (typep ref 'widget)
679 ;        ref
680 ;      (notebook-nth-page-child notebook ref))
681 ;    widget))
682
683 ; (defbinding %notebook-set-tab-label () nil
684 ;   (notebook notebook)
685 ;   (reference widget)
686 ;   (tab-label widget))
687
688 ; (defun (setf notebook-tab-label) (tab-label notebook reference)
689 ;   (let ((tab-label-widget (if (stringp tab-label)
690 ;                             (label-new tab-label)
691 ;                           tab-label)))
692 ;     (%notebook-set-tab-label
693 ;      notebook
694 ;      (if (typep reference 'widget)
695 ;        reference
696 ;        (notebook-nth-page-child notebook reference))
697 ;      tab-label-widget)
698 ;     tab-label-widget))
699    
700 ; (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
701 ;     (notebook ref) widget
702 ;   (notebook notebook)
703 ;   ((if (typep ref 'widget)
704 ;        ref
705 ;      (notebook-nth-page-child notebook ref))
706 ;    widget))
707
708 ; (defbinding %notebook-set-menu-label () nil
709 ;   (notebook notebook)
710 ;   (reference widget)
711 ;   (menu-label widget))
712
713 ; (defun (setf notebook-menu-label) (menu-label notebook reference)
714 ;   (let ((menu-label-widget (if (stringp menu-label)
715 ;                             (label-new menu-label)
716 ;                           menu-label)))
717 ;     (%notebook-set-menu-label
718 ;      notebook
719 ;      (if (typep reference 'widget)
720 ;        reference
721 ;        (notebook-nth-page-child notebook reference))
722 ;      menu-label-widget)
723 ;     menu-label-widget))
724
725 (defbinding notebook-query-tab-label-packing (notebook ref) nil
726   (notebook notebook)
727   ((if (typep ref 'widget)
728        ref
729      (notebook-nth-page-child notebook ref))
730    widget)
731   (expand boolean :out)
732   (fill boolean :out)
733   (pack-type pack-type :out))
734
735 (defbinding
736     notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil
737   (notebook notebook)
738   ((if (typep ref 'widget)
739        ref
740      (notebook-nth-page-child notebook ref))
741    widget)
742   (expand boolean)
743   (fill boolean)
744   (pack-type pack-type))
745
746 (defbinding notebook-reorder-child () nil
747   (notebook notebook)
748   (child widget)
749   (position int))
750
751
752
753 ;;; Paned
754
755 (defbinding paned-pack1 () nil
756   (paned paned)
757   (child widget)
758   (resize boolean)
759   (shrink boolean))
760
761 (defbinding paned-pack2 () nil
762   (paned paned)
763   (child widget)
764   (resize boolean)
765   (shrink boolean))
766
767 ;; gtkglue.c
768 (defbinding paned-child1 () widget
769   (paned paned)
770   (resize boolean :out)
771   (shrink boolean :out))
772
773 ;; gtkglue.c
774 (defbinding paned-child2 () widget
775   (paned paned)
776   (resize boolean :out)
777   (shrink boolean :out))
778
779 (defun (setf paned-child1) (child paned)
780   (paned-pack1 paned child nil t))
781
782 (defun (setf paned-child2) (child paned)
783   (paned-pack2 paned child t t))
784
785
786
787 ;;; Layout
788
789 (defbinding layout-put () nil
790   (layout layout)
791   (widget widget)
792   (x int)
793   (y int))
794
795 (defbinding layout-move () nil
796   (layout layout)
797   (widget widget)
798   (x int)
799   (y int))
800
801 (defbinding layout-set-size () nil
802   (layout layout)
803   (width int)
804   (height int))
805
806 (defbinding layout-get-size () nil
807   (layout layout)
808   (width int :out)
809   (height int :out))
810
811
812
813 ;;; Menu shell
814
815 (defbinding menu-shell-insert () nil
816   (menu-shell menu-shell)
817   (menu-item menu-item)
818   (position int))
819
820 (defun menu-shell-append (menu-shell menu-item)
821   (menu-shell-insert menu-shell menu-item -1))
822
823 (defun menu-shell-prepend (menu-shell menu-item)
824   (menu-shell-insert menu-shell menu-item 0))
825
826 (defbinding menu-shell-deactivate () nil
827   (menu-shell menu-shell))
828
829 (defbinding menu-shell-select-item () nil
830   (menu-shell menu-shell)
831   (menu-item menu-item))
832
833 (defbinding menu-shell-deselect () nil
834   (menu-shell menu-shell))
835
836 (defbinding menu-shell-activate-item () nil
837   (menu-shell menu-shell)
838   (menu-item menu-item)
839   (fore-deactivate boolean))
840
841
842
843 ; ;;; Menu bar
844
845 ; (defbinding menu-bar-insert () nil
846 ;   (menu-bar menu-bar)
847 ;   (menu menu)
848 ;   (position int))
849
850 ; (defun menu-bar-append (menu-bar menu)
851 ;   (menu-bar-insert menu-bar menu -1))
852
853 ; (defun menu-bar-prepend (menu-bar menu)
854 ;   (menu-bar-insert menu-bar menu 0))
855
856
857
858 ; ;;; Menu
859
860 ;(defun menu-popup ...)
861
862 (defbinding menu-reposition () nil
863   (menu menu))
864
865 (defbinding menu-popdown () nil
866   (menu menu))
867
868 (defbinding %menu-set-active () nil
869   (menu menu)
870   (index unsigned-int))
871
872 (defun (setf menu-active) (menu index)
873   (%menu-set-active menu index))
874   
875 (defbinding menu-reorder-child () nil
876   (menu menu)
877   (menu-item menu-item)
878   (position int))
879
880
881 ;;; Table
882
883 (defbinding table-resize () nil
884   (table table)
885   (rows unsigned-int)
886   (columns unsigned-int))
887
888 (defbinding table-attach (table child left right top bottom
889                                &key (x-options '(:expand :fill))
890                                     (y-options '(:expand :fill))
891                                     (x-padding 0) (y-padding 0)) nil
892   (table table)
893   (child widget)
894   (left unsigned-int)
895   (right unsigned-int)
896   (top unsigned-int)
897   (bottom unsigned-int)
898   (x-options attach-options)
899   (y-options attach-options)
900   (x-padding unsigned-int)
901   (y-padding unsigned-int))
902
903
904 (defbinding %table-set-row-spacing () nil
905   (table table)
906   (row unsigned-int)
907   (spacing unsigned-int))
908
909 (defbinding %table-set-row-spacings () nil
910   (table table)
911   (spacing unsigned-int))
912
913 (defun (setf table-row-spacing) (spacing table &optional row)
914   (if row
915       (%table-set-row-spacing table row spacing)
916     (%table-set-row-spacings table spacing))
917   spacing)
918
919 (defbinding %table-get-row-spacing () unsigned-int
920   (table table)
921   (row unsigned-int))
922
923 (defbinding %table-get-default-row-spacing () unsigned-int
924   (table table))
925
926 (defun table-row-spacing (table &optional row)
927   (if row
928       (%table-get-row-spacing table row)
929     (%table-get-default-row-spacing table)))
930
931
932 (defbinding %table-set-col-spacing () nil
933   (table table)
934   (col unsigned-int)
935   (spacing unsigned-int))
936
937 (defbinding %table-set-col-spacings () nil
938   (table table)
939   (spacing unsigned-int))
940
941 (defun (setf table-col-spacing) (spacing table &optional col)
942   (if col
943       (%table-set-col-spacing table col spacing)
944     (%table-set-col-spacings table spacing))
945   spacing)
946
947 (defbinding %table-get-col-spacing () unsigned-int
948   (table table)
949   (col unsigned-int))
950
951 (defbinding %table-get-default-col-spacing () unsigned-int
952   (table table))
953
954 (defun table-col-spacing (table &optional col)
955   (if col
956       (%table-get-col-spacing table col)
957     (%table-get-default-col-spacing table)))
958   
959
960
961 ;;; Toolbar
962
963 ;; gtkglue.c
964 (defbinding toolbar-num-children () int
965   (toolbar toolbar))
966
967 (defun %toolbar-position-num (toolbar position)
968   (case position
969     (:prepend 0)
970     (:append (toolbar-num-children toolbar))
971     (t
972      (assert (and (>= position 0) (< position (toolbar-num-children toolbar))))
973      position)))
974
975 (defbinding %toolbar-insert-element () widget
976   (toolbar toolbar)
977   (type toolbar-child-type)
978   (widget (or null widget))
979   (text string)
980   (tooltip-text string)
981   (tooltip-private-text string)
982   (icon (or null widget))
983   (nil null)
984   (nil null)
985   (position int))
986
987 (defun toolbar-insert-element (toolbar position
988                                &key tooltip-text tooltip-private-text
989                                type widget icon text callback)
990   (let* ((icon-widget (typecase icon
991                        ((or null widget) icon)
992                        (t (pixmap-new icon))))
993          (toolbar-child
994           (%toolbar-insert-element
995            toolbar (or type (and widget :widget) :button)
996            widget text tooltip-text tooltip-private-text icon-widget
997            (%toolbar-position-num toolbar position))))
998     (when callback
999       (signal-connect toolbar-child 'clicked callback))
1000     toolbar-child))
1001
1002 (defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text
1003                                type widget icon text callback)
1004   (toolbar-insert-element
1005    toolbar :append :type type :widget widget :icon icon :text text
1006    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1007    :callback callback))
1008
1009 (defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text
1010                                 type widget icon text callback)
1011   (toolbar-insert-element
1012    toolbar :prepend :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-insert-space (toolbar position)
1017   (toolbar-insert-element toolbar position :type :space))
1018
1019 (defun toolbar-append-space (toolbar)
1020   (toolbar-insert-space toolbar :append))
1021
1022 (defun toolbar-prepend-space (toolbar)
1023   (toolbar-insert-space toolbar :prepend))
1024
1025 (defun toolbar-insert-widget (toolbar widget position &key tooltip-text
1026                               tooltip-private-text callback)
1027   (toolbar-insert-element
1028    toolbar position :widget widget :tooltip-text tooltip-text
1029    :tooltip-private-text tooltip-private-text :callback callback))
1030  
1031 (defun toolbar-append-widget (toolbar widget &key tooltip-text
1032                               tooltip-private-text callback)
1033   (toolbar-insert-widget
1034    toolbar widget :append :tooltip-text tooltip-text
1035    :tooltip-private-text tooltip-private-text :callback callback))
1036
1037 (defun toolbar-prepend-widget (toolbar widget &key tooltip-text
1038                                tooltip-private-text callback)
1039   (toolbar-insert-widget
1040    toolbar widget :prepend :tooltip-text tooltip-text
1041    :tooltip-private-text tooltip-private-text :callback callback))
1042
1043 (defun toolbar-insert-item (toolbar text icon position &key tooltip-text
1044                             tooltip-private-text callback)
1045   (toolbar-insert-element
1046    toolbar position :text text :icon icon :callback callback
1047    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1048
1049 (defun toolbar-append-item (toolbar text icon &key tooltip-text
1050                             tooltip-private-text callback)
1051   (toolbar-insert-item
1052    toolbar text icon :append :callback callback
1053    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1054
1055                        
1056 (defun toolbar-prepend-item (toolbar text icon &key tooltip-text
1057                              tooltip-private-text callback)
1058   (toolbar-insert-item
1059    toolbar text icon :prepend :callback callback
1060    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1061
1062 (defun toolbar-enable-tooltips (toolbar)
1063   (setf (toolbar-tooltips-p toolbar) t))
1064
1065 (defun toolbar-disable-tooltips (toolbar)
1066   (setf (toolbar-tooltips-p toolbar) nil))
1067
1068
1069
1070
1071
1072
1073
1074
1075 ;;; Editable
1076 #|
1077 (defbinding editable-select-region (editable &optional (start 0) end) nil
1078   (editable editable)
1079   (start int)
1080   ((or end -1) int))
1081
1082 (defbinding editable-insert-text
1083     (editable text &optional (position 0)) nil
1084   (editable editable)
1085   (text string)
1086   ((length text) int)
1087   ((or position -1) int :in-out))
1088
1089 (defun editable-append-text (editable text)
1090   (editable-insert-text editable text nil))
1091
1092 (defun editable-prepend-text (editable text)
1093   (editable-insert-text editable text 0))
1094
1095 (defbinding editable-delete-text (editable &optional (start 0) end) nil
1096   (editable editable)
1097   (start int)
1098   ((or end -1) int))
1099
1100 (defbinding (editable-text "gtk_editable_get_chars")
1101     (editable &optional (start 0) end) string
1102   (editable editable)
1103   (start int)
1104   ((or end -1) int))
1105
1106 (defun (setf editable-text) (text editable)
1107   (if text
1108       (editable-delete-text
1109        editable
1110        (editable-insert-text editable text))
1111     (editable-delete-text editable))
1112   text)
1113
1114 (defbinding editable-cut-clipboard () nil
1115   (editable editable))
1116
1117 (defbinding editable-copy-clipboard () nil
1118   (editable editable))
1119
1120 (defbinding editable-paste-clipboard () nil
1121   (editable editable))
1122
1123 ; (defbinding editable-claim-selection () nil
1124 ;   (editable editable)
1125 ;   (claim boolean)
1126 ;   (time unsigned-int))
1127
1128 (defbinding editable-delete-selection () nil
1129   (editable editable))
1130
1131 ; (defbinding editable-changed () nil
1132 ;   (editable editable))
1133 |#
1134
1135
1136 ;;; Spin button
1137
1138 (defun spin-button-value-as-int (spin-button)
1139   (round (spin-button-value spin-button)))
1140
1141 (defbinding spin-button-spin () nil
1142   (spin-button spin-button)
1143   (direction spin-type)
1144   (increment single-float))
1145
1146 (defbinding spin-button-update () nil
1147   (spin-button spin-button))
1148
1149
1150
1151 ; ;;; Ruler
1152
1153 (defbinding ruler-set-range () nil
1154   (ruler ruler)
1155   (lower single-float)
1156   (upper single-float)
1157   (position single-float)
1158   (max-size single-float))
1159
1160 (defbinding ruler-draw-ticks () nil
1161   (ruler ruler))
1162
1163 (defbinding ruler-draw-pos () nil
1164   (ruler ruler))
1165
1166
1167
1168 ;;; Range
1169 #|
1170 (defbinding range-draw-background () nil
1171   (range range))
1172
1173 (defbinding range-clear-background () nil
1174   (range range))
1175
1176 (defbinding range-draw-trough () nil
1177   (range range))
1178
1179 (defbinding range-draw-slider () nil
1180   (range range))
1181
1182 (defbinding range-draw-step-forw () nil
1183   (range range))
1184
1185 (defbinding range-slider-update () nil
1186   (range range))
1187
1188 (defbinding range-trough-click () int
1189   (range range)
1190   (x int)
1191   (y int)
1192   (jump-perc single-float :out))
1193
1194 (defbinding range-default-hslider-update () nil
1195   (range range))
1196
1197 (defbinding range-default-vslider-update () nil
1198   (range range))
1199
1200 (defbinding range-default-htrough-click () int
1201   (range range)
1202   (x int)
1203   (y int)
1204   (jump-perc single-float :out))
1205
1206 (defbinding range-default-vtrough-click () int
1207   (range range)
1208   (x int)
1209   (y int)
1210   (jump-perc single-float :out))
1211
1212 (defbinding range-default-hmotion () int
1213   (range range)
1214   (x-delta int)
1215   (y-delta int))
1216
1217 (defbinding range-default-vmotion () int
1218   (range range)
1219   (x-delta int)
1220   (y-delta int))
1221 |#
1222
1223
1224 ;;; Scale
1225
1226 ; (defbinding scale-draw-value () nil
1227 ;   (scale scale))
1228
1229
1230
1231 ;;; Progress bar
1232
1233 (defbinding progress-bar-pulse () nil
1234   (progress-bar progress-bar))
1235
1236
1237
1238
1239
1240 ;;; Tooltips
1241
1242 (defbinding tooltips-enable () nil
1243   (tooltips tooltips))
1244
1245 (defbinding tooltips-disable () nil
1246   (tooltips tooltips))
1247
1248 (defun (setf tooltips-enabled-p) (enable tooltips)
1249   (if enable
1250       (tooltips-enable tooltips)
1251     (tooltips-disable tooltips)))
1252
1253 (defbinding tooltips-set-tip () nil
1254   (tooltips tooltips)
1255   (widget widget)
1256   (tip-text string)
1257   (tip-private string))
1258
1259 (defbinding tooltips-force-window () nil
1260   (tooltips tooltips))
1261
1262
1263
1264 ;;; Rc
1265
1266 (defbinding rc-add-default-file (filename) nil
1267   ((namestring (truename filename)) string))
1268
1269 (defbinding rc-parse (filename) nil
1270   ((namestring (truename filename)) string))
1271
1272 (defbinding rc-parse-string () nil
1273   (rc-string string))
1274
1275 (defbinding rc-reparse-all () nil)
1276
1277 (defbinding rc-get-style () style
1278   (widget widget))
1279
1280
1281
1282 ;;; Accelerator Groups
1283 #|
1284 (defbinding accel-group-get-default () accel-group)
1285
1286 (deftype-method alien-ref accel-group (type-spec)
1287   (declare (ignore type-spec))
1288   '%accel-group-ref)
1289
1290 (deftype-method alien-unref accel-group (type-spec)
1291   (declare (ignore type-spec))
1292   '%accel-group-unref)
1293
1294 (defbinding %accel-group-ref () accel-group
1295   (accel-group (or accel-group pointer)))
1296
1297 (defbinding %accel-group-unref () nil
1298   (accel-group (or accel-group pointer)))
1299
1300 (defbinding accel-group-activate (accel-group key modifiers) boolean
1301   (accel-group accel-group)
1302   ((gdk:keyval-from-name key) unsigned-int)
1303   (modifiers gdk:modifier-type))
1304
1305 (defbinding accel-groups-activate (object key modifiers) boolean
1306   (object object)
1307   ((gdk:keyval-from-name key) unsigned-int)
1308   (modifiers gdk:modifier-type))
1309
1310 (defbinding accel-group-attach () nil
1311   (accel-group accel-group)
1312   (object object))
1313
1314 (defbinding accel-group-detach () nil
1315   (accel-group accel-group)
1316   (object object))
1317
1318 (defbinding accel-group-lock () nil
1319   (accel-group accel-group))
1320
1321 (defbinding accel-group-unlock () nil
1322   (accel-group accel-group))
1323
1324
1325 ;;; Accelerator Groups Entries
1326
1327 (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry
1328   (accel-group accel-group)
1329   ((gdk:keyval-from-name key) unsigned-int)
1330   (modifiers gdk:modifier-type))
1331
1332 (defbinding accel-group-lock-entry (accel-group key modifiers) nil
1333   (accel-group accel-group)
1334   ((gdk:keyval-from-name key) unsigned-int)
1335   (modifiers gdk:modifier-type))
1336
1337 (defbinding accel-group-unlock-entry (accel-group key modifiers) nil
1338   (accel-group accel-group)
1339   ((gdk:keyval-from-name key) unsigned-int)
1340   (modifiers gdk:modifier-type))
1341
1342 (defbinding accel-group-add
1343     (accel-group key modifiers flags object signal) nil
1344   (accel-group accel-group)
1345   ((gdk:keyval-from-name key) unsigned-int)
1346   (modifiers gdk:modifier-type)
1347   (flags accel-flags)
1348   (object object)
1349   ((name-to-string signal) string))
1350
1351 (defbinding accel-group-add (accel-group key modifiers object) nil
1352   (accel-group accel-group)
1353   ((gdk:keyval-from-name key) unsigned-int)
1354   (modifiers gdk:modifier-type)
1355   (object object))
1356
1357
1358 ;;; Accelerator Signals
1359
1360 (defbinding accel-group-handle-add
1361     (object signal-id accel-group key modifiers flags) nil
1362   (object object)
1363   (signal-id unsigned-int)
1364   (accel-group accel-group)
1365   ((gdk:keyval-from-name key) unsigned-int)
1366   (modifiers gdk:modifier-type)
1367   (flags accel-flags))
1368
1369 (defbinding accel-group-handle-remove
1370     (object accel-group key modifiers) nil
1371   (object object)
1372   (accel-group accel-group)
1373   ((gdk:keyval-from-name key) unsigned-int)
1374   (modifiers gdk:modifier-type))
1375 |#