1 ;; Common Lisp bindings for GTK+ v2.x
2 ;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net>
4 ;; Permission is hereby granted, free of charge, to any person obtaining
5 ;; a copy of this software and associated documentation files (the
6 ;; "Software"), to deal in the Software without restriction, including
7 ;; without limitation the rights to use, copy, modify, merge, publish,
8 ;; distribute, sublicense, and/or sell copies of the Software, and to
9 ;; permit persons to whom the Software is furnished to do so, subject to
10 ;; the following conditions:
12 ;; The above copyright notice and this permission notice shall be
13 ;; included in all copies or substantial portions of the Software.
15 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 ;; $Id: gtk.lisp,v 1.88 2008-01-10 22:11:15 espen Exp $
30 (defbinding check-version () (copy-of string)
31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
35 (defbinding query-version () nil
36 (major unsigned-int :out)
37 (minor unsigned-int :out)
38 (micro unsigned-int :out))
41 (multiple-value-bind (major minor micro)
44 (format nil "Gtk+ v~A.~A" major minor)
45 (format nil "Gtk+ v~A.~A.~A" major minor micro))))
51 ;;;; Initalization and display handling
53 (defparameter *event-poll-interval* 10000) ; in microseconds
56 (defbinding (gtk-init "gtk_parse_args") () boolean
57 "Initializes the library without opening the display."
61 (defun clg-init (&optional display multi-threading-p)
62 "Initializes the system and starts event handling."
63 (unless (gdk:display-get-default)
64 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
66 #+sbcl(sb-int:set-floating-point-modes :traps nil)
67 #+cmu(ext:set-floating-point-modes :traps nil))
71 (error "Initialization of GTK+ failed."))
73 (if (not multi-threading-p)
74 (%init-async-event-handling display)
75 #+sb-thread(%init-multi-threaded-event-handling display)
76 #-sb-thread(error "Multi threading not supported on this platform")))
77 (gdk:ensure-display display t))
79 (defun clg-init-with-threading (&optional display)
84 ;; A very minimal implementation of CLISP's socket-status
85 (defun socket-status (socket seconds microseconds)
86 (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set)))
87 (let ((fd (sb-sys:fd-stream-fd (car socket))))
88 (sb-unix:fd-zero read-fds)
89 (sb-unix:fd-set fd read-fds)
91 (let ((num-fds-changed
92 (sb-unix:unix-fast-select
93 (1+ fd) (sb-alien:addr read-fds) nil nil
94 seconds microseconds)))
95 (unless (or (not num-fds-changed) (zerop num-fds-changed))
96 (if (peek-char nil (car socket) nil)
100 (defun %init-async-event-handling (display)
101 (let ((style #?(or (featurep :cmu) (sbcl< 1 0 6)) :fd-handler
102 #?-(or (featurep :cmu) (sbcl< 1 0 6)) nil))
104 (find-package "SWANK")
105 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style)))
106 (error "When running clg in Slime, the communication style ~S must be used in combination with asynchronous event handling on this platform. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information." style)))
108 #?(or (featurep :cmu) (sbcl< 1 0 6))
110 (signal-connect (gdk:display-manager) 'display-opened
112 (let ((fd (gdk:display-connection-number display)))
114 (let ((handler (add-fd-handler
115 (gdk:display-connection-number display)
116 :input #'main-iterate-all)))
117 (signal-connect display 'closed
118 #'(lambda (is-error-p)
119 (declare (ignore is-error-p))
120 (remove-fd-handler handler))))))))
121 (setq *periodic-polling-function* #'main-iterate-all)
122 (setq *max-event-to-sec* 0)
123 (setq *max-event-to-usec* *event-poll-interval*))
125 #+(and clisp readline)
126 ;; Readline will call the event hook at most ten times per second
127 (setf readline:event-hook #'main-iterate-all)
129 #?-(or (featurep :cmu) (sbcl< 1 0 6))
130 ;; When running in Slime we need to hook into the Swank server
131 ;; to handle events asynchronously.
132 (if (find-package "SWANK")
133 (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")))
134 (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK")))))
135 (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))
138 (case (socket-status (cons stream :input) 0 *event-poll-interval*)
139 ((:input :eof) (return (funcall read-from-emacs)))
140 (otherwise (main-iterate-all)))))))
141 #-(and clisp readline)
142 (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started."))
144 (gdk:display-open display))
148 (defvar *main-thread* nil)
150 ;; Hopefully, when threading support is added to the Win32 port of
151 ;; SBCL in the future, this will work just out of the box.
153 (let ((done (sb-thread:make-waitqueue))
157 ;; In Win32 all GDK calls have to be made from the main loop
158 ;; thread, so we add a timeout function which will poll for code and
161 (defun funcall-in-main (function)
164 (eq sb-thread:*current-thread* *main-thread*))
166 (gdk:with-global-lock
167 (push function functions)
168 (sb-thread:condition-wait done gdk:*global-lock*)
171 ;; Will lock REPL on error, need to be fixed!
172 (defun %funcall-in-main-poll ()
177 do (push (funcall (pop functions)) results)
178 finally (sb-thread:condition-notify done n)))
181 (defmacro within-main-loop (&body body)
182 #-win32 `(gdk:with-global-lock ,@body)
183 #+win32 `(funcall-in-main #'(lambda () ,@body)))
185 (defun %init-multi-threaded-event-handling (display)
187 (find-package "SWANK")
188 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn)))
189 (error "When running clg in Slime, the communication style :spawn must be used in combination with multi threaded event handling. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information."))
191 (let ((main-running (sb-thread:make-waitqueue)))
192 (gdk:with-global-lock
194 (sb-thread:make-thread
196 (gdk:with-global-lock
197 (gdk:display-open display)
198 #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000)
199 #'%funcall-in-main-poll)
200 (sb-thread:condition-notify main-running)
202 :name "gtk event loop"))
203 (sb-thread:condition-wait main-running gdk:*global-lock*)))
205 ;; We need to hook into the Swank server to protect calls to GDK properly.
206 ;; This will *only* protect code entered directly in the REPL.
207 (when (find-package "SWANK")
208 (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
210 (push #'(lambda (form)
211 (within-main-loop (eval form)))
212 (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
213 (warn "Your version of Slime does not have *SLIME-REPL-EVAL-HOOKS* so all calls to Gtk+ functions have to be explicit protected by wrapping them in a WITHIN-MAIN-LOOP form"))))))
216 (defmacro within-main-loop (&body body)
221 ;;; Generic functions
223 (defgeneric add-to-radio-group (item1 item2))
224 (defgeneric activate-radio-widget (item))
225 (defgeneric (setf tool-item-tip-text) (tip-text tool-item))
226 (defgeneric (setf tool-item-tip-private) (tip-private tool-item))
232 (defbinding grab-add () nil
235 (defbinding grab-get-current () widget)
237 (defbinding grab-remove () nil
240 (defbinding get-default-language () (copy-of pango:language))
245 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
247 (define-callback-marshal %about-dialog-activate-link-callback nil
248 (about-dialog (link string)))
250 (defbinding about-dialog-set-email-hook (function) nil
251 (%about-dialog-activate-link-callback callback)
252 ((register-callback-function function) unsigned-int)
253 (user-data-destroy-callback callback))
255 (defbinding about-dialog-set-url-hook (function) nil
256 (%about-dialog-activate-link-callback callback)
257 ((register-callback-function function) unsigned-int)
258 (user-data-destroy-callback callback)))
263 (defbinding %accel-group-connect () nil
264 (accel-group accel-group)
266 (modifiers gdk:modifier-type)
270 (defun accel-group-connect (group accelerator function &optional flags)
271 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
272 (let ((gclosure (make-callback-closure function)))
273 (%accel-group-connect group key modifiers flags gclosure)
276 (defbinding accel-group-connect-by-path (group path function) nil
279 ((make-callback-closure function) gclosure :in/return))
281 (defbinding %accel-group-disconnect (group gclosure) boolean
285 (defbinding %accel-group-disconnect-key () boolean
288 (modifiers gdk:modifier-type))
290 (defun accel-group-disconnect (group accelerator)
291 (etypecase accelerator
292 (gclosure (%accel-group-disconnect group accelerator))
294 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
295 (%accel-group-disconnect-key group key modifiers)))))
297 (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
298 (accel-group accel-group)
300 (modifiers gdk:modifier-type)
303 (defun accel-group-query (accel-group accelerator)
304 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
305 (%accel-group-query accel-group key modifiers)))
307 (defbinding %accel-group-activate () boolean
308 (accel-group accel-group)
309 (acceleratable gobject)
311 (modifiers gdk:modifier-type))
313 (defun accel-group-activate (accel-group acceleratable accelerator)
314 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
315 (%accel-group-activate accel-group acceleratable key modifiers)))
317 (defbinding accel-group-lock () nil
318 (accel-group accel-group))
320 (defbinding accel-group-unlock () nil
321 (accel-group accel-group))
323 (defbinding accel-group-from-accel-closure () accel-group
326 (defbinding %accel-groups-activate () boolean
329 (modifiers gdk:modifier-type))
331 (defun accel-groups-activate (object accelerator)
332 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
333 (%accel-groups-activate object key modifiers)))
335 (defbinding accel-groups-from-object () (gslist accel-group)
338 (defbinding accelerator-valid-p (key &optional modifiers) boolean
340 (modifiers gdk:modifier-type))
342 (defbinding %accelerator-parse () nil
344 (key unsigned-int :out)
345 (modifiers gdk:modifier-type :out))
347 (defgeneric parse-accelerator (accelerator))
349 (defmethod parse-accelerator ((accelerator string))
350 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
352 (error "Invalid accelerator: ~A" accelerator)
353 (values key modifiers))))
355 (defmethod parse-accelerator ((accelerator cons))
356 (destructuring-bind (key modifiers) accelerator
362 (gdk:keyval-from-name key)
363 (error "Invalid key name: ~A" key)))
364 (character (parse-accelerator key)))
367 (defmethod parse-accelerator ((key integer))
370 (defmethod parse-accelerator ((key character))
372 (gdk:keyval-from-name (string key))
373 (error "Invalid key name: ~A" key)))
376 (defbinding accelerator-name () string
378 (modifiers gdk:modifier-type))
380 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
381 (defbinding accelerator-get-label () string
383 (modifiers gdk:modifier-type))
385 (defbinding %accelerator-set-default-mod-mask () nil
386 (default-modifiers gdk:modifier-type))
388 (defun (setf accelerator-default-modifier-mask) (default-modifiers)
389 (%accelerator-set-default-mod-mask default-modifiers))
391 (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
396 (defbinding accel-label-get-accel-width () unsigned-int
397 (accel-label accel-label))
399 (defbinding accel-label-refetch () boolean
400 (accel-label accel-label))
406 (defbinding %accel-map-add-entry () nil
409 (modifiers gdk:modifier-type))
411 (defun accel-map-add-entry (path accelerator)
412 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
413 (%accel-map-add-entry path key modifiers)))
415 (defbinding %accel-map-lookup-entry () boolean
417 ((make-instance 'accel-key) accel-key :in/return))
419 (defun accel-map-lookup-entry (path)
420 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
423 (slot-value accel-key 'key)
424 (slot-value accel-key 'modifiers)
425 (slot-value accel-key 'flags)))))
427 (defbinding %accel-map-change-entry () boolean
430 (modifiers gdk:modifier-type)
433 (defun accel-map-change-entry (path accelerator &optional replace)
434 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
435 (%accel-map-change-entry path key modifiers replace)))
437 (defbinding accel-map-load () nil
440 (defbinding accel-map-save () nil
443 (define-callback-marshal %accel-map-foreach-callback nil
444 ((accel-path string) (key unsigned-int)
445 (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first)
447 (defbinding %accel-map-foreach (callback-id) nil
448 (callback-id unsigned-int)
449 (%accel-map-foreach-callback callback))
451 (defbinding %accel-map-foreach-unfiltered (callback-id) nil
452 (callback-id unsigned-int)
453 (%accel-map-foreach-callback callback))
455 (defun accel-map-foreach (function &optional (filter-p t))
456 (with-callback-function (id function)
458 (%accel-map-foreach id)
459 (%accel-map-foreach-unfiltered id))))
461 (defbinding accel-map-add-filter () nil
464 (defbinding accel-map-get () accel-map)
466 (defbinding accel-map-lock-path () nil
469 (defbinding accel-map-unlock-path () nil
476 (defbinding accessible-connect-widget-destroyed () nil
477 (accessible accessible))
482 (defmethod initialize-instance ((adjustment adjustment) &key value)
485 ;; we need to make sure that the value is set last, otherwise it
486 ;; may be outside current limits and ignored
488 (setf (slot-value adjustment 'value) value))))
491 (defbinding adjustment-changed () nil
492 (adjustment adjustment))
494 (defbinding adjustment-value-changed () nil
495 (adjustment adjustment))
497 (defbinding adjustment-clamp-page () nil
498 (adjustment adjustment)
500 (upper single-float))
505 (defbinding alignment-set () nil
506 (alognment alignment)
507 (x-align single-float)
508 (y-align single-float)
509 (x-scale single-float)
510 (y-scale single-float))
512 (defbinding alignment-get-padding () nil
513 (alognment alignment)
514 (top unsigned-int :out)
515 (bottom unsigned-int :out)
516 (left unsigned-int :out)
517 (right unsigned-int :out))
519 (defbinding alignment-set-padding () nil
520 (alognment alignment)
522 (bottom unsigned-int)
524 (right unsigned-int))
529 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
531 (defbinding assistant-get-nth-page () widget
532 (assistant assistant)
535 (defbinding %assistant-insert-page () int
536 (assistant assistant)
540 (defun assistant-insert-page (assistant page position &rest child-args)
541 (let ((pos (case position
546 (%assistant-insert-page assistant page pos)
547 (init-child-slots assistant page child-args))))
549 (defun assistant-append-page (assistant page &rest child-args)
550 (apply #'assistant-insert-page assistant page :last child-args))
552 (defun assistant-prepend-page (assistant page &rest child-args)
553 (apply #'assistant-insert-page assistant page :first child-args))
555 (define-callback-marshal %assistant-page-func-callback int
556 ((current-page int)))
558 (defbinding assistant-set-forward-page-func (assistant function) nil
559 (assistant assistant)
560 (%assistant-page-func-callback callback)
561 ((register-callback-function function) pointer-data)
562 (user-data-destroy-callback callback))
564 (defbinding assistant-add-action-widget () nil
565 (assistant assistant)
568 (defbinding assistant-remove-action-widget () nil
569 (assistant assistant)
572 (defbinding assistant-update-buttons-state () nil
573 (assistant assistant)))
582 (defun (setf bin-child) (child bin)
583 (when-bind (current-child (bin-child bin))
584 (container-remove bin current-child))
585 (container-add bin child)
588 (defmethod compute-signal-function ((bin bin) signal function object args)
589 (declare (ignore signal))
590 (if (eq object :child)
591 #'(lambda (&rest emission-args)
592 (apply function (bin-child bin) (nconc (rest emission-args) args)))
598 (defbinding box-pack-start () nil
603 (padding unsigned-int))
605 (defbinding box-pack-end () nil
610 (padding unsigned-int))
612 (defun box-pack (box child &key end (expand t) (fill t) (padding 0))
614 (box-pack-end box child expand fill padding)
615 (box-pack-start box child expand fill padding)))
617 (defbinding box-reorder-child () nil
622 (defbinding box-query-child-packing () nil
625 (expand boolean :out)
627 (padding unsigned-int :out)
628 (pack-type pack-type :out))
630 (defbinding box-set-child-packing () nil
635 (padding unsigned-int)
636 (pack-type pack-type))
642 (defmethod initialize-instance ((button button) &rest initargs &key stock)
644 (apply #'call-next-method button
645 :label stock :use-stock t :use-underline t initargs)
649 (defbinding button-pressed () nil
652 (defbinding button-released () nil
655 (defbinding button-clicked () nil
658 (defbinding button-enter () nil
661 (defbinding button-leave () nil
668 (defbinding calendar-select-month () int
673 (defbinding calendar-select-day () nil
677 (defbinding calendar-mark-day () int
681 (defbinding calendar-unmark-day () int
685 (defbinding calendar-clear-marks () nil
688 (defbinding calendar-get-date () nil
690 (year unsigned-int :out)
691 (month unsigned-int :out)
692 (day unsigned-int :out))
694 (defbinding calendar-freeze () nil
697 (defbinding calendar-thaw () nil
703 (defbinding check-menu-item-toggled () nil
704 (check-menu-item check-menu-item))
709 (defbinding color-selection-is-adjusting-p () boolean
710 (colorsel color-selection))
712 (defbinding (color-selection-previous-color
713 "gtk_color_selection_get_previous_color") () nil
714 (colorsel color-selection)
715 ((make-instance 'gdk:color) gdk:color :in/return))
718 ;;; Color selection dialog -- no functions
724 (defmethod initialize-instance ((combo-box combo-box) &rest initargs
725 &key model content active)
726 (remf initargs :active)
728 (apply #'call-next-method combo-box initargs)
730 (apply #'call-next-method combo-box
731 :model (make-instance 'list-store :column-types '(string))
733 (unless (typep combo-box 'combo-box-entry)
734 (let ((cell (make-instance 'cell-renderer-text)))
735 (cell-layout-pack combo-box cell :expand t)
736 (cell-layout-add-attribute combo-box cell :text 0)))))
738 (mapc #'(lambda (text)
739 (combo-box-append-text combo-box text))
742 (setf (combo-box-active combo-box) active)))
745 ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
747 ;; (signal-emit combo-box 'changed)))
749 (defbinding combo-box-append-text () nil
750 (combo-box combo-box)
753 (defbinding combo-box-insert-text () nil
754 (combo-box combo-box)
758 (defbinding combo-box-prepend-text () nil
759 (combo-box combo-box)
762 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
763 (defbinding combo-box-get-active-text () string
764 (combo-box combo-box))
766 (defbinding combo-box-popup () nil
767 (combo-box combo-box))
769 (defbinding combo-box-popdown () nil
770 (combo-box combo-box))
776 (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
779 (setf (combo-box-entry-text-column combo-box-entry) 0)))
784 (defmethod shared-initialize ((dialog dialog) names &rest initargs
786 (declare (ignore names button buttons))
789 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
792 (defun dialog-response-id (dialog response &optional create-p error-p)
793 "Returns a numeric response id"
794 (if (typep response 'response-type)
795 (response-type-to-int response)
796 (let ((responses (user-data dialog 'responses)))
798 ((and responses (position response responses :test #'equal)))
802 (vector-push-extend response responses)
803 (1- (length responses)))
806 (user-data dialog 'responses)
807 (make-array 1 :adjustable t :fill-pointer t
808 :initial-element response))
811 (error "Invalid response: ~A" response))))))
813 (defun dialog-find-response (dialog id)
814 "Finds a symbolic response given a numeric id"
816 ((not (numberp id)) id)
817 ((< id 0) (int-to-response-type id))
818 ((aref (user-data dialog 'responses) id))))
821 (defmethod compute-signal-id ((dialog dialog) signal)
822 (if (dialog-response-id dialog signal)
823 (ensure-signal-id 'response dialog)
826 (defmethod compute-signal-function ((dialog dialog) signal function object args)
827 (declare (ignore function object args))
828 (let ((callback (call-next-method))
829 (id (dialog-response-id dialog signal)))
832 #'(lambda (dialog response)
833 (when (= response id)
834 (funcall callback dialog))))
835 ((string-equal signal "response")
836 #'(lambda (dialog response)
837 (funcall callback dialog (dialog-find-response dialog response))))
840 (defbinding dialog-run () nil
843 (defbinding dialog-response (dialog response) nil
845 ((dialog-response-id dialog response nil t) int))
848 (defbinding %dialog-add-button () button
853 (defun dialog-add-button (dialog label &optional (response label)
854 &key default object after)
855 "Adds a button to the dialog."
856 (let* ((signal (if (functionp response)
859 (id (dialog-response-id dialog signal t))
860 (button (%dialog-add-button dialog label id)))
861 (when (functionp response)
862 (signal-connect dialog signal response :object object :after after))
864 (%dialog-set-default-response dialog id))
868 (defbinding %dialog-add-action-widget () nil
870 (action-widget widget)
873 (defun dialog-add-action-widget (dialog widget &optional (response widget)
874 &key default object after)
875 (let* ((signal (if (functionp response)
878 (id (dialog-response-id dialog signal t)))
879 (unless (widget-hidden-p widget)
880 (widget-show widget))
881 (%dialog-add-action-widget dialog widget id)
882 (when (functionp response)
883 (signal-connect dialog signal response :object object :after after))
885 (setf (widget-can-default-p widget) t)
886 (%dialog-set-default-response dialog id))
890 (defbinding %dialog-set-default-response () nil
894 (defun dialog-set-default-response (dialog response)
895 (%dialog-set-default-response
896 dialog (dialog-response-id dialog response nil t)))
898 (defbinding dialog-set-response-sensitive (dialog response sensitive) nil
900 ((dialog-response-id dialog response nil t) int)
903 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
904 (defbinding alternative-dialog-button-order-p (&optional screen) boolean
905 (screen (or null gdk:screen)))
907 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
908 (defbinding (dialog-set-alternative-button-order
909 "gtk_dialog_set_alternative_button_order_from_array")
910 (dialog new-order) nil
912 ((length new-order) int)
913 ((map 'vector #'(lambda (response)
914 (dialog-response-id dialog response nil t))
915 new-order) (vector int)))
918 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
920 (defbinding %dialog-get-response-for-widget () int
924 (defun dialog-get-response-for-widget (dialog widget)
925 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
928 (defmethod container-add ((dialog dialog) (child widget) &rest args)
929 (apply #'container-add (dialog-vbox dialog) child args))
932 (defmethod container-remove ((dialog dialog) (child widget))
933 (container-remove (dialog-vbox dialog) child))
935 (defmethod container-children ((dialog dialog))
936 (container-children (dialog-vbox dialog)))
938 (defmethod (setf container-children) (children (dialog dialog))
939 (setf (container-children (dialog-vbox dialog)) children))
944 (defun drawing-area-scroll (drawing-area dx dy)
945 (gdk:window-scroll (widget-window drawing-area) dx dy))
950 (defbinding entry-get-layout-offsets () nil
955 (defbinding entry-layout-index-to-text-index () int
959 (defbinding entry-text-index-to-layout-index () int
966 (define-callback-marshal %entry-completion-match-callback boolean
967 (entry-completion string tree-iter))
969 (defbinding entry-completion-set-match-func (completion function) nil
970 (completion entry-completion)
971 (%entry-completion-match-callback callback)
972 ((register-callback-function function) unsigned-int)
973 (user-data-destroy-callback callback))
975 (defbinding entry-completion-complete () nil
976 (completion entry-completion))
978 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
979 (defbinding entry-completion-get-completion-prefix () string
980 (completion entry-completion))
982 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
983 (defbinding entry-completion-insert-prefix () nil
984 (completion entry-completion))
986 (defbinding entry-completion-insert-action-text () nil
987 (completion entry-completion)
991 (defbinding entry-completion-insert-action-markup () nil
992 (completion entry-completion)
996 (defbinding entry-completion-delete-action () nil
997 (completion entry-completion)
1003 (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
1004 &key filter filters shortcut-folder
1005 shortcut-folders shortcut-folder-uti
1006 shortcut-folder-uris)
1007 (declare (ignore filter filters shortcut-folder shortcut-folders
1008 shortcut-folder-uti shortcut-folder-uris))
1011 (initial-add file-chooser #'file-chooser-add-filter
1012 initargs :filer :filters)
1013 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1014 initargs :shortcut-folder :shortcut-folders)
1015 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1016 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1019 (defbinding file-chooser-select-filename () boolean
1020 (file-chooser file-chooser)
1023 (defbinding file-chooser-unselect-filename () nil
1024 (file-chooser file-chooser)
1027 (defbinding file-chooser-select-all () boolean
1028 (file-chooser file-chooser))
1030 (defbinding file-chooser-unselect-all () boolean
1031 (file-chooser file-chooser))
1033 (defbinding file-chooser-get-filenames () (gslist string)
1034 (file-chooser file-chooser))
1036 (defbinding file-chooser-select-uri () boolean
1037 (file-chooser file-chooser)
1040 (defbinding file-chooser-unselect-uri () nil
1041 (file-chooser file-chooser)
1044 (defbinding file-chooser-get-uris () (gslist string)
1045 (file-chooser file-chooser))
1047 (defbinding file-chooser-add-filter () nil
1048 (file-chooser file-chooser)
1049 (filter file-filter))
1051 (defbinding file-chooser-remove-filter () nil
1052 (file-chooser file-chooser)
1053 (filter file-filter))
1055 (defbinding file-chooser-list-filters () (gslist file-filter)
1056 (file-chooser file-chooser))
1058 (defbinding file-chooser-add-shortcut-folder () boolean
1059 (file-chooser file-chooser)
1063 (defbinding file-chooser-remove-shortcut-folder () nil
1064 (file-chooser file-chooser)
1068 (defbinding file-chooser-list-shortcut-folders () (gslist string)
1069 (file-chooser file-chooser))
1071 (defbinding file-chooser-add-shortcut-folder-uri () boolean
1072 (file-chooser file-chooser)
1076 (defbinding file-chooser-remove-shortcut-folder-uri () nil
1077 (file-chooser file-chooser)
1081 (defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1082 (file-chooser file-chooser))
1087 (defmethod initialize-instance ((file-filter file-filter) &rest initargs
1088 &key mime-type mime-types pattern patterns
1090 (declare (ignore mime-type mime-types pattern patterns))
1093 (when pixbuf-formats
1094 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1095 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1096 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1097 (file-filter-add-pixbuf-formats file-filter))
1098 (initial-add file-filter #'file-filter-add-mime-type
1099 initargs :mime-type :mime-types)
1100 (initial-add file-filter #'file-filter-add-pattern
1101 initargs :pattern :patterns)))
1104 (defbinding file-filter-add-mime-type () nil
1105 (filter file-filter)
1108 (defbinding file-filter-add-pattern () nil
1109 (filter file-filter)
1112 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1113 (defbinding file-filter-add-pixbuf-formats () nil
1114 (filter file-filter))
1116 (define-callback-marshal %file-filter-callback boolean (file-filter-info))
1118 (defbinding file-filter-add-custom (filter needed function) nil
1119 (filter file-filter)
1120 (needed file-filter-flags)
1121 (%file-filter-callback callback)
1122 ((register-callback-function function) unsigned-int)
1123 (user-data-destroy-callback callback))
1125 (defbinding file-filter-get-needed () file-filter-flags
1126 (filter file-filter))
1128 (defbinding file-filter-filter () boolean
1129 (filter file-filter)
1130 (filter-info file-filter-info))
1136 (defbinding image-set-from-file () nil
1138 (filename pathname))
1140 (defmethod (setf image-pixmap) ((data vector) (image image))
1141 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1142 (setf (image-pixmap image) pixmap)
1143 (setf (image-mask image) mask)))
1145 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1147 ((typep pixmap 'vector)
1148 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1149 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1153 (image-set-from-file image file)))
1154 ((call-next-method))))
1156 (defun create-image-widget (source &optional mask)
1158 (gdk:pixbuf (make-instance 'image :pixbuf source))
1159 (string (make-instance 'image :stock source))
1160 (pathname (make-instance 'image :file source))
1161 ((or list vector) (make-instance 'image :pixmap source))
1162 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1164 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1165 (defbinding image-clear () nil
1172 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1173 (if (and image (not (typep image 'widget)))
1174 (apply #'call-next-method item :image (create-image-widget image) initargs)
1175 (call-next-method)))
1178 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1179 (setf (slot-value item 'image) widget))
1181 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
1182 (setf (image-menu-item-image item) (create-image-widget image)))
1187 (defmethod shared-initialize ((label label) names &key pattern)
1188 (declare (ignore names))
1191 (setf (label-pattern label) pattern)))
1193 (defbinding label-get-layout-offsets () nil
1198 (defbinding label-select-region () nil
1203 (defbinding label-get-selection-bounds () boolean
1212 (defbinding %radio-button-get-group () pointer
1213 (radio-button radio-button))
1215 (defbinding %radio-button-set-group () nil
1216 (radio-button radio-button)
1219 (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
1220 "Add BUTTON1 to the group which BUTTON2 belongs to."
1221 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1223 (defun %add-activate-callback (widget signal function object after)
1225 (signal-connect widget signal
1227 (when (slot-value widget 'active)
1228 (funcall function object (slot-value widget 'value))))
1229 :object object :after after)
1230 (signal-connect widget signal
1232 (when (slot-value widget 'active)
1233 (funcall function (slot-value widget 'value))))
1236 (defmethod activate-radio-widget ((button radio-button))
1237 (signal-emit button 'clicked))
1239 (defgeneric add-activate-callback (action function &key object after))
1241 (defmethod add-activate-callback ((button radio-button) function &key object after)
1242 (%add-activate-callback button 'clicked function object after))
1244 (defmethod initialize-instance ((button radio-button) &key group)
1248 (add-to-radio-group button group))))
1253 (defbinding item-select () nil
1256 (defbinding item-deselect () nil
1259 (defbinding item-toggle () nil
1266 (defmethod initialize-instance ((item menu-item) &key label)
1270 (setf (menu-item-label item) label))))
1273 (defun (setf menu-item-label) (label menu-item)
1274 (make-instance 'accel-label
1275 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
1276 :use-underline (menu-item-use-underline-p menu-item)
1277 :visible t :parent menu-item)
1280 (defun menu-item-label (menu-item)
1281 (when (and (slot-boundp menu-item 'child)
1282 (typep (bin-child menu-item) 'label))
1283 (label-label (bin-child menu-item))))
1285 (defbinding menu-item-remove-submenu () nil
1286 (menu-item menu-item))
1288 (defbinding menu-item-set-accel-path () nil
1289 (menu-item menu-item)
1290 (accel-path string))
1292 (defbinding menu-item-select () nil
1293 (menu-item menu-item))
1295 (defbinding menu-item-deselect () nil
1296 (menu-item menu-item))
1298 (defbinding menu-item-activate () nil
1299 (menu-item menu-item))
1301 (defbinding menu-item-toggle-size-request () nil
1302 (menu-item menu-item)
1303 (requisition int :out))
1305 (defbinding menu-item-toggle-size-allocate () nil
1306 (menu-item menu-item)
1310 ;;; Menu tool button
1312 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1313 (defbinding menu-tool-button-set-arrow-tooltip () nil
1314 (menu-tool-button menu-tool-button)
1317 (tip-private string))
1322 (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1323 button buttons flags transient-parent)
1324 (let ((stock-buttons
1326 ((and (not buttons) (not button))
1330 ((listp buttons) :none)
1332 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1335 (defmethod shared-initialize ((dialog message-dialog) names &rest initargs
1336 &key message-type buttons button text
1337 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1339 (declare (ignore names))
1341 (message-dialog-set-markup dialog text))
1342 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1343 (when secondary-text
1344 (message-dialog-format-secondary-markup dialog secondary-text))
1345 (when (and (not buttons) (not button))
1347 for (key value) on initargs by #'cddr
1348 when (and (eq key :signal) (eq (first value) :close))
1349 do (warn "Default button configuration changed from ~A to ~A" :close
1350 (if (eq message-type :question) :yes-no :ok))
1352 (if (typep buttons 'buttons-type)
1353 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1354 (call-next-method)))
1357 (defbinding %message-dialog-new () pointer
1358 (parent (or null window))
1359 (flags dialog-flags)
1361 (buttons buttons-type)
1364 (defbinding message-dialog-set-markup () nil
1365 (message-dialog message-dialog)
1368 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1369 (defbinding message-dialog-format-secondary-text () nil
1370 (message-dialog message-dialog)
1373 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1374 (defbinding message-dialog-format-secondary-markup () nil
1375 (message-dialog message-dialog)
1382 (defbinding %radio-menu-item-get-group () pointer
1383 (radio-menu-item radio-menu-item))
1385 (defbinding %radio-menu-item-set-group () nil
1386 (radio-menu-item radio-menu-item)
1389 (defmethod activate-radio-widget ((item radio-menu-item))
1390 (menu-item-activate item))
1392 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
1393 "Add ITEM1 to the group which ITEM2 belongs to."
1394 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1396 (defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1397 (%add-activate-callback item 'activate function object after))
1399 (defmethod initialize-instance ((item radio-menu-item) &key group)
1403 (add-to-radio-group item group))))
1407 ;;; Radio tool button
1409 (defbinding %radio-tool-button-get-group () pointer
1410 (radio-tool-button radio-tool-button))
1412 (defbinding %radio-tool-button-set-group () nil
1413 (radio-tool-button radio-tool-button)
1416 (defmethod activate-radio-widget ((button radio-tool-button))
1417 (signal-emit button 'clicked))
1419 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
1420 "Add BUTTON1 to the group which BUTTON2 belongs to."
1421 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
1422 (defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1423 (%add-activate-callback button 'clicked function object after))
1425 (defmethod initialize-instance ((button radio-tool-button) &key group)
1429 (add-to-radio-group button group))))
1435 (defbinding toggle-button-toggled () nil
1436 (toggle-button toggle-button))
1441 (defmethod initialize-instance ((window window) &rest initargs
1442 &key display accel-group accel-groups)
1443 (declare (ignore accel-group accel-groups))
1446 (apply #'call-next-method
1447 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
1449 (initial-add window #'window-add-accel-group
1450 initargs :accel-group :accel-groups)))
1452 #-debug-ref-counting
1453 (defmethod print-object ((window window) stream)
1455 (proxy-valid-p window)
1456 (slot-boundp window 'title)
1457 (not (zerop (length (window-title window)))))
1458 (print-unreadable-object (window stream :type t :identity nil)
1459 (format stream "~S at 0x~X"
1460 (window-title window) (pointer-address (foreign-location window))))
1461 (call-next-method)))
1463 (defbinding window-set-wmclass () nil
1465 (wmclass-name string)
1466 (wmclass-class string))
1468 (defbinding window-add-accel-group () nil
1470 (accel-group accel-group))
1472 (defbinding window-remove-accel-group () nil
1474 (accel-group accel-group))
1476 (defbinding window-activate-focus () int
1479 (defbinding window-activate-default () int
1482 (defbinding window-set-default-size (window width height) int
1485 ((or height -1) int))
1487 (defbinding %window-set-geometry-hints () nil
1489 (widget (or widget null))
1490 (geometry gdk:geometry)
1491 (geometry-mask gdk:window-hints))
1493 (defun window-set-geometry-hints (window &key widget min-width min-height
1494 max-width max-height base-width base-height
1495 width-inc height-inc gravity
1496 aspect (min-aspect aspect) (max-aspect aspect))
1497 (let ((geometry (make-instance 'gdk:geometry
1498 :min-width (or min-width -1)
1499 :min-height (or min-height -1)
1500 :max-width (or max-width -1)
1501 :max-height (or max-height -1)
1502 :base-width (or base-width 0)
1503 :base-height (or base-height 0)
1504 :width-inc (or width-inc 0)
1505 :height-inc (or height-inc 0)
1506 :min-aspect (or min-aspect 0)
1507 :max-aspect (or max-aspect 0)))
1509 (when (or min-width min-height)
1510 (push :min-size mask))
1511 (when (or max-width max-height)
1512 (push :max-size mask))
1513 (when (or base-width base-height)
1514 (push :base-size mask))
1515 (when (or width-inc height-inc)
1516 (push :resize-inc mask))
1517 (when (or min-aspect max-aspect)
1518 (push :aspect mask))
1520 (push :win-gravity mask)
1521 (setf (gdk:geometry-gravity geometry) gravity))
1522 (%window-set-geometry-hints window widget geometry mask)))
1524 (defbinding window-list-toplevels () (glist (copy-of window))
1525 "Returns a list of all existing toplevel windows.")
1527 (defbinding window-add-mnemonic (window key target) nil
1529 ((gdk:keyval-from-name key) unsigned-int)
1532 (defbinding window-remove-mnemonic (window key target) nil
1534 ((gdk:keyval-from-name key) unsigned-int)
1537 (defbinding window-mnemonic-activate (window key modifier) nil
1539 ((gdk:keyval-from-name key) unsigned-int)
1540 (modifier gdk:modifier-type))
1542 (defbinding window-activate-key () boolean
1544 (event gdk:key-event))
1546 (defbinding window-propagate-key-event () boolean
1548 (event gdk:key-event))
1550 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1551 (defbinding window-present () nil
1554 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1556 (defbinding %window-present () nil
1559 (defbinding %window-present-with-time () nil
1561 (timespamp unsigned-int))
1563 (defun window-present (window &optional timestamp)
1565 (%window-present-with-time window timestamp)
1566 (%window-present window))))
1568 (defbinding window-iconify () nil
1571 (defbinding window-deiconify () nil
1574 (defbinding window-stick () nil
1577 (defbinding window-unstick () nil
1580 (defbinding window-maximize () nil
1583 (defbinding window-unmaximize () nil
1586 (defbinding window-fullscreen () nil
1589 (defbinding window-unfullscreen () nil
1592 (defbinding window-set-keep-above () nil
1596 (defbinding window-set-keep-below () nil
1600 (defbinding window-begin-resize-drag () nil
1602 (edge gdk:window-edge)
1604 (root-x int) (root-y int)
1605 (timestamp unsigned-int))
1607 (defbinding window-begin-move-drag () nil
1609 (edge gdk:window-edge)
1611 (root-x int) (root-y int)
1612 (timestamp unsigned-int))
1614 (defbinding window-set-frame-dimensions () nil
1616 (left int) (top int) (rigth int) (bottom int))
1618 (defbinding %window-get-default-size () nil
1623 (defun window-get-default-size (window)
1624 (multiple-value-bind (width height) (%window-get-default-size window)
1625 (values (unless (= width -1) width) (unless (= height -1) height))))
1627 (defbinding window-get-frame-dimensions () nil
1629 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1631 (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
1634 (defbinding window-get-position () nil
1639 (defbinding window-get-size () nil
1644 (defbinding window-move () nil
1649 (defbinding window-parse-geometry () boolean
1653 (defbinding window-reshow-with-initial-size () nil
1656 (defbinding window-resize () nil
1661 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1662 () (glist gdk:pixbuf))
1664 (defun window-default-icon ()
1665 (first (window-default-icon-list)))
1667 (defbinding %window-set-default-icon-list () nil
1668 (icons (glist gdk:pixbuf)))
1670 (defun (setf window-default-icon-list) (icons)
1671 (%window-set-default-icon-list icons)
1674 (defbinding %window-set-default-icon () nil
1675 (icons (glist gdk:pixbuf)))
1677 (defgeneric (setf window-default-icon) (icon))
1679 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1680 (%window-set-default-icon icon)
1683 (defgeneric (setf window-group) (group window))
1685 (defmethod (setf window-group) ((group window-group) (window window))
1686 (window-group-add-window group window)
1689 (defbinding %window-set-default-icon-from-file () boolean
1693 (defmethod (setf window-default-icon) ((icon-file pathname))
1694 (%window-set-default-icon-from-file icon-file)
1697 (defbinding %window-set-icon-from-file () boolean
1702 (defmethod (setf window-icon) ((icon-file pathname) (window window))
1703 (%window-set-icon-from-file window icon-file)
1706 (defbinding window-set-auto-startup-notification () nil
1709 (defbinding decorated-window-init () nil
1712 (defbinding decorated-window-calculate-frame-size () nil
1715 (defbinding decorated-window-set-title () nil
1719 (defbinding decorated-window-move-resize-window () nil
1729 (defmethod initialize-instance ((window-group window-group) &rest initargs
1730 &key window windows)
1731 (declare (ignore window windows))
1734 (initial-add window-group #'window-group-add-window
1735 initargs :window :windows)))
1738 (defbinding window-group-add-window () nil
1739 (window-group window-group)
1742 (defbinding window-group-remove-window () nil
1743 (window-group window-group)
1749 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1750 (setf (scrolled-window-hscrollbar-policy window) policy)
1751 (setf (scrolled-window-vscrollbar-policy window) policy))
1753 (defbinding scrolled-window-add-with-viewport () nil
1754 (scrolled-window scrolled-window)
1757 (defmethod shared-initialize ((window scrolled-window) names &key policy)
1758 (declare (ignore names))
1760 (setf (slot-value window 'hscrollbar-policy) policy)
1761 (setf (slot-value window 'vscrollbar-policy) policy))
1767 (defbinding statusbar-get-context-id () unsigned-int
1768 (statusbar statusbar)
1769 (context-description string))
1771 (defbinding statusbar-push () unsigned-int
1772 (statusbar statusbar)
1773 (context-id unsigned-int)
1776 (defbinding statusbar-pop () nil
1777 (statusbar statusbar)
1778 (context-id unsigned-int))
1780 (defbinding statusbar-remove () nil
1781 (statusbar statusbar)
1782 (context-id unsigned-int)
1783 (message-id unsigned-int))
1789 (defbinding fixed-put () nil
1794 (defbinding fixed-move () nil
1803 (defun %ensure-notebook-position (notebook page)
1806 (widget (notebook-page-num notebook page t))))
1808 (defun %ensure-notebook-child (notebook position)
1811 (t (notebook-get-nth-page notebook position))))
1813 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1814 (notebook position child &optional tab-label menu-label) nil
1817 ((if (stringp tab-label)
1818 (make-instance 'label :label tab-label)
1819 tab-label) (or null widget))
1820 ((if (stringp menu-label)
1821 (make-instance 'label :label menu-label)
1822 menu-label) (or null widget))
1823 ((%ensure-notebook-position notebook position) position))
1825 (defun notebook-append (notebook child &optional tab-label menu-label)
1826 (notebook-insert notebook :last child tab-label menu-label))
1828 (defun notebook-prepend (notebook child &optional tab-label menu-label)
1829 (notebook-insert notebook :first child tab-label menu-label))
1831 (defbinding notebook-remove-page (notebook page) nil
1833 ((%ensure-notebook-position notebook page) position))
1835 (defbinding %notebook-page-num () int
1839 (defun notebook-page-num (notebook child &optional error-p)
1840 (let ((page-num (%notebook-page-num notebook child)))
1843 (error "~A is not a page in ~A" child notebook))
1846 (defbinding notebook-next-page () nil
1847 (notebook notebook))
1849 (defbinding notebook-prev-page () nil
1850 (notebook notebook))
1852 (defbinding notebook-reorder-child (notebook child position) nil
1855 ((%ensure-notebook-position notebook position) int))
1857 (defbinding notebook-popup-enable () nil
1858 (notebook notebook))
1860 (defbinding notebook-popup-disable () nil
1861 (notebook notebook))
1863 (defbinding notebook-get-nth-page () widget
1867 (defun %notebook-current-page (notebook)
1868 (when (slot-boundp notebook 'current-page-num)
1869 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
1871 (defun (setf notebook-current-page) (page notebook)
1872 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
1874 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1875 (notebook page) widget
1877 ((%ensure-notebook-child notebook page) widget))
1879 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1880 (notebook page) (copy-of string)
1882 ((%ensure-notebook-child notebook page) widget))
1884 (defbinding %notebook-set-tab-label () nil
1889 (defun (setf notebook-tab-label) (tab-label notebook page)
1890 (let ((widget (if (stringp tab-label)
1891 (make-instance 'label :label tab-label)
1893 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1897 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1898 (notebook page) widget
1900 ((%ensure-notebook-child notebook page) widget))
1902 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1903 (notebook page) (copy-of string)
1905 ((%ensure-notebook-child notebook page) widget))
1907 (defbinding %notebook-set-menu-label () nil
1910 (menu-label widget))
1912 (defun (setf notebook-menu-label) (menu-label notebook page)
1913 (let ((widget (if (stringp menu-label)
1914 (make-instance 'label :label menu-label)
1916 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1920 (defbinding notebook-query-tab-label-packing (notebook page) nil
1922 ((%ensure-notebook-child notebook page) widget)
1923 (expand boolean :out)
1925 (pack-type pack-type :out))
1927 (defbinding notebook-set-tab-label-packing
1928 (notebook page expand fill pack-type) nil
1930 ((%ensure-notebook-child notebook page) widget)
1933 (pack-type pack-type))
1939 (defbinding paned-pack1 () nil
1945 (defbinding paned-pack2 () nil
1954 (defbinding layout-put () nil
1960 (defbinding layout-move () nil
1966 (defbinding layout-set-size () nil
1968 (width unsigned-int)
1969 (height unsigned-int))
1971 (defbinding layout-get-size () nil
1973 (width unsigned-int :out)
1974 (height unsigned-int :out))
1979 (defbinding menu-shell-insert (menu-shell menu-item position) nil
1980 (menu-shell menu-shell)
1981 (menu-item menu-item)
1987 (defun menu-shell-append (menu-shell menu-item)
1988 (menu-shell-insert menu-shell menu-item :last))
1990 (defun menu-shell-prepend (menu-shell menu-item)
1991 (menu-shell-insert menu-shell menu-item :fisrt))
1993 (defbinding menu-shell-deactivate () nil
1994 (menu-shell menu-shell))
1996 (defbinding menu-shell-select-item () nil
1997 (menu-shell menu-shell)
1998 (menu-item menu-item))
2000 (defbinding menu-shell-select-first () nil
2001 (menu-shell menu-shell)
2002 (search-sensitive boolean))
2004 (defbinding menu-shell-deselect () nil
2005 (menu-shell menu-shell))
2007 (defbinding menu-shell-activate-item () nil
2008 (menu-shell menu-shell)
2009 (menu-item menu-item)
2010 (fore-deactivate boolean))
2012 (defbinding menu-shell-cancel () nil
2013 (menu-shell menu-shell))
2018 (defun %menu-position (menu child)
2021 (keyword (case child
2024 (t (error "Invalid position keyword: ~A" child))))
2025 (widget (menu-child-position menu child))))
2028 (defbinding menu-reorder-child (menu menu-item position) nil
2030 (menu-item menu-item)
2031 ((%menu-position menu position) int))
2033 (defbinding menu-attach () nil
2035 (menu-item menu-item)
2036 (left-attach unsigned-int)
2037 (right-attach unsigned-int)
2038 (top-attach unsigned-int)
2039 (bottom-attach unsigned-int))
2041 (define-callback-marshal %menu-position-callback nil
2042 (menu (x int) (y int) (push-in boolean)))
2044 (defbinding %menu-popup () nil
2046 (parent-menu-shell (or null menu-shell))
2047 (parent-menu-item (or null menu-item))
2048 (callback (or null callback))
2049 (callback-id unsigned-int)
2050 (button unsigned-int)
2051 (activate-time (unsigned 32)))
2053 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
2056 (with-callback-function (id callback)
2058 menu parent-menu-shell parent-menu-item
2059 %menu-position-callback id button activate-time))
2061 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2063 (defbinding menu-set-accel-path () nil
2065 (accel-path string))
2067 (defbinding menu-reposition () nil
2070 (defbinding menu-popdown () nil
2073 (defun menu-child-position (menu child)
2074 (position child (container-children menu)))
2076 (defun menu-active-num (menu)
2077 (menu-child-position menu (menu-active menu)))
2079 (defbinding %menu-set-active () nil
2081 (index unsigned-int))
2083 (defun (setf menu-active) (menu child)
2084 (%menu-set-active menu (%menu-position menu child))
2087 (define-callback %menu-detach-callback nil ((widget widget) (menu menu))
2088 (funcall (user-data menu 'detach-func) widget menu))
2090 (defbinding %menu-attach-to-widget (menu widget) nil
2093 (%menu-detach-callback callback))
2095 (defun menu-attach-to-widget (menu widget function)
2096 (setf (user-data menu 'detach-func) function)
2097 (%menu-attach-to-widget menu widget))
2099 (defbinding menu-detach () nil
2102 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2103 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2106 (defbinding menu-set-monitor () nil
2113 (defbinding table-resize () nil
2116 (columns unsigned-int))
2118 (defbinding table-attach (table child left right top bottom
2119 &key options x-options y-options
2120 (x-padding 0) (y-padding 0)) nil
2124 (right unsigned-int)
2126 (bottom unsigned-int)
2127 ((append (mklist options) (mklist x-options)) attach-options)
2128 ((append (mklist options) (mklist y-options)) attach-options)
2129 (x-padding unsigned-int)
2130 (y-padding unsigned-int))
2133 (defbinding %table-set-row-spacing () nil
2136 (spacing unsigned-int))
2138 (defbinding %table-set-row-spacings () nil
2140 (spacing unsigned-int))
2142 (defun (setf table-row-spacing) (spacing table &optional row)
2144 (%table-set-row-spacing table row spacing)
2145 (%table-set-row-spacings table spacing))
2148 (defbinding %table-get-row-spacing () unsigned-int
2152 (defbinding %table-get-default-row-spacing () unsigned-int
2155 (defun table-row-spacing (table &optional row)
2157 (%table-get-row-spacing table row)
2158 (%table-get-default-row-spacing table)))
2161 (defbinding %table-set-col-spacing () nil
2164 (spacing unsigned-int))
2166 (defbinding %table-set-col-spacings () nil
2168 (spacing unsigned-int))
2170 (defun (setf table-column-spacing) (spacing table &optional column)
2172 (%table-set-col-spacing table column spacing)
2173 (%table-set-col-spacings table spacing))
2176 (defun (setf table-col-spacing) (spacing table &optional col)
2177 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2178 (setf (table-column-spacing table col) spacing))
2180 (defbinding %table-get-col-spacing () unsigned-int
2184 (defbinding %table-get-default-col-spacing () unsigned-int
2187 (defun table-column-spacing (table &optional column)
2189 (%table-get-col-spacing table column)
2190 (%table-get-default-col-spacing table)))
2192 (defun table-col-spacing (table &optional col)
2193 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2194 (table-column-spacing table col))
2200 (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2202 (apply #'call-next-method toolbar
2203 :tooltips (make-instance 'tooltips) initargs)
2204 (call-next-method)))
2206 (defbinding %toolbar-insert () nil
2208 (tool-item tool-item)
2209 (position position))
2211 (defun toolbar-insert (toolbar tool-item &optional (position :end))
2212 (%toolbar-insert toolbar tool-item position)
2213 (%tool-item-update-tooltips tool-item))
2215 (defbinding toolbar-get-item-index () int
2219 (defbinding toolbar-get-nth-item () tool-item
2223 (defbinding toolbar-get-drop-index () int
2227 (defbinding toolbar-set-drop-highlight-item () nil
2229 (tool-item tool-item)
2235 (defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2236 (if (and icon (not (typep icon 'widget)))
2237 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2238 (call-next-method)))
2243 (defbinding tool-item-set-tooltip () nil
2244 (tool-item tool-item)
2247 (tip-private string))
2250 (defun %tool-item-update-tooltips (tool-item)
2252 (slot-boundp tool-item 'parent)
2254 (user-data-p tool-item 'tip-text)
2255 (user-data-p tool-item 'tip-private)))
2256 (tool-item-set-tooltip
2257 tool-item (toolbar-tooltips (widget-parent tool-item))
2258 (or (user-data tool-item 'tip-text) "")
2259 (or (user-data tool-item 'tip-private) ""))))
2261 (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2262 (setf (user-data tool-item 'tip-text) tip-text)
2263 (%tool-item-update-tooltips tool-item)
2266 (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2267 (setf (user-data tool-item 'tip-private) tip-private)
2268 (%tool-item-update-tooltips tool-item)
2271 (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2272 (declare (ignore args))
2275 (%tool-item-update-tooltips tool-item)))
2278 (defbinding tool-item-retrieve-proxy-menu-item () widget
2279 (tool-item tool-item))
2281 (defbinding (tool-item-proxy-menu-item
2282 "gtk_tool_item_get_proxy_menu_item") () menu-item
2283 (tool-item tool-item)
2284 (menu-item-id string))
2286 (defbinding %tool-item-set-proxy-menu-item () nil
2287 (tool-item tool-item)
2288 (menu-item-id string)
2289 (menu-item menu-item))
2291 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2292 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2295 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2296 (defbinding tool-item-rebuild-menu () nil
2297 (tool-item tool-item))
2302 (defbinding editable-select-region (editable &optional (start 0) end) nil
2307 (defbinding editable-get-selection-bounds (editable) nil
2312 (defbinding editable-insert-text (editable text &optional (position 0)) nil
2316 (position position :in/out))
2318 (defun editable-append-text (editable text)
2319 (editable-insert-text editable text nil))
2321 (defun editable-prepend-text (editable text)
2322 (editable-insert-text editable text 0))
2324 (defbinding editable-delete-text (editable &optional (start 0) end) nil
2329 (defbinding (editable-text "gtk_editable_get_chars")
2330 (editable &optional (start 0) end) string
2335 (defun (setf editable-text) (text editable)
2337 (editable-delete-text
2339 (editable-insert-text editable text))
2340 (editable-delete-text editable))
2343 (defbinding editable-cut-clipboard () nil
2344 (editable editable))
2346 (defbinding editable-copy-clipboard () nil
2347 (editable editable))
2349 (defbinding editable-paste-clipboard () nil
2350 (editable editable))
2352 (defbinding editable-delete-selection () nil
2353 (editable editable))
2359 (defbinding spin-button-configure () nil
2360 (spin-button spin-button)
2361 (adjustment adjustment)
2362 (climb-rate double-float)
2363 (digits unsigned-int))
2365 (defbinding spin-button-set-range () nil
2366 (spin-button spin-button)
2370 (defbinding spin-button-get-range () nil
2371 (spin-button spin-button)
2372 (min double-float :out)
2373 (max double-float :out))
2375 (defun spin-button-value-as-int (spin-button)
2376 (round (spin-button-value spin-button)))
2378 (defbinding %spin-button-spin () nil
2379 (spin-button spin-button)
2380 (direction spin-type)
2381 (increment double-float))
2383 (defun spin-button-spin (spin-button value)
2385 (real (%spin-button-spin spin-button :spin-user-defined value))
2386 (spin-type (%spin-button-spin spin-button value 0))))
2389 (defbinding spin-button-update () nil
2390 (spin-button spin-button))
2396 (defbinding ruler-set-range () nil
2398 (lower single-float)
2399 (upper single-float)
2400 (position single-float)
2401 (max-size single-float))
2403 (defbinding ruler-get-range () nil
2405 (lower single-float :out)
2406 (upper single-float :out)
2407 (position single-float :out)
2408 (max-size single-float :out))
2414 (defun range-lower (range)
2415 (adjustment-lower (range-adjustment range)))
2417 (defun range-upper (range)
2418 (adjustment-upper (range-adjustment range)))
2420 (defun (setf range-lower) (value range)
2421 (setf (adjustment-lower (range-adjustment range)) value))
2423 (defun (setf range-upper) (value range)
2424 (setf (adjustment-upper (range-adjustment range)) value))
2426 (defun range-page-increment (range)
2427 (adjustment-page-increment (range-adjustment range)))
2429 (defun range-step-increment (range)
2430 (adjustment-step-increment (range-adjustment range)))
2432 (defun (setf range-page-increment) (value range)
2433 (setf (adjustment-page-increment (range-adjustment range)) value))
2435 (defun (setf range-step-increment) (value range)
2436 (setf (adjustment-step-increment (range-adjustment range)) value))
2438 (defbinding range-set-range () nil
2440 (lower double-float)
2441 (upper double-float))
2443 (defbinding range-set-increments () nil
2446 (page double-float))
2451 (defbinding scale-get-layout-offsets () nil
2459 (defbinding progress-bar-pulse () nil
2460 (progress-bar progress-bar))
2465 (defmethod initialize-instance ((size-group size-group) &rest initargs
2466 &key widget widgets)
2467 (declare (ignore widget widgets))
2470 (initial-add size-group #'size-group-add-widget
2471 initargs :widget :widgets)))
2474 (defbinding size-group-add-widget () nil
2475 (size-group size-group)
2478 (defbinding size-group-remove-widget () nil
2479 (size-group size-group)
2485 (defbinding %stock-item-copy () pointer
2488 (defbinding %stock-item-free () nil
2491 (defbinding stock-add (stock-item) nil
2492 (stock-item stock-item)
2495 (defbinding stock-list-ids () (gslist string))
2497 (defbinding %stock-lookup () boolean
2501 (defun stock-lookup (stock-id)
2502 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
2503 (when (%stock-lookup stock-id stock-item)
2504 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
2506 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
2508 (define-callback-marshal %stock-translate-callback string ((path string)))
2510 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2511 (domain function) nil
2513 (%stock-translate-callback callback)
2514 ((register-callback-function function) unsigned-int)
2515 (user-data-destroy-callback callback)))
2520 ;; #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2522 ;; (defbinding %tooltip-set-markup () nil
2526 ;; (defbinding %tooltip-set-text () nil
2530 ;; (defbinding %tooltip-set-icon () nil
2532 ;; (icon gdk:pixbuf))
2534 ;; (defbinding %tooltip-set-from-stock-icon () nil
2536 ;; (stock-id string)
2539 ;; (defbinding %tooltip-set-custom () nil
2543 ;; (defun tooltip-set (tooltip value &key (markup t) (icon-size :button))
2545 ;; (string (if markup
2546 ;; (tooltip-set-markup tooltip value)
2547 ;; (tooltip-set-text tooltip value)))
2548 ;; (pixbuf (tooltip-set-icon tooltip value))
2549 ;; (keyword (tooltip-set-icon-from-stock tooltip value icon-size))
2555 ;; GtkTooltips has been deprecated in favor of the new tooltip API
2556 ;; introduced in in GTK+ 2.12
2558 (defbinding tooltips-enable () nil
2559 (tooltips tooltips))
2561 (defbinding tooltips-disable () nil
2562 (tooltips tooltips))
2564 (defun (setf tooltips-enabled-p) (enable tooltips)
2566 (tooltips-enable tooltips)
2567 (tooltips-disable tooltips)))
2569 (defbinding tooltips-set-tip () nil
2573 (tip-private string))
2575 (defbinding tooltips-data-get () tooltips-data
2578 (defbinding tooltips-force-window () nil
2579 (tooltips tooltips))
2581 (defbinding tooltips-get-info-from-tip-window () boolean
2583 (tooltips tooltips :out)
2584 (current-widget widget :out))
2589 (defbinding rc-get-style () style
2592 (defbinding rc-get-style-by-paths (&key path class-path class) style
2593 (path (or null string))
2594 (class-path (or null string))
2597 (defbinding rc-parse () nil
2598 (filename pathname))
2600 (defbinding rc-parse-string () nil
2603 (defbinding %rc-reparse-all () boolean)
2605 (defbinding %rc-reparse-all-for-settings () boolean
2607 (force-load-p boolean))
2609 (defun rc-reparse-all (&optional setting force-load-p)
2611 (%rc-reparse-all-for-settings setting force-load-p)
2614 (defbinding rc-reset-styles () nil
2615 (settings settings))
2617 (defbinding rc-add-default-file () nil
2618 (filename pathname))
2620 (defbinding rc-get-default-files ()
2621 (copy-of (null-terminated-vector (copy-of string))))
2623 (defbinding rc-get-module-dir () string)
2625 (defbinding rc-get-im-module-path () string)
2627 (defbinding rc-get-im-module-file () string)
2629 (defbinding rc-get-theme-dir () string)
2634 (defbinding (settings-get "gtk_settings_get_for_screen")
2635 (&optional (screen (gdk:display-get-default-screen))) settings
2636 (screen gdk:screen))
2641 (defbinding socket-add-id () nil
2643 (id gdk:native-window))
2645 (defbinding %plug-new () pointer
2646 (id gdk:native-window))
2648 (defmethod allocate-foreign ((plug plug) &key id)
2649 (%plug-new (or id 0)))
2654 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2656 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2658 (defbinding link-button-set-uri-hook (function) pointer
2659 (%link-button-uri-callback callback)
2660 ((register-callback-function function) unsigned-int)
2661 (user-data-destroy-callback callback)))
2666 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2668 (defmethod initialize-instance ((builder builder) &key interface
2669 (connect-signals t) (package *package*))
2671 (etypecase interface
2673 (string (builder-add-from-string builder interface))
2674 (pathname (builder-add-from-file builder interface)))
2675 (when connect-signals
2676 (builder-connect-signals builder package)))
2679 (defbinding builder-add-from-file () boolean
2682 (nil gerror-signal :out))
2684 (defbinding builder-add-from-string () boolean
2687 (-1 int) ; TODO: add gsize type
2688 (nil gerror-signal :out))
2690 (defbinding builder-get-object () gobject
2694 (defbinding builder-get-objects () (gslist gobject)
2697 (defun intern-with-package-prefix (name default-package)
2698 (let ((pos (position #\: name)))
2701 (string-upcase (subseq name (1+ pos)))
2702 (string-upcase (subseq name 0 pos)))
2703 (intern (string-upcase name) default-package))))
2705 (define-callback %builder-connect-function nil
2706 (builder (object gobject) (signal-name string) (handler-name string)
2707 (connect-object gobject) connect-flags (package user-data-id))
2708 (format t "Connect signal ~A for ~A to ~A in default package ~A with flags ~A~%" signal-name object handler-name (find-user-data package) connect-flags)
2711 (intern-with-package-prefix handler-name (find-user-data package))
2712 :object (or connect-object object) :after (find :after connect-flags)))
2714 (defbinding %builder-connect-signals-full (builder package) nil
2716 (%builder-connect-function callback)
2717 (package user-data-id))
2719 (defun builder-connect-signals (builder &optional (package *package*))
2720 (with-user-data (id package)
2721 (%builder-connect-signals-full builder id))))