chiark / gitweb /
f47058816e4ab600dd59d36ed4047f9709b68190
[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.28 2004-12-29 21:17:36 espen Exp $
19
20
21 (in-package "GTK")
22
23 ;;; Gtk version
24
25 (defbinding check-version () (copy-of 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 () (copy-of pango:language))
43
44
45 ;;;; Initalization
46
47 (defbinding (gtk-init "gtk_parse_args") () nil
48   "Initializes the library without opening the display."
49   (nil null)
50   (nil null))
51
52 (defun clg-init (&optional display)
53   "Initializes the system and starts the event handling"
54   (unless (gdk:display-get-default)
55     (gdk:gdk-init)
56     (gtk-init)
57     (prog1
58         (gdk:display-open display)
59       (system:add-fd-handler 
60        (gdk:display-connection-number) :input #'main-iterate-all)
61       (setq lisp::*periodic-polling-function* #'main-iterate-all)
62       (setq lisp::*max-event-to-sec* 0)
63       (setq lisp::*max-event-to-usec* 1000))))
64
65
66 ;;; Acccel group
67
68
69
70 ;;; Acccel label
71
72 (defbinding accel-label-refetch () boolean
73   (accel-label accel-label))
74
75
76 ;;; Accessible
77
78 (defbinding accessible-connect-widget-destroyed () nil
79   (accessible accessible))
80
81
82 ;;; Adjustment
83
84 (defmethod initialize-instance ((adjustment adjustment) &key value)
85   (prog1
86       (call-next-method)
87     ;; we need to make sure that the value is set last, otherwise it
88     ;; may be outside current limits and ignored
89     (when value
90       (setf (slot-value adjustment 'value) value))))
91
92
93 (defbinding adjustment-changed () nil
94   (adjustment adjustment))
95
96 (defbinding adjustment-value-changed () nil
97   (adjustment adjustment))
98
99 (defbinding adjustment-clamp-page () nil
100   (adjustment adjustment)
101   (lower single-float)
102   (upper single-float))
103
104
105 ;;; Aspect frame
106
107
108 ;;; Bin
109
110 (defun (setf bin-child) (child bin)
111   (when-bind (current-child (bin-child bin))
112     (container-remove bin current-child))
113   (container-add bin child)
114   child)
115
116
117 ;;; Binding
118
119
120
121 ;;; Box
122
123 (defbinding box-pack-start () nil
124   (box box)
125   (child widget)
126   (expand boolean)
127   (fill boolean)
128   (padding unsigned-int))
129
130 (defbinding box-pack-end () nil
131   (box box)
132   (child widget)
133   (expand boolean)
134   (fill boolean)
135   (padding unsigned-int))
136
137 (defun box-pack (box child &key end (expand t) (fill t) (padding 0))
138   (if end
139       (box-pack-end box child expand fill padding)
140     (box-pack-start box child expand fill padding)))
141
142 (defbinding box-reorder-child () nil
143   (box box)
144   (child widget)
145   (position int))
146
147 (defbinding box-query-child-packing () nil
148   (box box)
149   (child widget)
150   (expand boolean :out)
151   (fill boolean :out)
152   (padding unsigned-int :out)
153   (pack-type pack-type :out))
154
155 (defbinding box-set-child-packing () nil
156   (box box)
157   (child widget)
158   (expand boolean)
159   (fill boolean)
160   (padding unsigned-int)
161   (pack-type pack-type))
162
163
164
165 ;;; Button
166
167 (defmethod initialize-instance ((button button) &rest initargs &key stock)
168   (if stock
169       (apply #'call-next-method button :label stock :use-stock t initargs)
170     (call-next-method)))
171
172
173 (defbinding button-pressed () nil
174   (button button))
175
176 (defbinding button-released () nil
177   (button button))
178
179 (defbinding button-clicked () nil
180   (button button))
181
182 (defbinding button-enter () nil
183   (button button))
184
185 (defbinding button-leave () nil
186   (button button))
187
188
189
190 ;;; Calendar
191
192 (defbinding calendar-select-month () int
193   (calendar calendar)
194   (month unsigned-int)
195   (year unsigned-int))
196
197 (defbinding calendar-select-day () nil
198   (calendar calendar)
199   (day unsigned-int))
200
201 (defbinding calendar-mark-day () int
202   (calendar calendar)
203   (day unsigned-int))
204
205 (defbinding calendar-unmark-day () int
206   (calendar calendar)
207   (day unsigned-int))
208
209 (defbinding calendar-clear-marks () nil
210   (calendar calendar))
211
212 (defbinding calendar-get-date () nil
213   (calendar calendar)
214   (year unsigned-int :out)
215   (month unsigned-int :out)
216   (day unsigned-int :out))
217
218 (defbinding calendar-freeze () nil
219   (calendar calendar))
220
221 (defbinding calendar-thaw () nil
222   (calendar calendar))
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 Box
248
249 (defmethod initialize-instance ((combo-box combo-box) &rest initargs 
250                                 &key model content active)
251   (remf initargs :active)
252   (if model
253       (apply #'call-next-method combo-box initargs)
254     (progn
255       (apply #'call-next-method combo-box 
256        :model (make-instance 'list-store :column-types '(string))
257        initargs)
258       (unless (typep combo-box 'combo-box-entry)
259         (let ((cell (make-instance 'cell-renderer-text)))
260           (cell-layout-pack combo-box cell :expand t)
261           (cell-layout-add-attribute combo-box cell :text 0)))))
262   (when content
263     (mapc #'(lambda (text)
264               (combo-box-append-text combo-box text))
265           content))
266   (when active
267     (setf (combo-box-active combo-box) active)))
268
269
270 ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
271 ;;   (when active
272 ;;     (signal-emit combo-box 'changed)))
273
274 (defbinding combo-box-append-text () nil
275   (combo-box combo-box)
276   (text string))
277
278 (defbinding combo-box-insert-text () nil
279   (combo-box combo-box)
280   (position int)
281   (text string))
282
283 (defbinding combo-box-prepend-text () nil
284   (combo-box combo-box)
285   (text string))
286
287 #+gtk2.6
288 (defbinding combo-box-get-active-text () string
289   (combo-box combo-box))
290
291 (defbinding combo-box-popup () nil
292   (combo-box combo-box))
293
294 (defbinding combo-box-popdown () nil
295   (combo-box combo-box))
296
297
298
299 ;;;; Combo Box Entry
300
301 (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
302   (call-next-method)
303   (unless model
304     (setf (combo-box-entry-text-column combo-box-entry) 0)))
305
306
307 ;;;; Dialog
308
309 (defmethod shared-initialize ((dialog dialog) names &rest initargs 
310                               &key button buttons)
311   (declare (ignore button buttons))
312   (prog1
313       (call-next-method)
314     (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
315   
316
317 (defun %dialog-find-response-id-num (dialog id &optional create-p error-p)
318   (or
319    (cadr (assoc id (rest (type-expand-1 'response-type))))
320    (let ((response-ids (object-data dialog 'response-id-key)))
321     (cond
322       ((and response-ids (position id response-ids :test #'equal)))
323       (create-p
324        (cond
325          (response-ids
326           (vector-push-extend id response-ids)
327           (1- (length response-ids)))
328          (t
329           (setf 
330            (object-data dialog 'response-id-key)
331            (make-array 1 :adjustable t :fill-pointer t :initial-element id))
332           0)))
333       (error-p
334        (error "Invalid response: ~A" id))))))
335
336 (defun %dialog-find-response-id (dialog response-id-num)
337   (if (< response-id-num 0)
338       (car
339        (rassoc
340         (list response-id-num)
341         (rest (type-expand-1 'response-type)) :test #'equal))
342     (aref (object-data dialog 'response-id-key) response-id-num )))
343
344
345 (defmethod signal-connect ((dialog dialog) signal function &key object after)
346   (let ((response-id-num (%dialog-find-response-id-num dialog signal)))
347     (cond
348      (response-id-num
349       (call-next-method
350        dialog 'response
351        #'(lambda (dialog id)
352            (when (= id response-id-num)
353              (cond
354               ((eq object t) (funcall function dialog))
355               (object (funcall function object))
356               (t (funcall function)))))
357        :object t :after after))
358     ((call-next-method)))))
359
360
361 (defbinding dialog-run () nil
362   (dialog dialog))
363
364 (defbinding dialog-response (dialog response-id) nil
365   (dialog dialog)
366   ((%dialog-find-response-id-num dialog response-id nil t) int))
367
368
369 (defbinding %dialog-add-button () button
370   (dialog dialog)
371   (text string)
372   (response-id-num int))
373
374 (defun dialog-add-button (dialog label &optional (response label)
375                           &key default object after)
376   "Adds a button to the dialog."
377   (let* ((id (if (functionp response)
378                  label
379                response))
380          (id-num (%dialog-find-response-id-num dialog id t))
381          (button (%dialog-add-button dialog label id-num)))
382     (when (functionp response)
383        (signal-connect dialog id response :object object :after after))
384     (when default
385       (%dialog-set-default-response dialog id-num))
386     button))
387
388
389 (defbinding %dialog-add-action-widget () button
390   (dialog dialog)
391   (action-widget widget)
392   (response-id-num int))
393
394 (defun dialog-add-action-widget (dialog widget &optional (response widget)
395                                  &key default object after)
396   (let* ((id (if (functionp response)
397                  widget
398                response))
399          (id-num (%dialog-find-response-id-num dialog id t)))
400     (%dialog-add-action-widget dialog widget id-num)
401     (when (functionp response)
402        (signal-connect dialog id response :object object :after after))
403     (when default
404       (%dialog-set-default-response dialog id-num))
405     widget))
406
407
408 (defbinding %dialog-set-default-response () nil
409   (dialog dialog)
410   (response-id-num int))
411
412 (defun dialog-set-default-response (dialog response-id)
413   (%dialog-set-default-response
414    dialog (%dialog-find-response-id-num dialog response-id nil t)))
415
416 (defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil
417   (dialog dialog)
418   ((%dialog-find-response-id-num dialog response-id nil t) int)
419   (sensitive boolean))
420
421 #+gtk2.6
422 (defbinding alternative-dialog-button-order-p(&optional screen)
423   (screen (or null screen)))
424
425 #+gtk2.6
426 (defbinding (dialog-set-alternative-button-order 
427              "gtk_dialog_set_alternative_button_order_from_array") 
428     (dialog new-order)
429   (dialog dialog)
430   ((length new-order) int)
431   ((map 'vector #'(lambda (id)
432                     (%dialog-find-response-id-num dialog id nil t))
433         new-order) (vector int)))
434
435
436 (defmethod container-add ((dialog dialog) (child widget) &rest args)
437   (apply #'container-add (dialog-vbox dialog) child args))
438
439 (defmethod container-remove ((dialog dialog) (child widget))
440   (container-remove (dialog-vbox dialog) child))
441
442 (defmethod container-children ((dialog dialog))
443   (container-children (dialog-vbox dialog)))
444
445 (defmethod (setf container-children) (children (dialog dialog))
446   (setf (container-children (dialog-vbox dialog)) children))
447
448
449 ;;; Entry
450
451 (defbinding entry-get-layout-offsets () nil
452   (entry entry)
453   (x int :out)
454   (y int :out))
455
456 (defbinding entry-layout-index-to-text-index () int
457   (entry entry)
458   (layout-index int))
459
460 (defbinding entry-text-index-to-layout-index () int
461   (entry entry)
462   (text-index int))
463
464
465 ;;; Entry Completion
466
467 (def-callback-marshal %entry-completion-match-func
468     (boolean entry-completion string (copy-of tree-iter)))
469
470 (defbinding entry-completion-set-match-func (completion function) nil
471   (completion entry-completion)
472   ((callback %entry-completion-match-func) pointer)
473   ((register-callback-function function) unsigned-int)
474   ((callback %destroy-user-data) pointer))
475
476 (defbinding entry-completion-complete () nil
477   (completion entry-completion))
478
479 #+gtk2.6
480 (defbinding entry-completion-insert-prefix () nil
481   (completion entry-completion))
482
483 (defbinding entry-completion-insert-action-text () nil
484   (completion entry-completion)
485   (index int)
486   (text string))
487
488 (defbinding entry-completion-insert-action-markup () nil
489   (completion entry-completion)
490   (index int)
491   (markup string))
492
493 (defbinding entry-completion-delete-action () nil
494   (completion entry-completion)
495   (index int))
496
497
498 ;;; Image
499
500 (defbinding image-set-from-file () nil
501   (image image)
502   (filename pathname))
503
504 (defmethod (setf image-pixmap) ((data vector) (image image))
505   (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
506     (setf (image-pixmap image) pixmap)
507     (setf (image-mask image) mask)))
508
509 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
510   (cond
511    ((typep pixmap 'vector)
512     (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
513       (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
514    (file
515     (prog1
516         (call-next-method)
517       (image-set-from-file image file)))
518    ((call-next-method))))
519
520 (defun create-image (source &optional mask)
521   (etypecase source
522     (gdk:pixbuf (make-instance 'image :pixbuf source))
523     (string (make-instance 'image :stock source))
524     (pathname (make-instance 'image :file source))
525     ((or list vector) (make-instance 'image :pixmap source))
526     (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
527
528
529 ;;; Image menu item
530
531 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
532   (if (and image (not (typep image 'widget)))
533       (apply #'call-next-method item :image (create-image image) initargs) 
534     (call-next-method)))
535
536
537 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
538   (setf (slot-value item 'image) widget))
539
540 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
541   (setf (image-menu-item-image item) (create-image image)))
542
543
544 ;;; Label
545
546 (defbinding label-get-layout-offsets () nil
547   (label label)
548   (x int :out)
549   (y int :out))
550
551 (defbinding label-select-region () nil
552   (label label)
553   (start int)
554   (end int))
555
556 (defbinding label-get-selection-bounds () boolean
557   (label label)
558   (start int :out)
559   (end int :out))
560
561
562
563 ;;; Radio button
564
565 (defbinding %radio-button-get-group () pointer
566   (radio-button radio-button))
567
568 (defbinding %radio-button-set-group () nil
569   (radio-button radio-button)
570   (group pointer))
571
572 (defun radio-button-add-to-group (button1 button2)
573   "Add BUTTON1 to the group which BUTTON2 belongs to."
574   (%radio-button-set-group button1 (%radio-button-get-group button2)))
575
576
577 (defmethod initialize-instance ((button radio-button) &key group)
578   (prog1
579       (call-next-method)
580     (when group
581       (radio-button-add-to-group button group))))
582
583
584 ;;; Item
585
586 (defbinding item-select () nil
587   (item item))
588
589 (defbinding item-deselect () nil
590   (item item))
591
592 (defbinding item-toggle () nil
593   (item item))
594
595
596
597 ;;; Menu item
598
599 (defmethod initialize-instance ((item menu-item) &key label)
600   (prog1
601       (call-next-method)
602     (when label
603       (setf (menu-item-label item) label))))
604
605
606 (defun (setf menu-item-label) (label menu-item)
607   (make-instance 'accel-label
608    :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
609    :use-underline (menu-item-use-underline-p menu-item)
610    :visible t  :parent menu-item)
611   label)
612
613 (defun menu-item-label (menu-item)
614   (when (and (slot-boundp menu-item 'child) 
615              (typep (bin-child menu-item) 'label))
616     (label-label (bin-child menu-item))))
617
618 (defbinding menu-item-remove-submenu () nil
619   (menu-item menu-item))
620
621 (defbinding menu-item-set-accel-path () nil
622   (menu-item menu-item)
623   (accel-path string))
624
625 (defbinding menu-item-select () nil
626   (menu-item menu-item))
627
628 (defbinding menu-item-deselect () nil
629   (menu-item menu-item))
630
631 (defbinding menu-item-activate () nil
632   (menu-item menu-item))
633
634 (defbinding menu-item-toggle-size-request () nil
635   (menu-item menu-item)
636   (requisition int :out))
637
638 (defbinding menu-item-toggle-size-allocate () nil
639   (menu-item menu-item)
640   (allocation int))
641
642
643 ;;; Menu tool button
644
645 #+gtk2.6
646 (defbinding menu-tool-button-set-arrow-tip () nil
647   (menu-tool-button menu-tool-button)
648   (tooltips tooltips)
649   (tip-text string)
650   (tip-private string))
651
652
653 ;;; Message dialog
654
655 (defmethod initialize-instance ((dialog message-dialog) &rest initargs 
656                                 &key (type :info) (buttons :close) ; or :ok? 
657                                 flags message parent)
658   (remf initargs :parent)
659   (setf 
660    (slot-value dialog 'location)
661    (%message-dialog-new parent flags type buttons nil))
662   (message-dialog-set-markup dialog message)
663   (apply #'call-next-method dialog initargs))
664
665
666 (defbinding %message-dialog-new () pointer
667   (parent (or null window))
668   (flags dialog-flags)
669   (type message-type)
670   (buttons buttons-type)
671   (message (or null string)))
672
673 (defbinding %message-dialog-new-with-markup () pointer
674   (parent (or null window))
675   (flags dialog-flags)
676   (type message-type)
677   (buttons buttons-type)
678   (message string))
679
680 (defbinding message-dialog-set-markup () nil
681   (message-dialog message-dialog)
682   (markup string))
683
684 #+gtk2.6
685 (defbinding message-dialog-format-secondary-text () nil
686   (message-dialog message-dialog)
687   (text string))
688
689 #+gtk2.6
690 (defbinding message-dialog-format-secondary-markup () nil
691   (message-dialog message-dialog)
692   (markup string))
693
694
695
696 ;;; Radio menu item
697
698 (defbinding %radio-menu-item-get-group () pointer
699   (radio-menu-item radio-menu-item))
700
701 (defbinding %radio-menu-item-set-group () nil
702   (radio-menu-item radio-menu-item)
703   (group pointer))
704
705 (defun radio-menu-item-add-to-group (item1 item2)
706   "Add ITEM1 to the group which ITEM2 belongs to."
707   (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
708
709 (defmethod initialize-instance ((item radio-menu-item) &key group)
710   (prog1
711       (call-next-method)
712     (when group
713       (radio-menu-item-add-to-group item group))))
714   
715
716 ;;; Radio tool button
717
718 (defbinding %radio-tool-button-get-group () pointer
719   (radio-tool-button radio-tool-button))
720
721 (defbinding %radio-tool-button-set-group () nil
722   (radio-tool-button radio-tool-button)
723   (group pointer))
724
725 (defun radio-tool-button-add-to-group (button1 button2)
726   "Add BUTTON1 to the group which BUTTON2 belongs to."
727   (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
728
729
730 (defmethod initialize-instance ((button radio-tool-button) &key group)
731   (prog1
732       (call-next-method)
733     (when group
734       (radio-tool-button-add-to-group button group))))
735
736
737 ;;; Toggle button
738
739 (defbinding toggle-button-toggled () nil
740   (toggle-button toggle-button))
741
742
743 ;;; Window
744
745 (defmethod initialize-instance ((window window) &rest initargs 
746                                 &key accel-group accel-groups)
747   (declare (ignore accel-group accel-groups))
748   (prog1
749       (call-next-method)
750     (initial-add window #'window-add-accel-group 
751      initargs :accel-group :accel-groups)))
752
753
754 (defbinding window-set-wmclass () nil
755   (window window)
756   (wmclass-name string)
757   (wmclass-class string))
758
759 (defbinding window-add-accel-group () nil
760   (window window)
761   (accel-group accel-group))
762
763 (defbinding window-remove-accel-group () nil
764   (window window)
765   (accel-group accel-group))
766
767 (defbinding window-activate-focus () int
768   (window window))
769
770 (defbinding window-activate-default () int
771   (window window))
772
773 (defbinding window-set-default-size (window width height) int
774   (window window)
775   ((or width -1) int)
776   ((or height -1) int))
777
778 (defbinding %window-set-geometry-hints () nil
779   (window window)
780   (geometry gdk:geometry)
781   (geometry-mask gdk:window-hints))
782
783 (defun window-set-geometry-hints (window &key min-width min-height
784                                   max-width max-height base-width base-height
785                                   width-inc height-inc min-aspect max-aspect
786                                   (gravity nil gravity-p) min-size max-size)
787   (let ((geometry (make-instance 'gdk:geometry 
788                    :min-width (or min-width -1)
789                    :min-height (or min-height -1)
790                    :max-width (or max-width -1)
791                    :max-height (or max-height -1)
792                    :base-width (or base-width 0)
793                    :base-height (or base-height 0)
794                    :width-inc (or width-inc 0)
795                    :height-inc (or height-inc 0)
796                    :min-aspect (or min-aspect 0)
797                    :max-aspect (or max-aspect 0)
798                    :gravity gravity))
799         (mask ()))
800     (when (or min-size min-width min-height)
801       (push :min-size mask))
802     (when (or max-size max-width max-height)
803       (push :max-size mask))
804     (when (or base-width base-height)
805       (push :base-size mask))
806     (when (or width-inc height-inc)
807       (push :resize-inc mask))
808     (when (or min-aspect max-aspect)
809       (push :aspect mask))
810     (when gravity-p
811       (push :win-gravity mask))
812     (%window-set-geometry-hints window geometry mask)))
813
814 (defbinding window-list-toplevels () (glist (copy-of window))
815   "Returns a list of all existing toplevel windows.")
816
817 (defbinding window-add-mnemonic (window key target) nil
818   (window window)
819   ((gdk:keyval-from-name key) unsigned-int)
820   (target widget))
821
822 (defbinding window-remove-mnemonic (window key target) nil
823   (window window)
824   ((gdk:keyval-from-name key) unsigned-int)
825   (target widget))
826
827 (defbinding window-mnemonic-activate (window key modifier) nil
828   (window window)
829   ((gdk:keyval-from-name key) unsigned-int)
830   (modifier gdk:modifier-type))
831
832 (defbinding window-activate-key () boolean
833   (window window)
834   (event gdk:key-event))
835
836 (defbinding window-propagate-key-event () boolean
837   (window window)
838   (event gdk:key-event))
839
840 (defbinding window-present () nil
841   (window window))
842
843 (defbinding window-iconify () nil
844   (window window))
845
846 (defbinding window-deiconify () nil
847   (window window))
848
849 (defbinding window-stick () nil
850   (window window))
851
852 (defbinding window-unstick () nil
853   (window window))
854
855 (defbinding window-maximize () nil
856   (window window))
857
858 (defbinding window-unmaximize () nil
859   (window window))
860
861 (defbinding window-fullscreen () nil
862   (window window))
863
864 (defbinding window-unfullscreen () nil
865   (window window))
866
867 (defbinding window-set-keep-above () nil
868   (window window)
869   (setting boolean))
870
871 (defbinding window-set-keep-below () nil
872   (window window)
873   (setting boolean))
874
875 (defbinding window-begin-resize-drag () nil
876   (window window)
877   (edge gdk:window-edge)
878   (button int)
879   (root-x int) (root-y int)
880   (timestamp unsigned-int))
881
882 (defbinding window-begin-move-drag () nil
883   (window window)
884   (edge gdk:window-edge)
885   (button int)
886   (root-x int) (root-y int)
887   (timestamp unsigned-int))
888
889 (defbinding window-set-frame-dimensions () nil
890   (window window)
891   (left int) (top int) (rigth int) (bottom int))
892
893 (defbinding %window-get-default-size () nil
894   (window window)
895   (width int :out)
896   (height int :out))
897
898 (defun window-get-default-size (window)
899   (multiple-value-bind (width height) (%window-get-default-size window)
900     (values (unless (= width -1) width) (unless (= height -1) height))))
901
902 (defbinding window-get-frame-dimensions () nil
903   (window window)
904   (left int :out) (top int :out) (rigth int :out) (bottom int :out))
905
906 (defbinding %window-get-icon-list () (glist gdk:pixbuf)
907   (window window))
908
909 (defbinding window-get-position () nil
910   (window window)
911   (root-x int :out)
912   (root-y int :out))
913
914 (defbinding window-get-size () nil
915   (window window)
916   (width int :out)
917   (height int :out))
918
919 (defbinding window-move () nil
920   (window window)
921   (x int)
922   (y int))
923
924 (defbinding window-parse-geometry () boolean
925   (window window)
926   (geometry string))
927
928 (defbinding window-reshow-with-initial-size () nil
929   (window window))
930
931 (defbinding window-resize () nil
932   (window window)
933   (width int)
934   (heigth int))
935
936 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
937     () (glist gdk:pixbuf))
938
939 (defun window-default-icon ()
940   (first (window-default-icon-list)))
941
942 (defbinding %window-set-default-icon-list () nil
943   (icons (glist gdk:pixbuf)))
944
945 (defun (setf window-default-icon-list) (icons)
946   (%window-set-default-icon-list icons)
947   icons)
948
949 (defbinding %window-set-default-icon () nil
950   (icons (glist gdk:pixbuf)))
951
952 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
953   (%window-set-default-icon icon)
954   icon)
955
956 (defmethod (setf window-group) ((group window-group) (window window))
957   (window-group-add-window group window)
958   group)
959
960 (defbinding %window-set-default-icon-from-file () boolean
961   (filename pathname)
962   (nil null))
963
964 (defmethod (setf window-default-icon) ((icon-file pathname))
965   (%window-set-default-icon-from-file icon-file)
966   icon-file)
967
968 (defbinding %window-set-icon-from-file () boolean
969   (window window)
970   (filename pathname)
971   (nil null))
972
973 (defmethod (setf window-icon) ((icon-file pathname) (window window))
974   (%window-set-icon-from-file window icon-file)
975   icon-file)
976
977 (defbinding window-set-auto-startup-notification () nil
978   (setting boolean))
979
980 (defbinding decorated-window-init () nil
981   (window window))
982
983 (defbinding decorated-window-calculate-frame-size () nil
984   (window window))
985
986 (defbinding decorated-window-set-title () nil
987   (window window)
988   (title string))
989
990 (defbinding decorated-window-move-resize-window () nil
991   (window window)
992   (x int)
993   (y int)
994   (width int)
995   (heigth int))
996
997
998 ;;; Window group
999
1000 (defmethod initialize-instance ((window-group window-group) &rest initargs 
1001                                 &key window windows)
1002   (declare (ignore window windows))
1003   (prog1
1004       (call-next-method)
1005     (initial-add window-group #'window-group-add-window 
1006      initargs :window :windows)))
1007
1008
1009 (defbinding window-group-add-window () nil
1010   (window-group window-group)
1011   (window window))
1012
1013 (defbinding window-group-remove-window () nil
1014   (window-group window-group)
1015   (window window))
1016
1017
1018 ;;; Scrolled window
1019
1020 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1021   (setf (scrolled-window-hscrollbar-policy window) policy)
1022   (setf (scrolled-window-vscrollbar-policy window) policy))
1023
1024 (defbinding scrolled-window-add-with-viewport () nil
1025    (scrolled-window scrolled-window)
1026    (child widget))
1027
1028 (defmethod initialize-instance ((window scrolled-window) &rest initargs 
1029                                 &key policy)
1030   (if policy
1031       (apply #'call-next-method window 
1032        :vscrollbar-policy policy :hscrollbar-policy policy initargs)
1033     (call-next-method)))
1034
1035
1036 ;;; Statusbar
1037
1038 (defbinding statusbar-get-context-id () unsigned-int
1039   (statusbar statusbar)
1040   (context-description string))
1041
1042 (defbinding statusbar-push () unsigned-int
1043   (statusbar statusbar)
1044   (context-id unsigned-int)  
1045   (text string))
1046
1047 (defbinding statusbar-pop () nil
1048   (statusbar statusbar)
1049   (context-id unsigned-int))
1050
1051 (defbinding statusbar-remove () nil
1052   (statusbar statusbar)
1053   (context-id unsigned-int)
1054   (message-id unsigned-int))
1055
1056
1057
1058 ;;; Fixed
1059
1060 (defbinding fixed-put () nil
1061   (fixed fixed)
1062   (widget widget)
1063   (x int) (y int))
1064
1065 (defbinding fixed-move () nil
1066   (fixed fixed)
1067   (widget widget)
1068   (x int) (y int))
1069
1070
1071
1072 ;;; Notebook
1073
1074 (defun %notebook-position (notebook page)
1075   (etypecase page
1076     (int page)
1077     (keyword (case page
1078                (:first 0)
1079                (:last -1)
1080                (t (error "Invalid position keyword: ~A" page))))
1081     (widget (notebook-page-num notebook page t))))
1082
1083 (defun %notebook-child (notebook position)
1084   (typecase position
1085      (widget position)
1086      (t (notebook-nth-page-child notebook position))))
1087
1088
1089 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1090     (notebook position child tab-label &optional menu-label) nil
1091   (notebook notebook)
1092   (child widget)
1093   ((if (stringp tab-label)
1094        (make-instance 'label :label tab-label)
1095      tab-label) widget)
1096   ((if (stringp menu-label)
1097        (make-instance 'label :label menu-label)
1098      menu-label) (or null widget))
1099   ((%notebook-position notebook position) int))
1100
1101 (defun notebook-append (notebook child tab-label &optional menu-label)
1102   (notebook-insert notebook :last child tab-label menu-label))
1103
1104 (defun notebook-prepend (notebook child tab-label &optional menu-label)
1105   (notebook-insert notebook :first child tab-label menu-label))
1106   
1107 (defbinding notebook-remove-page (notebook page) nil
1108   (notebook notebook)
1109   ((%notebook-position notebook page) int))
1110
1111 (defbinding %notebook-page-num () int
1112   (notebook notebook)
1113   (child widget))
1114
1115 (defun notebook-page-num (notebook child &optional error-p)
1116   (let ((page-num (%notebook-page-num notebook child)))
1117     (if (= page-num -1)
1118         (when error-p
1119           (error "~A is not a child of ~A" child notebook))
1120       page-num)))
1121
1122 (defbinding notebook-next-page () nil
1123   (notebook notebook))
1124
1125 (defbinding notebook-prev-page () nil
1126   (notebook notebook))
1127
1128 (defbinding notebook-reorder-child (notebook child position) nil
1129   (notebook notebook)
1130   (child widget)
1131   ((%notebook-position notebook position) int))
1132
1133 (defbinding notebook-popup-enable () nil
1134   (notebook notebook))
1135
1136 (defbinding notebook-popup-disable () nil
1137   (notebook notebook))
1138
1139 (defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page")
1140     (notebook page) widget
1141   (notebook notebook)
1142   ((case page
1143      (:first 0)
1144      (:last -1)
1145      (t page)) int))
1146
1147
1148 (defbinding %notebook-get-current-page () int
1149   (notebook notebook))
1150
1151 (defun notebook-current-page-num (notebook)
1152   (let ((num (%notebook-get-current-page notebook)))
1153     (when (>= num 0)
1154       num)))
1155
1156 (defun notebook-current-page (notebook)
1157   (let ((page-num (notebook-current-page-num notebook)))
1158     (when page-num
1159       (notebook-nth-page-child notebook page-num))))
1160
1161 (defbinding  %notebook-set-current-page () nil
1162   (notebook notebook)
1163   (page-num int))
1164
1165 (defun (setf notebook-current-page) (page notebook)
1166   (%notebook-set-current-page notebook (%notebook-position notebook page))
1167   page)
1168
1169
1170 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1171     (notebook page) widget
1172   (notebook notebook)
1173   ((%notebook-child notebook page) widget))
1174
1175 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1176     (notebook page) (copy-of string)
1177   (notebook notebook)
1178   ((%notebook-child notebook page) widget))
1179
1180 (defbinding %notebook-set-tab-label () nil
1181   (notebook notebook)
1182   (page widget)
1183   (tab-label widget))
1184
1185 (defun (setf notebook-tab-label) (tab-label notebook page)
1186   (let ((widget (if (stringp tab-label)
1187                     (make-instance 'label :label tab-label)
1188                   tab-label)))
1189     (%notebook-set-tab-label notebook (%notebook-child notebook page) widget)
1190     widget))
1191
1192
1193 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1194     (notebook page) widget
1195   (notebook notebook)
1196   ((%notebook-child notebook page) widget))
1197
1198 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1199     (notebook page) (copy-of string)
1200   (notebook notebook)
1201   ((%notebook-child notebook page) widget))
1202
1203 (defbinding %notebook-set-menu-label () nil
1204   (notebook notebook)
1205   (page widget)
1206   (menu-label widget))
1207
1208 (defun (setf notebook-menu-label) (menu-label notebook page)
1209   (let ((widget (if (stringp menu-label)
1210                     (make-instance 'label :label menu-label)
1211                   menu-label)))
1212     (%notebook-set-menu-label notebook (%notebook-child notebook page) widget)
1213     widget))
1214
1215
1216 (defbinding notebook-query-tab-label-packing (notebook page) nil
1217   (notebook notebook)
1218   ((%notebook-child notebook page) widget)
1219   (expand boolean :out)
1220   (fill boolean :out)
1221   (pack-type pack-type :out))
1222
1223 (defbinding notebook-set-tab-label-packing
1224     (notebook page expand fill pack-type) nil
1225   (notebook notebook)
1226   ((%notebook-child notebook page) widget)
1227   (expand boolean)
1228   (fill boolean)
1229   (pack-type pack-type))
1230
1231
1232
1233 ;;; Paned
1234
1235 (defbinding paned-pack1 () nil
1236   (paned paned)
1237   (child widget)
1238   (resize boolean)
1239   (shrink boolean))
1240
1241 (defbinding paned-pack2 () nil
1242   (paned paned)
1243   (child widget)
1244   (resize boolean)
1245   (shrink boolean))
1246
1247
1248 ;;; Layout
1249
1250 (defbinding layout-put () nil
1251   (layout layout)
1252   (widget widget)
1253   (x int)
1254   (y int))
1255
1256 (defbinding layout-move () nil
1257   (layout layout)
1258   (widget widget)
1259   (x int)
1260   (y int))
1261
1262
1263
1264 ;;; Menu shell
1265
1266 (defbinding menu-shell-insert (menu-shell menu-item position) nil
1267   (menu-shell menu-shell)
1268   (menu-item menu-item)
1269   ((case position
1270      (:first 0)
1271      (:last -1)
1272      (t position)) int))
1273
1274 (defun menu-shell-append (menu-shell menu-item)
1275   (menu-shell-insert menu-shell menu-item :last))
1276
1277 (defun menu-shell-prepend (menu-shell menu-item)
1278   (menu-shell-insert menu-shell menu-item :fisrt))
1279
1280 (defbinding menu-shell-deactivate () nil
1281   (menu-shell menu-shell))
1282
1283 (defbinding menu-shell-select-item () nil
1284   (menu-shell menu-shell)
1285   (menu-item menu-item))
1286
1287 (defbinding menu-shell-select-first () nil
1288   (menu-shell menu-shell)
1289   (search-sensitive boolean))
1290
1291 (defbinding menu-shell-deselect () nil
1292   (menu-shell menu-shell))
1293
1294 (defbinding menu-shell-activate-item () nil
1295   (menu-shell menu-shell)
1296   (menu-item menu-item)
1297   (fore-deactivate boolean))
1298
1299 (defbinding menu-shell-cancel () nil
1300   (menu-shell menu-shell))
1301
1302
1303 ;;; Menu
1304
1305 (defun %menu-position (menu child)
1306   (etypecase child
1307     (int child)
1308     (keyword (case child
1309                (:first 0)
1310                (:last -1)
1311                (t (error "Invalid position keyword: ~A" child))))
1312     (widget (menu-child-position menu child))))
1313
1314
1315 (defbinding menu-reorder-child (menu menu-item position) nil
1316   (menu menu)
1317   (menu-item menu-item)
1318   ((%menu-position menu position) int))
1319
1320 (defbinding menu-attach () nil
1321   (menu menu)
1322   (menu-item menu-item)
1323   (left-attach unsigned-int)
1324   (right-attach unsigned-int)
1325   (top-attach unsigned-int)
1326   (bottom-attach unsigned-int))
1327
1328 (def-callback-marshal %menu-position-func (nil (menu menu) (x int) (y int) (push-in boolean)))
1329
1330 (defbinding %menu-popup () nil
1331   (menu menu)
1332   (parent-menu-shell (or null menu-shell))
1333   (parent-menu-item (or null menu-item))
1334   (callback-func (or null pointer))
1335   (callback-id unsigned-int)
1336   (button unsigned-int)
1337   (activate-time (unsigned 32)))
1338
1339 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
1340                    parent-menu-item)
1341   (if callback
1342       (with-callback-function (id callback)
1343         (%menu-popup 
1344          menu parent-menu-shell parent-menu-item 
1345          (callback %menu-position-func) id button activate-time))
1346     (%menu-popup
1347      menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
1348  
1349 (defbinding menu-set-accel-path () nil
1350   (menu menu)
1351   (accel-path string))
1352
1353 (defbinding menu-reposition () nil
1354   (menu menu))
1355
1356 (defbinding menu-popdown () nil
1357   (menu menu))
1358
1359 (defun menu-child-position (menu child)
1360   (position child (container-children menu)))
1361
1362 (defun menu-active-num (menu)
1363   (menu-child-position menu (menu-active menu)))
1364
1365 (defbinding %menu-set-active () nil
1366   (menu menu)
1367   (index unsigned-int))
1368
1369 (defun (setf menu-active) (menu child)
1370   (%menu-set-active menu (%menu-position menu child))
1371   child)
1372   
1373 (defcallback %menu-detach-func (nil (widget widget) (menu menu))
1374   (funcall (object-data menu 'detach-func) widget menu))
1375
1376 (defbinding %menu-attach-to-widget () nil
1377   (menu menu)
1378   (widget widget)
1379   ((callback %menu-detach-func) pointer))
1380
1381 (defun menu-attach-to-widget (menu widget function)
1382   (setf (object-data menu 'detach-func) function)
1383   (%menu-attach-to-widget menu widget))
1384
1385 (defbinding menu-detach () nil
1386   (menu menu))
1387
1388 #+gtk2.6
1389 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
1390   (widget widget))
1391
1392 (defbinding menu-set-monitor () nil
1393   (menu menu)
1394   (monitor-num int))
1395
1396
1397 ;;; Table
1398
1399 (defbinding table-resize () nil
1400   (table table)
1401   (rows unsigned-int)
1402   (columns unsigned-int))
1403
1404 (defbinding table-attach (table child left right top bottom
1405                           &key options x-options y-options
1406                           (x-padding 0) (y-padding 0)) nil
1407   (table table)
1408   (child widget)
1409   (left unsigned-int)
1410   (right unsigned-int)
1411   (top unsigned-int)
1412   (bottom unsigned-int)
1413   ((append (mklist options) (mklist x-options)) attach-options)
1414   ((append (mklist options) (mklist y-options)) attach-options)
1415   (x-padding unsigned-int)
1416   (y-padding unsigned-int))
1417
1418
1419 (defbinding %table-set-row-spacing () nil
1420   (table table)
1421   (row unsigned-int)
1422   (spacing unsigned-int))
1423
1424 (defbinding %table-set-row-spacings () nil
1425   (table table)
1426   (spacing unsigned-int))
1427
1428 (defun (setf table-row-spacing) (spacing table &optional row)
1429   (if row
1430       (%table-set-row-spacing table row spacing)
1431     (%table-set-row-spacings table spacing))
1432   spacing)
1433
1434 (defbinding %table-get-row-spacing () unsigned-int
1435   (table table)
1436   (row unsigned-int))
1437
1438 (defbinding %table-get-default-row-spacing () unsigned-int
1439   (table table))
1440
1441 (defun table-row-spacing (table &optional row)
1442   (if row
1443       (%table-get-row-spacing table row)
1444     (%table-get-default-row-spacing table)))
1445
1446
1447 (defbinding %table-set-col-spacing () nil
1448   (table table)
1449   (col unsigned-int)
1450   (spacing unsigned-int))
1451
1452 (defbinding %table-set-col-spacings () nil
1453   (table table)
1454   (spacing unsigned-int))
1455
1456 (defun (setf table-col-spacing) (spacing table &optional col)
1457   (if col
1458       (%table-set-col-spacing table col spacing)
1459     (%table-set-col-spacings table spacing))
1460   spacing)
1461
1462 (defbinding %table-get-col-spacing () unsigned-int
1463   (table table)
1464   (col unsigned-int))
1465
1466 (defbinding %table-get-default-col-spacing () unsigned-int
1467   (table table))
1468
1469 (defun table-col-spacing (table &optional col)
1470   (if col
1471       (%table-get-col-spacing table col)
1472     (%table-get-default-col-spacing table)))
1473   
1474
1475
1476 ;;; Toolbar
1477
1478 (defbinding %toolbar-insert-element () widget
1479   (toolbar toolbar)
1480   (type toolbar-child-type)
1481   (widget (or null widget))
1482   (text string)
1483   (tooltip-text string)
1484   (tooltip-private-text string)
1485   (icon (or null widget))
1486   (nil null)
1487   (nil null)
1488   (position int))
1489
1490 (defbinding %toolbar-insert-stock () widget
1491   (toolbar toolbar)
1492   (stock-id string)
1493   (tooltip-text string)
1494   (tooltip-private-text string)
1495   (nil null)
1496   (nil null)
1497   (position int))
1498
1499 (defun toolbar-insert (toolbar position element
1500                        &key tooltip-text tooltip-private-text
1501                        type icon group callback object)
1502   (let* ((numpos (case position
1503                    (:first -1)
1504                    (:last 0)
1505                    (t position)))
1506          (widget
1507           (cond
1508            ((or
1509              (eq type :space)
1510              (and (not type) (eq element :space)))
1511             (%toolbar-insert-element
1512              toolbar :space nil nil
1513              tooltip-text tooltip-private-text nil numpos))
1514            ((or
1515              (eq type :widget)
1516              (and (not type) (typep element 'widget)))
1517             (%toolbar-insert-element
1518              toolbar :widget element nil
1519              tooltip-text tooltip-private-text nil numpos))
1520            ((or
1521              (eq type :stock)
1522              (and
1523               (not type)
1524               (typep element 'string)
1525               (stock-lookup element)))
1526             (%toolbar-insert-stock
1527              toolbar element tooltip-text tooltip-private-text numpos))
1528            ((typep element 'string)
1529             (%toolbar-insert-element
1530              toolbar (or type :button) (when (eq type :radio-button) group)
1531              element tooltip-text tooltip-private-text 
1532              (etypecase icon
1533                (null nil)
1534                (widget icon)
1535                (string (make-instance 'image :stock icon))
1536                (pathname (make-instance 'image :file icon))
1537                ((or list vector)
1538                 (make-instance 'image 
1539                  :pixmap icon ; :icon-size (toolbar-icon-size toolbar)
1540                  )))
1541              numpos))
1542            ((error "Invalid element type: ~A" element)))))
1543     (when callback
1544       (signal-connect widget 'clicked callback :object object))
1545     widget))
1546
1547 (defun toolbar-append (toolbar element &key tooltip-text tooltip-private-text
1548                        type icon group callback object)
1549   (toolbar-insert
1550    toolbar :first element :type type :icon icon :group group
1551    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1552    :callback callback :object object))
1553
1554 (defun toolbar-prepend (toolbar element &key tooltip-text tooltip-private-text
1555                         type icon group callback object)
1556   (toolbar-insert
1557    toolbar :last element :type type :icon icon :group group
1558    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1559    :callback callback :object object))
1560
1561
1562 (defun toolbar-insert-space (toolbar position)
1563   (toolbar-insert toolbar position :space))
1564
1565 (defun toolbar-append-space (toolbar)
1566   (toolbar-append toolbar :space))
1567
1568 (defun toolbar-prepend-space (toolbar)
1569   (toolbar-prepend toolbar :space))
1570
1571
1572 (defun toolbar-enable-tooltips (toolbar)
1573   (setf (toolbar-tooltips-p toolbar) t))
1574
1575 (defun toolbar-disable-tooltips (toolbar)
1576   (setf (toolbar-tooltips-p toolbar) nil))
1577
1578
1579 (defbinding toolbar-remove-space () nil
1580   (toolbar toolbar)
1581   (position int))
1582
1583 (defbinding toolbar-unset-icon-size () nil
1584   (toolbar toolbar))
1585
1586 (defbinding toolbar-unset-style () nil
1587   (toolbar toolbar))
1588
1589
1590 ;;; Tool item
1591
1592 (defbinding tool-item-retrieve-proxy-menu-item () widget
1593   (tool-item tool-item))
1594
1595 (defbinding (tool-item-proxy-menu-item 
1596              "gtk_tool_item_get_proxy_menu_item") () menu-item
1597   (tool-item tool-item)
1598   (menu-item-id string))
1599
1600 (defbinding %tool-item-set-proxy-menu-item () nil
1601   (tool-item tool-item)
1602   (menu-item-id string)
1603   (menu-item menu-item))
1604
1605 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
1606   (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
1607    menu-item)
1608
1609 #+gtk2.6
1610 (defbinding tool-item-rebuild-menu () nil
1611   (tool-item tool-item))
1612
1613
1614 ;;; Editable
1615
1616 (defbinding editable-select-region (editable &optional (start 0) end) nil
1617   (editable editable)
1618   (start int)
1619   ((or end -1) int))
1620
1621 (defbinding editable-get-selection-bounds (editable) nil
1622   (editable editable)
1623   (start int :out)
1624   (end int :out))
1625
1626 (defbinding editable-insert-text (editable text &optional (position 0)) nil
1627   (editable editable)
1628   (text string)
1629   ((length text) int)
1630   (position editable-position :in-out))
1631
1632 (defun editable-append-text (editable text)
1633   (editable-insert-text editable text nil))
1634
1635 (defun editable-prepend-text (editable text)
1636   (editable-insert-text editable text 0))
1637
1638 (defbinding editable-delete-text (editable &optional (start 0) end) nil
1639   (editable editable)
1640   (start int)
1641   ((or end -1) int))
1642
1643 (defbinding (editable-text "gtk_editable_get_chars")
1644     (editable &optional (start 0) end) string
1645   (editable editable)
1646   (start int)
1647   ((or end -1) int))
1648
1649 (defun (setf editable-text) (text editable)
1650   (if text
1651       (editable-delete-text
1652        editable
1653        (editable-insert-text editable text))
1654     (editable-delete-text editable))
1655   text)
1656
1657 (defbinding editable-cut-clipboard () nil
1658   (editable editable))
1659
1660 (defbinding editable-copy-clipboard () nil
1661   (editable editable))
1662
1663 (defbinding editable-paste-clipboard () nil
1664   (editable editable))
1665
1666 (defbinding editable-delete-selection () nil
1667   (editable editable))
1668
1669
1670
1671 ;;; Spin button
1672
1673 (defbinding spin-button-configure () nil
1674   (spin-button spin-button)
1675   (adjustment adjustment)
1676   (climb-rate double-float)
1677   (digits unsigned-int))
1678
1679 (defbinding spin-button-set-range () nil
1680   (spin-button spin-button)
1681   (min double-float)
1682   (max double-float))
1683
1684 (defbinding spin-button-get-range () nil
1685   (spin-button spin-button)
1686   (min double-float :out)
1687   (max double-float :out))
1688
1689 (defun spin-button-value-as-int (spin-button)
1690   (round (spin-button-value spin-button)))
1691
1692 (defbinding spin-button-spin () nil
1693   (spin-button spin-button)
1694   (direction spin-type)
1695   (increment single-float))
1696
1697 (defbinding spin-button-update () nil
1698   (spin-button spin-button))
1699
1700
1701
1702 ; ;;; Ruler
1703
1704 (defbinding ruler-set-range () nil
1705   (ruler ruler)
1706   (lower single-float)
1707   (upper single-float)
1708   (position single-float)
1709   (max-size single-float))
1710
1711 (defbinding ruler-draw-ticks () nil
1712   (ruler ruler))
1713
1714 (defbinding ruler-draw-pos () nil
1715   (ruler ruler))
1716
1717
1718
1719 ;;; Range
1720
1721 (defun range-lower (range)
1722   (adjustment-lower (range-adjustment range)))
1723
1724 (defun range-upper (range)
1725   (adjustment-upper (range-adjustment range)))
1726
1727 (defun (setf range-lower) (value range)
1728   (setf (adjustment-lower (range-adjustment range)) value))
1729
1730 (defun (setf range-upper) (value range)
1731   (setf (adjustment-upper (range-adjustment range)) value))
1732
1733 (defun range-page-increment (range)
1734   (adjustment-page-increment (range-adjustment range)))
1735
1736 (defun range-step-increment (range)
1737   (adjustment-step-increment (range-adjustment range)))
1738
1739 (defun (setf range-page-increment) (value range)
1740   (setf (adjustment-page-increment (range-adjustment range)) value))
1741
1742 (defun (setf range-step-increment) (value range)
1743   (setf (adjustment-step-increment (range-adjustment range)) value))
1744
1745 (defbinding range-set-range () nil
1746   (range range)
1747   (lower double-float)
1748   (upper double-float))
1749
1750 (defbinding range-set-increments () nil
1751   (range range)
1752   (step double-float)
1753   (page double-float))
1754
1755
1756 ;;; Scale
1757
1758 ; (defbinding scale-draw-value () nil
1759 ;   (scale scale))
1760
1761
1762
1763 ;;; Progress bar
1764
1765 (defbinding progress-bar-pulse () nil
1766   (progress-bar progress-bar))
1767
1768
1769 ;;; Size group
1770
1771 (defmethod initialize-instance ((size-group size-group) &rest initargs 
1772                                 &key widget widgets)
1773   (declare (ignore widget widgets))
1774   (prog1
1775       (call-next-method)
1776     (initial-add size-group #'size-group-add-widget 
1777      initargs :widget :widgets)))
1778
1779
1780 (defbinding size-group-add-widget () nil
1781   (size-group size-group)
1782   (widget widget))
1783
1784 (defbinding size-group-remove-widget () nil
1785   (size-group size-group)
1786   (widget widget))
1787
1788
1789 ;;; Stock items
1790
1791 (defbinding %stock-item-copy () pointer
1792   (location pointer))
1793
1794 (defbinding %stock-item-free () nil
1795   (location pointer))
1796
1797 (defmethod reference-foreign ((class (eql (find-class 'stock-item))) location)
1798   (%stock-item-copy location))
1799
1800 (defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location)
1801   (%stock-item-free location))
1802
1803 (defbinding stock-add (stock-item) nil
1804   (stock-item stock-item)
1805   (1 unsigned-int))
1806
1807 (defbinding stock-list-ids () (gslist string))
1808
1809 (defbinding %stock-lookup () boolean
1810   (stock-id string)
1811   (location pointer))
1812
1813 (defun stock-lookup (stock-id)
1814   (let ((location 
1815          (allocate-memory (proxy-instance-size (find-class 'stock-item)))))
1816     (unwind-protect
1817         (when (%stock-lookup stock-id location)
1818           (ensure-proxy-instance 'stock-item (%stock-item-copy location)))
1819         (deallocate-memory location))))
1820
1821
1822 ;;; Tooltips
1823
1824 (defbinding tooltips-enable () nil
1825   (tooltips tooltips))
1826
1827 (defbinding tooltips-disable () nil
1828   (tooltips tooltips))
1829
1830 (defun (setf tooltips-enabled-p) (enable tooltips)
1831   (if enable
1832       (tooltips-enable tooltips)
1833     (tooltips-disable tooltips)))
1834
1835 (defbinding tooltips-set-tip () nil
1836   (tooltips tooltips)
1837   (widget widget)
1838   (tip-text string)
1839   (tip-private string))
1840
1841 (defbinding tooltips-data-get () tooltips-data
1842   (widget widget))
1843
1844 (defbinding tooltips-force-window () nil
1845   (tooltips tooltips))
1846
1847 (defbinding tooltips-get-info-from-tip-window () boolean
1848   (tip-window window)
1849   (tooltips tooltips :out)
1850   (current-widget widget :out))
1851
1852
1853 ;;; Rc
1854
1855 (defbinding rc-add-default-file (filename) nil
1856   ((namestring (truename filename)) string))
1857
1858 (defbinding rc-parse (filename) nil
1859   ((namestring (truename filename)) string))
1860
1861 (defbinding rc-parse-string () nil
1862   (rc-string string))
1863
1864 (defbinding rc-reparse-all () nil)
1865
1866 (defbinding rc-get-style () style
1867   (widget widget))
1868
1869
1870
1871 ;;; Accelerator Groups
1872 #|
1873 (defbinding accel-group-activate (accel-group key modifiers) boolean
1874   (accel-group accel-group)
1875   ((gdk:keyval-from-name key) unsigned-int)
1876   (modifiers gdk:modifier-type))
1877
1878 (defbinding accel-groups-activate (object key modifiers) boolean
1879   (object object)
1880   ((gdk:keyval-from-name key) unsigned-int)
1881   (modifiers gdk:modifier-type))
1882
1883 (defbinding accel-group-attach () nil
1884   (accel-group accel-group)
1885   (object object))
1886
1887 (defbinding accel-group-detach () nil
1888   (accel-group accel-group)
1889   (object object))
1890
1891 (defbinding accel-group-lock () nil
1892   (accel-group accel-group))
1893
1894 (defbinding accel-group-unlock () nil
1895   (accel-group accel-group))
1896
1897
1898 ;;; Accelerator Groups Entries
1899
1900 (defbinding accel-group-get-entry (accel-group key modifiers) accel-entry
1901   (accel-group accel-group)
1902   ((gdk:keyval-from-name key) unsigned-int)
1903   (modifiers gdk:modifier-type))
1904
1905 (defbinding accel-group-lock-entry (accel-group key modifiers) nil
1906   (accel-group accel-group)
1907   ((gdk:keyval-from-name key) unsigned-int)
1908   (modifiers gdk:modifier-type))
1909
1910 (defbinding accel-group-unlock-entry (accel-group key modifiers) nil
1911   (accel-group accel-group)
1912   ((gdk:keyval-from-name key) unsigned-int)
1913   (modifiers gdk:modifier-type))
1914
1915 (defbinding accel-group-add
1916     (accel-group key modifiers flags object signal) nil
1917   (accel-group accel-group)
1918   ((gdk:keyval-from-name key) unsigned-int)
1919   (modifiers gdk:modifier-type)
1920   (flags accel-flags)
1921   (object object)
1922   ((name-to-string signal) string))
1923
1924 (defbinding accel-group-add (accel-group key modifiers object) nil
1925   (accel-group accel-group)
1926   ((gdk:keyval-from-name key) unsigned-int)
1927   (modifiers gdk:modifier-type)
1928   (object object))
1929
1930
1931 ;;; Accelerator Signals
1932
1933 (defbinding accel-group-handle-add
1934     (object signal-id accel-group key modifiers flags) nil
1935   (object object)
1936   (signal-id unsigned-int)
1937   (accel-group accel-group)
1938   ((gdk:keyval-from-name key) unsigned-int)
1939   (modifiers gdk:modifier-type)
1940   (flags accel-flags))
1941
1942 (defbinding accel-group-handle-remove
1943     (object accel-group key modifiers) nil
1944   (object object)
1945   (accel-group accel-group)
1946   ((gdk:keyval-from-name key) unsigned-int)
1947   (modifiers gdk:modifier-type))
1948 |#