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.98 2008/11/25 22:11:08 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)))
114 (signal-connect (gdk:display-manager) 'display-opened
116 (let ((fd (gdk:display-connection-number display)))
118 (let ((handler (add-fd-handler
119 (gdk:display-connection-number display)
120 :input #'main-iterate-all)))
121 (signal-connect display 'closed
122 #'(lambda (is-error-p)
123 (declare (ignore is-error-p))
124 (remove-fd-handler handler))))))))
126 #?(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6))
128 (setq *periodic-polling-function* #'main-iterate-all)
129 #?(or (featurep :cmu) (sbcl< 1 0 6))
130 (multiple-value-setq (*max-event-to-sec* *max-event-to-usec*)
131 (decompose-time *event-polling-interval*))
133 (setq *periodic-polling-period* *event-polling-interval*))
135 #?(or (featurep :clisp) (and (sbcl>= 1 0 6) (sbcl< 1 0 15 6)))
136 ;; When running in CLISP or certain versions of SBCL in Slime we need
137 ;; to hook into the Swank server to handle events asynchronously.
139 ((and (find-package "SWANK") (find-symbol "CHECK-SLIME-INTERRUPTS" "SWANK"))
140 (let ((check-slime-interrupts
141 (symbol-function (find-symbol "CHECK-SLIME-INTERRUPTS" "SWANK"))))
143 (symbol-function (find-symbol "CHECK-SLIME-INTERRUPTS" "SWANK"))
146 (funcall check-slime-interrupts)))))
147 ((and (find-package "SWANK")
148 (find-symbol "READ-FROM-EMACS" "SWANK")
149 (find-symbol "*EMACS-CONNECTION*" "SWANK")
150 (find-symbol "CONNECTION.SOCKET-IO" "SWANK"))
151 (let ((connection (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK"))))
153 (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")))
154 (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") connection)))
155 (multiple-value-bind (sec usec)
156 (decompose-time *event-polling-interval*)
157 (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))
160 (case (socket-status (cons stream :input) sec usec)
161 ((:input :eof) (return (funcall read-from-emacs)))
162 (otherwise (main-iterate-all)))))))))))
163 ((flet ((warn-main-loop ()
164 (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started.")))
165 #+(and clisp readline)
166 (if (find-package "SWANK")
167 (warn-main-loop) ; assuming we're running in SLIME
168 ;; Readline will call the event hook at most ten times per second
169 (setf readline:event-hook #'main-iterate-all))
170 #-(and clisp readline)(warn-main-loop))))
172 (gdk:display-open display))
176 (defvar *main-thread* nil)
178 ;; Hopefully, when threading support is added to the Win32 port of
179 ;; SBCL in the future, this will work just out of the box.
181 (let ((done (sb-thread:make-waitqueue))
185 ;; In Win32 all GDK calls have to be made from the main loop
186 ;; thread, so we add a timeout function which will poll for code and
189 (defun funcall-in-main (function)
192 (eq sb-thread:*current-thread* *main-thread*))
194 (gdk:with-global-lock
195 (push function functions)
196 (sb-thread:condition-wait done gdk:*global-lock*)
199 ;; Will lock REPL on error, need to be fixed!
200 (defun %funcall-in-main-poll ()
205 do (push (funcall (pop functions)) results)
206 finally (sb-thread:condition-notify done n)))
209 (defmacro within-main-loop (&body body)
210 #-win32 `(gdk:with-global-lock ,@body)
211 #+win32 `(funcall-in-main #'(lambda () ,@body)))
213 (defun %init-multi-threaded-event-handling (display)
215 (find-package "SWANK")
216 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn)))
217 (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."))
219 (let ((main-running (sb-thread:make-waitqueue)))
220 (gdk:with-global-lock
222 (sb-thread:make-thread
224 (gdk:with-global-lock
225 (gdk:display-open display)
226 #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000)
227 #'%funcall-in-main-poll)
228 (sb-thread:condition-notify main-running)
230 :name "gtk event loop"))
231 (sb-thread:condition-wait main-running gdk:*global-lock*)))
233 ;; We need to hook into the Swank server to protect calls to GDK properly.
234 ;; This will *only* protect code entered directly in the REPL.
235 (when (find-package "SWANK")
236 (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
238 (push #'(lambda (form)
239 (within-main-loop (eval form)))
240 (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
241 (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"))))))
244 (defmacro within-main-loop (&body body)
249 ;;; Generic functions
251 (defgeneric add-to-radio-group (item1 item2))
252 (defgeneric activate-radio-widget (item))
253 (defgeneric (setf tool-item-tip-text) (tip-text tool-item))
254 (defgeneric (setf tool-item-tip-private) (tip-private tool-item))
260 (defbinding grab-add () nil
263 (defbinding grab-get-current () widget)
265 (defbinding grab-remove () nil
268 (defbinding get-default-language () (copy-of pango:language))
273 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
275 (define-callback-marshal %about-dialog-activate-link-callback nil
276 (about-dialog (link string)))
278 (defbinding about-dialog-set-email-hook (function) nil
279 (%about-dialog-activate-link-callback callback)
280 ((register-callback-function function) unsigned-int)
281 (user-data-destroy-callback callback))
283 (defbinding about-dialog-set-url-hook (function) nil
284 (%about-dialog-activate-link-callback callback)
285 ((register-callback-function function) unsigned-int)
286 (user-data-destroy-callback callback)))
291 (defbinding %accel-group-connect () nil
292 (accel-group accel-group)
294 (modifiers gdk:modifier-type)
298 (defun accel-group-connect (group accelerator function &optional flags)
299 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
300 (let ((gclosure (make-callback-closure function)))
301 (%accel-group-connect group key modifiers flags gclosure)
304 (defbinding accel-group-connect-by-path (group path function) nil
307 ((make-callback-closure function) gclosure :in/return))
309 (defbinding %accel-group-disconnect (group gclosure) boolean
313 (defbinding %accel-group-disconnect-key () boolean
316 (modifiers gdk:modifier-type))
318 (defun accel-group-disconnect (group accelerator)
319 (etypecase accelerator
320 (gclosure (%accel-group-disconnect group accelerator))
322 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
323 (%accel-group-disconnect-key group key modifiers)))))
325 (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
326 (accel-group accel-group)
328 (modifiers gdk:modifier-type)
331 (defun accel-group-query (accel-group accelerator)
332 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
333 (%accel-group-query accel-group key modifiers)))
335 (defbinding %accel-group-activate () boolean
336 (accel-group accel-group)
337 (acceleratable gobject)
339 (modifiers gdk:modifier-type))
341 (defun accel-group-activate (accel-group acceleratable accelerator)
342 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
343 (%accel-group-activate accel-group acceleratable key modifiers)))
345 (defbinding accel-group-lock () nil
346 (accel-group accel-group))
348 (defbinding accel-group-unlock () nil
349 (accel-group accel-group))
351 (defbinding accel-group-from-accel-closure () accel-group
354 (defbinding %accel-groups-activate () boolean
357 (modifiers gdk:modifier-type))
359 (defun accel-groups-activate (object accelerator)
360 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
361 (%accel-groups-activate object key modifiers)))
363 (defbinding accel-groups-from-object () (gslist accel-group)
366 (defbinding accelerator-valid-p (key &optional modifiers) boolean
368 (modifiers gdk:modifier-type))
370 (defbinding %accelerator-parse () nil
372 (key unsigned-int :out)
373 (modifiers gdk:modifier-type :out))
375 (defgeneric parse-accelerator (accelerator))
377 (defmethod parse-accelerator ((accelerator string))
378 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
380 (error "Invalid accelerator: ~A" accelerator)
381 (values key modifiers))))
383 (defmethod parse-accelerator ((accelerator cons))
384 (destructuring-bind (key modifiers) accelerator
390 (gdk:keyval-from-name key)
391 (error "Invalid key name: ~A" key)))
392 (character (parse-accelerator key)))
395 (defmethod parse-accelerator ((key integer))
398 (defmethod parse-accelerator ((key character))
400 (gdk:keyval-from-name (string key))
401 (error "Invalid key name: ~A" key)))
404 (defbinding accelerator-name () string
406 (modifiers gdk:modifier-type))
408 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
409 (defbinding accelerator-get-label () string
411 (modifiers gdk:modifier-type))
413 (defbinding %accelerator-set-default-mod-mask () nil
414 (default-modifiers gdk:modifier-type))
416 (defun (setf accelerator-default-modifier-mask) (default-modifiers)
417 (%accelerator-set-default-mod-mask default-modifiers))
419 (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
424 (defbinding accel-label-get-accel-width () unsigned-int
425 (accel-label accel-label))
427 (defbinding accel-label-refetch () boolean
428 (accel-label accel-label))
434 (defbinding %accel-map-add-entry () nil
437 (modifiers gdk:modifier-type))
439 (defun accel-map-add-entry (path accelerator)
440 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
441 (%accel-map-add-entry path key modifiers)))
443 (defbinding %accel-map-lookup-entry () boolean
445 ((make-instance 'accel-key) accel-key :in/return))
447 (defun accel-map-lookup-entry (path)
448 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
451 (slot-value accel-key 'key)
452 (slot-value accel-key 'modifiers)
453 (slot-value accel-key 'flags)))))
455 (defbinding %accel-map-change-entry () boolean
458 (modifiers gdk:modifier-type)
461 (defun accel-map-change-entry (path accelerator &optional replace)
462 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
463 (%accel-map-change-entry path key modifiers replace)))
465 (defbinding accel-map-load () nil
468 (defbinding accel-map-save () nil
471 (define-callback-marshal %accel-map-foreach-callback nil
472 ((accel-path string) (key unsigned-int)
473 (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first)
475 (defbinding %accel-map-foreach (callback-id) nil
476 (callback-id unsigned-int)
477 (%accel-map-foreach-callback callback))
479 (defbinding %accel-map-foreach-unfiltered (callback-id) nil
480 (callback-id unsigned-int)
481 (%accel-map-foreach-callback callback))
483 (defun accel-map-foreach (function &optional (filter-p t))
484 (with-callback-function (id function)
486 (%accel-map-foreach id)
487 (%accel-map-foreach-unfiltered id))))
489 (defbinding accel-map-add-filter () nil
492 (defbinding accel-map-get () accel-map)
494 (defbinding accel-map-lock-path () nil
497 (defbinding accel-map-unlock-path () nil
504 (defbinding accessible-connect-widget-destroyed () nil
505 (accessible accessible))
510 (defmethod initialize-instance ((adjustment adjustment) &key value)
513 ;; we need to make sure that the value is set last, otherwise it
514 ;; may be outside current limits and ignored
516 (setf (slot-value adjustment 'value) value))))
519 (defbinding adjustment-changed () nil
520 (adjustment adjustment))
522 (defbinding adjustment-value-changed () nil
523 (adjustment adjustment))
525 (defbinding adjustment-clamp-page () nil
526 (adjustment adjustment)
528 (upper single-float))
533 (defbinding alignment-set () nil
534 (alognment alignment)
535 (x-align single-float)
536 (y-align single-float)
537 (x-scale single-float)
538 (y-scale single-float))
540 (defbinding alignment-get-padding () nil
541 (alognment alignment)
542 (top unsigned-int :out)
543 (bottom unsigned-int :out)
544 (left unsigned-int :out)
545 (right unsigned-int :out))
547 (defbinding alignment-set-padding () nil
548 (alognment alignment)
550 (bottom unsigned-int)
552 (right unsigned-int))
557 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
559 (defbinding assistant-get-nth-page () widget
560 (assistant assistant)
563 (defbinding %assistant-insert-page () int
564 (assistant assistant)
568 (defun assistant-insert-page (assistant page position &rest child-args)
569 (let ((pos (case position
574 (%assistant-insert-page assistant page pos)
575 (init-child-slots assistant page child-args))))
577 (defun assistant-append-page (assistant page &rest child-args)
578 (apply #'assistant-insert-page assistant page :last child-args))
580 (defun assistant-prepend-page (assistant page &rest child-args)
581 (apply #'assistant-insert-page assistant page :first child-args))
583 (define-callback-marshal %assistant-page-func-callback int
584 ((current-page int)))
586 (defbinding assistant-set-forward-page-func (assistant function) nil
587 (assistant assistant)
588 (%assistant-page-func-callback callback)
589 ((register-callback-function function) pointer-data)
590 (user-data-destroy-callback callback))
592 (defbinding assistant-add-action-widget () nil
593 (assistant assistant)
596 (defbinding assistant-remove-action-widget () nil
597 (assistant assistant)
600 (defbinding assistant-update-buttons-state () nil
601 (assistant assistant)))
610 (defun (setf bin-child) (child bin)
611 (when-bind (current-child (bin-child bin))
612 (container-remove bin current-child))
613 (container-add bin child)
616 (defmethod compute-signal-function ((bin bin) signal function object args)
617 (declare (ignore signal))
618 (if (eq object :child)
619 #'(lambda (bin &rest emission-args)
620 (apply function (bin-child bin) (nconc emission-args args)))
626 (defbinding box-pack-start () nil
631 (padding unsigned-int))
633 (defbinding box-pack-end () nil
638 (padding unsigned-int))
640 (defun box-pack (box child &key end (expand t) (fill t) (padding 0))
642 (box-pack-end box child expand fill padding)
643 (box-pack-start box child expand fill padding)))
645 (defbinding box-reorder-child () nil
650 (defbinding box-query-child-packing () nil
653 (expand boolean :out)
655 (padding unsigned-int :out)
656 (pack-type pack-type :out))
658 (defbinding box-set-child-packing () nil
663 (padding unsigned-int)
664 (pack-type pack-type))
670 (defmethod initialize-instance ((button button) &rest initargs &key stock)
672 (apply #'call-next-method button
673 :label stock :use-stock t :use-underline t initargs)
677 (defbinding button-pressed () nil
680 (defbinding button-released () nil
683 (defbinding button-clicked () nil
686 (defbinding button-enter () nil
689 (defbinding button-leave () nil
696 (defbinding calendar-select-month () int
701 (defbinding calendar-select-day () nil
705 (defbinding calendar-mark-day () int
709 (defbinding calendar-unmark-day () int
713 (defbinding calendar-clear-marks () nil
716 (defbinding calendar-get-date () nil
718 (year unsigned-int :out)
719 (month unsigned-int :out)
720 (day unsigned-int :out))
722 (defbinding calendar-freeze () nil
725 (defbinding calendar-thaw () nil
731 (defbinding check-menu-item-toggled () nil
732 (check-menu-item check-menu-item))
737 (defbinding color-selection-is-adjusting-p () boolean
738 (colorsel color-selection))
740 (defbinding (color-selection-previous-color
741 "gtk_color_selection_get_previous_color") () nil
742 (colorsel color-selection)
743 ((make-instance 'gdk:color) gdk:color :in/return))
746 ;;; Color selection dialog -- no functions
752 (defmethod initialize-instance ((combo-box combo-box) &rest initargs
753 &key model content active)
754 (remf initargs :active)
756 (apply #'call-next-method combo-box initargs)
758 (apply #'call-next-method combo-box
759 :model (make-instance 'list-store :column-types '(string))
761 (unless (typep combo-box 'combo-box-entry)
762 (let ((cell (make-instance 'cell-renderer-text)))
763 (cell-layout-pack combo-box cell :expand t)
764 (cell-layout-add-attribute combo-box cell :text 0)))))
766 (mapc #'(lambda (text)
767 (combo-box-append-text combo-box text))
770 (setf (combo-box-active combo-box) active)))
773 ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
775 ;; (signal-emit combo-box 'changed)))
777 (defbinding combo-box-append-text () nil
778 (combo-box combo-box)
781 (defbinding combo-box-insert-text () nil
782 (combo-box combo-box)
786 (defbinding combo-box-prepend-text () nil
787 (combo-box combo-box)
790 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
791 (defbinding combo-box-get-active-text () (or null string)
792 (combo-box combo-box))
794 (defbinding combo-box-popup () nil
795 (combo-box combo-box))
797 (defbinding combo-box-popdown () nil
798 (combo-box combo-box))
804 (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
807 (setf (combo-box-entry-text-column combo-box-entry) 0)))
812 (defmethod shared-initialize ((dialog dialog) names &rest initargs
814 (declare (ignore names button buttons))
817 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
820 (defun dialog-response-id (dialog response &optional create-p error-p)
821 "Returns a numeric response id"
822 (if (typep response 'response-type)
823 (response-type-to-int response)
824 (let ((responses (user-data dialog 'responses)))
826 ((and responses (position response responses :test #'equal)))
830 (vector-push-extend response responses)
831 (1- (length responses)))
834 (user-data dialog 'responses)
835 (make-array 1 :adjustable t :fill-pointer t
836 :initial-element response))
839 (error "Invalid response: ~A" response))))))
841 (defun dialog-find-response (dialog id)
842 "Finds a symbolic response given a numeric id"
844 ((not (numberp id)) id)
845 ((< id 0) (int-to-response-type id))
846 ((aref (user-data dialog 'responses) id))))
849 (defmethod compute-signal-id ((dialog dialog) signal)
850 (if (dialog-response-id dialog signal)
851 (ensure-signal-id 'response dialog)
854 (defmethod compute-signal-function ((dialog dialog) signal function object args)
855 (declare (ignore function object args))
856 (let ((callback (call-next-method))
857 (id (dialog-response-id dialog signal)))
860 #'(lambda (dialog response)
861 (when (= response id)
862 (funcall callback dialog))))
863 ((string-equal signal "response")
864 #'(lambda (dialog response)
865 (funcall callback dialog (dialog-find-response dialog response))))
868 (defbinding dialog-run () nil
871 (defbinding dialog-response (dialog response) nil
873 ((dialog-response-id dialog response nil t) int))
876 (defbinding %dialog-add-button () button
881 (defun dialog-add-button (dialog label &optional (response label)
882 &key default object after)
883 "Adds a button to the dialog."
884 (let* ((signal (if (functionp response)
887 (id (dialog-response-id dialog signal t))
888 (button (%dialog-add-button dialog label id)))
889 (when (functionp response)
890 (signal-connect dialog signal response :object object :after after))
892 (%dialog-set-default-response dialog id))
896 (defbinding %dialog-add-action-widget () nil
898 (action-widget widget)
901 (defun dialog-add-action-widget (dialog widget &optional (response widget)
902 &key default object after)
903 (let* ((signal (if (functionp response)
906 (id (dialog-response-id dialog signal t)))
907 (unless (widget-hidden-p widget)
908 (widget-show widget))
909 (%dialog-add-action-widget dialog widget id)
910 (when (functionp response)
911 (signal-connect dialog signal response :object object :after after))
913 (setf (widget-can-default-p widget) t)
914 (%dialog-set-default-response dialog id))
918 (defbinding %dialog-set-default-response () nil
922 (defun dialog-set-default-response (dialog response)
923 (%dialog-set-default-response
924 dialog (dialog-response-id dialog response nil t)))
926 (defbinding dialog-set-response-sensitive (dialog response sensitive) nil
928 ((dialog-response-id dialog response nil t) int)
931 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
932 (defbinding alternative-dialog-button-order-p (&optional screen) boolean
933 (screen (or null gdk:screen)))
935 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
936 (defbinding (dialog-set-alternative-button-order
937 "gtk_dialog_set_alternative_button_order_from_array")
938 (dialog new-order) nil
940 ((length new-order) int)
941 ((map 'vector #'(lambda (response)
942 (dialog-response-id dialog response nil t))
943 new-order) (vector int)))
946 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
948 (defbinding %dialog-get-response-for-widget () int
952 (defun dialog-get-response-for-widget (dialog widget)
953 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
956 (defmethod container-add ((dialog dialog) (child widget) &rest args)
957 (apply #'container-add (dialog-vbox dialog) child args))
960 (defmethod container-remove ((dialog dialog) (child widget))
961 (container-remove (dialog-vbox dialog) child))
963 (defmethod container-children ((dialog dialog))
964 (container-children (dialog-vbox dialog)))
966 (defmethod (setf container-children) (children (dialog dialog))
967 (setf (container-children (dialog-vbox dialog)) children))
972 (defun drawing-area-scroll (drawing-area dx dy)
973 (gdk:window-scroll (widget-window drawing-area) dx dy))
978 (defbinding entry-get-layout-offsets () nil
983 (defbinding entry-layout-index-to-text-index () int
987 (defbinding entry-text-index-to-layout-index () int
994 (define-callback-marshal %entry-completion-match-callback boolean
995 (entry-completion string tree-iter))
997 (defbinding entry-completion-set-match-func (completion function) nil
998 (completion entry-completion)
999 (%entry-completion-match-callback callback)
1000 ((register-callback-function function) unsigned-int)
1001 (user-data-destroy-callback callback))
1003 (defbinding entry-completion-complete () nil
1004 (completion entry-completion))
1006 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
1007 (defbinding entry-completion-get-completion-prefix () string
1008 (completion entry-completion))
1010 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1011 (defbinding entry-completion-insert-prefix () nil
1012 (completion entry-completion))
1014 (defbinding entry-completion-insert-action-text () nil
1015 (completion entry-completion)
1019 (defbinding entry-completion-insert-action-markup () nil
1020 (completion entry-completion)
1024 (defbinding entry-completion-delete-action () nil
1025 (completion entry-completion)
1031 (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
1032 &key filter filters shortcut-folder
1033 shortcut-folders shortcut-folder-uti
1034 shortcut-folder-uris)
1035 (declare (ignore filter filters shortcut-folder shortcut-folders
1036 shortcut-folder-uti shortcut-folder-uris))
1039 (initial-add file-chooser #'file-chooser-add-filter
1040 initargs :filer :filters)
1041 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1042 initargs :shortcut-folder :shortcut-folders)
1043 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1044 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1047 (defbinding file-chooser-select-filename () boolean
1048 (file-chooser file-chooser)
1051 (defbinding file-chooser-unselect-filename () nil
1052 (file-chooser file-chooser)
1055 (defbinding file-chooser-select-all () boolean
1056 (file-chooser file-chooser))
1058 (defbinding file-chooser-unselect-all () boolean
1059 (file-chooser file-chooser))
1061 (defbinding file-chooser-get-filenames () (gslist string)
1062 (file-chooser file-chooser))
1064 (defbinding file-chooser-select-uri () boolean
1065 (file-chooser file-chooser)
1068 (defbinding file-chooser-unselect-uri () nil
1069 (file-chooser file-chooser)
1072 (defbinding file-chooser-get-uris () (gslist string)
1073 (file-chooser file-chooser))
1075 (defbinding file-chooser-add-filter () nil
1076 (file-chooser file-chooser)
1077 (filter file-filter))
1079 (defbinding file-chooser-remove-filter () nil
1080 (file-chooser file-chooser)
1081 (filter file-filter))
1083 (defbinding file-chooser-list-filters () (gslist file-filter)
1084 (file-chooser file-chooser))
1086 (defbinding file-chooser-add-shortcut-folder () boolean
1087 (file-chooser file-chooser)
1091 (defbinding file-chooser-remove-shortcut-folder () nil
1092 (file-chooser file-chooser)
1096 (defbinding file-chooser-list-shortcut-folders () (gslist string)
1097 (file-chooser file-chooser))
1099 (defbinding file-chooser-add-shortcut-folder-uri () boolean
1100 (file-chooser file-chooser)
1104 (defbinding file-chooser-remove-shortcut-folder-uri () nil
1105 (file-chooser file-chooser)
1109 (defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1110 (file-chooser file-chooser))
1115 (defmethod initialize-instance ((file-filter file-filter) &rest initargs
1116 &key mime-type mime-types pattern patterns
1118 (declare (ignore mime-type mime-types pattern patterns))
1121 (when pixbuf-formats
1122 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1123 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1124 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1125 (file-filter-add-pixbuf-formats file-filter))
1126 (initial-add file-filter #'file-filter-add-mime-type
1127 initargs :mime-type :mime-types)
1128 (initial-add file-filter #'file-filter-add-pattern
1129 initargs :pattern :patterns)))
1132 (defbinding file-filter-add-mime-type () nil
1133 (filter file-filter)
1136 (defbinding file-filter-add-pattern () nil
1137 (filter file-filter)
1140 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1141 (defbinding file-filter-add-pixbuf-formats () nil
1142 (filter file-filter))
1144 (define-callback-marshal %file-filter-callback boolean (file-filter-info))
1146 (defbinding file-filter-add-custom (filter needed function) nil
1147 (filter file-filter)
1148 (needed file-filter-flags)
1149 (%file-filter-callback callback)
1150 ((register-callback-function function) unsigned-int)
1151 (user-data-destroy-callback callback))
1153 (defbinding file-filter-get-needed () file-filter-flags
1154 (filter file-filter))
1156 (defbinding file-filter-filter () boolean
1157 (filter file-filter)
1158 (filter-info file-filter-info))
1164 (defbinding image-set-from-file () nil
1166 (filename pathname))
1168 (defmethod (setf image-pixmap) ((data vector) (image image))
1169 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1170 (setf (image-pixmap image) pixmap)
1171 (setf (image-mask image) mask)))
1173 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1175 ((typep pixmap 'vector)
1176 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1177 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1181 (image-set-from-file image file)))
1182 ((call-next-method))))
1184 (defun create-image-widget (source &optional mask)
1186 (gdk:pixbuf (make-instance 'image :pixbuf source))
1187 (string (make-instance 'image :stock source))
1188 (pathname (make-instance 'image :file source))
1189 ((or list vector) (make-instance 'image :pixmap source))
1190 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1192 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1193 (defbinding image-clear () nil
1200 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1201 (if (and image (not (typep image 'widget)))
1202 (apply #'call-next-method item :image (create-image-widget image) initargs)
1203 (call-next-method)))
1206 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1207 (setf (slot-value item 'image) widget))
1209 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
1210 (setf (image-menu-item-image item) (create-image-widget image)))
1215 (defmethod shared-initialize ((label label) names &key pattern)
1216 (declare (ignore names))
1219 (setf (label-pattern label) pattern)))
1221 (defbinding label-get-layout-offsets () nil
1226 (defbinding label-select-region () nil
1231 (defbinding label-get-selection-bounds () boolean
1240 (defbinding %radio-button-get-group () pointer
1241 (radio-button radio-button))
1243 (defbinding %radio-button-set-group () nil
1244 (radio-button radio-button)
1247 (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
1248 "Add BUTTON1 to the group which BUTTON2 belongs to."
1249 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1251 (defun %add-activate-callback (widget signal function object after)
1253 (signal-connect widget signal
1255 (when (slot-value widget 'active)
1256 (funcall function object (slot-value widget 'value))))
1257 :object object :after after)
1258 (signal-connect widget signal
1260 (when (slot-value widget 'active)
1261 (funcall function (slot-value widget 'value))))
1264 (defmethod activate-radio-widget ((button radio-button))
1265 (signal-emit button 'clicked))
1267 (defgeneric add-activate-callback (action function &key object after))
1269 (defmethod add-activate-callback ((button radio-button) function &key object after)
1270 (%add-activate-callback button 'clicked function object after))
1272 (defmethod initialize-instance ((button radio-button) &key group)
1276 (add-to-radio-group button group))))
1281 (defbinding item-select () nil
1284 (defbinding item-deselect () nil
1287 (defbinding item-toggle () nil
1294 (defmethod initialize-instance ((item menu-item) &key label)
1298 (setf (menu-item-label item) label))))
1301 (defun (setf menu-item-label) (label menu-item)
1302 (make-instance 'accel-label
1303 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
1304 :use-underline (menu-item-use-underline-p menu-item)
1305 :visible t :parent menu-item)
1308 (defun menu-item-label (menu-item)
1309 (when (and (slot-boundp menu-item 'child)
1310 (typep (bin-child menu-item) 'label))
1311 (label-label (bin-child menu-item))))
1313 (defbinding menu-item-remove-submenu () nil
1314 (menu-item menu-item))
1316 (defbinding menu-item-set-accel-path () nil
1317 (menu-item menu-item)
1318 (accel-path string))
1320 (defbinding menu-item-select () nil
1321 (menu-item menu-item))
1323 (defbinding menu-item-deselect () nil
1324 (menu-item menu-item))
1326 (defbinding menu-item-activate () nil
1327 (menu-item menu-item))
1329 (defbinding menu-item-toggle-size-request () nil
1330 (menu-item menu-item)
1331 (requisition int :out))
1333 (defbinding menu-item-toggle-size-allocate () nil
1334 (menu-item menu-item)
1338 ;;; Menu tool button
1340 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1341 (defbinding menu-tool-button-set-arrow-tooltip () nil
1342 (menu-tool-button menu-tool-button)
1345 (tip-private string))
1350 (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1351 button buttons flags transient-parent)
1352 (let ((stock-buttons
1354 ((and (not buttons) (not button))
1358 ((listp buttons) :none)
1360 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1363 (defmethod shared-initialize ((dialog message-dialog) names &rest initargs
1364 &key message-type buttons button text
1365 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1367 (declare (ignore names))
1369 (message-dialog-set-markup dialog text))
1370 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1371 (when secondary-text
1372 (message-dialog-format-secondary-markup dialog secondary-text))
1373 (when (and (not buttons) (not button))
1375 for (key value) on initargs by #'cddr
1376 when (and (eq key :signal) (eq (first value) :close))
1377 do (warn "Default button configuration changed from ~A to ~A" :close
1378 (if (eq message-type :question) :yes-no :ok))
1380 (if (typep buttons 'buttons-type)
1381 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1382 (call-next-method)))
1385 (defbinding %message-dialog-new () pointer
1386 (parent (or null window))
1387 (flags dialog-flags)
1389 (buttons buttons-type)
1392 (defbinding message-dialog-set-markup () nil
1393 (message-dialog message-dialog)
1396 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1397 (defbinding message-dialog-format-secondary-text () nil
1398 (message-dialog message-dialog)
1401 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1402 (defbinding message-dialog-format-secondary-markup () nil
1403 (message-dialog message-dialog)
1410 (defbinding %radio-menu-item-get-group () pointer
1411 (radio-menu-item radio-menu-item))
1413 (defbinding %radio-menu-item-set-group () nil
1414 (radio-menu-item radio-menu-item)
1417 (defmethod activate-radio-widget ((item radio-menu-item))
1418 (menu-item-activate item))
1420 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
1421 "Add ITEM1 to the group which ITEM2 belongs to."
1422 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1424 (defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1425 (%add-activate-callback item 'activate function object after))
1427 (defmethod initialize-instance ((item radio-menu-item) &key group)
1431 (add-to-radio-group item group))))
1435 ;;; Radio tool button
1437 (defbinding %radio-tool-button-get-group () pointer
1438 (radio-tool-button radio-tool-button))
1440 (defbinding %radio-tool-button-set-group () nil
1441 (radio-tool-button radio-tool-button)
1444 (defmethod activate-radio-widget ((button radio-tool-button))
1445 (signal-emit button 'clicked))
1447 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
1448 "Add BUTTON1 to the group which BUTTON2 belongs to."
1449 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
1450 (defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1451 (%add-activate-callback button 'clicked function object after))
1453 (defmethod initialize-instance ((button radio-tool-button) &key group)
1457 (add-to-radio-group button group))))
1463 (defbinding toggle-button-toggled () nil
1464 (toggle-button toggle-button))
1469 (defmethod initialize-instance ((window window) &rest initargs
1470 &key display accel-group accel-groups)
1471 (declare (ignore accel-group accel-groups))
1474 (apply #'call-next-method
1475 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
1477 (initial-add window #'window-add-accel-group
1478 initargs :accel-group :accel-groups)))
1480 #-debug-ref-counting
1481 (defmethod print-object ((window window) stream)
1483 (proxy-valid-p window)
1484 (slot-boundp window 'title)
1485 (not (zerop (length (window-title window)))))
1486 (print-unreadable-object (window stream :type t :identity nil)
1487 (format stream "~S at 0x~X"
1488 (window-title window) (pointer-address (foreign-location window))))
1489 (call-next-method)))
1491 (defbinding window-set-wmclass () nil
1493 (wmclass-name string)
1494 (wmclass-class string))
1496 (defbinding window-add-accel-group () nil
1498 (accel-group accel-group))
1500 (defbinding window-remove-accel-group () nil
1502 (accel-group accel-group))
1504 (defbinding window-activate-focus () int
1507 (defbinding window-activate-default () int
1510 (defbinding window-set-default-size (window width height) int
1513 ((or height -1) int))
1515 (defbinding %window-set-geometry-hints () nil
1517 (widget (or widget null))
1518 (geometry gdk:geometry)
1519 (geometry-mask gdk:window-hints))
1521 (defun window-set-geometry-hints (window &key widget min-width min-height
1522 max-width max-height base-width base-height
1523 width-inc height-inc gravity
1524 aspect (min-aspect aspect) (max-aspect aspect))
1525 (let ((geometry (make-instance 'gdk:geometry
1526 :min-width (or min-width -1)
1527 :min-height (or min-height -1)
1528 :max-width (or max-width -1)
1529 :max-height (or max-height -1)
1530 :base-width (or base-width 0)
1531 :base-height (or base-height 0)
1532 :width-inc (or width-inc 0)
1533 :height-inc (or height-inc 0)
1534 :min-aspect (or min-aspect 0)
1535 :max-aspect (or max-aspect 0)))
1537 (when (or min-width min-height)
1538 (push :min-size mask))
1539 (when (or max-width max-height)
1540 (push :max-size mask))
1541 (when (or base-width base-height)
1542 (push :base-size mask))
1543 (when (or width-inc height-inc)
1544 (push :resize-inc mask))
1545 (when (or min-aspect max-aspect)
1546 (push :aspect mask))
1548 (push :win-gravity mask)
1549 (setf (gdk:geometry-gravity geometry) gravity))
1550 (%window-set-geometry-hints window widget geometry mask)))
1552 (defbinding window-list-toplevels () (glist (copy-of window))
1553 "Returns a list of all existing toplevel windows.")
1555 (defbinding window-add-mnemonic (window key target) nil
1557 ((gdk:keyval-from-name key) unsigned-int)
1560 (defbinding window-remove-mnemonic (window key target) nil
1562 ((gdk:keyval-from-name key) unsigned-int)
1565 (defbinding window-mnemonic-activate (window key modifier) nil
1567 ((gdk:keyval-from-name key) unsigned-int)
1568 (modifier gdk:modifier-type))
1570 (defbinding window-activate-key () boolean
1572 (event gdk:key-event))
1574 (defbinding window-propagate-key-event () boolean
1576 (event gdk:key-event))
1578 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1579 (defbinding window-present () nil
1582 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1584 (defbinding %window-present () nil
1587 (defbinding %window-present-with-time () nil
1589 (timespamp unsigned-int))
1591 (defun window-present (window &optional timestamp)
1593 (%window-present-with-time window timestamp)
1594 (%window-present window))))
1596 (defbinding window-iconify () nil
1599 (defbinding window-deiconify () nil
1602 (defbinding window-stick () nil
1605 (defbinding window-unstick () nil
1608 (defbinding window-maximize () nil
1611 (defbinding window-unmaximize () nil
1614 (defbinding window-fullscreen () nil
1617 (defbinding window-unfullscreen () nil
1620 (defbinding window-set-keep-above () nil
1624 (defbinding window-set-keep-below () nil
1628 (defbinding window-begin-resize-drag () nil
1630 (edge gdk:window-edge)
1632 (root-x int) (root-y int)
1633 (timestamp unsigned-int))
1635 (defbinding window-begin-move-drag () nil
1637 (edge gdk:window-edge)
1639 (root-x int) (root-y int)
1640 (timestamp unsigned-int))
1642 (defbinding window-set-frame-dimensions () nil
1644 (left int) (top int) (rigth int) (bottom int))
1646 (defbinding %window-get-default-size () nil
1651 (defun window-get-default-size (window)
1652 (multiple-value-bind (width height) (%window-get-default-size window)
1653 (values (unless (= width -1) width) (unless (= height -1) height))))
1655 (defbinding window-get-frame-dimensions () nil
1657 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1659 (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
1662 (defbinding window-get-position () nil
1667 (defbinding window-get-size () nil
1672 (defbinding window-move () nil
1677 (defbinding window-parse-geometry () boolean
1681 (defbinding window-reshow-with-initial-size () nil
1684 (defbinding window-resize () nil
1689 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1690 () (glist gdk:pixbuf))
1692 (defun window-default-icon ()
1693 (first (window-default-icon-list)))
1695 (defbinding %window-set-default-icon-list () nil
1696 (icons (glist gdk:pixbuf)))
1698 (defun (setf window-default-icon-list) (icons)
1699 (%window-set-default-icon-list icons)
1702 (defbinding %window-set-default-icon () nil
1705 (defgeneric (setf window-default-icon) (icon))
1707 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1708 (%window-set-default-icon icon)
1711 (defgeneric (setf window-group) (group window))
1713 (defmethod (setf window-group) ((group window-group) (window window))
1714 (window-group-add-window group window)
1717 (defbinding %window-set-default-icon-from-file () boolean
1721 (defmethod (setf window-default-icon) ((icon-file pathname))
1722 (%window-set-default-icon-from-file icon-file)
1725 (defbinding %window-set-icon-from-file () boolean
1730 (defmethod (setf window-icon) ((icon-file pathname) (window window))
1731 (%window-set-icon-from-file window icon-file)
1734 (defbinding window-set-auto-startup-notification () nil
1737 (defbinding decorated-window-init () nil
1740 (defbinding decorated-window-calculate-frame-size () nil
1743 (defbinding decorated-window-set-title () nil
1747 (defbinding decorated-window-move-resize-window () nil
1757 (defmethod initialize-instance ((window-group window-group) &rest initargs
1758 &key window windows)
1759 (declare (ignore window windows))
1762 (initial-add window-group #'window-group-add-window
1763 initargs :window :windows)))
1766 (defbinding window-group-add-window () nil
1767 (window-group window-group)
1770 (defbinding window-group-remove-window () nil
1771 (window-group window-group)
1777 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1778 (setf (scrolled-window-hscrollbar-policy window) policy)
1779 (setf (scrolled-window-vscrollbar-policy window) policy))
1781 (defbinding scrolled-window-add-with-viewport () nil
1782 (scrolled-window scrolled-window)
1785 (defmethod shared-initialize ((window scrolled-window) names &key policy)
1786 (declare (ignore names))
1788 (setf (slot-value window 'hscrollbar-policy) policy)
1789 (setf (slot-value window 'vscrollbar-policy) policy))
1795 (defbinding statusbar-get-context-id () unsigned-int
1796 (statusbar statusbar)
1797 (context-description string))
1799 (defbinding statusbar-push () unsigned-int
1800 (statusbar statusbar)
1801 (context-id unsigned-int)
1804 (defbinding statusbar-pop () nil
1805 (statusbar statusbar)
1806 (context-id unsigned-int))
1808 (defbinding statusbar-remove () nil
1809 (statusbar statusbar)
1810 (context-id unsigned-int)
1811 (message-id unsigned-int))
1817 (defbinding fixed-put () nil
1822 (defbinding fixed-move () nil
1831 (defun %ensure-notebook-position (notebook page)
1834 (widget (notebook-page-num notebook page t))))
1836 (defun %ensure-notebook-child (notebook position)
1839 (t (notebook-get-nth-page notebook position))))
1841 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1842 (notebook position child &optional tab-label menu-label) nil
1845 ((if (stringp tab-label)
1846 (make-instance 'label :label tab-label)
1847 tab-label) (or null widget))
1848 ((if (stringp menu-label)
1849 (make-instance 'label :label menu-label)
1850 menu-label) (or null widget))
1851 ((%ensure-notebook-position notebook position) position))
1853 (defun notebook-append (notebook child &optional tab-label menu-label)
1854 (notebook-insert notebook :last child tab-label menu-label))
1856 (defun notebook-prepend (notebook child &optional tab-label menu-label)
1857 (notebook-insert notebook :first child tab-label menu-label))
1859 (defbinding notebook-remove-page (notebook page) nil
1861 ((%ensure-notebook-position notebook page) position))
1863 (defbinding %notebook-page-num () int
1867 (defun notebook-page-num (notebook child &optional error-p)
1868 (let ((page-num (%notebook-page-num notebook child)))
1871 (error "~A is not a page in ~A" child notebook))
1874 (defbinding notebook-next-page () nil
1875 (notebook notebook))
1877 (defbinding notebook-prev-page () nil
1878 (notebook notebook))
1880 (defbinding notebook-reorder-child (notebook child position) nil
1883 ((%ensure-notebook-position notebook position) int))
1885 (defbinding notebook-popup-enable () nil
1886 (notebook notebook))
1888 (defbinding notebook-popup-disable () nil
1889 (notebook notebook))
1891 (defbinding notebook-get-nth-page () widget
1895 (defun %notebook-current-page (notebook)
1896 (when (slot-boundp notebook 'current-page-num)
1897 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
1899 (defun (setf notebook-current-page) (page notebook)
1900 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
1902 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1903 (notebook page) widget
1905 ((%ensure-notebook-child notebook page) widget))
1907 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1908 (notebook page) (copy-of string)
1910 ((%ensure-notebook-child notebook page) widget))
1912 (defbinding %notebook-set-tab-label () nil
1917 (defun (setf notebook-tab-label) (tab-label notebook page)
1918 (let ((widget (if (stringp tab-label)
1919 (make-instance 'label :label tab-label)
1921 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1925 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1926 (notebook page) widget
1928 ((%ensure-notebook-child notebook page) widget))
1930 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1931 (notebook page) (copy-of string)
1933 ((%ensure-notebook-child notebook page) widget))
1935 (defbinding %notebook-set-menu-label () nil
1938 (menu-label widget))
1940 (defun (setf notebook-menu-label) (menu-label notebook page)
1941 (let ((widget (if (stringp menu-label)
1942 (make-instance 'label :label menu-label)
1944 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1948 (defbinding notebook-query-tab-label-packing (notebook page) nil
1950 ((%ensure-notebook-child notebook page) widget)
1951 (expand boolean :out)
1953 (pack-type pack-type :out))
1955 (defbinding notebook-set-tab-label-packing
1956 (notebook page expand fill pack-type) nil
1958 ((%ensure-notebook-child notebook page) widget)
1961 (pack-type pack-type))
1967 (defbinding paned-pack1 () nil
1973 (defbinding paned-pack2 () nil
1982 (defbinding layout-put () nil
1988 (defbinding layout-move () nil
1994 (defbinding layout-set-size () nil
1996 (width unsigned-int)
1997 (height unsigned-int))
1999 (defbinding layout-get-size () nil
2001 (width unsigned-int :out)
2002 (height unsigned-int :out))
2007 (defbinding menu-shell-insert (menu-shell menu-item position) nil
2008 (menu-shell menu-shell)
2009 (menu-item menu-item)
2015 (defun menu-shell-append (menu-shell menu-item)
2016 (menu-shell-insert menu-shell menu-item :last))
2018 (defun menu-shell-prepend (menu-shell menu-item)
2019 (menu-shell-insert menu-shell menu-item :fisrt))
2021 (defbinding menu-shell-deactivate () nil
2022 (menu-shell menu-shell))
2024 (defbinding menu-shell-select-item () nil
2025 (menu-shell menu-shell)
2026 (menu-item menu-item))
2028 (defbinding menu-shell-select-first () nil
2029 (menu-shell menu-shell)
2030 (search-sensitive boolean))
2032 (defbinding menu-shell-deselect () nil
2033 (menu-shell menu-shell))
2035 (defbinding menu-shell-activate-item () nil
2036 (menu-shell menu-shell)
2037 (menu-item menu-item)
2038 (fore-deactivate boolean))
2040 (defbinding menu-shell-cancel () nil
2041 (menu-shell menu-shell))
2046 (defun %menu-position (menu child)
2049 (keyword (case child
2052 (t (error "Invalid position keyword: ~A" child))))
2053 (widget (menu-child-position menu child))))
2056 (defbinding menu-reorder-child (menu menu-item position) nil
2058 (menu-item menu-item)
2059 ((%menu-position menu position) int))
2061 (defbinding menu-attach () nil
2063 (menu-item menu-item)
2064 (left-attach unsigned-int)
2065 (right-attach unsigned-int)
2066 (top-attach unsigned-int)
2067 (bottom-attach unsigned-int))
2069 (define-callback-marshal %menu-position-callback nil
2070 (menu (x int) (y int) (push-in boolean)))
2072 (defbinding %menu-popup () nil
2074 (parent-menu-shell (or null menu-shell))
2075 (parent-menu-item (or null menu-item))
2076 (callback (or null callback))
2077 (callback-id unsigned-int)
2078 (button unsigned-int)
2079 (activate-time (unsigned 32)))
2081 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
2084 (with-callback-function (id callback)
2086 menu parent-menu-shell parent-menu-item
2087 %menu-position-callback id button activate-time))
2089 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2091 (defbinding menu-set-accel-path () nil
2093 (accel-path string))
2095 (defbinding menu-reposition () nil
2098 (defbinding menu-popdown () nil
2101 (defun menu-child-position (menu child)
2102 (position child (container-children menu)))
2104 (defun menu-active-num (menu)
2105 (menu-child-position menu (menu-active menu)))
2107 (defbinding %menu-set-active () nil
2109 (index unsigned-int))
2111 (defun (setf menu-active) (menu child)
2112 (%menu-set-active menu (%menu-position menu child))
2115 (define-callback %menu-detach-callback nil ((widget widget) (menu menu))
2116 (funcall (user-data menu 'detach-func) widget menu))
2118 (defbinding %menu-attach-to-widget (menu widget) nil
2121 (%menu-detach-callback callback))
2123 (defun menu-attach-to-widget (menu widget function)
2124 (setf (user-data menu 'detach-func) function)
2125 (%menu-attach-to-widget menu widget))
2127 (defbinding menu-detach () nil
2130 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2131 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2134 (defbinding menu-set-monitor () nil
2141 (defbinding table-resize () nil
2144 (columns unsigned-int))
2146 (defbinding table-attach (table child left right top bottom
2147 &key options x-options y-options
2148 (x-padding 0) (y-padding 0)) nil
2152 (right unsigned-int)
2154 (bottom unsigned-int)
2155 ((append (mklist options) (mklist x-options)) attach-options)
2156 ((append (mklist options) (mklist y-options)) attach-options)
2157 (x-padding unsigned-int)
2158 (y-padding unsigned-int))
2161 (defbinding %table-set-row-spacing () nil
2164 (spacing unsigned-int))
2166 (defbinding %table-set-row-spacings () nil
2168 (spacing unsigned-int))
2170 (defun (setf table-row-spacing) (spacing table &optional row)
2172 (%table-set-row-spacing table row spacing)
2173 (%table-set-row-spacings table spacing))
2176 (defbinding %table-get-row-spacing () unsigned-int
2180 (defbinding %table-get-default-row-spacing () unsigned-int
2183 (defun table-row-spacing (table &optional row)
2185 (%table-get-row-spacing table row)
2186 (%table-get-default-row-spacing table)))
2189 (defbinding %table-set-col-spacing () nil
2192 (spacing unsigned-int))
2194 (defbinding %table-set-col-spacings () nil
2196 (spacing unsigned-int))
2198 (defun (setf table-column-spacing) (spacing table &optional column)
2200 (%table-set-col-spacing table column spacing)
2201 (%table-set-col-spacings table spacing))
2204 (defun (setf table-col-spacing) (spacing table &optional col)
2205 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2206 (setf (table-column-spacing table col) spacing))
2208 (defbinding %table-get-col-spacing () unsigned-int
2212 (defbinding %table-get-default-col-spacing () unsigned-int
2215 (defun table-column-spacing (table &optional column)
2217 (%table-get-col-spacing table column)
2218 (%table-get-default-col-spacing table)))
2220 (defun table-col-spacing (table &optional col)
2221 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2222 (table-column-spacing table col))
2228 (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2230 (apply #'call-next-method toolbar
2231 :tooltips (make-instance 'tooltips) initargs)
2232 (call-next-method)))
2234 (defbinding %toolbar-insert () nil
2236 (tool-item tool-item)
2237 (position position))
2239 (defun toolbar-insert (toolbar tool-item &optional (position :end))
2240 (%toolbar-insert toolbar tool-item position)
2241 (%tool-item-update-tooltips tool-item))
2243 (defbinding toolbar-get-item-index () int
2247 (defbinding toolbar-get-nth-item () tool-item
2251 (defbinding toolbar-get-drop-index () int
2255 (defbinding toolbar-set-drop-highlight-item () nil
2257 (tool-item tool-item)
2263 (defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2264 (if (and icon (not (typep icon 'widget)))
2265 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2266 (call-next-method)))
2271 (defbinding tool-item-set-tooltip () nil
2272 (tool-item tool-item)
2275 (tip-private string))
2278 (defun %tool-item-update-tooltips (tool-item)
2280 (slot-boundp tool-item 'parent)
2282 (user-data-p tool-item 'tip-text)
2283 (user-data-p tool-item 'tip-private)))
2284 (tool-item-set-tooltip
2285 tool-item (toolbar-tooltips (widget-parent tool-item))
2286 (or (user-data tool-item 'tip-text) "")
2287 (or (user-data tool-item 'tip-private) ""))))
2289 (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2290 (setf (user-data tool-item 'tip-text) tip-text)
2291 (%tool-item-update-tooltips tool-item)
2294 (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2295 (setf (user-data tool-item 'tip-private) tip-private)
2296 (%tool-item-update-tooltips tool-item)
2299 (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2300 (declare (ignore args))
2303 (%tool-item-update-tooltips tool-item)))
2306 (defbinding tool-item-retrieve-proxy-menu-item () widget
2307 (tool-item tool-item))
2309 (defbinding (tool-item-proxy-menu-item
2310 "gtk_tool_item_get_proxy_menu_item") () menu-item
2311 (tool-item tool-item)
2312 (menu-item-id string))
2314 (defbinding %tool-item-set-proxy-menu-item () nil
2315 (tool-item tool-item)
2316 (menu-item-id string)
2317 (menu-item menu-item))
2319 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2320 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2323 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2324 (defbinding tool-item-rebuild-menu () nil
2325 (tool-item tool-item))
2330 (defbinding editable-select-region (editable &optional (start 0) end) nil
2335 (defbinding editable-get-selection-bounds (editable) nil
2340 (defbinding editable-insert-text (editable text &optional (position 0)) nil
2344 (position position :in/out))
2346 (defun editable-append-text (editable text)
2347 (editable-insert-text editable text nil))
2349 (defun editable-prepend-text (editable text)
2350 (editable-insert-text editable text 0))
2352 (defbinding editable-delete-text (editable &optional (start 0) end) nil
2357 (defbinding (editable-text "gtk_editable_get_chars")
2358 (editable &optional (start 0) end) string
2363 (defun (setf editable-text) (text editable)
2365 (editable-delete-text
2367 (editable-insert-text editable text))
2368 (editable-delete-text editable))
2371 (defbinding editable-cut-clipboard () nil
2372 (editable editable))
2374 (defbinding editable-copy-clipboard () nil
2375 (editable editable))
2377 (defbinding editable-paste-clipboard () nil
2378 (editable editable))
2380 (defbinding editable-delete-selection () nil
2381 (editable editable))
2387 (defbinding spin-button-configure () nil
2388 (spin-button spin-button)
2389 (adjustment adjustment)
2390 (climb-rate double-float)
2391 (digits unsigned-int))
2393 (defbinding spin-button-set-range () nil
2394 (spin-button spin-button)
2398 (defbinding spin-button-get-range () nil
2399 (spin-button spin-button)
2400 (min double-float :out)
2401 (max double-float :out))
2403 (defun spin-button-value-as-int (spin-button)
2404 (round (spin-button-value spin-button)))
2406 (defbinding %spin-button-spin () nil
2407 (spin-button spin-button)
2408 (direction spin-type)
2409 (increment double-float))
2411 (defun spin-button-spin (spin-button value)
2413 (real (%spin-button-spin spin-button :user-defined value))
2414 (spin-type (%spin-button-spin spin-button value 0))))
2417 (defbinding spin-button-update () nil
2418 (spin-button spin-button))
2424 (defbinding ruler-set-range () nil
2426 (lower single-float)
2427 (upper single-float)
2428 (position single-float)
2429 (max-size single-float))
2431 (defbinding ruler-get-range () nil
2433 (lower single-float :out)
2434 (upper single-float :out)
2435 (position single-float :out)
2436 (max-size single-float :out))
2442 (defun range-lower (range)
2443 (adjustment-lower (range-adjustment range)))
2445 (defun range-upper (range)
2446 (adjustment-upper (range-adjustment range)))
2448 (defun (setf range-lower) (value range)
2449 (setf (adjustment-lower (range-adjustment range)) value))
2451 (defun (setf range-upper) (value range)
2452 (setf (adjustment-upper (range-adjustment range)) value))
2454 (defun range-page-increment (range)
2455 (adjustment-page-increment (range-adjustment range)))
2457 (defun range-step-increment (range)
2458 (adjustment-step-increment (range-adjustment range)))
2460 (defun (setf range-page-increment) (value range)
2461 (setf (adjustment-page-increment (range-adjustment range)) value))
2463 (defun (setf range-step-increment) (value range)
2464 (setf (adjustment-step-increment (range-adjustment range)) value))
2466 (defbinding range-set-range () nil
2468 (lower double-float)
2469 (upper double-float))
2471 (defbinding range-set-increments () nil
2474 (page double-float))
2479 (defbinding scale-get-layout-offsets () nil
2487 (defbinding progress-bar-pulse () nil
2488 (progress-bar progress-bar))
2493 (defmethod initialize-instance ((size-group size-group) &rest initargs
2494 &key widget widgets)
2495 (declare (ignore widget widgets))
2498 (initial-add size-group #'size-group-add-widget
2499 initargs :widget :widgets)))
2502 (defbinding size-group-add-widget () nil
2503 (size-group size-group)
2506 (defbinding size-group-remove-widget () nil
2507 (size-group size-group)
2513 (defbinding %stock-item-copy () pointer
2516 (defbinding %stock-item-free () nil
2519 (defbinding stock-add (stock-item) nil
2520 (stock-item stock-item)
2523 (defbinding stock-list-ids () (gslist string))
2525 (defbinding %stock-lookup () boolean
2529 (defun stock-lookup (stock-id)
2530 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
2531 (when (%stock-lookup stock-id stock-item)
2532 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
2534 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
2536 (define-callback-marshal %stock-translate-callback string ((path string)))
2538 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2539 (domain function) nil
2541 (%stock-translate-callback callback)
2542 ((register-callback-function function) unsigned-int)
2543 (user-data-destroy-callback callback)))
2548 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2550 (defbinding tooltip-set-markup () nil
2554 (defbinding tooltip-set-text () nil
2558 (defbinding %tooltip-set-icon () nil
2562 (defbinding %tooltip-set-icon-from-stock () nil
2567 (defun tooltip-set-icon (tooltip icon &key (size :button))
2569 (gdk:pixbuf (%tooltip-set-icon tooltip icon))
2570 (string (%tooltip-set-icon-from-stock tooltip icon size))))
2572 (defbinding tooltip-set-custom () nil
2576 (defbinding tooltip-trigger-tooltip-query (&optional (display (gdk:display-get-default))) nil
2577 (display gdk:display))
2579 (defbinding tooltip-set-tip-area () nil
2587 ;; GtkTooltips has been deprecated in favor of the new tooltip API
2588 ;; introduced in in GTK+ 2.12
2590 (defbinding tooltips-enable () nil
2591 (tooltips tooltips))
2593 (defbinding tooltips-disable () nil
2594 (tooltips tooltips))
2596 (defun (setf tooltips-enabled-p) (enable tooltips)
2598 (tooltips-enable tooltips)
2599 (tooltips-disable tooltips)))
2601 (defbinding tooltips-set-tip () nil
2605 (tip-private string))
2607 (defbinding tooltips-data-get () tooltips-data
2610 (defbinding tooltips-force-window () nil
2611 (tooltips tooltips))
2613 (defbinding tooltips-get-info-from-tip-window () boolean
2615 (tooltips tooltips :out)
2616 (current-widget widget :out))
2621 (defbinding rc-get-style () style
2624 (defbinding rc-get-style-by-paths (&key path class-path class) style
2625 (path (or null string))
2626 (class-path (or null string))
2629 (defbinding rc-parse () nil
2630 (filename pathname))
2632 (defbinding rc-parse-string () nil
2635 (defbinding %rc-reparse-all () boolean)
2637 (defbinding %rc-reparse-all-for-settings () boolean
2639 (force-load-p boolean))
2641 (defun rc-reparse-all (&optional setting force-load-p)
2643 (%rc-reparse-all-for-settings setting force-load-p)
2646 (defbinding rc-reset-styles () nil
2647 (settings settings))
2649 (defbinding rc-add-default-file () nil
2650 (filename pathname))
2652 (defbinding rc-get-default-files ()
2653 (copy-of (null-terminated-vector (copy-of string))))
2655 (defbinding rc-get-module-dir () string)
2657 (defbinding rc-get-im-module-path () string)
2659 (defbinding rc-get-im-module-file () string)
2661 (defbinding rc-get-theme-dir () string)
2666 (defbinding (settings-get "gtk_settings_get_for_screen")
2667 (&optional (screen (gdk:display-get-default-screen))) settings
2668 (screen gdk:screen))
2673 (defbinding socket-add-id () nil
2675 (id gdk:native-window))
2677 (defbinding %plug-new () pointer
2678 (id gdk:native-window))
2680 (defmethod allocate-foreign ((plug plug) &key id)
2681 (%plug-new (or id 0)))
2686 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2688 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2690 (defbinding link-button-set-uri-hook (function) pointer
2691 (%link-button-uri-callback callback)
2692 ((register-callback-function function) unsigned-int)
2693 (user-data-destroy-callback callback)))
2698 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2700 (defmethod initialize-instance ((builder builder) &key interface
2701 (connect-signals t) (package *package*))
2703 (etypecase interface
2705 (string (builder-add-from-string builder interface))
2706 (pathname (builder-add-from-file builder interface)))
2707 (when connect-signals
2708 (builder-connect-signals builder package)))
2711 (defbinding builder-add-from-file () boolean
2714 (nil gerror-signal :out))
2716 (defbinding builder-add-from-string () boolean
2719 (-1 int) ; TODO: add gsize type
2720 (nil gerror-signal :out))
2722 (defbinding builder-get-object () gobject
2726 (defbinding builder-get-objects () (gslist gobject)
2729 (defun intern-with-package-prefix (name default-package)
2730 (let ((pos (position #\: name)))
2733 (string-upcase (subseq name (1+ pos)))
2734 (string-upcase (subseq name 0 pos)))
2735 (intern (string-upcase name) default-package))))
2737 (define-callback %builder-connect-function nil
2738 (builder (object gobject) (signal-name string) (handler-name string)
2739 (connect-object gobject) connect-flags (package user-data-id))
2740 (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)
2743 (intern-with-package-prefix handler-name (find-user-data package))
2744 :object (or connect-object object) :after (find :after connect-flags)))
2746 (defbinding %builder-connect-signals-full (builder package) nil
2748 (%builder-connect-function callback)
2749 (package user-data-id))
2751 (defun builder-connect-signals (builder &optional (package *package*))
2752 (with-user-data (id package)
2753 (%builder-connect-signals-full builder id))))