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.95 2008/10/08 18:18:52 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-polling-interval* 0.01)
55 #?(or (featurep :clisp) (featurep :cmu) (and (sbcl>= 1 0 6) (sbcl< 1 0 15 6)))
56 (defun decompose-time (time)
57 (multiple-value-bind (sec subsec) (truncate *event-polling-interval*)
58 (values sec (truncate (* subsec 1e6)))))
60 (defbinding (gtk-init "gtk_parse_args") () boolean
61 "Initializes the library without opening the display."
65 (defun clg-init (&optional display multi-threading-p)
66 "Initializes the system and starts event handling."
67 (unless (gdk:display-get-default)
68 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
70 #+sbcl(sb-int:set-floating-point-modes :traps nil)
71 #+cmu(ext:set-floating-point-modes :traps nil))
75 (error "Initialization of GTK+ failed."))
77 (if (not multi-threading-p)
78 (%init-async-event-handling display)
79 #+sb-thread(%init-multi-threaded-event-handling display)
80 #-sb-thread(error "Multi threading not supported on this platform")))
81 (gdk:ensure-display display t))
83 (defun clg-init-with-threading (&optional display)
87 #?(and (sbcl>= 1 0 6) (sbcl< 1 0 15 6))
88 ;; A very minimal implementation of CLISP's socket-status
89 (defun socket-status (socket seconds microseconds)
90 (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set)))
91 (let ((fd (sb-sys:fd-stream-fd (car socket))))
92 (sb-unix:fd-zero read-fds)
93 (sb-unix:fd-set fd read-fds)
95 (let ((num-fds-changed
96 (sb-unix:unix-fast-select
97 (1+ fd) (sb-alien:addr read-fds) nil nil
98 seconds microseconds)))
99 (unless (or (not num-fds-changed) (zerop num-fds-changed))
100 (if (peek-char nil (car socket) nil)
104 (defun %init-async-event-handling (display)
106 #?(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6)) :fd-handler
107 #?-(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6)) nil))
109 (find-package "SWANK")
110 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style)))
111 (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/Communication-style.html> for more information." style)))
113 #?(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6))
115 (signal-connect (gdk:display-manager) 'display-opened
117 (let ((fd (gdk:display-connection-number display)))
119 (let ((handler (add-fd-handler
120 (gdk:display-connection-number display)
121 :input #'main-iterate-all)))
122 (signal-connect display 'closed
123 #'(lambda (is-error-p)
124 (declare (ignore is-error-p))
125 (remove-fd-handler handler))))))))
126 (setq *periodic-polling-function* #'main-iterate-all)
127 #?(or (featurep :cmu) (sbcl< 1 0 6))
128 (multiple-value-setq (*max-event-to-sec* *max-event-to-usec*)
129 (decompose-time *event-polling-interval*))
131 (setq *periodic-polling-period* *event-polling-interval*))
133 #+(and clisp readline)
134 ;; Readline will call the event hook at most ten times per second
135 (setf readline:event-hook #'main-iterate-all)
137 #?(or (featurep :clisp) (and (sbcl>= 1 0 6) (sbcl< 1 0 15 6)))
138 ;; When running in Slime we need to hook into the Swank server
139 ;; to handle events asynchronously.
141 (find-package "SWANK")
142 (let ((connection (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK"))))
144 (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")))
145 (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") connection)))
146 (multiple-value-bind (sec usec)
147 (decompose-time *event-polling-interval*)
149 (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))
152 (case (socket-status (cons stream :input) sec usec)
153 ((:input :eof) (return (funcall read-from-emacs)))
154 (otherwise (main-iterate-all)))))))))))
155 #-(and clisp readline)
156 (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started."))
158 (gdk:display-open display))
162 (defvar *main-thread* nil)
164 ;; Hopefully, when threading support is added to the Win32 port of
165 ;; SBCL in the future, this will work just out of the box.
167 (let ((done (sb-thread:make-waitqueue))
171 ;; In Win32 all GDK calls have to be made from the main loop
172 ;; thread, so we add a timeout function which will poll for code and
175 (defun funcall-in-main (function)
178 (eq sb-thread:*current-thread* *main-thread*))
180 (gdk:with-global-lock
181 (push function functions)
182 (sb-thread:condition-wait done gdk:*global-lock*)
185 ;; Will lock REPL on error, need to be fixed!
186 (defun %funcall-in-main-poll ()
191 do (push (funcall (pop functions)) results)
192 finally (sb-thread:condition-notify done n)))
195 (defmacro within-main-loop (&body body)
196 #-win32 `(gdk:with-global-lock ,@body)
197 #+win32 `(funcall-in-main #'(lambda () ,@body)))
199 (defun %init-multi-threaded-event-handling (display)
201 (find-package "SWANK")
202 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn)))
203 (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."))
205 (let ((main-running (sb-thread:make-waitqueue)))
206 (gdk:with-global-lock
208 (sb-thread:make-thread
210 (gdk:with-global-lock
211 (gdk:display-open display)
212 #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000)
213 #'%funcall-in-main-poll)
214 (sb-thread:condition-notify main-running)
216 :name "gtk event loop"))
217 (sb-thread:condition-wait main-running gdk:*global-lock*)))
219 ;; We need to hook into the Swank server to protect calls to GDK properly.
220 ;; This will *only* protect code entered directly in the REPL.
221 (when (find-package "SWANK")
222 (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
224 (push #'(lambda (form)
225 (within-main-loop (eval form)))
226 (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
227 (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"))))))
230 (defmacro within-main-loop (&body body)
235 ;;; Generic functions
237 (defgeneric add-to-radio-group (item1 item2))
238 (defgeneric activate-radio-widget (item))
239 (defgeneric (setf tool-item-tip-text) (tip-text tool-item))
240 (defgeneric (setf tool-item-tip-private) (tip-private tool-item))
246 (defbinding grab-add () nil
249 (defbinding grab-get-current () widget)
251 (defbinding grab-remove () nil
254 (defbinding get-default-language () (copy-of pango:language))
259 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
261 (define-callback-marshal %about-dialog-activate-link-callback nil
262 (about-dialog (link string)))
264 (defbinding about-dialog-set-email-hook (function) nil
265 (%about-dialog-activate-link-callback callback)
266 ((register-callback-function function) unsigned-int)
267 (user-data-destroy-callback callback))
269 (defbinding about-dialog-set-url-hook (function) nil
270 (%about-dialog-activate-link-callback callback)
271 ((register-callback-function function) unsigned-int)
272 (user-data-destroy-callback callback)))
277 (defbinding %accel-group-connect () nil
278 (accel-group accel-group)
280 (modifiers gdk:modifier-type)
284 (defun accel-group-connect (group accelerator function &optional flags)
285 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
286 (let ((gclosure (make-callback-closure function)))
287 (%accel-group-connect group key modifiers flags gclosure)
290 (defbinding accel-group-connect-by-path (group path function) nil
293 ((make-callback-closure function) gclosure :in/return))
295 (defbinding %accel-group-disconnect (group gclosure) boolean
299 (defbinding %accel-group-disconnect-key () boolean
302 (modifiers gdk:modifier-type))
304 (defun accel-group-disconnect (group accelerator)
305 (etypecase accelerator
306 (gclosure (%accel-group-disconnect group accelerator))
308 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
309 (%accel-group-disconnect-key group key modifiers)))))
311 (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
312 (accel-group accel-group)
314 (modifiers gdk:modifier-type)
317 (defun accel-group-query (accel-group accelerator)
318 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
319 (%accel-group-query accel-group key modifiers)))
321 (defbinding %accel-group-activate () boolean
322 (accel-group accel-group)
323 (acceleratable gobject)
325 (modifiers gdk:modifier-type))
327 (defun accel-group-activate (accel-group acceleratable accelerator)
328 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
329 (%accel-group-activate accel-group acceleratable key modifiers)))
331 (defbinding accel-group-lock () nil
332 (accel-group accel-group))
334 (defbinding accel-group-unlock () nil
335 (accel-group accel-group))
337 (defbinding accel-group-from-accel-closure () accel-group
340 (defbinding %accel-groups-activate () boolean
343 (modifiers gdk:modifier-type))
345 (defun accel-groups-activate (object accelerator)
346 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
347 (%accel-groups-activate object key modifiers)))
349 (defbinding accel-groups-from-object () (gslist accel-group)
352 (defbinding accelerator-valid-p (key &optional modifiers) boolean
354 (modifiers gdk:modifier-type))
356 (defbinding %accelerator-parse () nil
358 (key unsigned-int :out)
359 (modifiers gdk:modifier-type :out))
361 (defgeneric parse-accelerator (accelerator))
363 (defmethod parse-accelerator ((accelerator string))
364 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
366 (error "Invalid accelerator: ~A" accelerator)
367 (values key modifiers))))
369 (defmethod parse-accelerator ((accelerator cons))
370 (destructuring-bind (key modifiers) accelerator
376 (gdk:keyval-from-name key)
377 (error "Invalid key name: ~A" key)))
378 (character (parse-accelerator key)))
381 (defmethod parse-accelerator ((key integer))
384 (defmethod parse-accelerator ((key character))
386 (gdk:keyval-from-name (string key))
387 (error "Invalid key name: ~A" key)))
390 (defbinding accelerator-name () string
392 (modifiers gdk:modifier-type))
394 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
395 (defbinding accelerator-get-label () string
397 (modifiers gdk:modifier-type))
399 (defbinding %accelerator-set-default-mod-mask () nil
400 (default-modifiers gdk:modifier-type))
402 (defun (setf accelerator-default-modifier-mask) (default-modifiers)
403 (%accelerator-set-default-mod-mask default-modifiers))
405 (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
410 (defbinding accel-label-get-accel-width () unsigned-int
411 (accel-label accel-label))
413 (defbinding accel-label-refetch () boolean
414 (accel-label accel-label))
420 (defbinding %accel-map-add-entry () nil
423 (modifiers gdk:modifier-type))
425 (defun accel-map-add-entry (path accelerator)
426 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
427 (%accel-map-add-entry path key modifiers)))
429 (defbinding %accel-map-lookup-entry () boolean
431 ((make-instance 'accel-key) accel-key :in/return))
433 (defun accel-map-lookup-entry (path)
434 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
437 (slot-value accel-key 'key)
438 (slot-value accel-key 'modifiers)
439 (slot-value accel-key 'flags)))))
441 (defbinding %accel-map-change-entry () boolean
444 (modifiers gdk:modifier-type)
447 (defun accel-map-change-entry (path accelerator &optional replace)
448 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
449 (%accel-map-change-entry path key modifiers replace)))
451 (defbinding accel-map-load () nil
454 (defbinding accel-map-save () nil
457 (define-callback-marshal %accel-map-foreach-callback nil
458 ((accel-path string) (key unsigned-int)
459 (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first)
461 (defbinding %accel-map-foreach (callback-id) nil
462 (callback-id unsigned-int)
463 (%accel-map-foreach-callback callback))
465 (defbinding %accel-map-foreach-unfiltered (callback-id) nil
466 (callback-id unsigned-int)
467 (%accel-map-foreach-callback callback))
469 (defun accel-map-foreach (function &optional (filter-p t))
470 (with-callback-function (id function)
472 (%accel-map-foreach id)
473 (%accel-map-foreach-unfiltered id))))
475 (defbinding accel-map-add-filter () nil
478 (defbinding accel-map-get () accel-map)
480 (defbinding accel-map-lock-path () nil
483 (defbinding accel-map-unlock-path () nil
490 (defbinding accessible-connect-widget-destroyed () nil
491 (accessible accessible))
496 (defmethod initialize-instance ((adjustment adjustment) &key value)
499 ;; we need to make sure that the value is set last, otherwise it
500 ;; may be outside current limits and ignored
502 (setf (slot-value adjustment 'value) value))))
505 (defbinding adjustment-changed () nil
506 (adjustment adjustment))
508 (defbinding adjustment-value-changed () nil
509 (adjustment adjustment))
511 (defbinding adjustment-clamp-page () nil
512 (adjustment adjustment)
514 (upper single-float))
519 (defbinding alignment-set () nil
520 (alognment alignment)
521 (x-align single-float)
522 (y-align single-float)
523 (x-scale single-float)
524 (y-scale single-float))
526 (defbinding alignment-get-padding () nil
527 (alognment alignment)
528 (top unsigned-int :out)
529 (bottom unsigned-int :out)
530 (left unsigned-int :out)
531 (right unsigned-int :out))
533 (defbinding alignment-set-padding () nil
534 (alognment alignment)
536 (bottom unsigned-int)
538 (right unsigned-int))
543 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
545 (defbinding assistant-get-nth-page () widget
546 (assistant assistant)
549 (defbinding %assistant-insert-page () int
550 (assistant assistant)
554 (defun assistant-insert-page (assistant page position &rest child-args)
555 (let ((pos (case position
560 (%assistant-insert-page assistant page pos)
561 (init-child-slots assistant page child-args))))
563 (defun assistant-append-page (assistant page &rest child-args)
564 (apply #'assistant-insert-page assistant page :last child-args))
566 (defun assistant-prepend-page (assistant page &rest child-args)
567 (apply #'assistant-insert-page assistant page :first child-args))
569 (define-callback-marshal %assistant-page-func-callback int
570 ((current-page int)))
572 (defbinding assistant-set-forward-page-func (assistant function) nil
573 (assistant assistant)
574 (%assistant-page-func-callback callback)
575 ((register-callback-function function) pointer-data)
576 (user-data-destroy-callback callback))
578 (defbinding assistant-add-action-widget () nil
579 (assistant assistant)
582 (defbinding assistant-remove-action-widget () nil
583 (assistant assistant)
586 (defbinding assistant-update-buttons-state () nil
587 (assistant assistant)))
596 (defun (setf bin-child) (child bin)
597 (when-bind (current-child (bin-child bin))
598 (container-remove bin current-child))
599 (container-add bin child)
602 (defmethod compute-signal-function ((bin bin) signal function object args)
603 (declare (ignore signal))
604 (if (eq object :child)
605 #'(lambda (bin &rest emission-args)
606 (apply function (bin-child bin) (nconc emission-args args)))
612 (defbinding box-pack-start () nil
617 (padding unsigned-int))
619 (defbinding box-pack-end () nil
624 (padding unsigned-int))
626 (defun box-pack (box child &key end (expand t) (fill t) (padding 0))
628 (box-pack-end box child expand fill padding)
629 (box-pack-start box child expand fill padding)))
631 (defbinding box-reorder-child () nil
636 (defbinding box-query-child-packing () nil
639 (expand boolean :out)
641 (padding unsigned-int :out)
642 (pack-type pack-type :out))
644 (defbinding box-set-child-packing () nil
649 (padding unsigned-int)
650 (pack-type pack-type))
656 (defmethod initialize-instance ((button button) &rest initargs &key stock)
658 (apply #'call-next-method button
659 :label stock :use-stock t :use-underline t initargs)
663 (defbinding button-pressed () nil
666 (defbinding button-released () nil
669 (defbinding button-clicked () nil
672 (defbinding button-enter () nil
675 (defbinding button-leave () nil
682 (defbinding calendar-select-month () int
687 (defbinding calendar-select-day () nil
691 (defbinding calendar-mark-day () int
695 (defbinding calendar-unmark-day () int
699 (defbinding calendar-clear-marks () nil
702 (defbinding calendar-get-date () nil
704 (year unsigned-int :out)
705 (month unsigned-int :out)
706 (day unsigned-int :out))
708 (defbinding calendar-freeze () nil
711 (defbinding calendar-thaw () nil
717 (defbinding check-menu-item-toggled () nil
718 (check-menu-item check-menu-item))
723 (defbinding color-selection-is-adjusting-p () boolean
724 (colorsel color-selection))
726 (defbinding (color-selection-previous-color
727 "gtk_color_selection_get_previous_color") () nil
728 (colorsel color-selection)
729 ((make-instance 'gdk:color) gdk:color :in/return))
732 ;;; Color selection dialog -- no functions
738 (defmethod initialize-instance ((combo-box combo-box) &rest initargs
739 &key model content active)
740 (remf initargs :active)
742 (apply #'call-next-method combo-box initargs)
744 (apply #'call-next-method combo-box
745 :model (make-instance 'list-store :column-types '(string))
747 (unless (typep combo-box 'combo-box-entry)
748 (let ((cell (make-instance 'cell-renderer-text)))
749 (cell-layout-pack combo-box cell :expand t)
750 (cell-layout-add-attribute combo-box cell :text 0)))))
752 (mapc #'(lambda (text)
753 (combo-box-append-text combo-box text))
756 (setf (combo-box-active combo-box) active)))
759 ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
761 ;; (signal-emit combo-box 'changed)))
763 (defbinding combo-box-append-text () nil
764 (combo-box combo-box)
767 (defbinding combo-box-insert-text () nil
768 (combo-box combo-box)
772 (defbinding combo-box-prepend-text () nil
773 (combo-box combo-box)
776 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
777 (defbinding combo-box-get-active-text () string
778 (combo-box combo-box))
780 (defbinding combo-box-popup () nil
781 (combo-box combo-box))
783 (defbinding combo-box-popdown () nil
784 (combo-box combo-box))
790 (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
793 (setf (combo-box-entry-text-column combo-box-entry) 0)))
798 (defmethod shared-initialize ((dialog dialog) names &rest initargs
800 (declare (ignore names button buttons))
803 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
806 (defun dialog-response-id (dialog response &optional create-p error-p)
807 "Returns a numeric response id"
808 (if (typep response 'response-type)
809 (response-type-to-int response)
810 (let ((responses (user-data dialog 'responses)))
812 ((and responses (position response responses :test #'equal)))
816 (vector-push-extend response responses)
817 (1- (length responses)))
820 (user-data dialog 'responses)
821 (make-array 1 :adjustable t :fill-pointer t
822 :initial-element response))
825 (error "Invalid response: ~A" response))))))
827 (defun dialog-find-response (dialog id)
828 "Finds a symbolic response given a numeric id"
830 ((not (numberp id)) id)
831 ((< id 0) (int-to-response-type id))
832 ((aref (user-data dialog 'responses) id))))
835 (defmethod compute-signal-id ((dialog dialog) signal)
836 (if (dialog-response-id dialog signal)
837 (ensure-signal-id 'response dialog)
840 (defmethod compute-signal-function ((dialog dialog) signal function object args)
841 (declare (ignore function object args))
842 (let ((callback (call-next-method))
843 (id (dialog-response-id dialog signal)))
846 #'(lambda (dialog response)
847 (when (= response id)
848 (funcall callback dialog))))
849 ((string-equal signal "response")
850 #'(lambda (dialog response)
851 (funcall callback dialog (dialog-find-response dialog response))))
854 (defbinding dialog-run () nil
857 (defbinding dialog-response (dialog response) nil
859 ((dialog-response-id dialog response nil t) int))
862 (defbinding %dialog-add-button () button
867 (defun dialog-add-button (dialog label &optional (response label)
868 &key default object after)
869 "Adds a button to the dialog."
870 (let* ((signal (if (functionp response)
873 (id (dialog-response-id dialog signal t))
874 (button (%dialog-add-button dialog label id)))
875 (when (functionp response)
876 (signal-connect dialog signal response :object object :after after))
878 (%dialog-set-default-response dialog id))
882 (defbinding %dialog-add-action-widget () nil
884 (action-widget widget)
887 (defun dialog-add-action-widget (dialog widget &optional (response widget)
888 &key default object after)
889 (let* ((signal (if (functionp response)
892 (id (dialog-response-id dialog signal t)))
893 (unless (widget-hidden-p widget)
894 (widget-show widget))
895 (%dialog-add-action-widget dialog widget id)
896 (when (functionp response)
897 (signal-connect dialog signal response :object object :after after))
899 (setf (widget-can-default-p widget) t)
900 (%dialog-set-default-response dialog id))
904 (defbinding %dialog-set-default-response () nil
908 (defun dialog-set-default-response (dialog response)
909 (%dialog-set-default-response
910 dialog (dialog-response-id dialog response nil t)))
912 (defbinding dialog-set-response-sensitive (dialog response sensitive) nil
914 ((dialog-response-id dialog response nil t) int)
917 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
918 (defbinding alternative-dialog-button-order-p (&optional screen) boolean
919 (screen (or null gdk:screen)))
921 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
922 (defbinding (dialog-set-alternative-button-order
923 "gtk_dialog_set_alternative_button_order_from_array")
924 (dialog new-order) nil
926 ((length new-order) int)
927 ((map 'vector #'(lambda (response)
928 (dialog-response-id dialog response nil t))
929 new-order) (vector int)))
932 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
934 (defbinding %dialog-get-response-for-widget () int
938 (defun dialog-get-response-for-widget (dialog widget)
939 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
942 (defmethod container-add ((dialog dialog) (child widget) &rest args)
943 (apply #'container-add (dialog-vbox dialog) child args))
946 (defmethod container-remove ((dialog dialog) (child widget))
947 (container-remove (dialog-vbox dialog) child))
949 (defmethod container-children ((dialog dialog))
950 (container-children (dialog-vbox dialog)))
952 (defmethod (setf container-children) (children (dialog dialog))
953 (setf (container-children (dialog-vbox dialog)) children))
958 (defun drawing-area-scroll (drawing-area dx dy)
959 (gdk:window-scroll (widget-window drawing-area) dx dy))
964 (defbinding entry-get-layout-offsets () nil
969 (defbinding entry-layout-index-to-text-index () int
973 (defbinding entry-text-index-to-layout-index () int
980 (define-callback-marshal %entry-completion-match-callback boolean
981 (entry-completion string tree-iter))
983 (defbinding entry-completion-set-match-func (completion function) nil
984 (completion entry-completion)
985 (%entry-completion-match-callback callback)
986 ((register-callback-function function) unsigned-int)
987 (user-data-destroy-callback callback))
989 (defbinding entry-completion-complete () nil
990 (completion entry-completion))
992 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
993 (defbinding entry-completion-get-completion-prefix () string
994 (completion entry-completion))
996 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
997 (defbinding entry-completion-insert-prefix () nil
998 (completion entry-completion))
1000 (defbinding entry-completion-insert-action-text () nil
1001 (completion entry-completion)
1005 (defbinding entry-completion-insert-action-markup () nil
1006 (completion entry-completion)
1010 (defbinding entry-completion-delete-action () nil
1011 (completion entry-completion)
1017 (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
1018 &key filter filters shortcut-folder
1019 shortcut-folders shortcut-folder-uti
1020 shortcut-folder-uris)
1021 (declare (ignore filter filters shortcut-folder shortcut-folders
1022 shortcut-folder-uti shortcut-folder-uris))
1025 (initial-add file-chooser #'file-chooser-add-filter
1026 initargs :filer :filters)
1027 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1028 initargs :shortcut-folder :shortcut-folders)
1029 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1030 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1033 (defbinding file-chooser-select-filename () boolean
1034 (file-chooser file-chooser)
1037 (defbinding file-chooser-unselect-filename () nil
1038 (file-chooser file-chooser)
1041 (defbinding file-chooser-select-all () boolean
1042 (file-chooser file-chooser))
1044 (defbinding file-chooser-unselect-all () boolean
1045 (file-chooser file-chooser))
1047 (defbinding file-chooser-get-filenames () (gslist string)
1048 (file-chooser file-chooser))
1050 (defbinding file-chooser-select-uri () boolean
1051 (file-chooser file-chooser)
1054 (defbinding file-chooser-unselect-uri () nil
1055 (file-chooser file-chooser)
1058 (defbinding file-chooser-get-uris () (gslist string)
1059 (file-chooser file-chooser))
1061 (defbinding file-chooser-add-filter () nil
1062 (file-chooser file-chooser)
1063 (filter file-filter))
1065 (defbinding file-chooser-remove-filter () nil
1066 (file-chooser file-chooser)
1067 (filter file-filter))
1069 (defbinding file-chooser-list-filters () (gslist file-filter)
1070 (file-chooser file-chooser))
1072 (defbinding file-chooser-add-shortcut-folder () boolean
1073 (file-chooser file-chooser)
1077 (defbinding file-chooser-remove-shortcut-folder () nil
1078 (file-chooser file-chooser)
1082 (defbinding file-chooser-list-shortcut-folders () (gslist string)
1083 (file-chooser file-chooser))
1085 (defbinding file-chooser-add-shortcut-folder-uri () boolean
1086 (file-chooser file-chooser)
1090 (defbinding file-chooser-remove-shortcut-folder-uri () nil
1091 (file-chooser file-chooser)
1095 (defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1096 (file-chooser file-chooser))
1101 (defmethod initialize-instance ((file-filter file-filter) &rest initargs
1102 &key mime-type mime-types pattern patterns
1104 (declare (ignore mime-type mime-types pattern patterns))
1107 (when pixbuf-formats
1108 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1109 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1110 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1111 (file-filter-add-pixbuf-formats file-filter))
1112 (initial-add file-filter #'file-filter-add-mime-type
1113 initargs :mime-type :mime-types)
1114 (initial-add file-filter #'file-filter-add-pattern
1115 initargs :pattern :patterns)))
1118 (defbinding file-filter-add-mime-type () nil
1119 (filter file-filter)
1122 (defbinding file-filter-add-pattern () nil
1123 (filter file-filter)
1126 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1127 (defbinding file-filter-add-pixbuf-formats () nil
1128 (filter file-filter))
1130 (define-callback-marshal %file-filter-callback boolean (file-filter-info))
1132 (defbinding file-filter-add-custom (filter needed function) nil
1133 (filter file-filter)
1134 (needed file-filter-flags)
1135 (%file-filter-callback callback)
1136 ((register-callback-function function) unsigned-int)
1137 (user-data-destroy-callback callback))
1139 (defbinding file-filter-get-needed () file-filter-flags
1140 (filter file-filter))
1142 (defbinding file-filter-filter () boolean
1143 (filter file-filter)
1144 (filter-info file-filter-info))
1150 (defbinding image-set-from-file () nil
1152 (filename pathname))
1154 (defmethod (setf image-pixmap) ((data vector) (image image))
1155 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1156 (setf (image-pixmap image) pixmap)
1157 (setf (image-mask image) mask)))
1159 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1161 ((typep pixmap 'vector)
1162 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1163 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1167 (image-set-from-file image file)))
1168 ((call-next-method))))
1170 (defun create-image-widget (source &optional mask)
1172 (gdk:pixbuf (make-instance 'image :pixbuf source))
1173 (string (make-instance 'image :stock source))
1174 (pathname (make-instance 'image :file source))
1175 ((or list vector) (make-instance 'image :pixmap source))
1176 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1178 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1179 (defbinding image-clear () nil
1186 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1187 (if (and image (not (typep image 'widget)))
1188 (apply #'call-next-method item :image (create-image-widget image) initargs)
1189 (call-next-method)))
1192 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1193 (setf (slot-value item 'image) widget))
1195 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
1196 (setf (image-menu-item-image item) (create-image-widget image)))
1201 (defmethod shared-initialize ((label label) names &key pattern)
1202 (declare (ignore names))
1205 (setf (label-pattern label) pattern)))
1207 (defbinding label-get-layout-offsets () nil
1212 (defbinding label-select-region () nil
1217 (defbinding label-get-selection-bounds () boolean
1226 (defbinding %radio-button-get-group () pointer
1227 (radio-button radio-button))
1229 (defbinding %radio-button-set-group () nil
1230 (radio-button radio-button)
1233 (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
1234 "Add BUTTON1 to the group which BUTTON2 belongs to."
1235 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1237 (defun %add-activate-callback (widget signal function object after)
1239 (signal-connect widget signal
1241 (when (slot-value widget 'active)
1242 (funcall function object (slot-value widget 'value))))
1243 :object object :after after)
1244 (signal-connect widget signal
1246 (when (slot-value widget 'active)
1247 (funcall function (slot-value widget 'value))))
1250 (defmethod activate-radio-widget ((button radio-button))
1251 (signal-emit button 'clicked))
1253 (defgeneric add-activate-callback (action function &key object after))
1255 (defmethod add-activate-callback ((button radio-button) function &key object after)
1256 (%add-activate-callback button 'clicked function object after))
1258 (defmethod initialize-instance ((button radio-button) &key group)
1262 (add-to-radio-group button group))))
1267 (defbinding item-select () nil
1270 (defbinding item-deselect () nil
1273 (defbinding item-toggle () nil
1280 (defmethod initialize-instance ((item menu-item) &key label)
1284 (setf (menu-item-label item) label))))
1287 (defun (setf menu-item-label) (label menu-item)
1288 (make-instance 'accel-label
1289 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
1290 :use-underline (menu-item-use-underline-p menu-item)
1291 :visible t :parent menu-item)
1294 (defun menu-item-label (menu-item)
1295 (when (and (slot-boundp menu-item 'child)
1296 (typep (bin-child menu-item) 'label))
1297 (label-label (bin-child menu-item))))
1299 (defbinding menu-item-remove-submenu () nil
1300 (menu-item menu-item))
1302 (defbinding menu-item-set-accel-path () nil
1303 (menu-item menu-item)
1304 (accel-path string))
1306 (defbinding menu-item-select () nil
1307 (menu-item menu-item))
1309 (defbinding menu-item-deselect () nil
1310 (menu-item menu-item))
1312 (defbinding menu-item-activate () nil
1313 (menu-item menu-item))
1315 (defbinding menu-item-toggle-size-request () nil
1316 (menu-item menu-item)
1317 (requisition int :out))
1319 (defbinding menu-item-toggle-size-allocate () nil
1320 (menu-item menu-item)
1324 ;;; Menu tool button
1326 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1327 (defbinding menu-tool-button-set-arrow-tooltip () nil
1328 (menu-tool-button menu-tool-button)
1331 (tip-private string))
1336 (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1337 button buttons flags transient-parent)
1338 (let ((stock-buttons
1340 ((and (not buttons) (not button))
1344 ((listp buttons) :none)
1346 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1349 (defmethod shared-initialize ((dialog message-dialog) names &rest initargs
1350 &key message-type buttons button text
1351 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1353 (declare (ignore names))
1355 (message-dialog-set-markup dialog text))
1356 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1357 (when secondary-text
1358 (message-dialog-format-secondary-markup dialog secondary-text))
1359 (when (and (not buttons) (not button))
1361 for (key value) on initargs by #'cddr
1362 when (and (eq key :signal) (eq (first value) :close))
1363 do (warn "Default button configuration changed from ~A to ~A" :close
1364 (if (eq message-type :question) :yes-no :ok))
1366 (if (typep buttons 'buttons-type)
1367 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1368 (call-next-method)))
1371 (defbinding %message-dialog-new () pointer
1372 (parent (or null window))
1373 (flags dialog-flags)
1375 (buttons buttons-type)
1378 (defbinding message-dialog-set-markup () nil
1379 (message-dialog message-dialog)
1382 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1383 (defbinding message-dialog-format-secondary-text () nil
1384 (message-dialog message-dialog)
1387 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1388 (defbinding message-dialog-format-secondary-markup () nil
1389 (message-dialog message-dialog)
1396 (defbinding %radio-menu-item-get-group () pointer
1397 (radio-menu-item radio-menu-item))
1399 (defbinding %radio-menu-item-set-group () nil
1400 (radio-menu-item radio-menu-item)
1403 (defmethod activate-radio-widget ((item radio-menu-item))
1404 (menu-item-activate item))
1406 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
1407 "Add ITEM1 to the group which ITEM2 belongs to."
1408 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1410 (defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1411 (%add-activate-callback item 'activate function object after))
1413 (defmethod initialize-instance ((item radio-menu-item) &key group)
1417 (add-to-radio-group item group))))
1421 ;;; Radio tool button
1423 (defbinding %radio-tool-button-get-group () pointer
1424 (radio-tool-button radio-tool-button))
1426 (defbinding %radio-tool-button-set-group () nil
1427 (radio-tool-button radio-tool-button)
1430 (defmethod activate-radio-widget ((button radio-tool-button))
1431 (signal-emit button 'clicked))
1433 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
1434 "Add BUTTON1 to the group which BUTTON2 belongs to."
1435 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
1436 (defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1437 (%add-activate-callback button 'clicked function object after))
1439 (defmethod initialize-instance ((button radio-tool-button) &key group)
1443 (add-to-radio-group button group))))
1449 (defbinding toggle-button-toggled () nil
1450 (toggle-button toggle-button))
1455 (defmethod initialize-instance ((window window) &rest initargs
1456 &key display accel-group accel-groups)
1457 (declare (ignore accel-group accel-groups))
1460 (apply #'call-next-method
1461 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
1463 (initial-add window #'window-add-accel-group
1464 initargs :accel-group :accel-groups)))
1466 #-debug-ref-counting
1467 (defmethod print-object ((window window) stream)
1469 (proxy-valid-p window)
1470 (slot-boundp window 'title)
1471 (not (zerop (length (window-title window)))))
1472 (print-unreadable-object (window stream :type t :identity nil)
1473 (format stream "~S at 0x~X"
1474 (window-title window) (pointer-address (foreign-location window))))
1475 (call-next-method)))
1477 (defbinding window-set-wmclass () nil
1479 (wmclass-name string)
1480 (wmclass-class string))
1482 (defbinding window-add-accel-group () nil
1484 (accel-group accel-group))
1486 (defbinding window-remove-accel-group () nil
1488 (accel-group accel-group))
1490 (defbinding window-activate-focus () int
1493 (defbinding window-activate-default () int
1496 (defbinding window-set-default-size (window width height) int
1499 ((or height -1) int))
1501 (defbinding %window-set-geometry-hints () nil
1503 (widget (or widget null))
1504 (geometry gdk:geometry)
1505 (geometry-mask gdk:window-hints))
1507 (defun window-set-geometry-hints (window &key widget min-width min-height
1508 max-width max-height base-width base-height
1509 width-inc height-inc gravity
1510 aspect (min-aspect aspect) (max-aspect aspect))
1511 (let ((geometry (make-instance 'gdk:geometry
1512 :min-width (or min-width -1)
1513 :min-height (or min-height -1)
1514 :max-width (or max-width -1)
1515 :max-height (or max-height -1)
1516 :base-width (or base-width 0)
1517 :base-height (or base-height 0)
1518 :width-inc (or width-inc 0)
1519 :height-inc (or height-inc 0)
1520 :min-aspect (or min-aspect 0)
1521 :max-aspect (or max-aspect 0)))
1523 (when (or min-width min-height)
1524 (push :min-size mask))
1525 (when (or max-width max-height)
1526 (push :max-size mask))
1527 (when (or base-width base-height)
1528 (push :base-size mask))
1529 (when (or width-inc height-inc)
1530 (push :resize-inc mask))
1531 (when (or min-aspect max-aspect)
1532 (push :aspect mask))
1534 (push :win-gravity mask)
1535 (setf (gdk:geometry-gravity geometry) gravity))
1536 (%window-set-geometry-hints window widget geometry mask)))
1538 (defbinding window-list-toplevels () (glist (copy-of window))
1539 "Returns a list of all existing toplevel windows.")
1541 (defbinding window-add-mnemonic (window key target) nil
1543 ((gdk:keyval-from-name key) unsigned-int)
1546 (defbinding window-remove-mnemonic (window key target) nil
1548 ((gdk:keyval-from-name key) unsigned-int)
1551 (defbinding window-mnemonic-activate (window key modifier) nil
1553 ((gdk:keyval-from-name key) unsigned-int)
1554 (modifier gdk:modifier-type))
1556 (defbinding window-activate-key () boolean
1558 (event gdk:key-event))
1560 (defbinding window-propagate-key-event () boolean
1562 (event gdk:key-event))
1564 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1565 (defbinding window-present () nil
1568 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1570 (defbinding %window-present () nil
1573 (defbinding %window-present-with-time () nil
1575 (timespamp unsigned-int))
1577 (defun window-present (window &optional timestamp)
1579 (%window-present-with-time window timestamp)
1580 (%window-present window))))
1582 (defbinding window-iconify () nil
1585 (defbinding window-deiconify () nil
1588 (defbinding window-stick () nil
1591 (defbinding window-unstick () nil
1594 (defbinding window-maximize () nil
1597 (defbinding window-unmaximize () nil
1600 (defbinding window-fullscreen () nil
1603 (defbinding window-unfullscreen () nil
1606 (defbinding window-set-keep-above () nil
1610 (defbinding window-set-keep-below () nil
1614 (defbinding window-begin-resize-drag () nil
1616 (edge gdk:window-edge)
1618 (root-x int) (root-y int)
1619 (timestamp unsigned-int))
1621 (defbinding window-begin-move-drag () nil
1623 (edge gdk:window-edge)
1625 (root-x int) (root-y int)
1626 (timestamp unsigned-int))
1628 (defbinding window-set-frame-dimensions () nil
1630 (left int) (top int) (rigth int) (bottom int))
1632 (defbinding %window-get-default-size () nil
1637 (defun window-get-default-size (window)
1638 (multiple-value-bind (width height) (%window-get-default-size window)
1639 (values (unless (= width -1) width) (unless (= height -1) height))))
1641 (defbinding window-get-frame-dimensions () nil
1643 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1645 (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
1648 (defbinding window-get-position () nil
1653 (defbinding window-get-size () nil
1658 (defbinding window-move () nil
1663 (defbinding window-parse-geometry () boolean
1667 (defbinding window-reshow-with-initial-size () nil
1670 (defbinding window-resize () nil
1675 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1676 () (glist gdk:pixbuf))
1678 (defun window-default-icon ()
1679 (first (window-default-icon-list)))
1681 (defbinding %window-set-default-icon-list () nil
1682 (icons (glist gdk:pixbuf)))
1684 (defun (setf window-default-icon-list) (icons)
1685 (%window-set-default-icon-list icons)
1688 (defbinding %window-set-default-icon () nil
1691 (defgeneric (setf window-default-icon) (icon))
1693 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1694 (%window-set-default-icon icon)
1697 (defgeneric (setf window-group) (group window))
1699 (defmethod (setf window-group) ((group window-group) (window window))
1700 (window-group-add-window group window)
1703 (defbinding %window-set-default-icon-from-file () boolean
1707 (defmethod (setf window-default-icon) ((icon-file pathname))
1708 (%window-set-default-icon-from-file icon-file)
1711 (defbinding %window-set-icon-from-file () boolean
1716 (defmethod (setf window-icon) ((icon-file pathname) (window window))
1717 (%window-set-icon-from-file window icon-file)
1720 (defbinding window-set-auto-startup-notification () nil
1723 (defbinding decorated-window-init () nil
1726 (defbinding decorated-window-calculate-frame-size () nil
1729 (defbinding decorated-window-set-title () nil
1733 (defbinding decorated-window-move-resize-window () nil
1743 (defmethod initialize-instance ((window-group window-group) &rest initargs
1744 &key window windows)
1745 (declare (ignore window windows))
1748 (initial-add window-group #'window-group-add-window
1749 initargs :window :windows)))
1752 (defbinding window-group-add-window () nil
1753 (window-group window-group)
1756 (defbinding window-group-remove-window () nil
1757 (window-group window-group)
1763 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1764 (setf (scrolled-window-hscrollbar-policy window) policy)
1765 (setf (scrolled-window-vscrollbar-policy window) policy))
1767 (defbinding scrolled-window-add-with-viewport () nil
1768 (scrolled-window scrolled-window)
1771 (defmethod shared-initialize ((window scrolled-window) names &key policy)
1772 (declare (ignore names))
1774 (setf (slot-value window 'hscrollbar-policy) policy)
1775 (setf (slot-value window 'vscrollbar-policy) policy))
1781 (defbinding statusbar-get-context-id () unsigned-int
1782 (statusbar statusbar)
1783 (context-description string))
1785 (defbinding statusbar-push () unsigned-int
1786 (statusbar statusbar)
1787 (context-id unsigned-int)
1790 (defbinding statusbar-pop () nil
1791 (statusbar statusbar)
1792 (context-id unsigned-int))
1794 (defbinding statusbar-remove () nil
1795 (statusbar statusbar)
1796 (context-id unsigned-int)
1797 (message-id unsigned-int))
1803 (defbinding fixed-put () nil
1808 (defbinding fixed-move () nil
1817 (defun %ensure-notebook-position (notebook page)
1820 (widget (notebook-page-num notebook page t))))
1822 (defun %ensure-notebook-child (notebook position)
1825 (t (notebook-get-nth-page notebook position))))
1827 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1828 (notebook position child &optional tab-label menu-label) nil
1831 ((if (stringp tab-label)
1832 (make-instance 'label :label tab-label)
1833 tab-label) (or null widget))
1834 ((if (stringp menu-label)
1835 (make-instance 'label :label menu-label)
1836 menu-label) (or null widget))
1837 ((%ensure-notebook-position notebook position) position))
1839 (defun notebook-append (notebook child &optional tab-label menu-label)
1840 (notebook-insert notebook :last child tab-label menu-label))
1842 (defun notebook-prepend (notebook child &optional tab-label menu-label)
1843 (notebook-insert notebook :first child tab-label menu-label))
1845 (defbinding notebook-remove-page (notebook page) nil
1847 ((%ensure-notebook-position notebook page) position))
1849 (defbinding %notebook-page-num () int
1853 (defun notebook-page-num (notebook child &optional error-p)
1854 (let ((page-num (%notebook-page-num notebook child)))
1857 (error "~A is not a page in ~A" child notebook))
1860 (defbinding notebook-next-page () nil
1861 (notebook notebook))
1863 (defbinding notebook-prev-page () nil
1864 (notebook notebook))
1866 (defbinding notebook-reorder-child (notebook child position) nil
1869 ((%ensure-notebook-position notebook position) int))
1871 (defbinding notebook-popup-enable () nil
1872 (notebook notebook))
1874 (defbinding notebook-popup-disable () nil
1875 (notebook notebook))
1877 (defbinding notebook-get-nth-page () widget
1881 (defun %notebook-current-page (notebook)
1882 (when (slot-boundp notebook 'current-page-num)
1883 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
1885 (defun (setf notebook-current-page) (page notebook)
1886 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
1888 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1889 (notebook page) widget
1891 ((%ensure-notebook-child notebook page) widget))
1893 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1894 (notebook page) (copy-of string)
1896 ((%ensure-notebook-child notebook page) widget))
1898 (defbinding %notebook-set-tab-label () nil
1903 (defun (setf notebook-tab-label) (tab-label notebook page)
1904 (let ((widget (if (stringp tab-label)
1905 (make-instance 'label :label tab-label)
1907 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1911 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1912 (notebook page) widget
1914 ((%ensure-notebook-child notebook page) widget))
1916 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1917 (notebook page) (copy-of string)
1919 ((%ensure-notebook-child notebook page) widget))
1921 (defbinding %notebook-set-menu-label () nil
1924 (menu-label widget))
1926 (defun (setf notebook-menu-label) (menu-label notebook page)
1927 (let ((widget (if (stringp menu-label)
1928 (make-instance 'label :label menu-label)
1930 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1934 (defbinding notebook-query-tab-label-packing (notebook page) nil
1936 ((%ensure-notebook-child notebook page) widget)
1937 (expand boolean :out)
1939 (pack-type pack-type :out))
1941 (defbinding notebook-set-tab-label-packing
1942 (notebook page expand fill pack-type) nil
1944 ((%ensure-notebook-child notebook page) widget)
1947 (pack-type pack-type))
1953 (defbinding paned-pack1 () nil
1959 (defbinding paned-pack2 () nil
1968 (defbinding layout-put () nil
1974 (defbinding layout-move () nil
1980 (defbinding layout-set-size () nil
1982 (width unsigned-int)
1983 (height unsigned-int))
1985 (defbinding layout-get-size () nil
1987 (width unsigned-int :out)
1988 (height unsigned-int :out))
1993 (defbinding menu-shell-insert (menu-shell menu-item position) nil
1994 (menu-shell menu-shell)
1995 (menu-item menu-item)
2001 (defun menu-shell-append (menu-shell menu-item)
2002 (menu-shell-insert menu-shell menu-item :last))
2004 (defun menu-shell-prepend (menu-shell menu-item)
2005 (menu-shell-insert menu-shell menu-item :fisrt))
2007 (defbinding menu-shell-deactivate () nil
2008 (menu-shell menu-shell))
2010 (defbinding menu-shell-select-item () nil
2011 (menu-shell menu-shell)
2012 (menu-item menu-item))
2014 (defbinding menu-shell-select-first () nil
2015 (menu-shell menu-shell)
2016 (search-sensitive boolean))
2018 (defbinding menu-shell-deselect () nil
2019 (menu-shell menu-shell))
2021 (defbinding menu-shell-activate-item () nil
2022 (menu-shell menu-shell)
2023 (menu-item menu-item)
2024 (fore-deactivate boolean))
2026 (defbinding menu-shell-cancel () nil
2027 (menu-shell menu-shell))
2032 (defun %menu-position (menu child)
2035 (keyword (case child
2038 (t (error "Invalid position keyword: ~A" child))))
2039 (widget (menu-child-position menu child))))
2042 (defbinding menu-reorder-child (menu menu-item position) nil
2044 (menu-item menu-item)
2045 ((%menu-position menu position) int))
2047 (defbinding menu-attach () nil
2049 (menu-item menu-item)
2050 (left-attach unsigned-int)
2051 (right-attach unsigned-int)
2052 (top-attach unsigned-int)
2053 (bottom-attach unsigned-int))
2055 (define-callback-marshal %menu-position-callback nil
2056 (menu (x int) (y int) (push-in boolean)))
2058 (defbinding %menu-popup () nil
2060 (parent-menu-shell (or null menu-shell))
2061 (parent-menu-item (or null menu-item))
2062 (callback (or null callback))
2063 (callback-id unsigned-int)
2064 (button unsigned-int)
2065 (activate-time (unsigned 32)))
2067 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
2070 (with-callback-function (id callback)
2072 menu parent-menu-shell parent-menu-item
2073 %menu-position-callback id button activate-time))
2075 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2077 (defbinding menu-set-accel-path () nil
2079 (accel-path string))
2081 (defbinding menu-reposition () nil
2084 (defbinding menu-popdown () nil
2087 (defun menu-child-position (menu child)
2088 (position child (container-children menu)))
2090 (defun menu-active-num (menu)
2091 (menu-child-position menu (menu-active menu)))
2093 (defbinding %menu-set-active () nil
2095 (index unsigned-int))
2097 (defun (setf menu-active) (menu child)
2098 (%menu-set-active menu (%menu-position menu child))
2101 (define-callback %menu-detach-callback nil ((widget widget) (menu menu))
2102 (funcall (user-data menu 'detach-func) widget menu))
2104 (defbinding %menu-attach-to-widget (menu widget) nil
2107 (%menu-detach-callback callback))
2109 (defun menu-attach-to-widget (menu widget function)
2110 (setf (user-data menu 'detach-func) function)
2111 (%menu-attach-to-widget menu widget))
2113 (defbinding menu-detach () nil
2116 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2117 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2120 (defbinding menu-set-monitor () nil
2127 (defbinding table-resize () nil
2130 (columns unsigned-int))
2132 (defbinding table-attach (table child left right top bottom
2133 &key options x-options y-options
2134 (x-padding 0) (y-padding 0)) nil
2138 (right unsigned-int)
2140 (bottom unsigned-int)
2141 ((append (mklist options) (mklist x-options)) attach-options)
2142 ((append (mklist options) (mklist y-options)) attach-options)
2143 (x-padding unsigned-int)
2144 (y-padding unsigned-int))
2147 (defbinding %table-set-row-spacing () nil
2150 (spacing unsigned-int))
2152 (defbinding %table-set-row-spacings () nil
2154 (spacing unsigned-int))
2156 (defun (setf table-row-spacing) (spacing table &optional row)
2158 (%table-set-row-spacing table row spacing)
2159 (%table-set-row-spacings table spacing))
2162 (defbinding %table-get-row-spacing () unsigned-int
2166 (defbinding %table-get-default-row-spacing () unsigned-int
2169 (defun table-row-spacing (table &optional row)
2171 (%table-get-row-spacing table row)
2172 (%table-get-default-row-spacing table)))
2175 (defbinding %table-set-col-spacing () nil
2178 (spacing unsigned-int))
2180 (defbinding %table-set-col-spacings () nil
2182 (spacing unsigned-int))
2184 (defun (setf table-column-spacing) (spacing table &optional column)
2186 (%table-set-col-spacing table column spacing)
2187 (%table-set-col-spacings table spacing))
2190 (defun (setf table-col-spacing) (spacing table &optional col)
2191 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2192 (setf (table-column-spacing table col) spacing))
2194 (defbinding %table-get-col-spacing () unsigned-int
2198 (defbinding %table-get-default-col-spacing () unsigned-int
2201 (defun table-column-spacing (table &optional column)
2203 (%table-get-col-spacing table column)
2204 (%table-get-default-col-spacing table)))
2206 (defun table-col-spacing (table &optional col)
2207 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2208 (table-column-spacing table col))
2214 (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2216 (apply #'call-next-method toolbar
2217 :tooltips (make-instance 'tooltips) initargs)
2218 (call-next-method)))
2220 (defbinding %toolbar-insert () nil
2222 (tool-item tool-item)
2223 (position position))
2225 (defun toolbar-insert (toolbar tool-item &optional (position :end))
2226 (%toolbar-insert toolbar tool-item position)
2227 (%tool-item-update-tooltips tool-item))
2229 (defbinding toolbar-get-item-index () int
2233 (defbinding toolbar-get-nth-item () tool-item
2237 (defbinding toolbar-get-drop-index () int
2241 (defbinding toolbar-set-drop-highlight-item () nil
2243 (tool-item tool-item)
2249 (defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2250 (if (and icon (not (typep icon 'widget)))
2251 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2252 (call-next-method)))
2257 (defbinding tool-item-set-tooltip () nil
2258 (tool-item tool-item)
2261 (tip-private string))
2264 (defun %tool-item-update-tooltips (tool-item)
2266 (slot-boundp tool-item 'parent)
2268 (user-data-p tool-item 'tip-text)
2269 (user-data-p tool-item 'tip-private)))
2270 (tool-item-set-tooltip
2271 tool-item (toolbar-tooltips (widget-parent tool-item))
2272 (or (user-data tool-item 'tip-text) "")
2273 (or (user-data tool-item 'tip-private) ""))))
2275 (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2276 (setf (user-data tool-item 'tip-text) tip-text)
2277 (%tool-item-update-tooltips tool-item)
2280 (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2281 (setf (user-data tool-item 'tip-private) tip-private)
2282 (%tool-item-update-tooltips tool-item)
2285 (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2286 (declare (ignore args))
2289 (%tool-item-update-tooltips tool-item)))
2292 (defbinding tool-item-retrieve-proxy-menu-item () widget
2293 (tool-item tool-item))
2295 (defbinding (tool-item-proxy-menu-item
2296 "gtk_tool_item_get_proxy_menu_item") () menu-item
2297 (tool-item tool-item)
2298 (menu-item-id string))
2300 (defbinding %tool-item-set-proxy-menu-item () nil
2301 (tool-item tool-item)
2302 (menu-item-id string)
2303 (menu-item menu-item))
2305 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2306 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2309 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2310 (defbinding tool-item-rebuild-menu () nil
2311 (tool-item tool-item))
2316 (defbinding editable-select-region (editable &optional (start 0) end) nil
2321 (defbinding editable-get-selection-bounds (editable) nil
2326 (defbinding editable-insert-text (editable text &optional (position 0)) nil
2330 (position position :in/out))
2332 (defun editable-append-text (editable text)
2333 (editable-insert-text editable text nil))
2335 (defun editable-prepend-text (editable text)
2336 (editable-insert-text editable text 0))
2338 (defbinding editable-delete-text (editable &optional (start 0) end) nil
2343 (defbinding (editable-text "gtk_editable_get_chars")
2344 (editable &optional (start 0) end) string
2349 (defun (setf editable-text) (text editable)
2351 (editable-delete-text
2353 (editable-insert-text editable text))
2354 (editable-delete-text editable))
2357 (defbinding editable-cut-clipboard () nil
2358 (editable editable))
2360 (defbinding editable-copy-clipboard () nil
2361 (editable editable))
2363 (defbinding editable-paste-clipboard () nil
2364 (editable editable))
2366 (defbinding editable-delete-selection () nil
2367 (editable editable))
2373 (defbinding spin-button-configure () nil
2374 (spin-button spin-button)
2375 (adjustment adjustment)
2376 (climb-rate double-float)
2377 (digits unsigned-int))
2379 (defbinding spin-button-set-range () nil
2380 (spin-button spin-button)
2384 (defbinding spin-button-get-range () nil
2385 (spin-button spin-button)
2386 (min double-float :out)
2387 (max double-float :out))
2389 (defun spin-button-value-as-int (spin-button)
2390 (round (spin-button-value spin-button)))
2392 (defbinding %spin-button-spin () nil
2393 (spin-button spin-button)
2394 (direction spin-type)
2395 (increment double-float))
2397 (defun spin-button-spin (spin-button value)
2399 (real (%spin-button-spin spin-button :user-defined value))
2400 (spin-type (%spin-button-spin spin-button value 0))))
2403 (defbinding spin-button-update () nil
2404 (spin-button spin-button))
2410 (defbinding ruler-set-range () nil
2412 (lower single-float)
2413 (upper single-float)
2414 (position single-float)
2415 (max-size single-float))
2417 (defbinding ruler-get-range () nil
2419 (lower single-float :out)
2420 (upper single-float :out)
2421 (position single-float :out)
2422 (max-size single-float :out))
2428 (defun range-lower (range)
2429 (adjustment-lower (range-adjustment range)))
2431 (defun range-upper (range)
2432 (adjustment-upper (range-adjustment range)))
2434 (defun (setf range-lower) (value range)
2435 (setf (adjustment-lower (range-adjustment range)) value))
2437 (defun (setf range-upper) (value range)
2438 (setf (adjustment-upper (range-adjustment range)) value))
2440 (defun range-page-increment (range)
2441 (adjustment-page-increment (range-adjustment range)))
2443 (defun range-step-increment (range)
2444 (adjustment-step-increment (range-adjustment range)))
2446 (defun (setf range-page-increment) (value range)
2447 (setf (adjustment-page-increment (range-adjustment range)) value))
2449 (defun (setf range-step-increment) (value range)
2450 (setf (adjustment-step-increment (range-adjustment range)) value))
2452 (defbinding range-set-range () nil
2454 (lower double-float)
2455 (upper double-float))
2457 (defbinding range-set-increments () nil
2460 (page double-float))
2465 (defbinding scale-get-layout-offsets () nil
2473 (defbinding progress-bar-pulse () nil
2474 (progress-bar progress-bar))
2479 (defmethod initialize-instance ((size-group size-group) &rest initargs
2480 &key widget widgets)
2481 (declare (ignore widget widgets))
2484 (initial-add size-group #'size-group-add-widget
2485 initargs :widget :widgets)))
2488 (defbinding size-group-add-widget () nil
2489 (size-group size-group)
2492 (defbinding size-group-remove-widget () nil
2493 (size-group size-group)
2499 (defbinding %stock-item-copy () pointer
2502 (defbinding %stock-item-free () nil
2505 (defbinding stock-add (stock-item) nil
2506 (stock-item stock-item)
2509 (defbinding stock-list-ids () (gslist string))
2511 (defbinding %stock-lookup () boolean
2515 (defun stock-lookup (stock-id)
2516 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
2517 (when (%stock-lookup stock-id stock-item)
2518 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
2520 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
2522 (define-callback-marshal %stock-translate-callback string ((path string)))
2524 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2525 (domain function) nil
2527 (%stock-translate-callback callback)
2528 ((register-callback-function function) unsigned-int)
2529 (user-data-destroy-callback callback)))
2534 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2536 (defbinding tooltip-set-markup () nil
2540 (defbinding tooltip-set-text () nil
2544 (defbinding %tooltip-set-icon () nil
2548 (defbinding %tooltip-set-icon-from-stock () nil
2553 (defun tooltip-set-icon (tooltip icon &key (size :button))
2555 (gdk:pixbuf (%tooltip-set-icon tooltip icon))
2556 (string (%tooltip-set-icon-from-stock tooltip icon size))))
2558 (defbinding tooltip-set-custom () nil
2562 (defbinding tooltip-trigger-tooltip-query (&optional (display (gdk:display-get-default))) nil
2563 (display gdk:display))
2565 (defbinding tooltip-set-tip-area () nil
2573 ;; GtkTooltips has been deprecated in favor of the new tooltip API
2574 ;; introduced in in GTK+ 2.12
2576 (defbinding tooltips-enable () nil
2577 (tooltips tooltips))
2579 (defbinding tooltips-disable () nil
2580 (tooltips tooltips))
2582 (defun (setf tooltips-enabled-p) (enable tooltips)
2584 (tooltips-enable tooltips)
2585 (tooltips-disable tooltips)))
2587 (defbinding tooltips-set-tip () nil
2591 (tip-private string))
2593 (defbinding tooltips-data-get () tooltips-data
2596 (defbinding tooltips-force-window () nil
2597 (tooltips tooltips))
2599 (defbinding tooltips-get-info-from-tip-window () boolean
2601 (tooltips tooltips :out)
2602 (current-widget widget :out))
2607 (defbinding rc-get-style () style
2610 (defbinding rc-get-style-by-paths (&key path class-path class) style
2611 (path (or null string))
2612 (class-path (or null string))
2615 (defbinding rc-parse () nil
2616 (filename pathname))
2618 (defbinding rc-parse-string () nil
2621 (defbinding %rc-reparse-all () boolean)
2623 (defbinding %rc-reparse-all-for-settings () boolean
2625 (force-load-p boolean))
2627 (defun rc-reparse-all (&optional setting force-load-p)
2629 (%rc-reparse-all-for-settings setting force-load-p)
2632 (defbinding rc-reset-styles () nil
2633 (settings settings))
2635 (defbinding rc-add-default-file () nil
2636 (filename pathname))
2638 (defbinding rc-get-default-files ()
2639 (copy-of (null-terminated-vector (copy-of string))))
2641 (defbinding rc-get-module-dir () string)
2643 (defbinding rc-get-im-module-path () string)
2645 (defbinding rc-get-im-module-file () string)
2647 (defbinding rc-get-theme-dir () string)
2652 (defbinding (settings-get "gtk_settings_get_for_screen")
2653 (&optional (screen (gdk:display-get-default-screen))) settings
2654 (screen gdk:screen))
2659 (defbinding socket-add-id () nil
2661 (id gdk:native-window))
2663 (defbinding %plug-new () pointer
2664 (id gdk:native-window))
2666 (defmethod allocate-foreign ((plug plug) &key id)
2667 (%plug-new (or id 0)))
2672 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2674 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2676 (defbinding link-button-set-uri-hook (function) pointer
2677 (%link-button-uri-callback callback)
2678 ((register-callback-function function) unsigned-int)
2679 (user-data-destroy-callback callback)))
2684 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2686 (defmethod initialize-instance ((builder builder) &key interface
2687 (connect-signals t) (package *package*))
2689 (etypecase interface
2691 (string (builder-add-from-string builder interface))
2692 (pathname (builder-add-from-file builder interface)))
2693 (when connect-signals
2694 (builder-connect-signals builder package)))
2697 (defbinding builder-add-from-file () boolean
2700 (nil gerror-signal :out))
2702 (defbinding builder-add-from-string () boolean
2705 (-1 int) ; TODO: add gsize type
2706 (nil gerror-signal :out))
2708 (defbinding builder-get-object () gobject
2712 (defbinding builder-get-objects () (gslist gobject)
2715 (defun intern-with-package-prefix (name default-package)
2716 (let ((pos (position #\: name)))
2719 (string-upcase (subseq name (1+ pos)))
2720 (string-upcase (subseq name 0 pos)))
2721 (intern (string-upcase name) default-package))))
2723 (define-callback %builder-connect-function nil
2724 (builder (object gobject) (signal-name string) (handler-name string)
2725 (connect-object gobject) connect-flags (package user-data-id))
2726 (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)
2729 (intern-with-package-prefix handler-name (find-user-data package))
2730 :object (or connect-object object) :after (find :after connect-flags)))
2732 (defbinding %builder-connect-signals-full (builder package) nil
2734 (%builder-connect-function callback)
2735 (package user-data-id))
2737 (defun builder-connect-signals (builder &optional (package *package*))
2738 (with-user-data (id package)
2739 (%builder-connect-signals-full builder id))))