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 () int
870 (defun dialog-run (dialog)
871 (dialog-find-response dialog (%dialog-run dialog)))
873 (defbinding dialog-response (dialog response) nil
875 ((dialog-response-id dialog response nil t) int))
878 (defbinding %dialog-add-button () button
883 (defun dialog-add-button (dialog label &optional (response label)
884 &key default object after)
885 "Adds a button to the dialog."
886 (let* ((signal (if (functionp response)
889 (id (dialog-response-id dialog signal t))
890 (button (%dialog-add-button dialog label id)))
891 (when (functionp response)
892 (signal-connect dialog signal response :object object :after after))
894 (%dialog-set-default-response dialog id))
898 (defbinding %dialog-add-action-widget () nil
900 (action-widget widget)
903 (defun dialog-add-action-widget (dialog widget &optional (response widget)
904 &key default object after)
905 (let* ((signal (if (functionp response)
908 (id (dialog-response-id dialog signal t)))
909 (unless (widget-hidden-p widget)
910 (widget-show widget))
911 (%dialog-add-action-widget dialog widget id)
912 (when (functionp response)
913 (signal-connect dialog signal response :object object :after after))
915 (setf (widget-can-default-p widget) t)
916 (%dialog-set-default-response dialog id))
920 (defbinding %dialog-set-default-response () nil
924 (defun dialog-set-default-response (dialog response)
925 (%dialog-set-default-response
926 dialog (dialog-response-id dialog response nil t)))
928 (defbinding dialog-set-response-sensitive (dialog response sensitive) nil
930 ((dialog-response-id dialog response nil t) int)
933 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
934 (defbinding alternative-dialog-button-order-p (&optional screen) boolean
935 (screen (or null gdk:screen)))
937 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
938 (defbinding (dialog-set-alternative-button-order
939 "gtk_dialog_set_alternative_button_order_from_array")
940 (dialog new-order) nil
942 ((length new-order) int)
943 ((map 'vector #'(lambda (response)
944 (dialog-response-id dialog response nil t))
945 new-order) (vector int)))
948 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
950 (defbinding %dialog-get-response-for-widget () int
954 (defun dialog-get-response-for-widget (dialog widget)
955 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
958 (defmethod container-add ((dialog dialog) (child widget) &rest args)
959 (apply #'container-add (dialog-vbox dialog) child args))
962 (defmethod container-remove ((dialog dialog) (child widget))
963 (container-remove (dialog-vbox dialog) child))
965 (defmethod container-children ((dialog dialog))
966 (container-children (dialog-vbox dialog)))
968 (defmethod (setf container-children) (children (dialog dialog))
969 (setf (container-children (dialog-vbox dialog)) children))
974 (defun drawing-area-scroll (drawing-area dx dy)
975 (gdk:window-scroll (widget-window drawing-area) dx dy))
980 (defbinding entry-get-layout-offsets () nil
985 (defbinding entry-layout-index-to-text-index () int
989 (defbinding entry-text-index-to-layout-index () int
996 (define-callback-marshal %entry-completion-match-callback boolean
997 (entry-completion string tree-iter))
999 (defbinding entry-completion-set-match-func (completion function) nil
1000 (completion entry-completion)
1001 (%entry-completion-match-callback callback)
1002 ((register-callback-function function) unsigned-int)
1003 (user-data-destroy-callback callback))
1005 (defbinding entry-completion-complete () nil
1006 (completion entry-completion))
1008 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
1009 (defbinding entry-completion-get-completion-prefix () string
1010 (completion entry-completion))
1012 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1013 (defbinding entry-completion-insert-prefix () nil
1014 (completion entry-completion))
1016 (defbinding entry-completion-insert-action-text () nil
1017 (completion entry-completion)
1021 (defbinding entry-completion-insert-action-markup () nil
1022 (completion entry-completion)
1026 (defbinding entry-completion-delete-action () nil
1027 (completion entry-completion)
1033 (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
1034 &key filter filters shortcut-folder
1035 shortcut-folders shortcut-folder-uti
1036 shortcut-folder-uris)
1037 (declare (ignore filter filters shortcut-folder shortcut-folders
1038 shortcut-folder-uti shortcut-folder-uris))
1041 (initial-add file-chooser #'file-chooser-add-filter
1042 initargs :filer :filters)
1043 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1044 initargs :shortcut-folder :shortcut-folders)
1045 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1046 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1049 (defbinding file-chooser-select-filename () boolean
1050 (file-chooser file-chooser)
1053 (defbinding file-chooser-unselect-filename () nil
1054 (file-chooser file-chooser)
1057 (defbinding file-chooser-select-all () boolean
1058 (file-chooser file-chooser))
1060 (defbinding file-chooser-unselect-all () boolean
1061 (file-chooser file-chooser))
1063 (defbinding file-chooser-get-filenames () (gslist string)
1064 (file-chooser file-chooser))
1066 (defbinding file-chooser-select-uri () boolean
1067 (file-chooser file-chooser)
1070 (defbinding file-chooser-unselect-uri () nil
1071 (file-chooser file-chooser)
1074 (defbinding file-chooser-get-uris () (gslist string)
1075 (file-chooser file-chooser))
1077 (defbinding file-chooser-add-filter () nil
1078 (file-chooser file-chooser)
1079 (filter file-filter))
1081 (defbinding file-chooser-remove-filter () nil
1082 (file-chooser file-chooser)
1083 (filter file-filter))
1085 (defbinding file-chooser-list-filters () (gslist file-filter)
1086 (file-chooser file-chooser))
1088 (defbinding file-chooser-add-shortcut-folder () boolean
1089 (file-chooser file-chooser)
1093 (defbinding file-chooser-remove-shortcut-folder () nil
1094 (file-chooser file-chooser)
1098 (defbinding file-chooser-list-shortcut-folders () (gslist string)
1099 (file-chooser file-chooser))
1101 (defbinding file-chooser-add-shortcut-folder-uri () boolean
1102 (file-chooser file-chooser)
1106 (defbinding file-chooser-remove-shortcut-folder-uri () nil
1107 (file-chooser file-chooser)
1111 (defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1112 (file-chooser file-chooser))
1117 (defmethod initialize-instance ((file-filter file-filter) &rest initargs
1118 &key mime-type mime-types pattern patterns
1120 (declare (ignore mime-type mime-types pattern patterns))
1123 (when pixbuf-formats
1124 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1125 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1126 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1127 (file-filter-add-pixbuf-formats file-filter))
1128 (initial-add file-filter #'file-filter-add-mime-type
1129 initargs :mime-type :mime-types)
1130 (initial-add file-filter #'file-filter-add-pattern
1131 initargs :pattern :patterns)))
1134 (defbinding file-filter-add-mime-type () nil
1135 (filter file-filter)
1138 (defbinding file-filter-add-pattern () nil
1139 (filter file-filter)
1142 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1143 (defbinding file-filter-add-pixbuf-formats () nil
1144 (filter file-filter))
1146 (define-callback-marshal %file-filter-callback boolean (file-filter-info))
1148 (defbinding file-filter-add-custom (filter needed function) nil
1149 (filter file-filter)
1150 (needed file-filter-flags)
1151 (%file-filter-callback callback)
1152 ((register-callback-function function) unsigned-int)
1153 (user-data-destroy-callback callback))
1155 (defbinding file-filter-get-needed () file-filter-flags
1156 (filter file-filter))
1158 (defbinding file-filter-filter () boolean
1159 (filter file-filter)
1160 (filter-info file-filter-info))
1166 (defbinding image-set-from-file () nil
1168 (filename pathname))
1170 (defmethod (setf image-pixmap) ((data vector) (image image))
1171 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1172 (setf (image-pixmap image) pixmap)
1173 (setf (image-mask image) mask)))
1175 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1177 ((typep pixmap 'vector)
1178 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1179 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1183 (image-set-from-file image file)))
1184 ((call-next-method))))
1186 (defun create-image-widget (source &optional mask)
1188 (gdk:pixbuf (make-instance 'image :pixbuf source))
1189 (string (make-instance 'image :stock source))
1190 (pathname (make-instance 'image :file source))
1191 ((or list vector) (make-instance 'image :pixmap source))
1192 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1194 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1195 (defbinding image-clear () nil
1202 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1203 (if (and image (not (typep image 'widget)))
1204 (apply #'call-next-method item :image (create-image-widget image) initargs)
1205 (call-next-method)))
1208 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1209 (setf (slot-value item 'image) widget))
1211 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
1212 (setf (image-menu-item-image item) (create-image-widget image)))
1217 (defmethod shared-initialize ((label label) names &key pattern)
1218 (declare (ignore names))
1221 (setf (label-pattern label) pattern)))
1223 (defbinding label-get-layout-offsets () nil
1228 (defbinding label-select-region () nil
1233 (defbinding label-get-selection-bounds () boolean
1242 (defbinding %radio-button-get-group () pointer
1243 (radio-button radio-button))
1245 (defbinding %radio-button-set-group () nil
1246 (radio-button radio-button)
1249 (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
1250 "Add BUTTON1 to the group which BUTTON2 belongs to."
1251 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1253 (defun %add-activate-callback (widget signal function object after)
1255 (signal-connect widget signal
1257 (when (slot-value widget 'active)
1258 (funcall function object (slot-value widget 'value))))
1259 :object object :after after)
1260 (signal-connect widget signal
1262 (when (slot-value widget 'active)
1263 (funcall function (slot-value widget 'value))))
1266 (defmethod activate-radio-widget ((button radio-button))
1267 (signal-emit button 'clicked))
1269 (defgeneric add-activate-callback (action function &key object after))
1271 (defmethod add-activate-callback ((button radio-button) function &key object after)
1272 (%add-activate-callback button 'clicked function object after))
1274 (defmethod initialize-instance ((button radio-button) &key group)
1278 (add-to-radio-group button group))))
1283 (defbinding item-select () nil
1286 (defbinding item-deselect () nil
1289 (defbinding item-toggle () nil
1296 (defmethod initialize-instance ((item menu-item) &key label)
1300 (setf (menu-item-label item) label))))
1303 (defun (setf menu-item-label) (label menu-item)
1304 (make-instance 'accel-label
1305 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
1306 :use-underline (menu-item-use-underline-p menu-item)
1307 :visible t :parent menu-item)
1310 (defun menu-item-label (menu-item)
1311 (when (and (slot-boundp menu-item 'child)
1312 (typep (bin-child menu-item) 'label))
1313 (label-label (bin-child menu-item))))
1315 (defbinding menu-item-remove-submenu () nil
1316 (menu-item menu-item))
1318 (defbinding menu-item-set-accel-path () nil
1319 (menu-item menu-item)
1320 (accel-path string))
1322 (defbinding menu-item-select () nil
1323 (menu-item menu-item))
1325 (defbinding menu-item-deselect () nil
1326 (menu-item menu-item))
1328 (defbinding menu-item-activate () nil
1329 (menu-item menu-item))
1331 (defbinding menu-item-toggle-size-request () nil
1332 (menu-item menu-item)
1333 (requisition int :out))
1335 (defbinding menu-item-toggle-size-allocate () nil
1336 (menu-item menu-item)
1340 ;;; Menu tool button
1342 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1343 (defbinding menu-tool-button-set-arrow-tooltip () nil
1344 (menu-tool-button menu-tool-button)
1347 (tip-private string))
1352 (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1353 button buttons flags transient-parent)
1354 (let ((stock-buttons
1356 ((and (not buttons) (not button))
1360 ((listp buttons) :none)
1362 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1365 (defmethod shared-initialize ((dialog message-dialog) names &rest initargs
1366 &key message-type buttons button text
1367 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1369 (declare (ignore names))
1371 (message-dialog-set-markup dialog text))
1372 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1373 (when secondary-text
1374 (message-dialog-format-secondary-markup dialog secondary-text))
1375 (when (and (not buttons) (not button))
1377 for (key value) on initargs by #'cddr
1378 when (and (eq key :signal) (eq (first value) :close))
1379 do (warn "Default button configuration changed from ~A to ~A" :close
1380 (if (eq message-type :question) :yes-no :ok))
1382 (if (typep buttons 'buttons-type)
1383 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1384 (call-next-method)))
1387 (defbinding %message-dialog-new () pointer
1388 (parent (or null window))
1389 (flags dialog-flags)
1391 (buttons buttons-type)
1394 (defbinding message-dialog-set-markup () nil
1395 (message-dialog message-dialog)
1398 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1399 (defbinding message-dialog-format-secondary-text () nil
1400 (message-dialog message-dialog)
1403 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1404 (defbinding message-dialog-format-secondary-markup () nil
1405 (message-dialog message-dialog)
1412 (defbinding %radio-menu-item-get-group () pointer
1413 (radio-menu-item radio-menu-item))
1415 (defbinding %radio-menu-item-set-group () nil
1416 (radio-menu-item radio-menu-item)
1419 (defmethod activate-radio-widget ((item radio-menu-item))
1420 (menu-item-activate item))
1422 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
1423 "Add ITEM1 to the group which ITEM2 belongs to."
1424 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1426 (defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1427 (%add-activate-callback item 'activate function object after))
1429 (defmethod initialize-instance ((item radio-menu-item) &key group)
1433 (add-to-radio-group item group))))
1437 ;;; Radio tool button
1439 (defbinding %radio-tool-button-get-group () pointer
1440 (radio-tool-button radio-tool-button))
1442 (defbinding %radio-tool-button-set-group () nil
1443 (radio-tool-button radio-tool-button)
1446 (defmethod activate-radio-widget ((button radio-tool-button))
1447 (signal-emit button 'clicked))
1449 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
1450 "Add BUTTON1 to the group which BUTTON2 belongs to."
1451 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
1452 (defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1453 (%add-activate-callback button 'clicked function object after))
1455 (defmethod initialize-instance ((button radio-tool-button) &key group)
1459 (add-to-radio-group button group))))
1465 (defbinding toggle-button-toggled () nil
1466 (toggle-button toggle-button))
1471 (defmethod initialize-instance ((window window) &rest initargs
1472 &key display accel-group accel-groups)
1473 (declare (ignore accel-group accel-groups))
1476 (apply #'call-next-method
1477 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
1479 (initial-add window #'window-add-accel-group
1480 initargs :accel-group :accel-groups)))
1482 #-debug-ref-counting
1483 (defmethod print-object ((window window) stream)
1485 (proxy-valid-p window)
1486 (slot-boundp window 'title)
1487 (not (zerop (length (window-title window)))))
1488 (print-unreadable-object (window stream :type t :identity nil)
1489 (format stream "~S at 0x~X"
1490 (window-title window) (pointer-address (foreign-location window))))
1491 (call-next-method)))
1493 (defbinding window-set-wmclass () nil
1495 (wmclass-name string)
1496 (wmclass-class string))
1498 (defbinding window-add-accel-group () nil
1500 (accel-group accel-group))
1502 (defbinding window-remove-accel-group () nil
1504 (accel-group accel-group))
1506 (defbinding window-activate-focus () int
1509 (defbinding window-activate-default () int
1512 (defbinding window-set-default-size (window width height) int
1515 ((or height -1) int))
1517 (defbinding %window-set-geometry-hints () nil
1519 (widget (or widget null))
1520 (geometry gdk:geometry)
1521 (geometry-mask gdk:window-hints))
1523 (defun window-set-geometry-hints (window &key widget min-width min-height
1524 max-width max-height base-width base-height
1525 width-inc height-inc gravity
1526 aspect (min-aspect aspect) (max-aspect aspect))
1527 (let ((geometry (make-instance 'gdk:geometry
1528 :min-width (or min-width -1)
1529 :min-height (or min-height -1)
1530 :max-width (or max-width -1)
1531 :max-height (or max-height -1)
1532 :base-width (or base-width 0)
1533 :base-height (or base-height 0)
1534 :width-inc (or width-inc 0)
1535 :height-inc (or height-inc 0)
1536 :min-aspect (or min-aspect 0)
1537 :max-aspect (or max-aspect 0)))
1539 (when (or min-width min-height)
1540 (push :min-size mask))
1541 (when (or max-width max-height)
1542 (push :max-size mask))
1543 (when (or base-width base-height)
1544 (push :base-size mask))
1545 (when (or width-inc height-inc)
1546 (push :resize-inc mask))
1547 (when (or min-aspect max-aspect)
1548 (push :aspect mask))
1550 (push :win-gravity mask)
1551 (setf (gdk:geometry-gravity geometry) gravity))
1552 (%window-set-geometry-hints window widget geometry mask)))
1554 (defbinding window-list-toplevels () (glist (copy-of window))
1555 "Returns a list of all existing toplevel windows.")
1557 (defbinding window-add-mnemonic (window key target) nil
1559 ((gdk:keyval-from-name key) unsigned-int)
1562 (defbinding window-remove-mnemonic (window key target) nil
1564 ((gdk:keyval-from-name key) unsigned-int)
1567 (defbinding window-mnemonic-activate (window key modifier) nil
1569 ((gdk:keyval-from-name key) unsigned-int)
1570 (modifier gdk:modifier-type))
1572 (defbinding window-activate-key () boolean
1574 (event gdk:key-event))
1576 (defbinding window-propagate-key-event () boolean
1578 (event gdk:key-event))
1580 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1581 (defbinding window-present () nil
1584 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1586 (defbinding %window-present () nil
1589 (defbinding %window-present-with-time () nil
1591 (timespamp unsigned-int))
1593 (defun window-present (window &optional timestamp)
1595 (%window-present-with-time window timestamp)
1596 (%window-present window))))
1598 (defbinding window-iconify () nil
1601 (defbinding window-deiconify () nil
1604 (defbinding window-stick () nil
1607 (defbinding window-unstick () nil
1610 (defbinding window-maximize () nil
1613 (defbinding window-unmaximize () nil
1616 (defbinding window-fullscreen () nil
1619 (defbinding window-unfullscreen () nil
1622 (defbinding window-set-keep-above () nil
1626 (defbinding window-set-keep-below () nil
1630 (defbinding window-begin-resize-drag () nil
1632 (edge gdk:window-edge)
1634 (root-x int) (root-y int)
1635 (timestamp unsigned-int))
1637 (defbinding window-begin-move-drag () nil
1639 (edge gdk:window-edge)
1641 (root-x int) (root-y int)
1642 (timestamp unsigned-int))
1644 (defbinding window-set-frame-dimensions () nil
1646 (left int) (top int) (rigth int) (bottom int))
1648 (defbinding %window-get-default-size () nil
1653 (defun window-get-default-size (window)
1654 (multiple-value-bind (width height) (%window-get-default-size window)
1655 (values (unless (= width -1) width) (unless (= height -1) height))))
1657 (defbinding window-get-frame-dimensions () nil
1659 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1661 (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
1664 (defbinding window-get-position () nil
1669 (defbinding window-get-size () nil
1674 (defbinding window-move () nil
1679 (defbinding window-parse-geometry () boolean
1683 (defbinding window-reshow-with-initial-size () nil
1686 (defbinding window-resize () nil
1691 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1692 () (glist gdk:pixbuf))
1694 (defun window-default-icon ()
1695 (first (window-default-icon-list)))
1697 (defbinding %window-set-default-icon-list () nil
1698 (icons (glist gdk:pixbuf)))
1700 (defun (setf window-default-icon-list) (icons)
1701 (%window-set-default-icon-list icons)
1704 (defbinding %window-set-default-icon () nil
1707 (defgeneric (setf window-default-icon) (icon))
1709 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1710 (%window-set-default-icon icon)
1713 (defgeneric (setf window-group) (group window))
1715 (defmethod (setf window-group) ((group window-group) (window window))
1716 (window-group-add-window group window)
1719 (defbinding %window-set-default-icon-from-file () boolean
1723 (defmethod (setf window-default-icon) ((icon-file pathname))
1724 (%window-set-default-icon-from-file icon-file)
1727 (defbinding %window-set-icon-from-file () boolean
1732 (defmethod (setf window-icon) ((icon-file pathname) (window window))
1733 (%window-set-icon-from-file window icon-file)
1736 (defbinding window-set-auto-startup-notification () nil
1739 (defbinding decorated-window-init () nil
1742 (defbinding decorated-window-calculate-frame-size () nil
1745 (defbinding decorated-window-set-title () nil
1749 (defbinding decorated-window-move-resize-window () nil
1759 (defmethod initialize-instance ((window-group window-group) &rest initargs
1760 &key window windows)
1761 (declare (ignore window windows))
1764 (initial-add window-group #'window-group-add-window
1765 initargs :window :windows)))
1768 (defbinding window-group-add-window () nil
1769 (window-group window-group)
1772 (defbinding window-group-remove-window () nil
1773 (window-group window-group)
1779 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1780 (setf (scrolled-window-hscrollbar-policy window) policy)
1781 (setf (scrolled-window-vscrollbar-policy window) policy))
1783 (defbinding scrolled-window-add-with-viewport () nil
1784 (scrolled-window scrolled-window)
1787 (defmethod shared-initialize ((window scrolled-window) names &key policy)
1788 (declare (ignore names))
1790 (setf (slot-value window 'hscrollbar-policy) policy)
1791 (setf (slot-value window 'vscrollbar-policy) policy))
1797 (defbinding statusbar-get-context-id () unsigned-int
1798 (statusbar statusbar)
1799 (context-description string))
1801 (defbinding statusbar-push () unsigned-int
1802 (statusbar statusbar)
1803 (context-id unsigned-int)
1806 (defbinding statusbar-pop () nil
1807 (statusbar statusbar)
1808 (context-id unsigned-int))
1810 (defbinding statusbar-remove () nil
1811 (statusbar statusbar)
1812 (context-id unsigned-int)
1813 (message-id unsigned-int))
1819 (defbinding fixed-put () nil
1824 (defbinding fixed-move () nil
1833 (defun %ensure-notebook-position (notebook page)
1836 (widget (notebook-page-num notebook page t))))
1838 (defun %ensure-notebook-child (notebook position)
1841 (t (notebook-get-nth-page notebook position))))
1843 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1844 (notebook position child &optional tab-label menu-label) nil
1847 ((if (stringp tab-label)
1848 (make-instance 'label :label tab-label)
1849 tab-label) (or null widget))
1850 ((if (stringp menu-label)
1851 (make-instance 'label :label menu-label)
1852 menu-label) (or null widget))
1853 ((%ensure-notebook-position notebook position) position))
1855 (defun notebook-append (notebook child &optional tab-label menu-label)
1856 (notebook-insert notebook :last child tab-label menu-label))
1858 (defun notebook-prepend (notebook child &optional tab-label menu-label)
1859 (notebook-insert notebook :first child tab-label menu-label))
1861 (defbinding notebook-remove-page (notebook page) nil
1863 ((%ensure-notebook-position notebook page) position))
1865 (defbinding %notebook-page-num () int
1869 (defun notebook-page-num (notebook child &optional error-p)
1870 (let ((page-num (%notebook-page-num notebook child)))
1873 (error "~A is not a page in ~A" child notebook))
1876 (defbinding notebook-next-page () nil
1877 (notebook notebook))
1879 (defbinding notebook-prev-page () nil
1880 (notebook notebook))
1882 (defbinding notebook-reorder-child (notebook child position) nil
1885 ((%ensure-notebook-position notebook position) int))
1887 (defbinding notebook-popup-enable () nil
1888 (notebook notebook))
1890 (defbinding notebook-popup-disable () nil
1891 (notebook notebook))
1893 (defbinding notebook-get-nth-page () widget
1897 (defun %notebook-current-page (notebook)
1898 (when (slot-boundp notebook 'current-page-num)
1899 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
1901 (defun (setf notebook-current-page) (page notebook)
1902 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
1904 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1905 (notebook page) widget
1907 ((%ensure-notebook-child notebook page) widget))
1909 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1910 (notebook page) (copy-of string)
1912 ((%ensure-notebook-child notebook page) widget))
1914 (defbinding %notebook-set-tab-label () nil
1919 (defun (setf notebook-tab-label) (tab-label notebook page)
1920 (let ((widget (if (stringp tab-label)
1921 (make-instance 'label :label tab-label)
1923 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1927 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1928 (notebook page) widget
1930 ((%ensure-notebook-child notebook page) widget))
1932 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1933 (notebook page) (copy-of string)
1935 ((%ensure-notebook-child notebook page) widget))
1937 (defbinding %notebook-set-menu-label () nil
1940 (menu-label widget))
1942 (defun (setf notebook-menu-label) (menu-label notebook page)
1943 (let ((widget (if (stringp menu-label)
1944 (make-instance 'label :label menu-label)
1946 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1950 (defbinding notebook-query-tab-label-packing (notebook page) nil
1952 ((%ensure-notebook-child notebook page) widget)
1953 (expand boolean :out)
1955 (pack-type pack-type :out))
1957 (defbinding notebook-set-tab-label-packing
1958 (notebook page expand fill pack-type) nil
1960 ((%ensure-notebook-child notebook page) widget)
1963 (pack-type pack-type))
1969 (defbinding paned-pack1 () nil
1975 (defbinding paned-pack2 () nil
1984 (defbinding layout-put () nil
1990 (defbinding layout-move () nil
1996 (defbinding layout-set-size () nil
1998 (width unsigned-int)
1999 (height unsigned-int))
2001 (defbinding layout-get-size () nil
2003 (width unsigned-int :out)
2004 (height unsigned-int :out))
2009 (defbinding menu-shell-insert (menu-shell menu-item position) nil
2010 (menu-shell menu-shell)
2011 (menu-item menu-item)
2017 (defun menu-shell-append (menu-shell menu-item)
2018 (menu-shell-insert menu-shell menu-item :last))
2020 (defun menu-shell-prepend (menu-shell menu-item)
2021 (menu-shell-insert menu-shell menu-item :fisrt))
2023 (defbinding menu-shell-deactivate () nil
2024 (menu-shell menu-shell))
2026 (defbinding menu-shell-select-item () nil
2027 (menu-shell menu-shell)
2028 (menu-item menu-item))
2030 (defbinding menu-shell-select-first () nil
2031 (menu-shell menu-shell)
2032 (search-sensitive boolean))
2034 (defbinding menu-shell-deselect () nil
2035 (menu-shell menu-shell))
2037 (defbinding menu-shell-activate-item () nil
2038 (menu-shell menu-shell)
2039 (menu-item menu-item)
2040 (fore-deactivate boolean))
2042 (defbinding menu-shell-cancel () nil
2043 (menu-shell menu-shell))
2048 (defun %menu-position (menu child)
2051 (keyword (case child
2054 (t (error "Invalid position keyword: ~A" child))))
2055 (widget (menu-child-position menu child))))
2058 (defbinding menu-reorder-child (menu menu-item position) nil
2060 (menu-item menu-item)
2061 ((%menu-position menu position) int))
2063 (defbinding menu-attach () nil
2065 (menu-item menu-item)
2066 (left-attach unsigned-int)
2067 (right-attach unsigned-int)
2068 (top-attach unsigned-int)
2069 (bottom-attach unsigned-int))
2071 (define-callback-marshal %menu-position-callback nil
2072 (menu (x int) (y int) (push-in boolean)))
2074 (defbinding %menu-popup () nil
2076 (parent-menu-shell (or null menu-shell))
2077 (parent-menu-item (or null menu-item))
2078 (callback (or null callback))
2079 (callback-id unsigned-int)
2080 (button unsigned-int)
2081 (activate-time (unsigned 32)))
2083 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
2086 (with-callback-function (id callback)
2088 menu parent-menu-shell parent-menu-item
2089 %menu-position-callback id button activate-time))
2091 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2093 (defbinding menu-set-accel-path () nil
2095 (accel-path string))
2097 (defbinding menu-reposition () nil
2100 (defbinding menu-popdown () nil
2103 (defun menu-child-position (menu child)
2104 (position child (container-children menu)))
2106 (defun menu-active-num (menu)
2107 (menu-child-position menu (menu-active menu)))
2109 (defbinding %menu-set-active () nil
2111 (index unsigned-int))
2113 (defun (setf menu-active) (menu child)
2114 (%menu-set-active menu (%menu-position menu child))
2117 (define-callback %menu-detach-callback nil ((widget widget) (menu menu))
2118 (funcall (user-data menu 'detach-func) widget menu))
2120 (defbinding %menu-attach-to-widget (menu widget) nil
2123 (%menu-detach-callback callback))
2125 (defun menu-attach-to-widget (menu widget function)
2126 (setf (user-data menu 'detach-func) function)
2127 (%menu-attach-to-widget menu widget))
2129 (defbinding menu-detach () nil
2132 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2133 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2136 (defbinding menu-set-monitor () nil
2143 (defbinding table-resize () nil
2146 (columns unsigned-int))
2148 (defbinding table-attach (table child left right top bottom
2149 &key options x-options y-options
2150 (x-padding 0) (y-padding 0)) nil
2154 (right unsigned-int)
2156 (bottom unsigned-int)
2157 ((append (mklist options) (mklist x-options)) attach-options)
2158 ((append (mklist options) (mklist y-options)) attach-options)
2159 (x-padding unsigned-int)
2160 (y-padding unsigned-int))
2163 (defbinding %table-set-row-spacing () nil
2166 (spacing unsigned-int))
2168 (defbinding %table-set-row-spacings () nil
2170 (spacing unsigned-int))
2172 (defun (setf table-row-spacing) (spacing table &optional row)
2174 (%table-set-row-spacing table row spacing)
2175 (%table-set-row-spacings table spacing))
2178 (defbinding %table-get-row-spacing () unsigned-int
2182 (defbinding %table-get-default-row-spacing () unsigned-int
2185 (defun table-row-spacing (table &optional row)
2187 (%table-get-row-spacing table row)
2188 (%table-get-default-row-spacing table)))
2191 (defbinding %table-set-col-spacing () nil
2194 (spacing unsigned-int))
2196 (defbinding %table-set-col-spacings () nil
2198 (spacing unsigned-int))
2200 (defun (setf table-column-spacing) (spacing table &optional column)
2202 (%table-set-col-spacing table column spacing)
2203 (%table-set-col-spacings table spacing))
2206 (defun (setf table-col-spacing) (spacing table &optional col)
2207 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2208 (setf (table-column-spacing table col) spacing))
2210 (defbinding %table-get-col-spacing () unsigned-int
2214 (defbinding %table-get-default-col-spacing () unsigned-int
2217 (defun table-column-spacing (table &optional column)
2219 (%table-get-col-spacing table column)
2220 (%table-get-default-col-spacing table)))
2222 (defun table-col-spacing (table &optional col)
2223 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2224 (table-column-spacing table col))
2230 (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2232 (apply #'call-next-method toolbar
2233 :tooltips (make-instance 'tooltips) initargs)
2234 (call-next-method)))
2236 (defbinding %toolbar-insert () nil
2238 (tool-item tool-item)
2239 (position position))
2241 (defun toolbar-insert (toolbar tool-item &optional (position :end))
2242 (%toolbar-insert toolbar tool-item position)
2243 (%tool-item-update-tooltips tool-item))
2245 (defbinding toolbar-get-item-index () int
2249 (defbinding toolbar-get-nth-item () tool-item
2253 (defbinding toolbar-get-drop-index () int
2257 (defbinding toolbar-set-drop-highlight-item () nil
2259 (tool-item tool-item)
2265 (defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2266 (if (and icon (not (typep icon 'widget)))
2267 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2268 (call-next-method)))
2273 (defbinding tool-item-set-tooltip () nil
2274 (tool-item tool-item)
2277 (tip-private string))
2280 (defun %tool-item-update-tooltips (tool-item)
2282 (slot-boundp tool-item 'parent)
2284 (user-data-p tool-item 'tip-text)
2285 (user-data-p tool-item 'tip-private)))
2286 (tool-item-set-tooltip
2287 tool-item (toolbar-tooltips (widget-parent tool-item))
2288 (or (user-data tool-item 'tip-text) "")
2289 (or (user-data tool-item 'tip-private) ""))))
2291 (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2292 (setf (user-data tool-item 'tip-text) tip-text)
2293 (%tool-item-update-tooltips tool-item)
2296 (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2297 (setf (user-data tool-item 'tip-private) tip-private)
2298 (%tool-item-update-tooltips tool-item)
2301 (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2302 (declare (ignore args))
2305 (%tool-item-update-tooltips tool-item)))
2308 (defbinding tool-item-retrieve-proxy-menu-item () widget
2309 (tool-item tool-item))
2311 (defbinding (tool-item-proxy-menu-item
2312 "gtk_tool_item_get_proxy_menu_item") () menu-item
2313 (tool-item tool-item)
2314 (menu-item-id string))
2316 (defbinding %tool-item-set-proxy-menu-item () nil
2317 (tool-item tool-item)
2318 (menu-item-id string)
2319 (menu-item menu-item))
2321 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2322 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2325 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2326 (defbinding tool-item-rebuild-menu () nil
2327 (tool-item tool-item))
2332 (defbinding editable-select-region (editable &optional (start 0) end) nil
2337 (defbinding editable-get-selection-bounds (editable) nil
2342 (defbinding editable-insert-text (editable text &optional (position 0)) nil
2346 (position position :in/out))
2348 (defun editable-append-text (editable text)
2349 (editable-insert-text editable text nil))
2351 (defun editable-prepend-text (editable text)
2352 (editable-insert-text editable text 0))
2354 (defbinding editable-delete-text (editable &optional (start 0) end) nil
2359 (defbinding (editable-text "gtk_editable_get_chars")
2360 (editable &optional (start 0) end) string
2365 (defun (setf editable-text) (text editable)
2367 (editable-delete-text
2369 (editable-insert-text editable text))
2370 (editable-delete-text editable))
2373 (defbinding editable-cut-clipboard () nil
2374 (editable editable))
2376 (defbinding editable-copy-clipboard () nil
2377 (editable editable))
2379 (defbinding editable-paste-clipboard () nil
2380 (editable editable))
2382 (defbinding editable-delete-selection () nil
2383 (editable editable))
2389 (defbinding spin-button-configure () nil
2390 (spin-button spin-button)
2391 (adjustment adjustment)
2392 (climb-rate double-float)
2393 (digits unsigned-int))
2395 (defbinding spin-button-set-range () nil
2396 (spin-button spin-button)
2400 (defbinding spin-button-get-range () nil
2401 (spin-button spin-button)
2402 (min double-float :out)
2403 (max double-float :out))
2405 (defun spin-button-value-as-int (spin-button)
2406 (round (spin-button-value spin-button)))
2408 (defbinding %spin-button-spin () nil
2409 (spin-button spin-button)
2410 (direction spin-type)
2411 (increment double-float))
2413 (defun spin-button-spin (spin-button value)
2415 (real (%spin-button-spin spin-button :user-defined value))
2416 (spin-type (%spin-button-spin spin-button value 0))))
2419 (defbinding spin-button-update () nil
2420 (spin-button spin-button))
2426 (defbinding ruler-set-range () nil
2428 (lower single-float)
2429 (upper single-float)
2430 (position single-float)
2431 (max-size single-float))
2433 (defbinding ruler-get-range () nil
2435 (lower single-float :out)
2436 (upper single-float :out)
2437 (position single-float :out)
2438 (max-size single-float :out))
2444 (defun range-lower (range)
2445 (adjustment-lower (range-adjustment range)))
2447 (defun range-upper (range)
2448 (adjustment-upper (range-adjustment range)))
2450 (defun (setf range-lower) (value range)
2451 (setf (adjustment-lower (range-adjustment range)) value))
2453 (defun (setf range-upper) (value range)
2454 (setf (adjustment-upper (range-adjustment range)) value))
2456 (defun range-page-increment (range)
2457 (adjustment-page-increment (range-adjustment range)))
2459 (defun range-step-increment (range)
2460 (adjustment-step-increment (range-adjustment range)))
2462 (defun (setf range-page-increment) (value range)
2463 (setf (adjustment-page-increment (range-adjustment range)) value))
2465 (defun (setf range-step-increment) (value range)
2466 (setf (adjustment-step-increment (range-adjustment range)) value))
2468 (defbinding range-set-range () nil
2470 (lower double-float)
2471 (upper double-float))
2473 (defbinding range-set-increments () nil
2476 (page double-float))
2481 (defbinding scale-get-layout-offsets () nil
2489 (defbinding progress-bar-pulse () nil
2490 (progress-bar progress-bar))
2495 (defmethod initialize-instance ((size-group size-group) &rest initargs
2496 &key widget widgets)
2497 (declare (ignore widget widgets))
2500 (initial-add size-group #'size-group-add-widget
2501 initargs :widget :widgets)))
2504 (defbinding size-group-add-widget () nil
2505 (size-group size-group)
2508 (defbinding size-group-remove-widget () nil
2509 (size-group size-group)
2515 (defbinding %stock-item-copy () pointer
2518 (defbinding %stock-item-free () nil
2521 (defbinding stock-add (stock-item) nil
2522 (stock-item stock-item)
2525 (defbinding stock-list-ids () (gslist string))
2527 (defbinding %stock-lookup () boolean
2531 (defun stock-lookup (stock-id)
2532 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
2533 (when (%stock-lookup stock-id stock-item)
2534 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
2536 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
2538 (define-callback-marshal %stock-translate-callback string ((path string)))
2540 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2541 (domain function) nil
2543 (%stock-translate-callback callback)
2544 ((register-callback-function function) unsigned-int)
2545 (user-data-destroy-callback callback)))
2550 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2552 (defbinding tooltip-set-markup () nil
2556 (defbinding tooltip-set-text () nil
2560 (defbinding %tooltip-set-icon () nil
2564 (defbinding %tooltip-set-icon-from-stock () nil
2569 (defun tooltip-set-icon (tooltip icon &key (size :button))
2571 (gdk:pixbuf (%tooltip-set-icon tooltip icon))
2572 (string (%tooltip-set-icon-from-stock tooltip icon size))))
2574 (defbinding tooltip-set-custom () nil
2578 (defbinding tooltip-trigger-tooltip-query (&optional (display (gdk:display-get-default))) nil
2579 (display gdk:display))
2581 (defbinding tooltip-set-tip-area () nil
2589 ;; GtkTooltips has been deprecated in favor of the new tooltip API
2590 ;; introduced in in GTK+ 2.12
2592 (defbinding tooltips-enable () nil
2593 (tooltips tooltips))
2595 (defbinding tooltips-disable () nil
2596 (tooltips tooltips))
2598 (defun (setf tooltips-enabled-p) (enable tooltips)
2600 (tooltips-enable tooltips)
2601 (tooltips-disable tooltips)))
2603 (defbinding tooltips-set-tip () nil
2607 (tip-private string))
2609 (defbinding tooltips-data-get () tooltips-data
2612 (defbinding tooltips-force-window () nil
2613 (tooltips tooltips))
2615 (defbinding tooltips-get-info-from-tip-window () boolean
2617 (tooltips tooltips :out)
2618 (current-widget widget :out))
2623 (defbinding rc-get-style () style
2626 (defbinding rc-get-style-by-paths (&key path class-path class) style
2627 (path (or null string))
2628 (class-path (or null string))
2631 (defbinding rc-parse () nil
2632 (filename pathname))
2634 (defbinding rc-parse-string () nil
2637 (defbinding %rc-reparse-all () boolean)
2639 (defbinding %rc-reparse-all-for-settings () boolean
2641 (force-load-p boolean))
2643 (defun rc-reparse-all (&optional setting force-load-p)
2645 (%rc-reparse-all-for-settings setting force-load-p)
2648 (defbinding rc-reset-styles () nil
2649 (settings settings))
2651 (defbinding rc-add-default-file () nil
2652 (filename pathname))
2654 (defbinding rc-get-default-files ()
2655 (copy-of (null-terminated-vector (copy-of string))))
2657 (defbinding rc-get-module-dir () string)
2659 (defbinding rc-get-im-module-path () string)
2661 (defbinding rc-get-im-module-file () string)
2663 (defbinding rc-get-theme-dir () string)
2668 (defbinding (settings-get "gtk_settings_get_for_screen")
2669 (&optional (screen (gdk:display-get-default-screen))) settings
2670 (screen gdk:screen))
2675 (defbinding socket-add-id () nil
2677 (id gdk:native-window))
2679 (defbinding %plug-new () pointer
2680 (id gdk:native-window))
2682 (defmethod allocate-foreign ((plug plug) &key id)
2683 (%plug-new (or id 0)))
2688 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2690 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2692 (defbinding link-button-set-uri-hook (function) pointer
2693 (%link-button-uri-callback callback)
2694 ((register-callback-function function) unsigned-int)
2695 (user-data-destroy-callback callback)))
2700 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2702 (defmethod initialize-instance ((builder builder) &key interface
2703 (connect-signals t) (package *package*))
2705 (etypecase interface
2707 (string (builder-add-from-string builder interface))
2708 (pathname (builder-add-from-file builder interface)))
2709 (when connect-signals
2710 (builder-connect-signals builder package)))
2713 (defbinding builder-add-from-file () boolean
2716 (nil gerror-signal :out))
2718 (defbinding builder-add-from-string () boolean
2721 (-1 int) ; TODO: add gsize type
2722 (nil gerror-signal :out))
2724 (defbinding builder-get-object () gobject
2728 (defbinding builder-get-objects () (gslist gobject)
2731 (defun intern-with-package-prefix (name default-package)
2732 (let ((pos (position #\: name)))
2735 (string-upcase (subseq name (1+ pos)))
2736 (string-upcase (subseq name 0 pos)))
2737 (intern (string-upcase name) default-package))))
2739 (define-callback %builder-connect-function nil
2740 (builder (object gobject) (signal-name string) (handler-name string)
2741 (connect-object gobject) connect-flags (package user-data-id))
2742 (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)
2745 (intern-with-package-prefix handler-name (find-user-data package))
2746 :object (or connect-object object) :after (find :after connect-flags)))
2748 (defbinding %builder-connect-signals-full (builder package) nil
2750 (%builder-connect-function callback)
2751 (package user-data-id))
2753 (defun builder-connect-signals (builder &optional (package *package*))
2754 (with-user-data (id package)
2755 (%builder-connect-signals-full builder id))))