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