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