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.89 2008-01-11 14:44:28 espen Exp $
30 (defbinding check-version () (copy-of string)
31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
35 (defbinding query-version () nil
36 (major unsigned-int :out)
37 (minor unsigned-int :out)
38 (micro unsigned-int :out))
41 (multiple-value-bind (major minor micro)
44 (format nil "Gtk+ v~A.~A" major minor)
45 (format nil "Gtk+ v~A.~A.~A" major minor micro))))
51 ;;;; Initalization and display handling
53 (defparameter *event-poll-interval* 10000) ; in microseconds
56 (defbinding (gtk-init "gtk_parse_args") () boolean
57 "Initializes the library without opening the display."
61 (defun clg-init (&optional display multi-threading-p)
62 "Initializes the system and starts event handling."
63 (unless (gdk:display-get-default)
64 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
66 #+sbcl(sb-int:set-floating-point-modes :traps nil)
67 #+cmu(ext:set-floating-point-modes :traps nil))
71 (error "Initialization of GTK+ failed."))
73 (if (not multi-threading-p)
74 (%init-async-event-handling display)
75 #+sb-thread(%init-multi-threaded-event-handling display)
76 #-sb-thread(error "Multi threading not supported on this platform")))
77 (gdk:ensure-display display t))
79 (defun clg-init-with-threading (&optional display)
84 ;; A very minimal implementation of CLISP's socket-status
85 (defun socket-status (socket seconds microseconds)
86 (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set)))
87 (let ((fd (sb-sys:fd-stream-fd (car socket))))
88 (sb-unix:fd-zero read-fds)
89 (sb-unix:fd-set fd read-fds)
91 (let ((num-fds-changed
92 (sb-unix:unix-fast-select
93 (1+ fd) (sb-alien:addr read-fds) nil nil
94 seconds microseconds)))
95 (unless (or (not num-fds-changed) (zerop num-fds-changed))
96 (if (peek-char nil (car socket) nil)
100 (defun %init-async-event-handling (display)
101 (let ((style #?(or (featurep :cmu) (sbcl< 1 0 6)) :fd-handler
102 #?-(or (featurep :cmu) (sbcl< 1 0 6)) nil))
104 (find-package "SWANK")
105 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style)))
106 (error "When running clg in Slime, the communication style ~S must be used in combination with asynchronous event handling on this platform. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information." style)))
108 #?(or (featurep :cmu) (sbcl< 1 0 6))
110 (signal-connect (gdk:display-manager) 'display-opened
112 (let ((fd (gdk:display-connection-number display)))
114 (let ((handler (add-fd-handler
115 (gdk:display-connection-number display)
116 :input #'main-iterate-all)))
117 (signal-connect display 'closed
118 #'(lambda (is-error-p)
119 (declare (ignore is-error-p))
120 (remove-fd-handler handler))))))))
121 (setq *periodic-polling-function* #'main-iterate-all)
122 (setq *max-event-to-sec* 0)
123 (setq *max-event-to-usec* *event-poll-interval*))
125 #+(and clisp readline)
126 ;; Readline will call the event hook at most ten times per second
127 (setf readline:event-hook #'main-iterate-all)
129 #?-(or (featurep :cmu) (sbcl< 1 0 6))
130 ;; When running in Slime we need to hook into the Swank server
131 ;; to handle events asynchronously.
133 (find-package "SWANK")
134 (let ((connection (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK"))))
136 (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")))
137 (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") connection)))
138 (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))
141 (case (socket-status (cons stream :input) 0
142 *event-poll-interval*)
143 ((:input :eof) (return (funcall read-from-emacs)))
144 (otherwise (main-iterate-all))))))))))
145 #-(and clisp readline)
146 (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started."))
148 (gdk:display-open display))
152 (defvar *main-thread* nil)
154 ;; Hopefully, when threading support is added to the Win32 port of
155 ;; SBCL in the future, this will work just out of the box.
157 (let ((done (sb-thread:make-waitqueue))
161 ;; In Win32 all GDK calls have to be made from the main loop
162 ;; thread, so we add a timeout function which will poll for code and
165 (defun funcall-in-main (function)
168 (eq sb-thread:*current-thread* *main-thread*))
170 (gdk:with-global-lock
171 (push function functions)
172 (sb-thread:condition-wait done gdk:*global-lock*)
175 ;; Will lock REPL on error, need to be fixed!
176 (defun %funcall-in-main-poll ()
181 do (push (funcall (pop functions)) results)
182 finally (sb-thread:condition-notify done n)))
185 (defmacro within-main-loop (&body body)
186 #-win32 `(gdk:with-global-lock ,@body)
187 #+win32 `(funcall-in-main #'(lambda () ,@body)))
189 (defun %init-multi-threaded-event-handling (display)
191 (find-package "SWANK")
192 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn)))
193 (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."))
195 (let ((main-running (sb-thread:make-waitqueue)))
196 (gdk:with-global-lock
198 (sb-thread:make-thread
200 (gdk:with-global-lock
201 (gdk:display-open display)
202 #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000)
203 #'%funcall-in-main-poll)
204 (sb-thread:condition-notify main-running)
206 :name "gtk event loop"))
207 (sb-thread:condition-wait main-running gdk:*global-lock*)))
209 ;; We need to hook into the Swank server to protect calls to GDK properly.
210 ;; This will *only* protect code entered directly in the REPL.
211 (when (find-package "SWANK")
212 (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
214 (push #'(lambda (form)
215 (within-main-loop (eval form)))
216 (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
217 (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"))))))
220 (defmacro within-main-loop (&body body)
225 ;;; Generic functions
227 (defgeneric add-to-radio-group (item1 item2))
228 (defgeneric activate-radio-widget (item))
229 (defgeneric (setf tool-item-tip-text) (tip-text tool-item))
230 (defgeneric (setf tool-item-tip-private) (tip-private tool-item))
236 (defbinding grab-add () nil
239 (defbinding grab-get-current () widget)
241 (defbinding grab-remove () nil
244 (defbinding get-default-language () (copy-of pango:language))
249 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
251 (define-callback-marshal %about-dialog-activate-link-callback nil
252 (about-dialog (link string)))
254 (defbinding about-dialog-set-email-hook (function) nil
255 (%about-dialog-activate-link-callback callback)
256 ((register-callback-function function) unsigned-int)
257 (user-data-destroy-callback callback))
259 (defbinding about-dialog-set-url-hook (function) nil
260 (%about-dialog-activate-link-callback callback)
261 ((register-callback-function function) unsigned-int)
262 (user-data-destroy-callback callback)))
267 (defbinding %accel-group-connect () nil
268 (accel-group accel-group)
270 (modifiers gdk:modifier-type)
274 (defun accel-group-connect (group accelerator function &optional flags)
275 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
276 (let ((gclosure (make-callback-closure function)))
277 (%accel-group-connect group key modifiers flags gclosure)
280 (defbinding accel-group-connect-by-path (group path function) nil
283 ((make-callback-closure function) gclosure :in/return))
285 (defbinding %accel-group-disconnect (group gclosure) boolean
289 (defbinding %accel-group-disconnect-key () boolean
292 (modifiers gdk:modifier-type))
294 (defun accel-group-disconnect (group accelerator)
295 (etypecase accelerator
296 (gclosure (%accel-group-disconnect group accelerator))
298 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
299 (%accel-group-disconnect-key group key modifiers)))))
301 (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
302 (accel-group accel-group)
304 (modifiers gdk:modifier-type)
307 (defun accel-group-query (accel-group accelerator)
308 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
309 (%accel-group-query accel-group key modifiers)))
311 (defbinding %accel-group-activate () boolean
312 (accel-group accel-group)
313 (acceleratable gobject)
315 (modifiers gdk:modifier-type))
317 (defun accel-group-activate (accel-group acceleratable accelerator)
318 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
319 (%accel-group-activate accel-group acceleratable key modifiers)))
321 (defbinding accel-group-lock () nil
322 (accel-group accel-group))
324 (defbinding accel-group-unlock () nil
325 (accel-group accel-group))
327 (defbinding accel-group-from-accel-closure () accel-group
330 (defbinding %accel-groups-activate () boolean
333 (modifiers gdk:modifier-type))
335 (defun accel-groups-activate (object accelerator)
336 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
337 (%accel-groups-activate object key modifiers)))
339 (defbinding accel-groups-from-object () (gslist accel-group)
342 (defbinding accelerator-valid-p (key &optional modifiers) boolean
344 (modifiers gdk:modifier-type))
346 (defbinding %accelerator-parse () nil
348 (key unsigned-int :out)
349 (modifiers gdk:modifier-type :out))
351 (defgeneric parse-accelerator (accelerator))
353 (defmethod parse-accelerator ((accelerator string))
354 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
356 (error "Invalid accelerator: ~A" accelerator)
357 (values key modifiers))))
359 (defmethod parse-accelerator ((accelerator cons))
360 (destructuring-bind (key modifiers) accelerator
366 (gdk:keyval-from-name key)
367 (error "Invalid key name: ~A" key)))
368 (character (parse-accelerator key)))
371 (defmethod parse-accelerator ((key integer))
374 (defmethod parse-accelerator ((key character))
376 (gdk:keyval-from-name (string key))
377 (error "Invalid key name: ~A" key)))
380 (defbinding accelerator-name () string
382 (modifiers gdk:modifier-type))
384 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
385 (defbinding accelerator-get-label () string
387 (modifiers gdk:modifier-type))
389 (defbinding %accelerator-set-default-mod-mask () nil
390 (default-modifiers gdk:modifier-type))
392 (defun (setf accelerator-default-modifier-mask) (default-modifiers)
393 (%accelerator-set-default-mod-mask default-modifiers))
395 (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
400 (defbinding accel-label-get-accel-width () unsigned-int
401 (accel-label accel-label))
403 (defbinding accel-label-refetch () boolean
404 (accel-label accel-label))
410 (defbinding %accel-map-add-entry () nil
413 (modifiers gdk:modifier-type))
415 (defun accel-map-add-entry (path accelerator)
416 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
417 (%accel-map-add-entry path key modifiers)))
419 (defbinding %accel-map-lookup-entry () boolean
421 ((make-instance 'accel-key) accel-key :in/return))
423 (defun accel-map-lookup-entry (path)
424 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
427 (slot-value accel-key 'key)
428 (slot-value accel-key 'modifiers)
429 (slot-value accel-key 'flags)))))
431 (defbinding %accel-map-change-entry () boolean
434 (modifiers gdk:modifier-type)
437 (defun accel-map-change-entry (path accelerator &optional replace)
438 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
439 (%accel-map-change-entry path key modifiers replace)))
441 (defbinding accel-map-load () nil
444 (defbinding accel-map-save () nil
447 (define-callback-marshal %accel-map-foreach-callback nil
448 ((accel-path string) (key unsigned-int)
449 (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first)
451 (defbinding %accel-map-foreach (callback-id) nil
452 (callback-id unsigned-int)
453 (%accel-map-foreach-callback callback))
455 (defbinding %accel-map-foreach-unfiltered (callback-id) nil
456 (callback-id unsigned-int)
457 (%accel-map-foreach-callback callback))
459 (defun accel-map-foreach (function &optional (filter-p t))
460 (with-callback-function (id function)
462 (%accel-map-foreach id)
463 (%accel-map-foreach-unfiltered id))))
465 (defbinding accel-map-add-filter () nil
468 (defbinding accel-map-get () accel-map)
470 (defbinding accel-map-lock-path () nil
473 (defbinding accel-map-unlock-path () nil
480 (defbinding accessible-connect-widget-destroyed () nil
481 (accessible accessible))
486 (defmethod initialize-instance ((adjustment adjustment) &key value)
489 ;; we need to make sure that the value is set last, otherwise it
490 ;; may be outside current limits and ignored
492 (setf (slot-value adjustment 'value) value))))
495 (defbinding adjustment-changed () nil
496 (adjustment adjustment))
498 (defbinding adjustment-value-changed () nil
499 (adjustment adjustment))
501 (defbinding adjustment-clamp-page () nil
502 (adjustment adjustment)
504 (upper single-float))
509 (defbinding alignment-set () nil
510 (alognment alignment)
511 (x-align single-float)
512 (y-align single-float)
513 (x-scale single-float)
514 (y-scale single-float))
516 (defbinding alignment-get-padding () nil
517 (alognment alignment)
518 (top unsigned-int :out)
519 (bottom unsigned-int :out)
520 (left unsigned-int :out)
521 (right unsigned-int :out))
523 (defbinding alignment-set-padding () nil
524 (alognment alignment)
526 (bottom unsigned-int)
528 (right unsigned-int))
533 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
535 (defbinding assistant-get-nth-page () widget
536 (assistant assistant)
539 (defbinding %assistant-insert-page () int
540 (assistant assistant)
544 (defun assistant-insert-page (assistant page position &rest child-args)
545 (let ((pos (case position
550 (%assistant-insert-page assistant page pos)
551 (init-child-slots assistant page child-args))))
553 (defun assistant-append-page (assistant page &rest child-args)
554 (apply #'assistant-insert-page assistant page :last child-args))
556 (defun assistant-prepend-page (assistant page &rest child-args)
557 (apply #'assistant-insert-page assistant page :first child-args))
559 (define-callback-marshal %assistant-page-func-callback int
560 ((current-page int)))
562 (defbinding assistant-set-forward-page-func (assistant function) nil
563 (assistant assistant)
564 (%assistant-page-func-callback callback)
565 ((register-callback-function function) pointer-data)
566 (user-data-destroy-callback callback))
568 (defbinding assistant-add-action-widget () nil
569 (assistant assistant)
572 (defbinding assistant-remove-action-widget () nil
573 (assistant assistant)
576 (defbinding assistant-update-buttons-state () nil
577 (assistant assistant)))
586 (defun (setf bin-child) (child bin)
587 (when-bind (current-child (bin-child bin))
588 (container-remove bin current-child))
589 (container-add bin child)
592 (defmethod compute-signal-function ((bin bin) signal function object args)
593 (declare (ignore signal))
594 (if (eq object :child)
595 #'(lambda (&rest emission-args)
596 (apply function (bin-child bin) (nconc (rest emission-args) args)))
602 (defbinding box-pack-start () nil
607 (padding unsigned-int))
609 (defbinding box-pack-end () nil
614 (padding unsigned-int))
616 (defun box-pack (box child &key end (expand t) (fill t) (padding 0))
618 (box-pack-end box child expand fill padding)
619 (box-pack-start box child expand fill padding)))
621 (defbinding box-reorder-child () nil
626 (defbinding box-query-child-packing () nil
629 (expand boolean :out)
631 (padding unsigned-int :out)
632 (pack-type pack-type :out))
634 (defbinding box-set-child-packing () nil
639 (padding unsigned-int)
640 (pack-type pack-type))
646 (defmethod initialize-instance ((button button) &rest initargs &key stock)
648 (apply #'call-next-method button
649 :label stock :use-stock t :use-underline t initargs)
653 (defbinding button-pressed () nil
656 (defbinding button-released () nil
659 (defbinding button-clicked () nil
662 (defbinding button-enter () nil
665 (defbinding button-leave () nil
672 (defbinding calendar-select-month () int
677 (defbinding calendar-select-day () nil
681 (defbinding calendar-mark-day () int
685 (defbinding calendar-unmark-day () int
689 (defbinding calendar-clear-marks () nil
692 (defbinding calendar-get-date () nil
694 (year unsigned-int :out)
695 (month unsigned-int :out)
696 (day unsigned-int :out))
698 (defbinding calendar-freeze () nil
701 (defbinding calendar-thaw () nil
707 (defbinding check-menu-item-toggled () nil
708 (check-menu-item check-menu-item))
713 (defbinding color-selection-is-adjusting-p () boolean
714 (colorsel color-selection))
716 (defbinding (color-selection-previous-color
717 "gtk_color_selection_get_previous_color") () nil
718 (colorsel color-selection)
719 ((make-instance 'gdk:color) gdk:color :in/return))
722 ;;; Color selection dialog -- no functions
728 (defmethod initialize-instance ((combo-box combo-box) &rest initargs
729 &key model content active)
730 (remf initargs :active)
732 (apply #'call-next-method combo-box initargs)
734 (apply #'call-next-method combo-box
735 :model (make-instance 'list-store :column-types '(string))
737 (unless (typep combo-box 'combo-box-entry)
738 (let ((cell (make-instance 'cell-renderer-text)))
739 (cell-layout-pack combo-box cell :expand t)
740 (cell-layout-add-attribute combo-box cell :text 0)))))
742 (mapc #'(lambda (text)
743 (combo-box-append-text combo-box text))
746 (setf (combo-box-active combo-box) active)))
749 ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
751 ;; (signal-emit combo-box 'changed)))
753 (defbinding combo-box-append-text () nil
754 (combo-box combo-box)
757 (defbinding combo-box-insert-text () nil
758 (combo-box combo-box)
762 (defbinding combo-box-prepend-text () nil
763 (combo-box combo-box)
766 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
767 (defbinding combo-box-get-active-text () string
768 (combo-box combo-box))
770 (defbinding combo-box-popup () nil
771 (combo-box combo-box))
773 (defbinding combo-box-popdown () nil
774 (combo-box combo-box))
780 (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
783 (setf (combo-box-entry-text-column combo-box-entry) 0)))
788 (defmethod shared-initialize ((dialog dialog) names &rest initargs
790 (declare (ignore names button buttons))
793 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
796 (defun dialog-response-id (dialog response &optional create-p error-p)
797 "Returns a numeric response id"
798 (if (typep response 'response-type)
799 (response-type-to-int response)
800 (let ((responses (user-data dialog 'responses)))
802 ((and responses (position response responses :test #'equal)))
806 (vector-push-extend response responses)
807 (1- (length responses)))
810 (user-data dialog 'responses)
811 (make-array 1 :adjustable t :fill-pointer t
812 :initial-element response))
815 (error "Invalid response: ~A" response))))))
817 (defun dialog-find-response (dialog id)
818 "Finds a symbolic response given a numeric id"
820 ((not (numberp id)) id)
821 ((< id 0) (int-to-response-type id))
822 ((aref (user-data dialog 'responses) id))))
825 (defmethod compute-signal-id ((dialog dialog) signal)
826 (if (dialog-response-id dialog signal)
827 (ensure-signal-id 'response dialog)
830 (defmethod compute-signal-function ((dialog dialog) signal function object args)
831 (declare (ignore function object args))
832 (let ((callback (call-next-method))
833 (id (dialog-response-id dialog signal)))
836 #'(lambda (dialog response)
837 (when (= response id)
838 (funcall callback dialog))))
839 ((string-equal signal "response")
840 #'(lambda (dialog response)
841 (funcall callback dialog (dialog-find-response dialog response))))
844 (defbinding dialog-run () nil
847 (defbinding dialog-response (dialog response) nil
849 ((dialog-response-id dialog response nil t) int))
852 (defbinding %dialog-add-button () button
857 (defun dialog-add-button (dialog label &optional (response label)
858 &key default object after)
859 "Adds a button to the dialog."
860 (let* ((signal (if (functionp response)
863 (id (dialog-response-id dialog signal t))
864 (button (%dialog-add-button dialog label id)))
865 (when (functionp response)
866 (signal-connect dialog signal response :object object :after after))
868 (%dialog-set-default-response dialog id))
872 (defbinding %dialog-add-action-widget () nil
874 (action-widget widget)
877 (defun dialog-add-action-widget (dialog widget &optional (response widget)
878 &key default object after)
879 (let* ((signal (if (functionp response)
882 (id (dialog-response-id dialog signal t)))
883 (unless (widget-hidden-p widget)
884 (widget-show widget))
885 (%dialog-add-action-widget dialog widget id)
886 (when (functionp response)
887 (signal-connect dialog signal response :object object :after after))
889 (setf (widget-can-default-p widget) t)
890 (%dialog-set-default-response dialog id))
894 (defbinding %dialog-set-default-response () nil
898 (defun dialog-set-default-response (dialog response)
899 (%dialog-set-default-response
900 dialog (dialog-response-id dialog response nil t)))
902 (defbinding dialog-set-response-sensitive (dialog response sensitive) nil
904 ((dialog-response-id dialog response nil t) int)
907 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
908 (defbinding alternative-dialog-button-order-p (&optional screen) boolean
909 (screen (or null gdk:screen)))
911 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
912 (defbinding (dialog-set-alternative-button-order
913 "gtk_dialog_set_alternative_button_order_from_array")
914 (dialog new-order) nil
916 ((length new-order) int)
917 ((map 'vector #'(lambda (response)
918 (dialog-response-id dialog response nil t))
919 new-order) (vector int)))
922 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
924 (defbinding %dialog-get-response-for-widget () int
928 (defun dialog-get-response-for-widget (dialog widget)
929 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
932 (defmethod container-add ((dialog dialog) (child widget) &rest args)
933 (apply #'container-add (dialog-vbox dialog) child args))
936 (defmethod container-remove ((dialog dialog) (child widget))
937 (container-remove (dialog-vbox dialog) child))
939 (defmethod container-children ((dialog dialog))
940 (container-children (dialog-vbox dialog)))
942 (defmethod (setf container-children) (children (dialog dialog))
943 (setf (container-children (dialog-vbox dialog)) children))
948 (defun drawing-area-scroll (drawing-area dx dy)
949 (gdk:window-scroll (widget-window drawing-area) dx dy))
954 (defbinding entry-get-layout-offsets () nil
959 (defbinding entry-layout-index-to-text-index () int
963 (defbinding entry-text-index-to-layout-index () int
970 (define-callback-marshal %entry-completion-match-callback boolean
971 (entry-completion string tree-iter))
973 (defbinding entry-completion-set-match-func (completion function) nil
974 (completion entry-completion)
975 (%entry-completion-match-callback callback)
976 ((register-callback-function function) unsigned-int)
977 (user-data-destroy-callback callback))
979 (defbinding entry-completion-complete () nil
980 (completion entry-completion))
982 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
983 (defbinding entry-completion-get-completion-prefix () string
984 (completion entry-completion))
986 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
987 (defbinding entry-completion-insert-prefix () nil
988 (completion entry-completion))
990 (defbinding entry-completion-insert-action-text () nil
991 (completion entry-completion)
995 (defbinding entry-completion-insert-action-markup () nil
996 (completion entry-completion)
1000 (defbinding entry-completion-delete-action () nil
1001 (completion entry-completion)
1007 (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
1008 &key filter filters shortcut-folder
1009 shortcut-folders shortcut-folder-uti
1010 shortcut-folder-uris)
1011 (declare (ignore filter filters shortcut-folder shortcut-folders
1012 shortcut-folder-uti shortcut-folder-uris))
1015 (initial-add file-chooser #'file-chooser-add-filter
1016 initargs :filer :filters)
1017 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1018 initargs :shortcut-folder :shortcut-folders)
1019 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1020 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1023 (defbinding file-chooser-select-filename () boolean
1024 (file-chooser file-chooser)
1027 (defbinding file-chooser-unselect-filename () nil
1028 (file-chooser file-chooser)
1031 (defbinding file-chooser-select-all () boolean
1032 (file-chooser file-chooser))
1034 (defbinding file-chooser-unselect-all () boolean
1035 (file-chooser file-chooser))
1037 (defbinding file-chooser-get-filenames () (gslist string)
1038 (file-chooser file-chooser))
1040 (defbinding file-chooser-select-uri () boolean
1041 (file-chooser file-chooser)
1044 (defbinding file-chooser-unselect-uri () nil
1045 (file-chooser file-chooser)
1048 (defbinding file-chooser-get-uris () (gslist string)
1049 (file-chooser file-chooser))
1051 (defbinding file-chooser-add-filter () nil
1052 (file-chooser file-chooser)
1053 (filter file-filter))
1055 (defbinding file-chooser-remove-filter () nil
1056 (file-chooser file-chooser)
1057 (filter file-filter))
1059 (defbinding file-chooser-list-filters () (gslist file-filter)
1060 (file-chooser file-chooser))
1062 (defbinding file-chooser-add-shortcut-folder () boolean
1063 (file-chooser file-chooser)
1067 (defbinding file-chooser-remove-shortcut-folder () nil
1068 (file-chooser file-chooser)
1072 (defbinding file-chooser-list-shortcut-folders () (gslist string)
1073 (file-chooser file-chooser))
1075 (defbinding file-chooser-add-shortcut-folder-uri () boolean
1076 (file-chooser file-chooser)
1080 (defbinding file-chooser-remove-shortcut-folder-uri () nil
1081 (file-chooser file-chooser)
1085 (defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1086 (file-chooser file-chooser))
1091 (defmethod initialize-instance ((file-filter file-filter) &rest initargs
1092 &key mime-type mime-types pattern patterns
1094 (declare (ignore mime-type mime-types pattern patterns))
1097 (when pixbuf-formats
1098 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1099 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1100 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1101 (file-filter-add-pixbuf-formats file-filter))
1102 (initial-add file-filter #'file-filter-add-mime-type
1103 initargs :mime-type :mime-types)
1104 (initial-add file-filter #'file-filter-add-pattern
1105 initargs :pattern :patterns)))
1108 (defbinding file-filter-add-mime-type () nil
1109 (filter file-filter)
1112 (defbinding file-filter-add-pattern () nil
1113 (filter file-filter)
1116 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1117 (defbinding file-filter-add-pixbuf-formats () nil
1118 (filter file-filter))
1120 (define-callback-marshal %file-filter-callback boolean (file-filter-info))
1122 (defbinding file-filter-add-custom (filter needed function) nil
1123 (filter file-filter)
1124 (needed file-filter-flags)
1125 (%file-filter-callback callback)
1126 ((register-callback-function function) unsigned-int)
1127 (user-data-destroy-callback callback))
1129 (defbinding file-filter-get-needed () file-filter-flags
1130 (filter file-filter))
1132 (defbinding file-filter-filter () boolean
1133 (filter file-filter)
1134 (filter-info file-filter-info))
1140 (defbinding image-set-from-file () nil
1142 (filename pathname))
1144 (defmethod (setf image-pixmap) ((data vector) (image image))
1145 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1146 (setf (image-pixmap image) pixmap)
1147 (setf (image-mask image) mask)))
1149 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1151 ((typep pixmap 'vector)
1152 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1153 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1157 (image-set-from-file image file)))
1158 ((call-next-method))))
1160 (defun create-image-widget (source &optional mask)
1162 (gdk:pixbuf (make-instance 'image :pixbuf source))
1163 (string (make-instance 'image :stock source))
1164 (pathname (make-instance 'image :file source))
1165 ((or list vector) (make-instance 'image :pixmap source))
1166 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1168 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1169 (defbinding image-clear () nil
1176 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1177 (if (and image (not (typep image 'widget)))
1178 (apply #'call-next-method item :image (create-image-widget image) initargs)
1179 (call-next-method)))
1182 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1183 (setf (slot-value item 'image) widget))
1185 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
1186 (setf (image-menu-item-image item) (create-image-widget image)))
1191 (defmethod shared-initialize ((label label) names &key pattern)
1192 (declare (ignore names))
1195 (setf (label-pattern label) pattern)))
1197 (defbinding label-get-layout-offsets () nil
1202 (defbinding label-select-region () nil
1207 (defbinding label-get-selection-bounds () boolean
1216 (defbinding %radio-button-get-group () pointer
1217 (radio-button radio-button))
1219 (defbinding %radio-button-set-group () nil
1220 (radio-button radio-button)
1223 (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
1224 "Add BUTTON1 to the group which BUTTON2 belongs to."
1225 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1227 (defun %add-activate-callback (widget signal function object after)
1229 (signal-connect widget signal
1231 (when (slot-value widget 'active)
1232 (funcall function object (slot-value widget 'value))))
1233 :object object :after after)
1234 (signal-connect widget signal
1236 (when (slot-value widget 'active)
1237 (funcall function (slot-value widget 'value))))
1240 (defmethod activate-radio-widget ((button radio-button))
1241 (signal-emit button 'clicked))
1243 (defgeneric add-activate-callback (action function &key object after))
1245 (defmethod add-activate-callback ((button radio-button) function &key object after)
1246 (%add-activate-callback button 'clicked function object after))
1248 (defmethod initialize-instance ((button radio-button) &key group)
1252 (add-to-radio-group button group))))
1257 (defbinding item-select () nil
1260 (defbinding item-deselect () nil
1263 (defbinding item-toggle () nil
1270 (defmethod initialize-instance ((item menu-item) &key label)
1274 (setf (menu-item-label item) label))))
1277 (defun (setf menu-item-label) (label menu-item)
1278 (make-instance 'accel-label
1279 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
1280 :use-underline (menu-item-use-underline-p menu-item)
1281 :visible t :parent menu-item)
1284 (defun menu-item-label (menu-item)
1285 (when (and (slot-boundp menu-item 'child)
1286 (typep (bin-child menu-item) 'label))
1287 (label-label (bin-child menu-item))))
1289 (defbinding menu-item-remove-submenu () nil
1290 (menu-item menu-item))
1292 (defbinding menu-item-set-accel-path () nil
1293 (menu-item menu-item)
1294 (accel-path string))
1296 (defbinding menu-item-select () nil
1297 (menu-item menu-item))
1299 (defbinding menu-item-deselect () nil
1300 (menu-item menu-item))
1302 (defbinding menu-item-activate () nil
1303 (menu-item menu-item))
1305 (defbinding menu-item-toggle-size-request () nil
1306 (menu-item menu-item)
1307 (requisition int :out))
1309 (defbinding menu-item-toggle-size-allocate () nil
1310 (menu-item menu-item)
1314 ;;; Menu tool button
1316 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1317 (defbinding menu-tool-button-set-arrow-tooltip () nil
1318 (menu-tool-button menu-tool-button)
1321 (tip-private string))
1326 (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1327 button buttons flags transient-parent)
1328 (let ((stock-buttons
1330 ((and (not buttons) (not button))
1334 ((listp buttons) :none)
1336 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1339 (defmethod shared-initialize ((dialog message-dialog) names &rest initargs
1340 &key message-type buttons button text
1341 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1343 (declare (ignore names))
1345 (message-dialog-set-markup dialog text))
1346 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1347 (when secondary-text
1348 (message-dialog-format-secondary-markup dialog secondary-text))
1349 (when (and (not buttons) (not button))
1351 for (key value) on initargs by #'cddr
1352 when (and (eq key :signal) (eq (first value) :close))
1353 do (warn "Default button configuration changed from ~A to ~A" :close
1354 (if (eq message-type :question) :yes-no :ok))
1356 (if (typep buttons 'buttons-type)
1357 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1358 (call-next-method)))
1361 (defbinding %message-dialog-new () pointer
1362 (parent (or null window))
1363 (flags dialog-flags)
1365 (buttons buttons-type)
1368 (defbinding message-dialog-set-markup () nil
1369 (message-dialog message-dialog)
1372 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1373 (defbinding message-dialog-format-secondary-text () nil
1374 (message-dialog message-dialog)
1377 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1378 (defbinding message-dialog-format-secondary-markup () nil
1379 (message-dialog message-dialog)
1386 (defbinding %radio-menu-item-get-group () pointer
1387 (radio-menu-item radio-menu-item))
1389 (defbinding %radio-menu-item-set-group () nil
1390 (radio-menu-item radio-menu-item)
1393 (defmethod activate-radio-widget ((item radio-menu-item))
1394 (menu-item-activate item))
1396 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
1397 "Add ITEM1 to the group which ITEM2 belongs to."
1398 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1400 (defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1401 (%add-activate-callback item 'activate function object after))
1403 (defmethod initialize-instance ((item radio-menu-item) &key group)
1407 (add-to-radio-group item group))))
1411 ;;; Radio tool button
1413 (defbinding %radio-tool-button-get-group () pointer
1414 (radio-tool-button radio-tool-button))
1416 (defbinding %radio-tool-button-set-group () nil
1417 (radio-tool-button radio-tool-button)
1420 (defmethod activate-radio-widget ((button radio-tool-button))
1421 (signal-emit button 'clicked))
1423 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
1424 "Add BUTTON1 to the group which BUTTON2 belongs to."
1425 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
1426 (defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1427 (%add-activate-callback button 'clicked function object after))
1429 (defmethod initialize-instance ((button radio-tool-button) &key group)
1433 (add-to-radio-group button group))))
1439 (defbinding toggle-button-toggled () nil
1440 (toggle-button toggle-button))
1445 (defmethod initialize-instance ((window window) &rest initargs
1446 &key display accel-group accel-groups)
1447 (declare (ignore accel-group accel-groups))
1450 (apply #'call-next-method
1451 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
1453 (initial-add window #'window-add-accel-group
1454 initargs :accel-group :accel-groups)))
1456 #-debug-ref-counting
1457 (defmethod print-object ((window window) stream)
1459 (proxy-valid-p window)
1460 (slot-boundp window 'title)
1461 (not (zerop (length (window-title window)))))
1462 (print-unreadable-object (window stream :type t :identity nil)
1463 (format stream "~S at 0x~X"
1464 (window-title window) (pointer-address (foreign-location window))))
1465 (call-next-method)))
1467 (defbinding window-set-wmclass () nil
1469 (wmclass-name string)
1470 (wmclass-class string))
1472 (defbinding window-add-accel-group () nil
1474 (accel-group accel-group))
1476 (defbinding window-remove-accel-group () nil
1478 (accel-group accel-group))
1480 (defbinding window-activate-focus () int
1483 (defbinding window-activate-default () int
1486 (defbinding window-set-default-size (window width height) int
1489 ((or height -1) int))
1491 (defbinding %window-set-geometry-hints () nil
1493 (widget (or widget null))
1494 (geometry gdk:geometry)
1495 (geometry-mask gdk:window-hints))
1497 (defun window-set-geometry-hints (window &key widget min-width min-height
1498 max-width max-height base-width base-height
1499 width-inc height-inc gravity
1500 aspect (min-aspect aspect) (max-aspect aspect))
1501 (let ((geometry (make-instance 'gdk:geometry
1502 :min-width (or min-width -1)
1503 :min-height (or min-height -1)
1504 :max-width (or max-width -1)
1505 :max-height (or max-height -1)
1506 :base-width (or base-width 0)
1507 :base-height (or base-height 0)
1508 :width-inc (or width-inc 0)
1509 :height-inc (or height-inc 0)
1510 :min-aspect (or min-aspect 0)
1511 :max-aspect (or max-aspect 0)))
1513 (when (or min-width min-height)
1514 (push :min-size mask))
1515 (when (or max-width max-height)
1516 (push :max-size mask))
1517 (when (or base-width base-height)
1518 (push :base-size mask))
1519 (when (or width-inc height-inc)
1520 (push :resize-inc mask))
1521 (when (or min-aspect max-aspect)
1522 (push :aspect mask))
1524 (push :win-gravity mask)
1525 (setf (gdk:geometry-gravity geometry) gravity))
1526 (%window-set-geometry-hints window widget geometry mask)))
1528 (defbinding window-list-toplevels () (glist (copy-of window))
1529 "Returns a list of all existing toplevel windows.")
1531 (defbinding window-add-mnemonic (window key target) nil
1533 ((gdk:keyval-from-name key) unsigned-int)
1536 (defbinding window-remove-mnemonic (window key target) nil
1538 ((gdk:keyval-from-name key) unsigned-int)
1541 (defbinding window-mnemonic-activate (window key modifier) nil
1543 ((gdk:keyval-from-name key) unsigned-int)
1544 (modifier gdk:modifier-type))
1546 (defbinding window-activate-key () boolean
1548 (event gdk:key-event))
1550 (defbinding window-propagate-key-event () boolean
1552 (event gdk:key-event))
1554 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1555 (defbinding window-present () nil
1558 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1560 (defbinding %window-present () nil
1563 (defbinding %window-present-with-time () nil
1565 (timespamp unsigned-int))
1567 (defun window-present (window &optional timestamp)
1569 (%window-present-with-time window timestamp)
1570 (%window-present window))))
1572 (defbinding window-iconify () nil
1575 (defbinding window-deiconify () nil
1578 (defbinding window-stick () nil
1581 (defbinding window-unstick () nil
1584 (defbinding window-maximize () nil
1587 (defbinding window-unmaximize () nil
1590 (defbinding window-fullscreen () nil
1593 (defbinding window-unfullscreen () nil
1596 (defbinding window-set-keep-above () nil
1600 (defbinding window-set-keep-below () nil
1604 (defbinding window-begin-resize-drag () nil
1606 (edge gdk:window-edge)
1608 (root-x int) (root-y int)
1609 (timestamp unsigned-int))
1611 (defbinding window-begin-move-drag () nil
1613 (edge gdk:window-edge)
1615 (root-x int) (root-y int)
1616 (timestamp unsigned-int))
1618 (defbinding window-set-frame-dimensions () nil
1620 (left int) (top int) (rigth int) (bottom int))
1622 (defbinding %window-get-default-size () nil
1627 (defun window-get-default-size (window)
1628 (multiple-value-bind (width height) (%window-get-default-size window)
1629 (values (unless (= width -1) width) (unless (= height -1) height))))
1631 (defbinding window-get-frame-dimensions () nil
1633 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1635 (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
1638 (defbinding window-get-position () nil
1643 (defbinding window-get-size () nil
1648 (defbinding window-move () nil
1653 (defbinding window-parse-geometry () boolean
1657 (defbinding window-reshow-with-initial-size () nil
1660 (defbinding window-resize () nil
1665 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1666 () (glist gdk:pixbuf))
1668 (defun window-default-icon ()
1669 (first (window-default-icon-list)))
1671 (defbinding %window-set-default-icon-list () nil
1672 (icons (glist gdk:pixbuf)))
1674 (defun (setf window-default-icon-list) (icons)
1675 (%window-set-default-icon-list icons)
1678 (defbinding %window-set-default-icon () nil
1679 (icons (glist gdk:pixbuf)))
1681 (defgeneric (setf window-default-icon) (icon))
1683 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1684 (%window-set-default-icon icon)
1687 (defgeneric (setf window-group) (group window))
1689 (defmethod (setf window-group) ((group window-group) (window window))
1690 (window-group-add-window group window)
1693 (defbinding %window-set-default-icon-from-file () boolean
1697 (defmethod (setf window-default-icon) ((icon-file pathname))
1698 (%window-set-default-icon-from-file icon-file)
1701 (defbinding %window-set-icon-from-file () boolean
1706 (defmethod (setf window-icon) ((icon-file pathname) (window window))
1707 (%window-set-icon-from-file window icon-file)
1710 (defbinding window-set-auto-startup-notification () nil
1713 (defbinding decorated-window-init () nil
1716 (defbinding decorated-window-calculate-frame-size () nil
1719 (defbinding decorated-window-set-title () nil
1723 (defbinding decorated-window-move-resize-window () nil
1733 (defmethod initialize-instance ((window-group window-group) &rest initargs
1734 &key window windows)
1735 (declare (ignore window windows))
1738 (initial-add window-group #'window-group-add-window
1739 initargs :window :windows)))
1742 (defbinding window-group-add-window () nil
1743 (window-group window-group)
1746 (defbinding window-group-remove-window () nil
1747 (window-group window-group)
1753 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1754 (setf (scrolled-window-hscrollbar-policy window) policy)
1755 (setf (scrolled-window-vscrollbar-policy window) policy))
1757 (defbinding scrolled-window-add-with-viewport () nil
1758 (scrolled-window scrolled-window)
1761 (defmethod shared-initialize ((window scrolled-window) names &key policy)
1762 (declare (ignore names))
1764 (setf (slot-value window 'hscrollbar-policy) policy)
1765 (setf (slot-value window 'vscrollbar-policy) policy))
1771 (defbinding statusbar-get-context-id () unsigned-int
1772 (statusbar statusbar)
1773 (context-description string))
1775 (defbinding statusbar-push () unsigned-int
1776 (statusbar statusbar)
1777 (context-id unsigned-int)
1780 (defbinding statusbar-pop () nil
1781 (statusbar statusbar)
1782 (context-id unsigned-int))
1784 (defbinding statusbar-remove () nil
1785 (statusbar statusbar)
1786 (context-id unsigned-int)
1787 (message-id unsigned-int))
1793 (defbinding fixed-put () nil
1798 (defbinding fixed-move () nil
1807 (defun %ensure-notebook-position (notebook page)
1810 (widget (notebook-page-num notebook page t))))
1812 (defun %ensure-notebook-child (notebook position)
1815 (t (notebook-get-nth-page notebook position))))
1817 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1818 (notebook position child &optional tab-label menu-label) nil
1821 ((if (stringp tab-label)
1822 (make-instance 'label :label tab-label)
1823 tab-label) (or null widget))
1824 ((if (stringp menu-label)
1825 (make-instance 'label :label menu-label)
1826 menu-label) (or null widget))
1827 ((%ensure-notebook-position notebook position) position))
1829 (defun notebook-append (notebook child &optional tab-label menu-label)
1830 (notebook-insert notebook :last child tab-label menu-label))
1832 (defun notebook-prepend (notebook child &optional tab-label menu-label)
1833 (notebook-insert notebook :first child tab-label menu-label))
1835 (defbinding notebook-remove-page (notebook page) nil
1837 ((%ensure-notebook-position notebook page) position))
1839 (defbinding %notebook-page-num () int
1843 (defun notebook-page-num (notebook child &optional error-p)
1844 (let ((page-num (%notebook-page-num notebook child)))
1847 (error "~A is not a page in ~A" child notebook))
1850 (defbinding notebook-next-page () nil
1851 (notebook notebook))
1853 (defbinding notebook-prev-page () nil
1854 (notebook notebook))
1856 (defbinding notebook-reorder-child (notebook child position) nil
1859 ((%ensure-notebook-position notebook position) int))
1861 (defbinding notebook-popup-enable () nil
1862 (notebook notebook))
1864 (defbinding notebook-popup-disable () nil
1865 (notebook notebook))
1867 (defbinding notebook-get-nth-page () widget
1871 (defun %notebook-current-page (notebook)
1872 (when (slot-boundp notebook 'current-page-num)
1873 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
1875 (defun (setf notebook-current-page) (page notebook)
1876 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
1878 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1879 (notebook page) widget
1881 ((%ensure-notebook-child notebook page) widget))
1883 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1884 (notebook page) (copy-of string)
1886 ((%ensure-notebook-child notebook page) widget))
1888 (defbinding %notebook-set-tab-label () nil
1893 (defun (setf notebook-tab-label) (tab-label notebook page)
1894 (let ((widget (if (stringp tab-label)
1895 (make-instance 'label :label tab-label)
1897 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1901 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1902 (notebook page) widget
1904 ((%ensure-notebook-child notebook page) widget))
1906 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1907 (notebook page) (copy-of string)
1909 ((%ensure-notebook-child notebook page) widget))
1911 (defbinding %notebook-set-menu-label () nil
1914 (menu-label widget))
1916 (defun (setf notebook-menu-label) (menu-label notebook page)
1917 (let ((widget (if (stringp menu-label)
1918 (make-instance 'label :label menu-label)
1920 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1924 (defbinding notebook-query-tab-label-packing (notebook page) nil
1926 ((%ensure-notebook-child notebook page) widget)
1927 (expand boolean :out)
1929 (pack-type pack-type :out))
1931 (defbinding notebook-set-tab-label-packing
1932 (notebook page expand fill pack-type) nil
1934 ((%ensure-notebook-child notebook page) widget)
1937 (pack-type pack-type))
1943 (defbinding paned-pack1 () nil
1949 (defbinding paned-pack2 () nil
1958 (defbinding layout-put () nil
1964 (defbinding layout-move () nil
1970 (defbinding layout-set-size () nil
1972 (width unsigned-int)
1973 (height unsigned-int))
1975 (defbinding layout-get-size () nil
1977 (width unsigned-int :out)
1978 (height unsigned-int :out))
1983 (defbinding menu-shell-insert (menu-shell menu-item position) nil
1984 (menu-shell menu-shell)
1985 (menu-item menu-item)
1991 (defun menu-shell-append (menu-shell menu-item)
1992 (menu-shell-insert menu-shell menu-item :last))
1994 (defun menu-shell-prepend (menu-shell menu-item)
1995 (menu-shell-insert menu-shell menu-item :fisrt))
1997 (defbinding menu-shell-deactivate () nil
1998 (menu-shell menu-shell))
2000 (defbinding menu-shell-select-item () nil
2001 (menu-shell menu-shell)
2002 (menu-item menu-item))
2004 (defbinding menu-shell-select-first () nil
2005 (menu-shell menu-shell)
2006 (search-sensitive boolean))
2008 (defbinding menu-shell-deselect () nil
2009 (menu-shell menu-shell))
2011 (defbinding menu-shell-activate-item () nil
2012 (menu-shell menu-shell)
2013 (menu-item menu-item)
2014 (fore-deactivate boolean))
2016 (defbinding menu-shell-cancel () nil
2017 (menu-shell menu-shell))
2022 (defun %menu-position (menu child)
2025 (keyword (case child
2028 (t (error "Invalid position keyword: ~A" child))))
2029 (widget (menu-child-position menu child))))
2032 (defbinding menu-reorder-child (menu menu-item position) nil
2034 (menu-item menu-item)
2035 ((%menu-position menu position) int))
2037 (defbinding menu-attach () nil
2039 (menu-item menu-item)
2040 (left-attach unsigned-int)
2041 (right-attach unsigned-int)
2042 (top-attach unsigned-int)
2043 (bottom-attach unsigned-int))
2045 (define-callback-marshal %menu-position-callback nil
2046 (menu (x int) (y int) (push-in boolean)))
2048 (defbinding %menu-popup () nil
2050 (parent-menu-shell (or null menu-shell))
2051 (parent-menu-item (or null menu-item))
2052 (callback (or null callback))
2053 (callback-id unsigned-int)
2054 (button unsigned-int)
2055 (activate-time (unsigned 32)))
2057 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
2060 (with-callback-function (id callback)
2062 menu parent-menu-shell parent-menu-item
2063 %menu-position-callback id button activate-time))
2065 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2067 (defbinding menu-set-accel-path () nil
2069 (accel-path string))
2071 (defbinding menu-reposition () nil
2074 (defbinding menu-popdown () nil
2077 (defun menu-child-position (menu child)
2078 (position child (container-children menu)))
2080 (defun menu-active-num (menu)
2081 (menu-child-position menu (menu-active menu)))
2083 (defbinding %menu-set-active () nil
2085 (index unsigned-int))
2087 (defun (setf menu-active) (menu child)
2088 (%menu-set-active menu (%menu-position menu child))
2091 (define-callback %menu-detach-callback nil ((widget widget) (menu menu))
2092 (funcall (user-data menu 'detach-func) widget menu))
2094 (defbinding %menu-attach-to-widget (menu widget) nil
2097 (%menu-detach-callback callback))
2099 (defun menu-attach-to-widget (menu widget function)
2100 (setf (user-data menu 'detach-func) function)
2101 (%menu-attach-to-widget menu widget))
2103 (defbinding menu-detach () nil
2106 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2107 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2110 (defbinding menu-set-monitor () nil
2117 (defbinding table-resize () nil
2120 (columns unsigned-int))
2122 (defbinding table-attach (table child left right top bottom
2123 &key options x-options y-options
2124 (x-padding 0) (y-padding 0)) nil
2128 (right unsigned-int)
2130 (bottom unsigned-int)
2131 ((append (mklist options) (mklist x-options)) attach-options)
2132 ((append (mklist options) (mklist y-options)) attach-options)
2133 (x-padding unsigned-int)
2134 (y-padding unsigned-int))
2137 (defbinding %table-set-row-spacing () nil
2140 (spacing unsigned-int))
2142 (defbinding %table-set-row-spacings () nil
2144 (spacing unsigned-int))
2146 (defun (setf table-row-spacing) (spacing table &optional row)
2148 (%table-set-row-spacing table row spacing)
2149 (%table-set-row-spacings table spacing))
2152 (defbinding %table-get-row-spacing () unsigned-int
2156 (defbinding %table-get-default-row-spacing () unsigned-int
2159 (defun table-row-spacing (table &optional row)
2161 (%table-get-row-spacing table row)
2162 (%table-get-default-row-spacing table)))
2165 (defbinding %table-set-col-spacing () nil
2168 (spacing unsigned-int))
2170 (defbinding %table-set-col-spacings () nil
2172 (spacing unsigned-int))
2174 (defun (setf table-column-spacing) (spacing table &optional column)
2176 (%table-set-col-spacing table column spacing)
2177 (%table-set-col-spacings table spacing))
2180 (defun (setf table-col-spacing) (spacing table &optional col)
2181 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2182 (setf (table-column-spacing table col) spacing))
2184 (defbinding %table-get-col-spacing () unsigned-int
2188 (defbinding %table-get-default-col-spacing () unsigned-int
2191 (defun table-column-spacing (table &optional column)
2193 (%table-get-col-spacing table column)
2194 (%table-get-default-col-spacing table)))
2196 (defun table-col-spacing (table &optional col)
2197 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2198 (table-column-spacing table col))
2204 (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2206 (apply #'call-next-method toolbar
2207 :tooltips (make-instance 'tooltips) initargs)
2208 (call-next-method)))
2210 (defbinding %toolbar-insert () nil
2212 (tool-item tool-item)
2213 (position position))
2215 (defun toolbar-insert (toolbar tool-item &optional (position :end))
2216 (%toolbar-insert toolbar tool-item position)
2217 (%tool-item-update-tooltips tool-item))
2219 (defbinding toolbar-get-item-index () int
2223 (defbinding toolbar-get-nth-item () tool-item
2227 (defbinding toolbar-get-drop-index () int
2231 (defbinding toolbar-set-drop-highlight-item () nil
2233 (tool-item tool-item)
2239 (defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2240 (if (and icon (not (typep icon 'widget)))
2241 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2242 (call-next-method)))
2247 (defbinding tool-item-set-tooltip () nil
2248 (tool-item tool-item)
2251 (tip-private string))
2254 (defun %tool-item-update-tooltips (tool-item)
2256 (slot-boundp tool-item 'parent)
2258 (user-data-p tool-item 'tip-text)
2259 (user-data-p tool-item 'tip-private)))
2260 (tool-item-set-tooltip
2261 tool-item (toolbar-tooltips (widget-parent tool-item))
2262 (or (user-data tool-item 'tip-text) "")
2263 (or (user-data tool-item 'tip-private) ""))))
2265 (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2266 (setf (user-data tool-item 'tip-text) tip-text)
2267 (%tool-item-update-tooltips tool-item)
2270 (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2271 (setf (user-data tool-item 'tip-private) tip-private)
2272 (%tool-item-update-tooltips tool-item)
2275 (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2276 (declare (ignore args))
2279 (%tool-item-update-tooltips tool-item)))
2282 (defbinding tool-item-retrieve-proxy-menu-item () widget
2283 (tool-item tool-item))
2285 (defbinding (tool-item-proxy-menu-item
2286 "gtk_tool_item_get_proxy_menu_item") () menu-item
2287 (tool-item tool-item)
2288 (menu-item-id string))
2290 (defbinding %tool-item-set-proxy-menu-item () nil
2291 (tool-item tool-item)
2292 (menu-item-id string)
2293 (menu-item menu-item))
2295 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2296 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2299 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2300 (defbinding tool-item-rebuild-menu () nil
2301 (tool-item tool-item))
2306 (defbinding editable-select-region (editable &optional (start 0) end) nil
2311 (defbinding editable-get-selection-bounds (editable) nil
2316 (defbinding editable-insert-text (editable text &optional (position 0)) nil
2320 (position position :in/out))
2322 (defun editable-append-text (editable text)
2323 (editable-insert-text editable text nil))
2325 (defun editable-prepend-text (editable text)
2326 (editable-insert-text editable text 0))
2328 (defbinding editable-delete-text (editable &optional (start 0) end) nil
2333 (defbinding (editable-text "gtk_editable_get_chars")
2334 (editable &optional (start 0) end) string
2339 (defun (setf editable-text) (text editable)
2341 (editable-delete-text
2343 (editable-insert-text editable text))
2344 (editable-delete-text editable))
2347 (defbinding editable-cut-clipboard () nil
2348 (editable editable))
2350 (defbinding editable-copy-clipboard () nil
2351 (editable editable))
2353 (defbinding editable-paste-clipboard () nil
2354 (editable editable))
2356 (defbinding editable-delete-selection () nil
2357 (editable editable))
2363 (defbinding spin-button-configure () nil
2364 (spin-button spin-button)
2365 (adjustment adjustment)
2366 (climb-rate double-float)
2367 (digits unsigned-int))
2369 (defbinding spin-button-set-range () nil
2370 (spin-button spin-button)
2374 (defbinding spin-button-get-range () nil
2375 (spin-button spin-button)
2376 (min double-float :out)
2377 (max double-float :out))
2379 (defun spin-button-value-as-int (spin-button)
2380 (round (spin-button-value spin-button)))
2382 (defbinding %spin-button-spin () nil
2383 (spin-button spin-button)
2384 (direction spin-type)
2385 (increment double-float))
2387 (defun spin-button-spin (spin-button value)
2389 (real (%spin-button-spin spin-button :spin-user-defined value))
2390 (spin-type (%spin-button-spin spin-button value 0))))
2393 (defbinding spin-button-update () nil
2394 (spin-button spin-button))
2400 (defbinding ruler-set-range () nil
2402 (lower single-float)
2403 (upper single-float)
2404 (position single-float)
2405 (max-size single-float))
2407 (defbinding ruler-get-range () nil
2409 (lower single-float :out)
2410 (upper single-float :out)
2411 (position single-float :out)
2412 (max-size single-float :out))
2418 (defun range-lower (range)
2419 (adjustment-lower (range-adjustment range)))
2421 (defun range-upper (range)
2422 (adjustment-upper (range-adjustment range)))
2424 (defun (setf range-lower) (value range)
2425 (setf (adjustment-lower (range-adjustment range)) value))
2427 (defun (setf range-upper) (value range)
2428 (setf (adjustment-upper (range-adjustment range)) value))
2430 (defun range-page-increment (range)
2431 (adjustment-page-increment (range-adjustment range)))
2433 (defun range-step-increment (range)
2434 (adjustment-step-increment (range-adjustment range)))
2436 (defun (setf range-page-increment) (value range)
2437 (setf (adjustment-page-increment (range-adjustment range)) value))
2439 (defun (setf range-step-increment) (value range)
2440 (setf (adjustment-step-increment (range-adjustment range)) value))
2442 (defbinding range-set-range () nil
2444 (lower double-float)
2445 (upper double-float))
2447 (defbinding range-set-increments () nil
2450 (page double-float))
2455 (defbinding scale-get-layout-offsets () nil
2463 (defbinding progress-bar-pulse () nil
2464 (progress-bar progress-bar))
2469 (defmethod initialize-instance ((size-group size-group) &rest initargs
2470 &key widget widgets)
2471 (declare (ignore widget widgets))
2474 (initial-add size-group #'size-group-add-widget
2475 initargs :widget :widgets)))
2478 (defbinding size-group-add-widget () nil
2479 (size-group size-group)
2482 (defbinding size-group-remove-widget () nil
2483 (size-group size-group)
2489 (defbinding %stock-item-copy () pointer
2492 (defbinding %stock-item-free () nil
2495 (defbinding stock-add (stock-item) nil
2496 (stock-item stock-item)
2499 (defbinding stock-list-ids () (gslist string))
2501 (defbinding %stock-lookup () boolean
2505 (defun stock-lookup (stock-id)
2506 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
2507 (when (%stock-lookup stock-id stock-item)
2508 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
2510 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
2512 (define-callback-marshal %stock-translate-callback string ((path string)))
2514 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2515 (domain function) nil
2517 (%stock-translate-callback callback)
2518 ((register-callback-function function) unsigned-int)
2519 (user-data-destroy-callback callback)))
2524 ;; #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2526 ;; (defbinding %tooltip-set-markup () nil
2530 ;; (defbinding %tooltip-set-text () nil
2534 ;; (defbinding %tooltip-set-icon () nil
2536 ;; (icon gdk:pixbuf))
2538 ;; (defbinding %tooltip-set-from-stock-icon () nil
2540 ;; (stock-id string)
2543 ;; (defbinding %tooltip-set-custom () nil
2547 ;; (defun tooltip-set (tooltip value &key (markup t) (icon-size :button))
2549 ;; (string (if markup
2550 ;; (tooltip-set-markup tooltip value)
2551 ;; (tooltip-set-text tooltip value)))
2552 ;; (pixbuf (tooltip-set-icon tooltip value))
2553 ;; (keyword (tooltip-set-icon-from-stock tooltip value icon-size))
2559 ;; GtkTooltips has been deprecated in favor of the new tooltip API
2560 ;; introduced in in GTK+ 2.12
2562 (defbinding tooltips-enable () nil
2563 (tooltips tooltips))
2565 (defbinding tooltips-disable () nil
2566 (tooltips tooltips))
2568 (defun (setf tooltips-enabled-p) (enable tooltips)
2570 (tooltips-enable tooltips)
2571 (tooltips-disable tooltips)))
2573 (defbinding tooltips-set-tip () nil
2577 (tip-private string))
2579 (defbinding tooltips-data-get () tooltips-data
2582 (defbinding tooltips-force-window () nil
2583 (tooltips tooltips))
2585 (defbinding tooltips-get-info-from-tip-window () boolean
2587 (tooltips tooltips :out)
2588 (current-widget widget :out))
2593 (defbinding rc-get-style () style
2596 (defbinding rc-get-style-by-paths (&key path class-path class) style
2597 (path (or null string))
2598 (class-path (or null string))
2601 (defbinding rc-parse () nil
2602 (filename pathname))
2604 (defbinding rc-parse-string () nil
2607 (defbinding %rc-reparse-all () boolean)
2609 (defbinding %rc-reparse-all-for-settings () boolean
2611 (force-load-p boolean))
2613 (defun rc-reparse-all (&optional setting force-load-p)
2615 (%rc-reparse-all-for-settings setting force-load-p)
2618 (defbinding rc-reset-styles () nil
2619 (settings settings))
2621 (defbinding rc-add-default-file () nil
2622 (filename pathname))
2624 (defbinding rc-get-default-files ()
2625 (copy-of (null-terminated-vector (copy-of string))))
2627 (defbinding rc-get-module-dir () string)
2629 (defbinding rc-get-im-module-path () string)
2631 (defbinding rc-get-im-module-file () string)
2633 (defbinding rc-get-theme-dir () string)
2638 (defbinding (settings-get "gtk_settings_get_for_screen")
2639 (&optional (screen (gdk:display-get-default-screen))) settings
2640 (screen gdk:screen))
2645 (defbinding socket-add-id () nil
2647 (id gdk:native-window))
2649 (defbinding %plug-new () pointer
2650 (id gdk:native-window))
2652 (defmethod allocate-foreign ((plug plug) &key id)
2653 (%plug-new (or id 0)))
2658 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2660 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2662 (defbinding link-button-set-uri-hook (function) pointer
2663 (%link-button-uri-callback callback)
2664 ((register-callback-function function) unsigned-int)
2665 (user-data-destroy-callback callback)))
2670 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2672 (defmethod initialize-instance ((builder builder) &key interface
2673 (connect-signals t) (package *package*))
2675 (etypecase interface
2677 (string (builder-add-from-string builder interface))
2678 (pathname (builder-add-from-file builder interface)))
2679 (when connect-signals
2680 (builder-connect-signals builder package)))
2683 (defbinding builder-add-from-file () boolean
2686 (nil gerror-signal :out))
2688 (defbinding builder-add-from-string () boolean
2691 (-1 int) ; TODO: add gsize type
2692 (nil gerror-signal :out))
2694 (defbinding builder-get-object () gobject
2698 (defbinding builder-get-objects () (gslist gobject)
2701 (defun intern-with-package-prefix (name default-package)
2702 (let ((pos (position #\: name)))
2705 (string-upcase (subseq name (1+ pos)))
2706 (string-upcase (subseq name 0 pos)))
2707 (intern (string-upcase name) default-package))))
2709 (define-callback %builder-connect-function nil
2710 (builder (object gobject) (signal-name string) (handler-name string)
2711 (connect-object gobject) connect-flags (package user-data-id))
2712 (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)
2715 (intern-with-package-prefix handler-name (find-user-data package))
2716 :object (or connect-object object) :after (find :after connect-flags)))
2718 (defbinding %builder-connect-signals-full (builder package) nil
2720 (%builder-connect-function callback)
2721 (package user-data-id))
2723 (defun builder-connect-signals (builder &optional (package *package*))
2724 (with-user-data (id package)
2725 (%builder-connect-signals-full builder id))))