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.86 2007-12-30 18:37:12 espen Exp $
30 (defbinding check-version () (copy-of string)
31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
35 (defbinding query-version () nil
36 (major unsigned-int :out)
37 (minor unsigned-int :out)
38 (micro unsigned-int :out))
41 (multiple-value-bind (major minor micro)
44 (format nil "Gtk+ v~A.~A" major minor)
45 (format nil "Gtk+ v~A.~A.~A" major minor micro))))
51 ;;;; Initalization and display handling
53 (defparameter *event-poll-interval* 10000) ; in microseconds
56 (defbinding (gtk-init "gtk_parse_args") () boolean
57 "Initializes the library without opening the display."
61 (defun clg-init (&optional display multi-threading-p)
62 "Initializes the system and starts event handling."
63 (unless (gdk:display-get-default)
64 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
66 #+sbcl(sb-int:set-floating-point-modes :traps nil)
67 #+cmu(ext:set-floating-point-modes :traps nil))
71 (error "Initialization of GTK+ failed."))
73 (if (not multi-threading-p)
74 (%init-async-event-handling display)
75 #+sb-thread(%init-multi-threaded-event-handling display)
76 #-sb-thread(error "Multi threading not supported on this platform")))
77 (gdk:ensure-display display t))
79 (defun clg-init-with-threading (&optional display)
84 ;; A very minimal implementation of CLISP's socket-status
85 (defun socket-status (socket seconds microseconds)
86 (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set)))
87 (let ((fd (sb-sys:fd-stream-fd (car socket))))
88 (sb-unix:fd-zero read-fds)
89 (sb-unix:fd-set fd read-fds)
91 (let ((num-fds-changed
92 (sb-unix:unix-fast-select
93 (1+ fd) (sb-alien:addr read-fds) nil nil
94 seconds microseconds)))
95 (unless (or (not num-fds-changed) (zerop num-fds-changed))
96 (if (peek-char nil (car socket) nil)
100 (defun %init-async-event-handling (display)
101 (let ((style #?(or (featurep :cmu) (sbcl< 1 0 6)) :fd-handler
102 #?-(or (featurep :cmu) (sbcl< 1 0 6)) nil))
104 (find-package "SWANK")
105 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style)))
106 (error "When running clg in Slime, the communication style ~S must be used in combination with asynchronous event handling on this platform. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information." style)))
108 #?(or (featurep :cmu) (sbcl< 1 0 6))
110 (signal-connect (gdk:display-manager) 'display-opened
112 (let ((fd (gdk:display-connection-number display)))
114 (let ((handler (add-fd-handler
115 (gdk:display-connection-number display)
116 :input #'main-iterate-all)))
117 (signal-connect display 'closed
118 #'(lambda (is-error-p)
119 (declare (ignore is-error-p))
120 (remove-fd-handler handler))))))))
121 (setq *periodic-polling-function* #'main-iterate-all)
122 (setq *max-event-to-sec* 0)
123 (setq *max-event-to-usec* *event-poll-interval*))
125 #+(and clisp readline)
126 ;; Readline will call the event hook at most ten times per second
127 (setf readline:event-hook #'main-iterate-all)
129 #?-(or (featurep :cmu) (sbcl< 1 0 6))
130 ;; When running in Slime we need to hook into the Swank server
131 ;; to handle events asynchronously.
132 (if (find-package "SWANK")
133 (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")))
134 (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK")))))
135 (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))
138 (case (socket-status (cons stream :input) 0 *event-poll-interval*)
139 ((:input :eof) (return (funcall read-from-emacs)))
140 (otherwise (main-iterate-all)))))))
141 #-(and clisp readline)
142 (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started."))
144 (gdk:display-open display))
148 (defvar *main-thread* nil)
150 ;; Hopefully, when threading support is added to the Win32 port of
151 ;; SBCL in the future, this will work just out of the box.
153 (let ((done (sb-thread:make-waitqueue))
157 ;; In Win32 all GDK calls have to be made from the main loop
158 ;; thread, so we add a timeout function which will poll for code and
161 (defun funcall-in-main (function)
164 (eq sb-thread:*current-thread* *main-thread*))
166 (gdk:with-global-lock
167 (push function functions)
168 (sb-thread:condition-wait done gdk:*global-lock*)
171 ;; Will lock REPL on error, need to be fixed!
172 (defun %funcall-in-main-poll ()
177 do (push (funcall (pop functions)) results)
178 finally (sb-thread:condition-notify done n)))
181 (defmacro within-main-loop (&body body)
182 #-win32 `(gdk:with-global-lock ,@body)
183 #+win32 `(funcall-in-main #'(lambda () ,@body)))
185 (defun %init-multi-threaded-event-handling (display)
187 (find-package "SWANK")
188 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn)))
189 (error "When running clg in Slime, the communication style :spawn must be used in combination with multi threaded event handling. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information."))
191 (let ((main-running (sb-thread:make-waitqueue)))
192 (gdk:with-global-lock
194 (sb-thread:make-thread
196 (gdk:with-global-lock
197 (gdk:display-open display)
198 #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000)
199 #'%funcall-in-main-poll)
200 (sb-thread:condition-notify main-running)
202 :name "gtk event loop"))
203 (sb-thread:condition-wait main-running gdk:*global-lock*)))
205 ;; We need to hook into the Swank server to protect calls to GDK properly.
206 ;; This will *only* protect code entered directly in the REPL.
207 (when (find-package "SWANK")
208 (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
210 (push #'(lambda (form)
211 (within-main-loop (eval form)))
212 (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
213 (warn "Your version of Slime does not have *SLIME-REPL-EVAL-HOOKS* so all calls to Gtk+ functions have to be explicit protected by wrapping them in a WITHIN-MAIN-LOOP form"))))))
216 (defmacro within-main-loop (&body body)
221 ;;; Generic functions
223 (defgeneric add-to-radio-group (item1 item2))
224 (defgeneric activate-radio-widget (item))
225 (defgeneric (setf tool-item-tip-text) (tip-text tool-item))
226 (defgeneric (setf tool-item-tip-private) (tip-private tool-item))
232 (defbinding grab-add () nil
235 (defbinding grab-get-current () widget)
237 (defbinding grab-remove () nil
240 (defbinding get-default-language () (copy-of pango:language))
245 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
247 (define-callback-marshal %about-dialog-activate-link-callback nil
248 (about-dialog (link string)))
250 (defbinding about-dialog-set-email-hook (function) nil
251 (%about-dialog-activate-link-callback callback)
252 ((register-callback-function function) unsigned-int)
253 (user-data-destroy-callback callback))
255 (defbinding about-dialog-set-url-hook (function) nil
256 (%about-dialog-activate-link-callback callback)
257 ((register-callback-function function) unsigned-int)
258 (user-data-destroy-callback callback)))
263 (defbinding %accel-group-connect () nil
264 (accel-group accel-group)
266 (modifiers gdk:modifier-type)
270 (defun accel-group-connect (group accelerator function &optional flags)
271 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
272 (let ((gclosure (make-callback-closure function)))
273 (%accel-group-connect group key modifiers flags gclosure)
276 (defbinding accel-group-connect-by-path (group path function) nil
279 ((make-callback-closure function) gclosure :in/return))
281 (defbinding %accel-group-disconnect (group gclosure) boolean
285 (defbinding %accel-group-disconnect-key () boolean
288 (modifiers gdk:modifier-type))
290 (defun accel-group-disconnect (group accelerator)
291 (etypecase accelerator
292 (gclosure (%accel-group-disconnect group accelerator))
294 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
295 (%accel-group-disconnect-key group key modifiers)))))
297 (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
298 (accel-group accel-group)
300 (modifiers gdk:modifier-type)
303 (defun accel-group-query (accel-group accelerator)
304 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
305 (%accel-group-query accel-group key modifiers)))
307 (defbinding %accel-group-activate () boolean
308 (accel-group accel-group)
309 (acceleratable gobject)
311 (modifiers gdk:modifier-type))
313 (defun accel-group-activate (accel-group acceleratable accelerator)
314 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
315 (%accel-group-activate accel-group acceleratable key modifiers)))
317 (defbinding accel-group-lock () nil
318 (accel-group accel-group))
320 (defbinding accel-group-unlock () nil
321 (accel-group accel-group))
323 (defbinding accel-group-from-accel-closure () accel-group
326 (defbinding %accel-groups-activate () boolean
329 (modifiers gdk:modifier-type))
331 (defun accel-groups-activate (object accelerator)
332 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
333 (%accel-groups-activate object key modifiers)))
335 (defbinding accel-groups-from-object () (gslist accel-group)
338 (defbinding accelerator-valid-p (key &optional modifiers) boolean
340 (modifiers gdk:modifier-type))
342 (defbinding %accelerator-parse () nil
344 (key unsigned-int :out)
345 (modifiers gdk:modifier-type :out))
347 (defgeneric parse-accelerator (accelerator))
349 (defmethod parse-accelerator ((accelerator string))
350 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
352 (error "Invalid accelerator: ~A" accelerator)
353 (values key modifiers))))
355 (defmethod parse-accelerator ((accelerator cons))
356 (destructuring-bind (key modifiers) accelerator
362 (gdk:keyval-from-name key)
363 (error "Invalid key name: ~A" key)))
364 (character (parse-accelerator key)))
367 (defmethod parse-accelerator ((key integer))
370 (defmethod parse-accelerator ((key character))
372 (gdk:keyval-from-name (string key))
373 (error "Invalid key name: ~A" key)))
376 (defbinding accelerator-name () string
378 (modifiers gdk:modifier-type))
380 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
381 (defbinding accelerator-get-label () string
383 (modifiers gdk:modifier-type))
385 (defbinding %accelerator-set-default-mod-mask () nil
386 (default-modifiers gdk:modifier-type))
388 (defun (setf accelerator-default-modifier-mask) (default-modifiers)
389 (%accelerator-set-default-mod-mask default-modifiers))
391 (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
396 (defbinding accel-label-get-accel-width () unsigned-int
397 (accel-label accel-label))
399 (defbinding accel-label-refetch () boolean
400 (accel-label accel-label))
406 (defbinding %accel-map-add-entry () nil
409 (modifiers gdk:modifier-type))
411 (defun accel-map-add-entry (path accelerator)
412 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
413 (%accel-map-add-entry path key modifiers)))
415 (defbinding %accel-map-lookup-entry () boolean
417 ((make-instance 'accel-key) accel-key :in/return))
419 (defun accel-map-lookup-entry (path)
420 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
423 (slot-value accel-key 'key)
424 (slot-value accel-key 'modifiers)
425 (slot-value accel-key 'flags)))))
427 (defbinding %accel-map-change-entry () boolean
430 (modifiers gdk:modifier-type)
433 (defun accel-map-change-entry (path accelerator &optional replace)
434 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
435 (%accel-map-change-entry path key modifiers replace)))
437 (defbinding accel-map-load () nil
440 (defbinding accel-map-save () nil
443 (define-callback-marshal %accel-map-foreach-callback nil
444 ((accel-path string) (key unsigned-int)
445 (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first)
447 (defbinding %accel-map-foreach (callback-id) nil
448 (callback-id unsigned-int)
449 (%accel-map-foreach-callback callback))
451 (defbinding %accel-map-foreach-unfiltered (callback-id) nil
452 (callback-id unsigned-int)
453 (%accel-map-foreach-callback callback))
455 (defun accel-map-foreach (function &optional (filter-p t))
456 (with-callback-function (id function)
458 (%accel-map-foreach id)
459 (%accel-map-foreach-unfiltered id))))
461 (defbinding accel-map-add-filter () nil
464 (defbinding accel-map-get () accel-map)
466 (defbinding accel-map-lock-path () nil
469 (defbinding accel-map-unlock-path () nil
476 (defbinding accessible-connect-widget-destroyed () nil
477 (accessible accessible))
482 (defmethod initialize-instance ((adjustment adjustment) &key value)
485 ;; we need to make sure that the value is set last, otherwise it
486 ;; may be outside current limits and ignored
488 (setf (slot-value adjustment 'value) value))))
491 (defbinding adjustment-changed () nil
492 (adjustment adjustment))
494 (defbinding adjustment-value-changed () nil
495 (adjustment adjustment))
497 (defbinding adjustment-clamp-page () nil
498 (adjustment adjustment)
500 (upper single-float))
505 (defbinding alignment-set () nil
506 (alognment alignment)
507 (x-align single-float)
508 (y-align single-float)
509 (x-scale single-float)
510 (y-scale single-float))
512 (defbinding alignment-get-padding () nil
513 (alognment alignment)
514 (top unsigned-int :out)
515 (bottom unsigned-int :out)
516 (left unsigned-int :out)
517 (right unsigned-int :out))
519 (defbinding alignment-set-padding () nil
520 (alognment alignment)
522 (bottom unsigned-int)
524 (right unsigned-int))
529 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
531 (defbinding assistant-get-nth-page () widget
532 (assistant assistant)
535 (defbinding %assistant-insert-page () int
536 (assistant assistant)
540 (defun assistant-insert-page (assistant page position &rest child-args)
541 (let ((pos (case position
546 (%assistant-insert-page assistant page pos)
547 (init-child-slots assistant page child-args))))
549 (defun assistant-append-page (assistant page &rest child-args)
550 (apply #'assistant-insert-page assistant page :last child-args))
552 (defun assistant-prepend-page (assistant page &rest child-args)
553 (apply #'assistant-insert-page assistant page :first child-args))
555 (define-callback-marshal %assistant-page-func-callback int
556 ((current-page int)))
558 (defbinding assistant-set-forward-page-func (assistant function) nil
559 (assistant assistant)
560 (%assistant-page-func-callback callback)
561 ((register-callback-function function) pointer-data)
562 (user-data-destroy-callback callback))
564 (defbinding assistant-add-action-widget () nil
565 (assistant assistant)
568 (defbinding assistant-remove-action-widget () nil
569 (assistant assistant)
572 (defbinding assistant-update-buttons-state () nil
573 (assistant assistant)))
582 (defun (setf bin-child) (child bin)
583 (when-bind (current-child (bin-child bin))
584 (container-remove bin current-child))
585 (container-add bin child)
588 (defmethod compute-signal-function ((bin bin) signal function object args)
589 (declare (ignore signal))
590 (if (eq object :child)
591 #'(lambda (&rest emission-args)
592 (apply function (bin-child bin) (nconc (rest emission-args) args)))
598 (defbinding box-pack-start () nil
603 (padding unsigned-int))
605 (defbinding box-pack-end () nil
610 (padding unsigned-int))
612 (defun box-pack (box child &key end (expand t) (fill t) (padding 0))
614 (box-pack-end box child expand fill padding)
615 (box-pack-start box child expand fill padding)))
617 (defbinding box-reorder-child () nil
622 (defbinding box-query-child-packing () nil
625 (expand boolean :out)
627 (padding unsigned-int :out)
628 (pack-type pack-type :out))
630 (defbinding box-set-child-packing () nil
635 (padding unsigned-int)
636 (pack-type pack-type))
642 (defmethod initialize-instance ((button button) &rest initargs &key stock)
644 (apply #'call-next-method button
645 :label stock :use-stock t :use-underline t initargs)
649 (defbinding button-pressed () nil
652 (defbinding button-released () nil
655 (defbinding button-clicked () nil
658 (defbinding button-enter () nil
661 (defbinding button-leave () nil
668 (defbinding calendar-select-month () int
673 (defbinding calendar-select-day () nil
677 (defbinding calendar-mark-day () int
681 (defbinding calendar-unmark-day () int
685 (defbinding calendar-clear-marks () nil
688 (defbinding calendar-get-date () nil
690 (year unsigned-int :out)
691 (month unsigned-int :out)
692 (day unsigned-int :out))
694 (defbinding calendar-freeze () nil
697 (defbinding calendar-thaw () nil
703 (defbinding check-menu-item-toggled () nil
704 (check-menu-item check-menu-item))
709 (defbinding (color-selection-is-adjusting-p
710 "gtk_color_selection_is_adjusting") () boolean
711 (colorsel color-selection))
715 ;;; Color selection dialog -- no functions
721 (defmethod initialize-instance ((combo-box combo-box) &rest initargs
722 &key model content active)
723 (remf initargs :active)
725 (apply #'call-next-method combo-box initargs)
727 (apply #'call-next-method combo-box
728 :model (make-instance 'list-store :column-types '(string))
730 (unless (typep combo-box 'combo-box-entry)
731 (let ((cell (make-instance 'cell-renderer-text)))
732 (cell-layout-pack combo-box cell :expand t)
733 (cell-layout-add-attribute combo-box cell :text 0)))))
735 (mapc #'(lambda (text)
736 (combo-box-append-text combo-box text))
739 (setf (combo-box-active combo-box) active)))
742 ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
744 ;; (signal-emit combo-box 'changed)))
746 (defbinding combo-box-append-text () nil
747 (combo-box combo-box)
750 (defbinding combo-box-insert-text () nil
751 (combo-box combo-box)
755 (defbinding combo-box-prepend-text () nil
756 (combo-box combo-box)
759 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
760 (defbinding combo-box-get-active-text () string
761 (combo-box combo-box))
763 (defbinding combo-box-popup () nil
764 (combo-box combo-box))
766 (defbinding combo-box-popdown () nil
767 (combo-box combo-box))
773 (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
776 (setf (combo-box-entry-text-column combo-box-entry) 0)))
781 (defmethod shared-initialize ((dialog dialog) names &rest initargs
783 (declare (ignore names button buttons))
786 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
789 (defun dialog-response-id (dialog response &optional create-p error-p)
790 "Returns a numeric response id"
791 (if (typep response 'response-type)
792 (response-type-to-int response)
793 (let ((responses (user-data dialog 'responses)))
795 ((and responses (position response responses :test #'equal)))
799 (vector-push-extend response responses)
800 (1- (length responses)))
803 (user-data dialog 'responses)
804 (make-array 1 :adjustable t :fill-pointer t
805 :initial-element response))
808 (error "Invalid response: ~A" response))))))
810 (defun dialog-find-response (dialog id)
811 "Finds a symbolic response given a numeric id"
813 ((not (numberp id)) id)
814 ((< id 0) (int-to-response-type id))
815 ((aref (user-data dialog 'responses) id))))
818 (defmethod compute-signal-id ((dialog dialog) signal)
819 (if (dialog-response-id dialog signal)
820 (ensure-signal-id 'response dialog)
823 (defmethod compute-signal-function ((dialog dialog) signal function object args)
824 (declare (ignore function object args))
825 (let ((callback (call-next-method))
826 (id (dialog-response-id dialog signal)))
829 #'(lambda (dialog response)
830 (when (= response id)
831 (funcall callback dialog))))
832 ((string-equal signal "response")
833 #'(lambda (dialog response)
834 (funcall callback dialog (dialog-find-response dialog response))))
837 (defbinding dialog-run () nil
840 (defbinding dialog-response (dialog response) nil
842 ((dialog-response-id dialog response nil t) int))
845 (defbinding %dialog-add-button () button
850 (defun dialog-add-button (dialog label &optional (response label)
851 &key default object after)
852 "Adds a button to the dialog."
853 (let* ((signal (if (functionp response)
856 (id (dialog-response-id dialog signal t))
857 (button (%dialog-add-button dialog label id)))
858 (when (functionp response)
859 (signal-connect dialog signal response :object object :after after))
861 (%dialog-set-default-response dialog id))
865 (defbinding %dialog-add-action-widget () nil
867 (action-widget widget)
870 (defun dialog-add-action-widget (dialog widget &optional (response widget)
871 &key default object after)
872 (let* ((signal (if (functionp response)
875 (id (dialog-response-id dialog signal t)))
876 (unless (widget-hidden-p widget)
877 (widget-show widget))
878 (%dialog-add-action-widget dialog widget id)
879 (when (functionp response)
880 (signal-connect dialog signal response :object object :after after))
882 (setf (widget-can-default-p widget) t)
883 (%dialog-set-default-response dialog id))
887 (defbinding %dialog-set-default-response () nil
891 (defun dialog-set-default-response (dialog response)
892 (%dialog-set-default-response
893 dialog (dialog-response-id dialog response nil t)))
895 (defbinding dialog-set-response-sensitive (dialog response sensitive) nil
897 ((dialog-response-id dialog response nil t) int)
900 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
901 (defbinding alternative-dialog-button-order-p (&optional screen) boolean
902 (screen (or null gdk:screen)))
904 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
905 (defbinding (dialog-set-alternative-button-order
906 "gtk_dialog_set_alternative_button_order_from_array")
907 (dialog new-order) nil
909 ((length new-order) int)
910 ((map 'vector #'(lambda (response)
911 (dialog-response-id dialog response nil t))
912 new-order) (vector int)))
915 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
917 (defbinding %dialog-get-response-for-widget () int
921 (defun dialog-get-response-for-widget (dialog widget)
922 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
925 (defmethod container-add ((dialog dialog) (child widget) &rest args)
926 (apply #'container-add (dialog-vbox dialog) child args))
929 (defmethod container-remove ((dialog dialog) (child widget))
930 (container-remove (dialog-vbox dialog) child))
932 (defmethod container-children ((dialog dialog))
933 (container-children (dialog-vbox dialog)))
935 (defmethod (setf container-children) (children (dialog dialog))
936 (setf (container-children (dialog-vbox dialog)) children))
941 (defun drawing-area-scroll (drawing-area dx dy)
942 (gdk:window-scroll (widget-window drawing-area) dx dy))
947 (defbinding entry-get-layout-offsets () nil
952 (defbinding entry-layout-index-to-text-index () int
956 (defbinding entry-text-index-to-layout-index () int
963 (define-callback-marshal %entry-completion-match-callback boolean
964 (entry-completion string tree-iter))
966 (defbinding entry-completion-set-match-func (completion function) nil
967 (completion entry-completion)
968 (%entry-completion-match-callback callback)
969 ((register-callback-function function) unsigned-int)
970 (user-data-destroy-callback callback))
972 (defbinding entry-completion-complete () nil
973 (completion entry-completion))
975 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
976 (defbinding entry-completion-insert-prefix () nil
977 (completion entry-completion))
979 (defbinding entry-completion-insert-action-text () nil
980 (completion entry-completion)
984 (defbinding entry-completion-insert-action-markup () nil
985 (completion entry-completion)
989 (defbinding entry-completion-delete-action () nil
990 (completion entry-completion)
996 (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
997 &key filter filters shortcut-folder
998 shortcut-folders shortcut-folder-uti
999 shortcut-folder-uris)
1000 (declare (ignore filter filters shortcut-folder shortcut-folders
1001 shortcut-folder-uti shortcut-folder-uris))
1004 (initial-add file-chooser #'file-chooser-add-filter
1005 initargs :filer :filters)
1006 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1007 initargs :shortcut-folder :shortcut-folders)
1008 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1009 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1012 (defbinding file-chooser-select-filename () boolean
1013 (file-chooser file-chooser)
1016 (defbinding file-chooser-unselect-filename () nil
1017 (file-chooser file-chooser)
1020 (defbinding file-chooser-select-all () boolean
1021 (file-chooser file-chooser))
1023 (defbinding file-chooser-unselect-all () boolean
1024 (file-chooser file-chooser))
1026 (defbinding file-chooser-get-filenames () (gslist string)
1027 (file-chooser file-chooser))
1029 (defbinding file-chooser-select-uri () boolean
1030 (file-chooser file-chooser)
1033 (defbinding file-chooser-unselect-uri () nil
1034 (file-chooser file-chooser)
1037 (defbinding file-chooser-get-uris () (gslist string)
1038 (file-chooser file-chooser))
1040 (defbinding file-chooser-add-filter () nil
1041 (file-chooser file-chooser)
1042 (filter file-filter))
1044 (defbinding file-chooser-remove-filter () nil
1045 (file-chooser file-chooser)
1046 (filter file-filter))
1048 (defbinding file-chooser-list-filters () (gslist file-filter)
1049 (file-chooser file-chooser))
1051 (defbinding file-chooser-add-shortcut-folder () boolean
1052 (file-chooser file-chooser)
1056 (defbinding file-chooser-remove-shortcut-folder () nil
1057 (file-chooser file-chooser)
1061 (defbinding file-chooser-list-shortcut-folders () (gslist string)
1062 (file-chooser file-chooser))
1064 (defbinding file-chooser-add-shortcut-folder-uri () boolean
1065 (file-chooser file-chooser)
1069 (defbinding file-chooser-remove-shortcut-folder-uri () nil
1070 (file-chooser file-chooser)
1074 (defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1075 (file-chooser file-chooser))
1080 (defmethod initialize-instance ((file-filter file-filter) &rest initargs
1081 &key mime-type mime-types pattern patterns
1083 (declare (ignore mime-type mime-types pattern patterns))
1086 (when pixbuf-formats
1087 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1088 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1089 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1090 (file-filter-add-pixbuf-formats file-filter))
1091 (initial-add file-filter #'file-filter-add-mime-type
1092 initargs :mime-type :mime-types)
1093 (initial-add file-filter #'file-filter-add-pattern
1094 initargs :pattern :patterns)))
1097 (defbinding file-filter-add-mime-type () nil
1098 (filter file-filter)
1101 (defbinding file-filter-add-pattern () nil
1102 (filter file-filter)
1105 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1106 (defbinding file-filter-add-pixbuf-formats () nil
1107 (filter file-filter))
1109 (define-callback-marshal %file-filter-callback boolean (file-filter-info))
1111 (defbinding file-filter-add-custom (filter needed function) nil
1112 (filter file-filter)
1113 (needed file-filter-flags)
1114 (%file-filter-callback callback)
1115 ((register-callback-function function) unsigned-int)
1116 (user-data-destroy-callback callback))
1118 (defbinding file-filter-get-needed () file-filter-flags
1119 (filter file-filter))
1121 (defbinding file-filter-filter () boolean
1122 (filter file-filter)
1123 (filter-info file-filter-info))
1129 (defbinding image-set-from-file () nil
1131 (filename pathname))
1133 (defmethod (setf image-pixmap) ((data vector) (image image))
1134 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1135 (setf (image-pixmap image) pixmap)
1136 (setf (image-mask image) mask)))
1138 (defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1140 ((typep pixmap 'vector)
1141 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1142 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1146 (image-set-from-file image file)))
1147 ((call-next-method))))
1149 (defun create-image-widget (source &optional mask)
1151 (gdk:pixbuf (make-instance 'image :pixbuf source))
1152 (string (make-instance 'image :stock source))
1153 (pathname (make-instance 'image :file source))
1154 ((or list vector) (make-instance 'image :pixmap source))
1155 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1157 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1158 (defbinding image-clear () nil
1165 (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1166 (if (and image (not (typep image 'widget)))
1167 (apply #'call-next-method item :image (create-image-widget image) initargs)
1168 (call-next-method)))
1171 (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1172 (setf (slot-value item 'image) widget))
1174 (defmethod (setf image-menu-item-image) (image (item image-menu-item))
1175 (setf (image-menu-item-image item) (create-image-widget image)))
1180 (defmethod shared-initialize ((label label) names &key pattern)
1181 (declare (ignore names))
1184 (setf (label-pattern label) pattern)))
1186 (defbinding label-get-layout-offsets () nil
1191 (defbinding label-select-region () nil
1196 (defbinding label-get-selection-bounds () boolean
1205 (defbinding %radio-button-get-group () pointer
1206 (radio-button radio-button))
1208 (defbinding %radio-button-set-group () nil
1209 (radio-button radio-button)
1212 (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
1213 "Add BUTTON1 to the group which BUTTON2 belongs to."
1214 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1216 (defun %add-activate-callback (widget signal function object after)
1218 (signal-connect widget signal
1220 (when (slot-value widget 'active)
1221 (funcall function object (slot-value widget 'value))))
1222 :object object :after after)
1223 (signal-connect widget signal
1225 (when (slot-value widget 'active)
1226 (funcall function (slot-value widget 'value))))
1229 (defmethod activate-radio-widget ((button radio-button))
1230 (signal-emit button 'clicked))
1232 (defgeneric add-activate-callback (action function &key object after))
1234 (defmethod add-activate-callback ((button radio-button) function &key object after)
1235 (%add-activate-callback button 'clicked function object after))
1237 (defmethod initialize-instance ((button radio-button) &key group)
1241 (add-to-radio-group button group))))
1246 (defbinding item-select () nil
1249 (defbinding item-deselect () nil
1252 (defbinding item-toggle () nil
1259 (defmethod initialize-instance ((item menu-item) &key label)
1263 (setf (menu-item-label item) label))))
1266 (defun (setf menu-item-label) (label menu-item)
1267 (make-instance 'accel-label
1268 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
1269 :use-underline (menu-item-use-underline-p menu-item)
1270 :visible t :parent menu-item)
1273 (defun menu-item-label (menu-item)
1274 (when (and (slot-boundp menu-item 'child)
1275 (typep (bin-child menu-item) 'label))
1276 (label-label (bin-child menu-item))))
1278 (defbinding menu-item-remove-submenu () nil
1279 (menu-item menu-item))
1281 (defbinding menu-item-set-accel-path () nil
1282 (menu-item menu-item)
1283 (accel-path string))
1285 (defbinding menu-item-select () nil
1286 (menu-item menu-item))
1288 (defbinding menu-item-deselect () nil
1289 (menu-item menu-item))
1291 (defbinding menu-item-activate () nil
1292 (menu-item menu-item))
1294 (defbinding menu-item-toggle-size-request () nil
1295 (menu-item menu-item)
1296 (requisition int :out))
1298 (defbinding menu-item-toggle-size-allocate () nil
1299 (menu-item menu-item)
1303 ;;; Menu tool button
1305 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1306 (defbinding menu-tool-button-set-arrow-tooltip () nil
1307 (menu-tool-button menu-tool-button)
1310 (tip-private string))
1315 (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1316 button buttons flags transient-parent)
1317 (let ((stock-buttons
1319 ((and (not buttons) (not button))
1323 ((listp buttons) :none)
1325 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1328 (defmethod shared-initialize ((dialog message-dialog) names &rest initargs
1329 &key message-type buttons button text
1330 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1332 (declare (ignore names))
1334 (message-dialog-set-markup dialog text))
1335 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1336 (when secondary-text
1337 (message-dialog-format-secondary-markup dialog secondary-text))
1338 (when (and (not buttons) (not button))
1340 for (key value) on initargs by #'cddr
1341 when (and (eq key :signal) (eq (first value) :close))
1342 do (warn "Default button configuration changed from ~A to ~A" :close
1343 (if (eq message-type :question) :yes-no :ok))
1345 (if (typep buttons 'buttons-type)
1346 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1347 (call-next-method)))
1350 (defbinding %message-dialog-new () pointer
1351 (parent (or null window))
1352 (flags dialog-flags)
1354 (buttons buttons-type)
1357 (defbinding message-dialog-set-markup () nil
1358 (message-dialog message-dialog)
1361 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1362 (defbinding message-dialog-format-secondary-text () nil
1363 (message-dialog message-dialog)
1366 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1367 (defbinding message-dialog-format-secondary-markup () nil
1368 (message-dialog message-dialog)
1375 (defbinding %radio-menu-item-get-group () pointer
1376 (radio-menu-item radio-menu-item))
1378 (defbinding %radio-menu-item-set-group () nil
1379 (radio-menu-item radio-menu-item)
1382 (defmethod activate-radio-widget ((item radio-menu-item))
1383 (menu-item-activate item))
1385 (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
1386 "Add ITEM1 to the group which ITEM2 belongs to."
1387 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1389 (defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1390 (%add-activate-callback item 'activate function object after))
1392 (defmethod initialize-instance ((item radio-menu-item) &key group)
1396 (add-to-radio-group item group))))
1400 ;;; Radio tool button
1402 (defbinding %radio-tool-button-get-group () pointer
1403 (radio-tool-button radio-tool-button))
1405 (defbinding %radio-tool-button-set-group () nil
1406 (radio-tool-button radio-tool-button)
1409 (defmethod activate-radio-widget ((button radio-tool-button))
1410 (signal-emit button 'clicked))
1412 (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
1413 "Add BUTTON1 to the group which BUTTON2 belongs to."
1414 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
1415 (defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1416 (%add-activate-callback button 'clicked function object after))
1418 (defmethod initialize-instance ((button radio-tool-button) &key group)
1422 (add-to-radio-group button group))))
1428 (defbinding toggle-button-toggled () nil
1429 (toggle-button toggle-button))
1434 (defmethod initialize-instance ((window window) &rest initargs
1435 &key display accel-group accel-groups)
1436 (declare (ignore accel-group accel-groups))
1439 (apply #'call-next-method
1440 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
1442 (initial-add window #'window-add-accel-group
1443 initargs :accel-group :accel-groups)))
1445 #-debug-ref-counting
1446 (defmethod print-object ((window window) stream)
1448 (proxy-valid-p window)
1449 (slot-boundp window 'title)
1450 (not (zerop (length (window-title window)))))
1451 (print-unreadable-object (window stream :type t :identity nil)
1452 (format stream "~S at 0x~X"
1453 (window-title window) (pointer-address (foreign-location window))))
1454 (call-next-method)))
1456 (defbinding window-set-wmclass () nil
1458 (wmclass-name string)
1459 (wmclass-class string))
1461 (defbinding window-add-accel-group () nil
1463 (accel-group accel-group))
1465 (defbinding window-remove-accel-group () nil
1467 (accel-group accel-group))
1469 (defbinding window-activate-focus () int
1472 (defbinding window-activate-default () int
1475 (defbinding window-set-default-size (window width height) int
1478 ((or height -1) int))
1480 (defbinding %window-set-geometry-hints () nil
1482 (widget (or widget null))
1483 (geometry gdk:geometry)
1484 (geometry-mask gdk:window-hints))
1486 (defun window-set-geometry-hints (window &key widget min-width min-height
1487 max-width max-height base-width base-height
1488 width-inc height-inc gravity
1489 aspect (min-aspect aspect) (max-aspect aspect))
1490 (let ((geometry (make-instance 'gdk:geometry
1491 :min-width (or min-width -1)
1492 :min-height (or min-height -1)
1493 :max-width (or max-width -1)
1494 :max-height (or max-height -1)
1495 :base-width (or base-width 0)
1496 :base-height (or base-height 0)
1497 :width-inc (or width-inc 0)
1498 :height-inc (or height-inc 0)
1499 :min-aspect (or min-aspect 0)
1500 :max-aspect (or max-aspect 0)))
1502 (when (or min-width min-height)
1503 (push :min-size mask))
1504 (when (or max-width max-height)
1505 (push :max-size mask))
1506 (when (or base-width base-height)
1507 (push :base-size mask))
1508 (when (or width-inc height-inc)
1509 (push :resize-inc mask))
1510 (when (or min-aspect max-aspect)
1511 (push :aspect mask))
1513 (push :win-gravity mask)
1514 (setf (gdk:geometry-gravity geometry) gravity))
1515 (%window-set-geometry-hints window widget geometry mask)))
1517 (defbinding window-list-toplevels () (glist (copy-of window))
1518 "Returns a list of all existing toplevel windows.")
1520 (defbinding window-add-mnemonic (window key target) nil
1522 ((gdk:keyval-from-name key) unsigned-int)
1525 (defbinding window-remove-mnemonic (window key target) nil
1527 ((gdk:keyval-from-name key) unsigned-int)
1530 (defbinding window-mnemonic-activate (window key modifier) nil
1532 ((gdk:keyval-from-name key) unsigned-int)
1533 (modifier gdk:modifier-type))
1535 (defbinding window-activate-key () boolean
1537 (event gdk:key-event))
1539 (defbinding window-propagate-key-event () boolean
1541 (event gdk:key-event))
1543 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1544 (defbinding window-present () nil
1547 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
1549 (defbinding %window-present () nil
1552 (defbinding %window-present-with-time () nil
1554 (timespamp unsigned-int))
1556 (defun window-present (window &optional timestamp)
1558 (%window-present-with-time window timestamp)
1559 (%window-present window))))
1561 (defbinding window-iconify () nil
1564 (defbinding window-deiconify () nil
1567 (defbinding window-stick () nil
1570 (defbinding window-unstick () nil
1573 (defbinding window-maximize () nil
1576 (defbinding window-unmaximize () nil
1579 (defbinding window-fullscreen () nil
1582 (defbinding window-unfullscreen () nil
1585 (defbinding window-set-keep-above () nil
1589 (defbinding window-set-keep-below () nil
1593 (defbinding window-begin-resize-drag () nil
1595 (edge gdk:window-edge)
1597 (root-x int) (root-y int)
1598 (timestamp unsigned-int))
1600 (defbinding window-begin-move-drag () nil
1602 (edge gdk:window-edge)
1604 (root-x int) (root-y int)
1605 (timestamp unsigned-int))
1607 (defbinding window-set-frame-dimensions () nil
1609 (left int) (top int) (rigth int) (bottom int))
1611 (defbinding %window-get-default-size () nil
1616 (defun window-get-default-size (window)
1617 (multiple-value-bind (width height) (%window-get-default-size window)
1618 (values (unless (= width -1) width) (unless (= height -1) height))))
1620 (defbinding window-get-frame-dimensions () nil
1622 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1624 (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
1627 (defbinding window-get-position () nil
1632 (defbinding window-get-size () nil
1637 (defbinding window-move () nil
1642 (defbinding window-parse-geometry () boolean
1646 (defbinding window-reshow-with-initial-size () nil
1649 (defbinding window-resize () nil
1654 (defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1655 () (glist gdk:pixbuf))
1657 (defun window-default-icon ()
1658 (first (window-default-icon-list)))
1660 (defbinding %window-set-default-icon-list () nil
1661 (icons (glist gdk:pixbuf)))
1663 (defun (setf window-default-icon-list) (icons)
1664 (%window-set-default-icon-list icons)
1667 (defbinding %window-set-default-icon () nil
1668 (icons (glist gdk:pixbuf)))
1670 (defgeneric (setf window-default-icon) (icon))
1672 (defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1673 (%window-set-default-icon icon)
1676 (defgeneric (setf window-group) (group window))
1678 (defmethod (setf window-group) ((group window-group) (window window))
1679 (window-group-add-window group window)
1682 (defbinding %window-set-default-icon-from-file () boolean
1686 (defmethod (setf window-default-icon) ((icon-file pathname))
1687 (%window-set-default-icon-from-file icon-file)
1690 (defbinding %window-set-icon-from-file () boolean
1695 (defmethod (setf window-icon) ((icon-file pathname) (window window))
1696 (%window-set-icon-from-file window icon-file)
1699 (defbinding window-set-auto-startup-notification () nil
1702 (defbinding decorated-window-init () nil
1705 (defbinding decorated-window-calculate-frame-size () nil
1708 (defbinding decorated-window-set-title () nil
1712 (defbinding decorated-window-move-resize-window () nil
1722 (defmethod initialize-instance ((window-group window-group) &rest initargs
1723 &key window windows)
1724 (declare (ignore window windows))
1727 (initial-add window-group #'window-group-add-window
1728 initargs :window :windows)))
1731 (defbinding window-group-add-window () nil
1732 (window-group window-group)
1735 (defbinding window-group-remove-window () nil
1736 (window-group window-group)
1742 (defun (setf scrolled-window-scrollbar-policy) (policy window)
1743 (setf (scrolled-window-hscrollbar-policy window) policy)
1744 (setf (scrolled-window-vscrollbar-policy window) policy))
1746 (defbinding scrolled-window-add-with-viewport () nil
1747 (scrolled-window scrolled-window)
1750 (defmethod shared-initialize ((window scrolled-window) names &key policy)
1751 (declare (ignore names))
1753 (setf (slot-value window 'hscrollbar-policy) policy)
1754 (setf (slot-value window 'vscrollbar-policy) policy))
1760 (defbinding statusbar-get-context-id () unsigned-int
1761 (statusbar statusbar)
1762 (context-description string))
1764 (defbinding statusbar-push () unsigned-int
1765 (statusbar statusbar)
1766 (context-id unsigned-int)
1769 (defbinding statusbar-pop () nil
1770 (statusbar statusbar)
1771 (context-id unsigned-int))
1773 (defbinding statusbar-remove () nil
1774 (statusbar statusbar)
1775 (context-id unsigned-int)
1776 (message-id unsigned-int))
1782 (defbinding fixed-put () nil
1787 (defbinding fixed-move () nil
1796 (defun %ensure-notebook-position (notebook page)
1799 (widget (notebook-page-num notebook page t))))
1801 (defun %ensure-notebook-child (notebook position)
1804 (t (notebook-get-nth-page notebook position))))
1806 (defbinding (notebook-insert "gtk_notebook_insert_page_menu")
1807 (notebook position child &optional tab-label menu-label) nil
1810 ((if (stringp tab-label)
1811 (make-instance 'label :label tab-label)
1812 tab-label) (or null widget))
1813 ((if (stringp menu-label)
1814 (make-instance 'label :label menu-label)
1815 menu-label) (or null widget))
1816 ((%ensure-notebook-position notebook position) position))
1818 (defun notebook-append (notebook child &optional tab-label menu-label)
1819 (notebook-insert notebook :last child tab-label menu-label))
1821 (defun notebook-prepend (notebook child &optional tab-label menu-label)
1822 (notebook-insert notebook :first child tab-label menu-label))
1824 (defbinding notebook-remove-page (notebook page) nil
1826 ((%ensure-notebook-position notebook page) position))
1828 (defbinding %notebook-page-num () int
1832 (defun notebook-page-num (notebook child &optional error-p)
1833 (let ((page-num (%notebook-page-num notebook child)))
1836 (error "~A is not a page in ~A" child notebook))
1839 (defbinding notebook-next-page () nil
1840 (notebook notebook))
1842 (defbinding notebook-prev-page () nil
1843 (notebook notebook))
1845 (defbinding notebook-reorder-child (notebook child position) nil
1848 ((%ensure-notebook-position notebook position) int))
1850 (defbinding notebook-popup-enable () nil
1851 (notebook notebook))
1853 (defbinding notebook-popup-disable () nil
1854 (notebook notebook))
1856 (defbinding notebook-get-nth-page () widget
1860 (defun %notebook-current-page (notebook)
1861 (when (slot-boundp notebook 'current-page-num)
1862 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
1864 (defun (setf notebook-current-page) (page notebook)
1865 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
1867 (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1868 (notebook page) widget
1870 ((%ensure-notebook-child notebook page) widget))
1872 (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
1873 (notebook page) (copy-of string)
1875 ((%ensure-notebook-child notebook page) widget))
1877 (defbinding %notebook-set-tab-label () nil
1882 (defun (setf notebook-tab-label) (tab-label notebook page)
1883 (let ((widget (if (stringp tab-label)
1884 (make-instance 'label :label tab-label)
1886 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1890 (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1891 (notebook page) widget
1893 ((%ensure-notebook-child notebook page) widget))
1895 (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
1896 (notebook page) (copy-of string)
1898 ((%ensure-notebook-child notebook page) widget))
1900 (defbinding %notebook-set-menu-label () nil
1903 (menu-label widget))
1905 (defun (setf notebook-menu-label) (menu-label notebook page)
1906 (let ((widget (if (stringp menu-label)
1907 (make-instance 'label :label menu-label)
1909 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1913 (defbinding notebook-query-tab-label-packing (notebook page) nil
1915 ((%ensure-notebook-child notebook page) widget)
1916 (expand boolean :out)
1918 (pack-type pack-type :out))
1920 (defbinding notebook-set-tab-label-packing
1921 (notebook page expand fill pack-type) nil
1923 ((%ensure-notebook-child notebook page) widget)
1926 (pack-type pack-type))
1932 (defbinding paned-pack1 () nil
1938 (defbinding paned-pack2 () nil
1947 (defbinding layout-put () nil
1953 (defbinding layout-move () nil
1959 (defbinding layout-set-size () nil
1961 (width unsigned-int)
1962 (height unsigned-int))
1964 (defbinding layout-get-size () nil
1966 (width unsigned-int :out)
1967 (height unsigned-int :out))
1972 (defbinding menu-shell-insert (menu-shell menu-item position) nil
1973 (menu-shell menu-shell)
1974 (menu-item menu-item)
1980 (defun menu-shell-append (menu-shell menu-item)
1981 (menu-shell-insert menu-shell menu-item :last))
1983 (defun menu-shell-prepend (menu-shell menu-item)
1984 (menu-shell-insert menu-shell menu-item :fisrt))
1986 (defbinding menu-shell-deactivate () nil
1987 (menu-shell menu-shell))
1989 (defbinding menu-shell-select-item () nil
1990 (menu-shell menu-shell)
1991 (menu-item menu-item))
1993 (defbinding menu-shell-select-first () nil
1994 (menu-shell menu-shell)
1995 (search-sensitive boolean))
1997 (defbinding menu-shell-deselect () nil
1998 (menu-shell menu-shell))
2000 (defbinding menu-shell-activate-item () nil
2001 (menu-shell menu-shell)
2002 (menu-item menu-item)
2003 (fore-deactivate boolean))
2005 (defbinding menu-shell-cancel () nil
2006 (menu-shell menu-shell))
2011 (defun %menu-position (menu child)
2014 (keyword (case child
2017 (t (error "Invalid position keyword: ~A" child))))
2018 (widget (menu-child-position menu child))))
2021 (defbinding menu-reorder-child (menu menu-item position) nil
2023 (menu-item menu-item)
2024 ((%menu-position menu position) int))
2026 (defbinding menu-attach () nil
2028 (menu-item menu-item)
2029 (left-attach unsigned-int)
2030 (right-attach unsigned-int)
2031 (top-attach unsigned-int)
2032 (bottom-attach unsigned-int))
2034 (define-callback-marshal %menu-position-callback nil
2035 (menu (x int) (y int) (push-in boolean)))
2037 (defbinding %menu-popup () nil
2039 (parent-menu-shell (or null menu-shell))
2040 (parent-menu-item (or null menu-item))
2041 (callback (or null callback))
2042 (callback-id unsigned-int)
2043 (button unsigned-int)
2044 (activate-time (unsigned 32)))
2046 (defun menu-popup (menu button activate-time &key callback parent-menu-shell
2049 (with-callback-function (id callback)
2051 menu parent-menu-shell parent-menu-item
2052 %menu-position-callback id button activate-time))
2054 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2056 (defbinding menu-set-accel-path () nil
2058 (accel-path string))
2060 (defbinding menu-reposition () nil
2063 (defbinding menu-popdown () nil
2066 (defun menu-child-position (menu child)
2067 (position child (container-children menu)))
2069 (defun menu-active-num (menu)
2070 (menu-child-position menu (menu-active menu)))
2072 (defbinding %menu-set-active () nil
2074 (index unsigned-int))
2076 (defun (setf menu-active) (menu child)
2077 (%menu-set-active menu (%menu-position menu child))
2080 (define-callback %menu-detach-callback nil ((widget widget) (menu menu))
2081 (funcall (user-data menu 'detach-func) widget menu))
2083 (defbinding %menu-attach-to-widget (menu widget) nil
2086 (%menu-detach-callback callback))
2088 (defun menu-attach-to-widget (menu widget function)
2089 (setf (user-data menu 'detach-func) function)
2090 (%menu-attach-to-widget menu widget))
2092 (defbinding menu-detach () nil
2095 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2096 (defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2099 (defbinding menu-set-monitor () nil
2106 (defbinding table-resize () nil
2109 (columns unsigned-int))
2111 (defbinding table-attach (table child left right top bottom
2112 &key options x-options y-options
2113 (x-padding 0) (y-padding 0)) nil
2117 (right unsigned-int)
2119 (bottom unsigned-int)
2120 ((append (mklist options) (mklist x-options)) attach-options)
2121 ((append (mklist options) (mklist y-options)) attach-options)
2122 (x-padding unsigned-int)
2123 (y-padding unsigned-int))
2126 (defbinding %table-set-row-spacing () nil
2129 (spacing unsigned-int))
2131 (defbinding %table-set-row-spacings () nil
2133 (spacing unsigned-int))
2135 (defun (setf table-row-spacing) (spacing table &optional row)
2137 (%table-set-row-spacing table row spacing)
2138 (%table-set-row-spacings table spacing))
2141 (defbinding %table-get-row-spacing () unsigned-int
2145 (defbinding %table-get-default-row-spacing () unsigned-int
2148 (defun table-row-spacing (table &optional row)
2150 (%table-get-row-spacing table row)
2151 (%table-get-default-row-spacing table)))
2154 (defbinding %table-set-col-spacing () nil
2157 (spacing unsigned-int))
2159 (defbinding %table-set-col-spacings () nil
2161 (spacing unsigned-int))
2163 (defun (setf table-column-spacing) (spacing table &optional column)
2165 (%table-set-col-spacing table column spacing)
2166 (%table-set-col-spacings table spacing))
2169 (defun (setf table-col-spacing) (spacing table &optional col)
2170 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2171 (setf (table-column-spacing table col) spacing))
2173 (defbinding %table-get-col-spacing () unsigned-int
2177 (defbinding %table-get-default-col-spacing () unsigned-int
2180 (defun table-column-spacing (table &optional column)
2182 (%table-get-col-spacing table column)
2183 (%table-get-default-col-spacing table)))
2185 (defun table-col-spacing (table &optional col)
2186 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2187 (table-column-spacing table col))
2193 (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2195 (apply #'call-next-method toolbar
2196 :tooltips (make-instance 'tooltips) initargs)
2197 (call-next-method)))
2199 (defbinding %toolbar-insert () nil
2201 (tool-item tool-item)
2202 (position position))
2204 (defun toolbar-insert (toolbar tool-item &optional (position :end))
2205 (%toolbar-insert toolbar tool-item position)
2206 (%tool-item-update-tooltips tool-item))
2208 (defbinding toolbar-get-item-index () int
2212 (defbinding toolbar-get-nth-item () tool-item
2216 (defbinding toolbar-get-drop-index () int
2220 (defbinding toolbar-set-drop-highlight-item () nil
2222 (tool-item tool-item)
2228 (defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2229 (if (and icon (not (typep icon 'widget)))
2230 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2231 (call-next-method)))
2236 (defbinding tool-item-set-tooltip () nil
2237 (tool-item tool-item)
2240 (tip-private string))
2243 (defun %tool-item-update-tooltips (tool-item)
2245 (slot-boundp tool-item 'parent)
2247 (user-data-p tool-item 'tip-text)
2248 (user-data-p tool-item 'tip-private)))
2249 (tool-item-set-tooltip
2250 tool-item (toolbar-tooltips (widget-parent tool-item))
2251 (or (user-data tool-item 'tip-text) "")
2252 (or (user-data tool-item 'tip-private) ""))))
2254 (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2255 (setf (user-data tool-item 'tip-text) tip-text)
2256 (%tool-item-update-tooltips tool-item)
2259 (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2260 (setf (user-data tool-item 'tip-private) tip-private)
2261 (%tool-item-update-tooltips tool-item)
2264 (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2265 (declare (ignore args))
2268 (%tool-item-update-tooltips tool-item)))
2271 (defbinding tool-item-retrieve-proxy-menu-item () widget
2272 (tool-item tool-item))
2274 (defbinding (tool-item-proxy-menu-item
2275 "gtk_tool_item_get_proxy_menu_item") () menu-item
2276 (tool-item tool-item)
2277 (menu-item-id string))
2279 (defbinding %tool-item-set-proxy-menu-item () nil
2280 (tool-item tool-item)
2281 (menu-item-id string)
2282 (menu-item menu-item))
2284 (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2285 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2288 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
2289 (defbinding tool-item-rebuild-menu () nil
2290 (tool-item tool-item))
2295 (defbinding editable-select-region (editable &optional (start 0) end) nil
2300 (defbinding editable-get-selection-bounds (editable) nil
2305 (defbinding editable-insert-text (editable text &optional (position 0)) nil
2309 (position position :in/out))
2311 (defun editable-append-text (editable text)
2312 (editable-insert-text editable text nil))
2314 (defun editable-prepend-text (editable text)
2315 (editable-insert-text editable text 0))
2317 (defbinding editable-delete-text (editable &optional (start 0) end) nil
2322 (defbinding (editable-text "gtk_editable_get_chars")
2323 (editable &optional (start 0) end) string
2328 (defun (setf editable-text) (text editable)
2330 (editable-delete-text
2332 (editable-insert-text editable text))
2333 (editable-delete-text editable))
2336 (defbinding editable-cut-clipboard () nil
2337 (editable editable))
2339 (defbinding editable-copy-clipboard () nil
2340 (editable editable))
2342 (defbinding editable-paste-clipboard () nil
2343 (editable editable))
2345 (defbinding editable-delete-selection () nil
2346 (editable editable))
2352 (defbinding spin-button-configure () nil
2353 (spin-button spin-button)
2354 (adjustment adjustment)
2355 (climb-rate double-float)
2356 (digits unsigned-int))
2358 (defbinding spin-button-set-range () nil
2359 (spin-button spin-button)
2363 (defbinding spin-button-get-range () nil
2364 (spin-button spin-button)
2365 (min double-float :out)
2366 (max double-float :out))
2368 (defun spin-button-value-as-int (spin-button)
2369 (round (spin-button-value spin-button)))
2371 (defbinding %spin-button-spin () nil
2372 (spin-button spin-button)
2373 (direction spin-type)
2374 (increment double-float))
2376 (defun spin-button-spin (spin-button value)
2378 (real (%spin-button-spin spin-button :spin-user-defined value))
2379 (spin-type (%spin-button-spin spin-button value 0))))
2382 (defbinding spin-button-update () nil
2383 (spin-button spin-button))
2389 (defbinding ruler-set-range () nil
2391 (lower single-float)
2392 (upper single-float)
2393 (position single-float)
2394 (max-size single-float))
2396 (defbinding ruler-get-range () nil
2398 (lower single-float :out)
2399 (upper single-float :out)
2400 (position single-float :out)
2401 (max-size single-float :out))
2407 (defun range-lower (range)
2408 (adjustment-lower (range-adjustment range)))
2410 (defun range-upper (range)
2411 (adjustment-upper (range-adjustment range)))
2413 (defun (setf range-lower) (value range)
2414 (setf (adjustment-lower (range-adjustment range)) value))
2416 (defun (setf range-upper) (value range)
2417 (setf (adjustment-upper (range-adjustment range)) value))
2419 (defun range-page-increment (range)
2420 (adjustment-page-increment (range-adjustment range)))
2422 (defun range-step-increment (range)
2423 (adjustment-step-increment (range-adjustment range)))
2425 (defun (setf range-page-increment) (value range)
2426 (setf (adjustment-page-increment (range-adjustment range)) value))
2428 (defun (setf range-step-increment) (value range)
2429 (setf (adjustment-step-increment (range-adjustment range)) value))
2431 (defbinding range-set-range () nil
2433 (lower double-float)
2434 (upper double-float))
2436 (defbinding range-set-increments () nil
2439 (page double-float))
2444 (defbinding scale-get-layout-offsets () nil
2452 (defbinding progress-bar-pulse () nil
2453 (progress-bar progress-bar))
2458 (defmethod initialize-instance ((size-group size-group) &rest initargs
2459 &key widget widgets)
2460 (declare (ignore widget widgets))
2463 (initial-add size-group #'size-group-add-widget
2464 initargs :widget :widgets)))
2467 (defbinding size-group-add-widget () nil
2468 (size-group size-group)
2471 (defbinding size-group-remove-widget () nil
2472 (size-group size-group)
2478 (defbinding %stock-item-copy () pointer
2481 (defbinding %stock-item-free () nil
2484 (defbinding stock-add (stock-item) nil
2485 (stock-item stock-item)
2488 (defbinding stock-list-ids () (gslist string))
2490 (defbinding %stock-lookup () boolean
2494 (defun stock-lookup (stock-id)
2495 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
2496 (when (%stock-lookup stock-id stock-item)
2497 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
2499 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
2501 (define-callback-marshal %stock-translate-callback string ((path string)))
2503 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2504 (domain function) nil
2506 (%stock-translate-callback callback)
2507 ((register-callback-function function) unsigned-int)
2508 (user-data-destroy-callback callback)))
2513 ;; #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2515 ;; (defbinding %tooltip-set-markup () nil
2519 ;; (defbinding %tooltip-set-text () nil
2523 ;; (defbinding %tooltip-set-icon () nil
2525 ;; (icon gdk:pixbuf))
2527 ;; (defbinding %tooltip-set-from-stock-icon () nil
2529 ;; (stock-id string)
2532 ;; (defbinding %tooltip-set-custom () nil
2536 ;; (defun tooltip-set (tooltip value &key (markup t) (icon-size :button))
2538 ;; (string (if markup
2539 ;; (tooltip-set-markup tooltip value)
2540 ;; (tooltip-set-text tooltip value)))
2541 ;; (pixbuf (tooltip-set-icon tooltip value))
2542 ;; (keyword (tooltip-set-icon-from-stock tooltip value icon-size))
2548 ;; GtkTooltips has been deprecated in favor of the new tooltip API
2549 ;; introduced in in GTK+ 2.12
2551 (defbinding tooltips-enable () nil
2552 (tooltips tooltips))
2554 (defbinding tooltips-disable () nil
2555 (tooltips tooltips))
2557 (defun (setf tooltips-enabled-p) (enable tooltips)
2559 (tooltips-enable tooltips)
2560 (tooltips-disable tooltips)))
2562 (defbinding tooltips-set-tip () nil
2566 (tip-private string))
2568 (defbinding tooltips-data-get () tooltips-data
2571 (defbinding tooltips-force-window () nil
2572 (tooltips tooltips))
2574 (defbinding tooltips-get-info-from-tip-window () boolean
2576 (tooltips tooltips :out)
2577 (current-widget widget :out))
2582 (defbinding rc-get-style () style
2585 (defbinding rc-get-style-by-paths (&key path class-path class) style
2586 (path (or null string))
2587 (class-path (or null string))
2590 (defbinding rc-parse () nil
2591 (filename pathname))
2593 (defbinding rc-parse-string () nil
2596 (defbinding %rc-reparse-all () boolean)
2598 (defbinding %rc-reparse-all-for-settings () boolean
2600 (force-load-p boolean))
2602 (defun rc-reparse-all (&optional setting force-load-p)
2604 (%rc-reparse-all-for-settings setting force-load-p)
2607 (defbinding rc-reset-styles () nil
2608 (settings settings))
2610 (defbinding rc-add-default-file () nil
2611 (filename pathname))
2613 (defbinding rc-get-default-files ()
2614 (copy-of (null-terminated-vector (copy-of string))))
2616 (defbinding rc-get-module-dir () string)
2618 (defbinding rc-get-im-module-path () string)
2620 (defbinding rc-get-im-module-file () string)
2622 (defbinding rc-get-theme-dir () string)
2627 (defbinding (settings-get "gtk_settings_get_for_screen")
2628 (&optional (screen (gdk:display-get-default-screen))) settings
2629 (screen gdk:screen))
2634 (defbinding socket-add-id () nil
2636 (id gdk:native-window))
2638 (defbinding %plug-new () pointer
2639 (id gdk:native-window))
2641 (defmethod allocate-foreign ((plug plug) &key id)
2642 (%plug-new (or id 0)))
2647 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2649 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2651 (defbinding link-button-set-uri-hook (function) pointer
2652 (%link-button-uri-callback callback)
2653 ((register-callback-function function) unsigned-int)
2654 (user-data-destroy-callback callback)))
2659 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2661 (defmethod initialize-instance ((builder builder) &key interface
2662 (connect-signals t) (package *package*))
2664 (etypecase interface
2666 (string (builder-add-from-string builder interface))
2667 (pathname (builder-add-from-file builder interface)))
2668 (when connect-signals
2669 (builder-connect-signals builder package)))
2672 (defbinding builder-add-from-file () boolean
2675 (nil gerror-signal :out))
2677 (defbinding builder-add-from-string () boolean
2680 (-1 int) ; TODO: add gsize type
2681 (nil gerror-signal :out))
2683 (defbinding builder-get-object () gobject
2687 (defbinding builder-get-objects () (gslist gobject)
2690 (defun intern-with-package-prefix (name default-package)
2691 (let ((pos (position #\: name)))
2694 (string-upcase (subseq name (1+ pos)))
2695 (string-upcase (subseq name 0 pos)))
2696 (intern (string-upcase name) default-package))))
2698 (define-callback %builder-connect-function nil
2699 (builder (object gobject) (signal-name string) (handler-name string)
2700 (connect-object gobject) connect-flags (package user-data-id))
2701 (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)
2704 (intern-with-package-prefix handler-name (find-user-data package))
2705 :object (or connect-object object) :after (find :after connect-flags)))
2707 (defbinding %builder-connect-signals-full (builder package) nil
2709 (%builder-connect-function callback)
2710 (package user-data-id))
2712 (defun builder-connect-signals (builder &optional (package *package*))
2713 (with-user-data (id package)
2714 (%builder-connect-signals-full builder id))))