| 1 | ;; Common Lisp bindings for GTK+ v2.x |
| 2 | ;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net> |
| 3 | ;; |
| 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: |
| 11 | ;; |
| 12 | ;; The above copyright notice and this permission notice shall be |
| 13 | ;; included in all copies or substantial portions of the Software. |
| 14 | ;; |
| 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. |
| 22 | |
| 23 | ;; $Id: gtk.lisp,v 1.98 2008-11-25 22:11:08 espen Exp $ |
| 24 | |
| 25 | |
| 26 | (in-package "GTK") |
| 27 | |
| 28 | ;;; Gtk version |
| 29 | |
| 30 | (defbinding check-version () (copy-of string) |
| 31 | (required-major unsigned-int) |
| 32 | (required-minor unsigned-int) |
| 33 | (required-micro unsigned-int)) |
| 34 | |
| 35 | (defbinding query-version () nil |
| 36 | (major unsigned-int :out) |
| 37 | (minor unsigned-int :out) |
| 38 | (micro unsigned-int :out)) |
| 39 | |
| 40 | (defun gtk-version () |
| 41 | (multiple-value-bind (major minor micro) |
| 42 | (query-version) |
| 43 | (if (zerop micro) |
| 44 | (format nil "Gtk+ v~A.~A" major minor) |
| 45 | (format nil "Gtk+ v~A.~A.~A" major minor micro)))) |
| 46 | |
| 47 | (defun clg-version () |
| 48 | "clg 0.94") |
| 49 | |
| 50 | |
| 51 | ;;;; Initalization and display handling |
| 52 | |
| 53 | (defparameter *event-polling-interval* 0.01) |
| 54 | |
| 55 | #?(or (featurep :clisp) (featurep :cmu) (and (sbcl>= 1 0 6) (sbcl< 1 0 15 6))) |
| 56 | (defun decompose-time (time) |
| 57 | (multiple-value-bind (sec subsec) (truncate *event-polling-interval*) |
| 58 | (values sec (truncate (* subsec 1e6))))) |
| 59 | |
| 60 | (defbinding (gtk-init "gtk_parse_args") () boolean |
| 61 | "Initializes the library without opening the display." |
| 62 | (nil null) |
| 63 | (nil null)) |
| 64 | |
| 65 | (defun clg-init (&optional display multi-threading-p) |
| 66 | "Initializes the system and starts event handling." |
| 67 | (unless (gdk:display-get-default) |
| 68 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
| 69 | (progn |
| 70 | #+sbcl(sb-int:set-floating-point-modes :traps nil) |
| 71 | #+cmu(ext:set-floating-point-modes :traps nil)) |
| 72 | |
| 73 | (gdk:gdk-init) |
| 74 | (unless (gtk-init) |
| 75 | (error "Initialization of GTK+ failed.")) |
| 76 | |
| 77 | (if (not multi-threading-p) |
| 78 | (%init-async-event-handling display) |
| 79 | #+sb-thread(%init-multi-threaded-event-handling display) |
| 80 | #-sb-thread(error "Multi threading not supported on this platform"))) |
| 81 | (gdk:ensure-display display t)) |
| 82 | |
| 83 | (defun clg-init-with-threading (&optional display) |
| 84 | (clg-init display t)) |
| 85 | |
| 86 | |
| 87 | #?(and (sbcl>= 1 0 6) (sbcl< 1 0 15 6)) |
| 88 | ;; A very minimal implementation of CLISP's socket-status |
| 89 | (defun socket-status (socket seconds microseconds) |
| 90 | (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set))) |
| 91 | (let ((fd (sb-sys:fd-stream-fd (car socket)))) |
| 92 | (sb-unix:fd-zero read-fds) |
| 93 | (sb-unix:fd-set fd read-fds) |
| 94 | |
| 95 | (let ((num-fds-changed |
| 96 | (sb-unix:unix-fast-select |
| 97 | (1+ fd) (sb-alien:addr read-fds) nil nil |
| 98 | seconds microseconds))) |
| 99 | (unless (or (not num-fds-changed) (zerop num-fds-changed)) |
| 100 | (if (peek-char nil (car socket) nil) |
| 101 | :input |
| 102 | :eof)))))) |
| 103 | |
| 104 | (defun %init-async-event-handling (display) |
| 105 | (let ((style |
| 106 | #?(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6)) :fd-handler |
| 107 | #?-(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6)) nil)) |
| 108 | (when (and |
| 109 | (find-package "SWANK") |
| 110 | (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style))) |
| 111 | (error "When running clg in Slime, the communication style ~S must be used in combination with asynchronous event handling on this platform. See the README file and <http://common-lisp.net/project/slime/doc/html/Communication-style.html> for more information." style))) |
| 112 | |
| 113 | #+(or cmu sbcl) |
| 114 | (signal-connect (gdk:display-manager) 'display-opened |
| 115 | #'(lambda (display) |
| 116 | (let ((fd (gdk:display-connection-number display))) |
| 117 | (unless (< fd 0) |
| 118 | (let ((handler (add-fd-handler |
| 119 | (gdk:display-connection-number display) |
| 120 | :input #'main-iterate-all))) |
| 121 | (signal-connect display 'closed |
| 122 | #'(lambda (is-error-p) |
| 123 | (declare (ignore is-error-p)) |
| 124 | (remove-fd-handler handler)))))))) |
| 125 | |
| 126 | #?(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6)) |
| 127 | (progn |
| 128 | (setq *periodic-polling-function* #'main-iterate-all) |
| 129 | #?(or (featurep :cmu) (sbcl< 1 0 6)) |
| 130 | (multiple-value-setq (*max-event-to-sec* *max-event-to-usec*) |
| 131 | (decompose-time *event-polling-interval*)) |
| 132 | #?(sbcl>= 1 0 15 6) |
| 133 | (setq *periodic-polling-period* *event-polling-interval*)) |
| 134 | |
| 135 | #?(or (featurep :clisp) (and (sbcl>= 1 0 6) (sbcl< 1 0 15 6))) |
| 136 | ;; When running in CLISP or certain versions of SBCL in Slime we need |
| 137 | ;; to hook into the Swank server to handle events asynchronously. |
| 138 | (cond |
| 139 | ((and (find-package "SWANK") (find-symbol "CHECK-SLIME-INTERRUPTS" "SWANK")) |
| 140 | (let ((check-slime-interrupts |
| 141 | (symbol-function (find-symbol "CHECK-SLIME-INTERRUPTS" "SWANK")))) |
| 142 | (setf |
| 143 | (symbol-function (find-symbol "CHECK-SLIME-INTERRUPTS" "SWANK")) |
| 144 | #'(lambda () |
| 145 | (main-iterate-all) |
| 146 | (funcall check-slime-interrupts))))) |
| 147 | ((and (find-package "SWANK") |
| 148 | (find-symbol "READ-FROM-EMACS" "SWANK") |
| 149 | (find-symbol "*EMACS-CONNECTION*" "SWANK") |
| 150 | (find-symbol "CONNECTION.SOCKET-IO" "SWANK")) |
| 151 | (let ((connection (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK")))) |
| 152 | (when connection |
| 153 | (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))) |
| 154 | (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") connection))) |
| 155 | (multiple-value-bind (sec usec) |
| 156 | (decompose-time *event-polling-interval*) |
| 157 | (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")) |
| 158 | #'(lambda () |
| 159 | (loop |
| 160 | (case (socket-status (cons stream :input) sec usec) |
| 161 | ((:input :eof) (return (funcall read-from-emacs))) |
| 162 | (otherwise (main-iterate-all))))))))))) |
| 163 | ((flet ((warn-main-loop () |
| 164 | (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started."))) |
| 165 | #+(and clisp readline) |
| 166 | (if (find-package "SWANK") |
| 167 | (warn-main-loop) ; assuming we're running in SLIME |
| 168 | ;; Readline will call the event hook at most ten times per second |
| 169 | (setf readline:event-hook #'main-iterate-all)) |
| 170 | #-(and clisp readline)(warn-main-loop)))) |
| 171 | |
| 172 | (gdk:display-open display)) |
| 173 | |
| 174 | #+sb-thread |
| 175 | (progn |
| 176 | (defvar *main-thread* nil) |
| 177 | |
| 178 | ;; Hopefully, when threading support is added to the Win32 port of |
| 179 | ;; SBCL in the future, this will work just out of the box. |
| 180 | #+win32 |
| 181 | (let ((done (sb-thread:make-waitqueue)) |
| 182 | (functions ()) |
| 183 | (results ())) |
| 184 | |
| 185 | ;; In Win32 all GDK calls have to be made from the main loop |
| 186 | ;; thread, so we add a timeout function which will poll for code and |
| 187 | ;; execute it. |
| 188 | |
| 189 | (defun funcall-in-main (function) |
| 190 | (if (or |
| 191 | (not *main-thread*) |
| 192 | (eq sb-thread:*current-thread* *main-thread*)) |
| 193 | (funcall function) |
| 194 | (gdk:with-global-lock |
| 195 | (push function functions) |
| 196 | (sb-thread:condition-wait done gdk:*global-lock*) |
| 197 | (pop results)))) |
| 198 | |
| 199 | ;; Will lock REPL on error, need to be fixed! |
| 200 | (defun %funcall-in-main-poll () |
| 201 | (when functions |
| 202 | (loop |
| 203 | for n from 0 |
| 204 | while functions |
| 205 | do (push (funcall (pop functions)) results) |
| 206 | finally (sb-thread:condition-notify done n))) |
| 207 | t)) |
| 208 | |
| 209 | (defmacro within-main-loop (&body body) |
| 210 | #-win32 `(gdk:with-global-lock ,@body) |
| 211 | #+win32 `(funcall-in-main #'(lambda () ,@body))) |
| 212 | |
| 213 | (defun %init-multi-threaded-event-handling (display) |
| 214 | (when (and |
| 215 | (find-package "SWANK") |
| 216 | (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn))) |
| 217 | (error "When running clg in Slime, the communication style :spawn must be used in combination with multi threaded event handling. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information.")) |
| 218 | (gdk:threads-init) |
| 219 | (let ((main-running (sb-thread:make-waitqueue))) |
| 220 | (gdk:with-global-lock |
| 221 | (setf *main-thread* |
| 222 | (sb-thread:make-thread |
| 223 | #'(lambda () |
| 224 | (gdk:with-global-lock |
| 225 | (gdk:display-open display) |
| 226 | #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000) |
| 227 | #'%funcall-in-main-poll) |
| 228 | (sb-thread:condition-notify main-running) |
| 229 | (main))) |
| 230 | :name "gtk event loop")) |
| 231 | (sb-thread:condition-wait main-running gdk:*global-lock*))) |
| 232 | |
| 233 | ;; We need to hook into the Swank server to protect calls to GDK properly. |
| 234 | ;; This will *only* protect code entered directly in the REPL. |
| 235 | (when (find-package "SWANK") |
| 236 | (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK"))) |
| 237 | (if repl-eval-hook |
| 238 | (push #'(lambda (form) |
| 239 | (within-main-loop (eval form))) |
| 240 | (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK"))) |
| 241 | (warn "Your version of Slime does not have *SLIME-REPL-EVAL-HOOKS* so all calls to Gtk+ functions have to be explicit protected by wrapping them in a WITHIN-MAIN-LOOP form")))))) |
| 242 | |
| 243 | #-sb-thread |
| 244 | (defmacro within-main-loop (&body body) |
| 245 | `(progn ,@body)) |
| 246 | |
| 247 | |
| 248 | |
| 249 | ;;; Generic functions |
| 250 | |
| 251 | (defgeneric add-to-radio-group (item1 item2)) |
| 252 | (defgeneric activate-radio-widget (item)) |
| 253 | (defgeneric (setf tool-item-tip-text) (tip-text tool-item)) |
| 254 | (defgeneric (setf tool-item-tip-private) (tip-private tool-item)) |
| 255 | |
| 256 | |
| 257 | |
| 258 | ;;; Misc |
| 259 | |
| 260 | (defbinding grab-add () nil |
| 261 | (widget widget)) |
| 262 | |
| 263 | (defbinding grab-get-current () widget) |
| 264 | |
| 265 | (defbinding grab-remove () nil |
| 266 | (widget widget)) |
| 267 | |
| 268 | (defbinding get-default-language () (copy-of pango:language)) |
| 269 | |
| 270 | |
| 271 | ;;; About dialog |
| 272 | |
| 273 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 274 | (progn |
| 275 | (define-callback-marshal %about-dialog-activate-link-callback nil |
| 276 | (about-dialog (link string))) |
| 277 | |
| 278 | (defbinding about-dialog-set-email-hook (function) nil |
| 279 | (%about-dialog-activate-link-callback callback) |
| 280 | ((register-callback-function function) unsigned-int) |
| 281 | (user-data-destroy-callback callback)) |
| 282 | |
| 283 | (defbinding about-dialog-set-url-hook (function) nil |
| 284 | (%about-dialog-activate-link-callback callback) |
| 285 | ((register-callback-function function) unsigned-int) |
| 286 | (user-data-destroy-callback callback))) |
| 287 | |
| 288 | |
| 289 | ;;; Acccel group |
| 290 | |
| 291 | (defbinding %accel-group-connect () nil |
| 292 | (accel-group accel-group) |
| 293 | (key unsigned-int) |
| 294 | (modifiers gdk:modifier-type) |
| 295 | (flags accel-flags) |
| 296 | (gclosure gclosure)) |
| 297 | |
| 298 | (defun accel-group-connect (group accelerator function &optional flags) |
| 299 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 300 | (let ((gclosure (make-callback-closure function))) |
| 301 | (%accel-group-connect group key modifiers flags gclosure) |
| 302 | gclosure))) |
| 303 | |
| 304 | (defbinding accel-group-connect-by-path (group path function) nil |
| 305 | (group accel-group) |
| 306 | (path string) |
| 307 | ((make-callback-closure function) gclosure :in/return)) |
| 308 | |
| 309 | (defbinding %accel-group-disconnect (group gclosure) boolean |
| 310 | (group accel-group) |
| 311 | (gclosure gclosure)) |
| 312 | |
| 313 | (defbinding %accel-group-disconnect-key () boolean |
| 314 | (group accel-group) |
| 315 | (key unsigned-int) |
| 316 | (modifiers gdk:modifier-type)) |
| 317 | |
| 318 | (defun accel-group-disconnect (group accelerator) |
| 319 | (etypecase accelerator |
| 320 | (gclosure (%accel-group-disconnect group accelerator)) |
| 321 | (string |
| 322 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 323 | (%accel-group-disconnect-key group key modifiers))))) |
| 324 | |
| 325 | (defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n)) |
| 326 | (accel-group accel-group) |
| 327 | (key unsigned-int) |
| 328 | (modifiers gdk:modifier-type) |
| 329 | (n int :out)) |
| 330 | |
| 331 | (defun accel-group-query (accel-group accelerator) |
| 332 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 333 | (%accel-group-query accel-group key modifiers))) |
| 334 | |
| 335 | (defbinding %accel-group-activate () boolean |
| 336 | (accel-group accel-group) |
| 337 | (acceleratable gobject) |
| 338 | (key unsigned-int) |
| 339 | (modifiers gdk:modifier-type)) |
| 340 | |
| 341 | (defun accel-group-activate (accel-group acceleratable accelerator) |
| 342 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 343 | (%accel-group-activate accel-group acceleratable key modifiers))) |
| 344 | |
| 345 | (defbinding accel-group-lock () nil |
| 346 | (accel-group accel-group)) |
| 347 | |
| 348 | (defbinding accel-group-unlock () nil |
| 349 | (accel-group accel-group)) |
| 350 | |
| 351 | (defbinding accel-group-from-accel-closure () accel-group |
| 352 | (closure gclosure)) |
| 353 | |
| 354 | (defbinding %accel-groups-activate () boolean |
| 355 | (object gobject) |
| 356 | (key unsigned-int) |
| 357 | (modifiers gdk:modifier-type)) |
| 358 | |
| 359 | (defun accel-groups-activate (object accelerator) |
| 360 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 361 | (%accel-groups-activate object key modifiers))) |
| 362 | |
| 363 | (defbinding accel-groups-from-object () (gslist accel-group) |
| 364 | (object gobject)) |
| 365 | |
| 366 | (defbinding accelerator-valid-p (key &optional modifiers) boolean |
| 367 | (key unsigned-int) |
| 368 | (modifiers gdk:modifier-type)) |
| 369 | |
| 370 | (defbinding %accelerator-parse () nil |
| 371 | (accelerator string) |
| 372 | (key unsigned-int :out) |
| 373 | (modifiers gdk:modifier-type :out)) |
| 374 | |
| 375 | (defgeneric parse-accelerator (accelerator)) |
| 376 | |
| 377 | (defmethod parse-accelerator ((accelerator string)) |
| 378 | (multiple-value-bind (key modifiers) (%accelerator-parse accelerator) |
| 379 | (if (zerop key) |
| 380 | (error "Invalid accelerator: ~A" accelerator) |
| 381 | (values key modifiers)))) |
| 382 | |
| 383 | (defmethod parse-accelerator ((accelerator cons)) |
| 384 | (destructuring-bind (key modifiers) accelerator |
| 385 | (values |
| 386 | (etypecase key |
| 387 | (integer key) |
| 388 | (string |
| 389 | (or |
| 390 | (gdk:keyval-from-name key) |
| 391 | (error "Invalid key name: ~A" key))) |
| 392 | (character (parse-accelerator key))) |
| 393 | modifiers))) |
| 394 | |
| 395 | (defmethod parse-accelerator ((key integer)) |
| 396 | key) |
| 397 | |
| 398 | (defmethod parse-accelerator ((key character)) |
| 399 | (or |
| 400 | (gdk:keyval-from-name (string key)) |
| 401 | (error "Invalid key name: ~A" key))) |
| 402 | |
| 403 | |
| 404 | (defbinding accelerator-name () string |
| 405 | (key unsigned-int) |
| 406 | (modifiers gdk:modifier-type)) |
| 407 | |
| 408 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 409 | (defbinding accelerator-get-label () string |
| 410 | (key unsigned-int) |
| 411 | (modifiers gdk:modifier-type)) |
| 412 | |
| 413 | (defbinding %accelerator-set-default-mod-mask () nil |
| 414 | (default-modifiers gdk:modifier-type)) |
| 415 | |
| 416 | (defun (setf accelerator-default-modifier-mask) (default-modifiers) |
| 417 | (%accelerator-set-default-mod-mask default-modifiers)) |
| 418 | |
| 419 | (defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type) |
| 420 | |
| 421 | |
| 422 | ;;; Acccel label |
| 423 | |
| 424 | (defbinding accel-label-get-accel-width () unsigned-int |
| 425 | (accel-label accel-label)) |
| 426 | |
| 427 | (defbinding accel-label-refetch () boolean |
| 428 | (accel-label accel-label)) |
| 429 | |
| 430 | |
| 431 | |
| 432 | ;;; Accel map |
| 433 | |
| 434 | (defbinding %accel-map-add-entry () nil |
| 435 | (path string) |
| 436 | (key unsigned-int) |
| 437 | (modifiers gdk:modifier-type)) |
| 438 | |
| 439 | (defun accel-map-add-entry (path accelerator) |
| 440 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 441 | (%accel-map-add-entry path key modifiers))) |
| 442 | |
| 443 | (defbinding %accel-map-lookup-entry () boolean |
| 444 | (path string) |
| 445 | ((make-instance 'accel-key) accel-key :in/return)) |
| 446 | |
| 447 | (defun accel-map-lookup-entry (path) |
| 448 | (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path) |
| 449 | (when found-p |
| 450 | (values |
| 451 | (slot-value accel-key 'key) |
| 452 | (slot-value accel-key 'modifiers) |
| 453 | (slot-value accel-key 'flags))))) |
| 454 | |
| 455 | (defbinding %accel-map-change-entry () boolean |
| 456 | (path string) |
| 457 | (key unsigned-int) |
| 458 | (modifiers gdk:modifier-type) |
| 459 | (replace boolean)) |
| 460 | |
| 461 | (defun accel-map-change-entry (path accelerator &optional replace) |
| 462 | (multiple-value-bind (key modifiers) (parse-accelerator accelerator) |
| 463 | (%accel-map-change-entry path key modifiers replace))) |
| 464 | |
| 465 | (defbinding accel-map-load () nil |
| 466 | (filename pathname)) |
| 467 | |
| 468 | (defbinding accel-map-save () nil |
| 469 | (filename pathname)) |
| 470 | |
| 471 | (define-callback-marshal %accel-map-foreach-callback nil |
| 472 | ((accel-path string) (key unsigned-int) |
| 473 | (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first) |
| 474 | |
| 475 | (defbinding %accel-map-foreach (callback-id) nil |
| 476 | (callback-id unsigned-int) |
| 477 | (%accel-map-foreach-callback callback)) |
| 478 | |
| 479 | (defbinding %accel-map-foreach-unfiltered (callback-id) nil |
| 480 | (callback-id unsigned-int) |
| 481 | (%accel-map-foreach-callback callback)) |
| 482 | |
| 483 | (defun accel-map-foreach (function &optional (filter-p t)) |
| 484 | (with-callback-function (id function) |
| 485 | (if filter-p |
| 486 | (%accel-map-foreach id) |
| 487 | (%accel-map-foreach-unfiltered id)))) |
| 488 | |
| 489 | (defbinding accel-map-add-filter () nil |
| 490 | (filter string)) |
| 491 | |
| 492 | (defbinding accel-map-get () accel-map) |
| 493 | |
| 494 | (defbinding accel-map-lock-path () nil |
| 495 | (path string)) |
| 496 | |
| 497 | (defbinding accel-map-unlock-path () nil |
| 498 | (path string)) |
| 499 | |
| 500 | |
| 501 | |
| 502 | ;;; Accessibility |
| 503 | |
| 504 | (defbinding accessible-connect-widget-destroyed () nil |
| 505 | (accessible accessible)) |
| 506 | |
| 507 | |
| 508 | ;;; Adjustment |
| 509 | |
| 510 | (defmethod initialize-instance ((adjustment adjustment) &key value) |
| 511 | (prog1 |
| 512 | (call-next-method) |
| 513 | ;; we need to make sure that the value is set last, otherwise it |
| 514 | ;; may be outside current limits and ignored |
| 515 | (when value |
| 516 | (setf (slot-value adjustment 'value) value)))) |
| 517 | |
| 518 | |
| 519 | (defbinding adjustment-changed () nil |
| 520 | (adjustment adjustment)) |
| 521 | |
| 522 | (defbinding adjustment-value-changed () nil |
| 523 | (adjustment adjustment)) |
| 524 | |
| 525 | (defbinding adjustment-clamp-page () nil |
| 526 | (adjustment adjustment) |
| 527 | (lower single-float) |
| 528 | (upper single-float)) |
| 529 | |
| 530 | |
| 531 | ;;; Alignment |
| 532 | |
| 533 | (defbinding alignment-set () nil |
| 534 | (alognment alignment) |
| 535 | (x-align single-float) |
| 536 | (y-align single-float) |
| 537 | (x-scale single-float) |
| 538 | (y-scale single-float)) |
| 539 | |
| 540 | (defbinding alignment-get-padding () nil |
| 541 | (alognment alignment) |
| 542 | (top unsigned-int :out) |
| 543 | (bottom unsigned-int :out) |
| 544 | (left unsigned-int :out) |
| 545 | (right unsigned-int :out)) |
| 546 | |
| 547 | (defbinding alignment-set-padding () nil |
| 548 | (alognment alignment) |
| 549 | (top unsigned-int) |
| 550 | (bottom unsigned-int) |
| 551 | (left unsigned-int) |
| 552 | (right unsigned-int)) |
| 553 | |
| 554 | |
| 555 | ;;; Assistant |
| 556 | |
| 557 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0") |
| 558 | (progn |
| 559 | (defbinding assistant-get-nth-page () widget |
| 560 | (assistant assistant) |
| 561 | (page-num int)) |
| 562 | |
| 563 | (defbinding %assistant-insert-page () int |
| 564 | (assistant assistant) |
| 565 | (page widget) |
| 566 | (pos int)) |
| 567 | |
| 568 | (defun assistant-insert-page (assistant page position &rest child-args) |
| 569 | (let ((pos (case position |
| 570 | (:first 0) |
| 571 | (:last -1) |
| 572 | (t position)))) |
| 573 | (prog1 |
| 574 | (%assistant-insert-page assistant page pos) |
| 575 | (init-child-slots assistant page child-args)))) |
| 576 | |
| 577 | (defun assistant-append-page (assistant page &rest child-args) |
| 578 | (apply #'assistant-insert-page assistant page :last child-args)) |
| 579 | |
| 580 | (defun assistant-prepend-page (assistant page &rest child-args) |
| 581 | (apply #'assistant-insert-page assistant page :first child-args)) |
| 582 | |
| 583 | (define-callback-marshal %assistant-page-func-callback int |
| 584 | ((current-page int))) |
| 585 | |
| 586 | (defbinding assistant-set-forward-page-func (assistant function) nil |
| 587 | (assistant assistant) |
| 588 | (%assistant-page-func-callback callback) |
| 589 | ((register-callback-function function) pointer-data) |
| 590 | (user-data-destroy-callback callback)) |
| 591 | |
| 592 | (defbinding assistant-add-action-widget () nil |
| 593 | (assistant assistant) |
| 594 | (child widget)) |
| 595 | |
| 596 | (defbinding assistant-remove-action-widget () nil |
| 597 | (assistant assistant) |
| 598 | (child widget)) |
| 599 | |
| 600 | (defbinding assistant-update-buttons-state () nil |
| 601 | (assistant assistant))) |
| 602 | |
| 603 | |
| 604 | |
| 605 | ;;; Aspect frame |
| 606 | |
| 607 | |
| 608 | ;;; Bin |
| 609 | |
| 610 | (defun (setf bin-child) (child bin) |
| 611 | (when-bind (current-child (bin-child bin)) |
| 612 | (container-remove bin current-child)) |
| 613 | (container-add bin child) |
| 614 | child) |
| 615 | |
| 616 | (defmethod compute-signal-function ((bin bin) signal function object args) |
| 617 | (declare (ignore signal)) |
| 618 | (if (eq object :child) |
| 619 | #'(lambda (bin &rest emission-args) |
| 620 | (apply function (bin-child bin) (nconc emission-args args))) |
| 621 | (call-next-method))) |
| 622 | |
| 623 | |
| 624 | ;;; Box |
| 625 | |
| 626 | (defbinding box-pack-start () nil |
| 627 | (box box) |
| 628 | (child widget) |
| 629 | (expand boolean) |
| 630 | (fill boolean) |
| 631 | (padding unsigned-int)) |
| 632 | |
| 633 | (defbinding box-pack-end () nil |
| 634 | (box box) |
| 635 | (child widget) |
| 636 | (expand boolean) |
| 637 | (fill boolean) |
| 638 | (padding unsigned-int)) |
| 639 | |
| 640 | (defun box-pack (box child &key end (expand t) (fill t) (padding 0)) |
| 641 | (if end |
| 642 | (box-pack-end box child expand fill padding) |
| 643 | (box-pack-start box child expand fill padding))) |
| 644 | |
| 645 | (defbinding box-reorder-child () nil |
| 646 | (box box) |
| 647 | (child widget) |
| 648 | (position int)) |
| 649 | |
| 650 | (defbinding box-query-child-packing () nil |
| 651 | (box box) |
| 652 | (child widget) |
| 653 | (expand boolean :out) |
| 654 | (fill boolean :out) |
| 655 | (padding unsigned-int :out) |
| 656 | (pack-type pack-type :out)) |
| 657 | |
| 658 | (defbinding box-set-child-packing () nil |
| 659 | (box box) |
| 660 | (child widget) |
| 661 | (expand boolean) |
| 662 | (fill boolean) |
| 663 | (padding unsigned-int) |
| 664 | (pack-type pack-type)) |
| 665 | |
| 666 | |
| 667 | |
| 668 | ;;; Button |
| 669 | |
| 670 | (defmethod initialize-instance ((button button) &rest initargs &key stock) |
| 671 | (if stock |
| 672 | (apply #'call-next-method button |
| 673 | :label stock :use-stock t :use-underline t initargs) |
| 674 | (call-next-method))) |
| 675 | |
| 676 | |
| 677 | (defbinding button-pressed () nil |
| 678 | (button button)) |
| 679 | |
| 680 | (defbinding button-released () nil |
| 681 | (button button)) |
| 682 | |
| 683 | (defbinding button-clicked () nil |
| 684 | (button button)) |
| 685 | |
| 686 | (defbinding button-enter () nil |
| 687 | (button button)) |
| 688 | |
| 689 | (defbinding button-leave () nil |
| 690 | (button button)) |
| 691 | |
| 692 | |
| 693 | |
| 694 | ;;; Calendar |
| 695 | |
| 696 | (defbinding calendar-select-month () int |
| 697 | (calendar calendar) |
| 698 | (month unsigned-int) |
| 699 | (year unsigned-int)) |
| 700 | |
| 701 | (defbinding calendar-select-day () nil |
| 702 | (calendar calendar) |
| 703 | (day unsigned-int)) |
| 704 | |
| 705 | (defbinding calendar-mark-day () int |
| 706 | (calendar calendar) |
| 707 | (day unsigned-int)) |
| 708 | |
| 709 | (defbinding calendar-unmark-day () int |
| 710 | (calendar calendar) |
| 711 | (day unsigned-int)) |
| 712 | |
| 713 | (defbinding calendar-clear-marks () nil |
| 714 | (calendar calendar)) |
| 715 | |
| 716 | (defbinding calendar-get-date () nil |
| 717 | (calendar calendar) |
| 718 | (year unsigned-int :out) |
| 719 | (month unsigned-int :out) |
| 720 | (day unsigned-int :out)) |
| 721 | |
| 722 | (defbinding calendar-freeze () nil |
| 723 | (calendar calendar)) |
| 724 | |
| 725 | (defbinding calendar-thaw () nil |
| 726 | (calendar calendar)) |
| 727 | |
| 728 | |
| 729 | ;;; Check menu item |
| 730 | |
| 731 | (defbinding check-menu-item-toggled () nil |
| 732 | (check-menu-item check-menu-item)) |
| 733 | |
| 734 | |
| 735 | ;;; Color selection |
| 736 | |
| 737 | (defbinding color-selection-is-adjusting-p () boolean |
| 738 | (colorsel color-selection)) |
| 739 | |
| 740 | (defbinding (color-selection-previous-color |
| 741 | "gtk_color_selection_get_previous_color") () nil |
| 742 | (colorsel color-selection) |
| 743 | ((make-instance 'gdk:color) gdk:color :in/return)) |
| 744 | |
| 745 | |
| 746 | ;;; Color selection dialog -- no functions |
| 747 | |
| 748 | |
| 749 | |
| 750 | ;;;; Combo Box |
| 751 | |
| 752 | (defmethod initialize-instance ((combo-box combo-box) &rest initargs |
| 753 | &key model content active) |
| 754 | (remf initargs :active) |
| 755 | (if model |
| 756 | (apply #'call-next-method combo-box initargs) |
| 757 | (progn |
| 758 | (apply #'call-next-method combo-box |
| 759 | :model (make-instance 'list-store :column-types '(string)) |
| 760 | initargs) |
| 761 | (unless (typep combo-box 'combo-box-entry) |
| 762 | (let ((cell (make-instance 'cell-renderer-text))) |
| 763 | (cell-layout-pack combo-box cell :expand t) |
| 764 | (cell-layout-add-attribute combo-box cell :text 0))))) |
| 765 | (when content |
| 766 | (mapc #'(lambda (text) |
| 767 | (combo-box-append-text combo-box text)) |
| 768 | content)) |
| 769 | (when active |
| 770 | (setf (combo-box-active combo-box) active))) |
| 771 | |
| 772 | |
| 773 | ;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active) |
| 774 | ;; (when active |
| 775 | ;; (signal-emit combo-box 'changed))) |
| 776 | |
| 777 | (defbinding combo-box-append-text () nil |
| 778 | (combo-box combo-box) |
| 779 | (text string)) |
| 780 | |
| 781 | (defbinding combo-box-insert-text () nil |
| 782 | (combo-box combo-box) |
| 783 | (position int) |
| 784 | (text string)) |
| 785 | |
| 786 | (defbinding combo-box-prepend-text () nil |
| 787 | (combo-box combo-box) |
| 788 | (text string)) |
| 789 | |
| 790 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 791 | (defbinding combo-box-get-active-text () (or null string) |
| 792 | (combo-box combo-box)) |
| 793 | |
| 794 | (defbinding combo-box-popup () nil |
| 795 | (combo-box combo-box)) |
| 796 | |
| 797 | (defbinding combo-box-popdown () nil |
| 798 | (combo-box combo-box)) |
| 799 | |
| 800 | |
| 801 | |
| 802 | ;;;; Combo Box Entry |
| 803 | |
| 804 | (defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model) |
| 805 | (call-next-method) |
| 806 | (unless model |
| 807 | (setf (combo-box-entry-text-column combo-box-entry) 0))) |
| 808 | |
| 809 | |
| 810 | ;;;; Dialog |
| 811 | |
| 812 | (defmethod shared-initialize ((dialog dialog) names &rest initargs |
| 813 | &key button buttons) |
| 814 | (declare (ignore names button buttons)) |
| 815 | (prog1 |
| 816 | (call-next-method) |
| 817 | (initial-apply-add dialog #'dialog-add-button initargs :button :buttons))) |
| 818 | |
| 819 | |
| 820 | (defun dialog-response-id (dialog response &optional create-p error-p) |
| 821 | "Returns a numeric response id" |
| 822 | (if (typep response 'response-type) |
| 823 | (response-type-to-int response) |
| 824 | (let ((responses (user-data dialog 'responses))) |
| 825 | (cond |
| 826 | ((and responses (position response responses :test #'equal))) |
| 827 | (create-p |
| 828 | (cond |
| 829 | (responses |
| 830 | (vector-push-extend response responses) |
| 831 | (1- (length responses))) |
| 832 | (t |
| 833 | (setf |
| 834 | (user-data dialog 'responses) |
| 835 | (make-array 1 :adjustable t :fill-pointer t |
| 836 | :initial-element response)) |
| 837 | 0))) |
| 838 | (error-p |
| 839 | (error "Invalid response: ~A" response)))))) |
| 840 | |
| 841 | (defun dialog-find-response (dialog id) |
| 842 | "Finds a symbolic response given a numeric id" |
| 843 | (cond |
| 844 | ((not (numberp id)) id) |
| 845 | ((< id 0) (int-to-response-type id)) |
| 846 | ((aref (user-data dialog 'responses) id)))) |
| 847 | |
| 848 | |
| 849 | (defmethod compute-signal-id ((dialog dialog) signal) |
| 850 | (if (dialog-response-id dialog signal) |
| 851 | (ensure-signal-id 'response dialog) |
| 852 | (call-next-method))) |
| 853 | |
| 854 | (defmethod compute-signal-function ((dialog dialog) signal function object args) |
| 855 | (declare (ignore function object args)) |
| 856 | (let ((callback (call-next-method)) |
| 857 | (id (dialog-response-id dialog signal))) |
| 858 | (cond |
| 859 | (id |
| 860 | #'(lambda (dialog response) |
| 861 | (when (= response id) |
| 862 | (funcall callback dialog)))) |
| 863 | ((string-equal signal "response") |
| 864 | #'(lambda (dialog response) |
| 865 | (funcall callback dialog (dialog-find-response dialog response)))) |
| 866 | (callback)))) |
| 867 | |
| 868 | (defbinding %dialog-run () int |
| 869 | (dialog dialog)) |
| 870 | (defun dialog-run (dialog) |
| 871 | (dialog-find-response dialog (%dialog-run dialog))) |
| 872 | |
| 873 | (defbinding dialog-response (dialog response) nil |
| 874 | (dialog dialog) |
| 875 | ((dialog-response-id dialog response nil t) int)) |
| 876 | |
| 877 | |
| 878 | (defbinding %dialog-add-button () button |
| 879 | (dialog dialog) |
| 880 | (text string) |
| 881 | (response-id int)) |
| 882 | |
| 883 | (defun dialog-add-button (dialog label &optional (response label) |
| 884 | &key default object after) |
| 885 | "Adds a button to the dialog." |
| 886 | (let* ((signal (if (functionp response) |
| 887 | label |
| 888 | response)) |
| 889 | (id (dialog-response-id dialog signal t)) |
| 890 | (button (%dialog-add-button dialog label id))) |
| 891 | (when (functionp response) |
| 892 | (signal-connect dialog signal response :object object :after after)) |
| 893 | (when default |
| 894 | (%dialog-set-default-response dialog id)) |
| 895 | button)) |
| 896 | |
| 897 | |
| 898 | (defbinding %dialog-add-action-widget () nil |
| 899 | (dialog dialog) |
| 900 | (action-widget widget) |
| 901 | (response-id int)) |
| 902 | |
| 903 | (defun dialog-add-action-widget (dialog widget &optional (response widget) |
| 904 | &key default object after) |
| 905 | (let* ((signal (if (functionp response) |
| 906 | widget |
| 907 | response)) |
| 908 | (id (dialog-response-id dialog signal t))) |
| 909 | (unless (widget-hidden-p widget) |
| 910 | (widget-show widget)) |
| 911 | (%dialog-add-action-widget dialog widget id) |
| 912 | (when (functionp response) |
| 913 | (signal-connect dialog signal response :object object :after after)) |
| 914 | (when default |
| 915 | (setf (widget-can-default-p widget) t) |
| 916 | (%dialog-set-default-response dialog id)) |
| 917 | widget)) |
| 918 | |
| 919 | |
| 920 | (defbinding %dialog-set-default-response () nil |
| 921 | (dialog dialog) |
| 922 | (response-id int)) |
| 923 | |
| 924 | (defun dialog-set-default-response (dialog response) |
| 925 | (%dialog-set-default-response |
| 926 | dialog (dialog-response-id dialog response nil t))) |
| 927 | |
| 928 | (defbinding dialog-set-response-sensitive (dialog response sensitive) nil |
| 929 | (dialog dialog) |
| 930 | ((dialog-response-id dialog response nil t) int) |
| 931 | (sensitive boolean)) |
| 932 | |
| 933 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 934 | (defbinding alternative-dialog-button-order-p (&optional screen) boolean |
| 935 | (screen (or null gdk:screen))) |
| 936 | |
| 937 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 938 | (defbinding (dialog-set-alternative-button-order |
| 939 | "gtk_dialog_set_alternative_button_order_from_array") |
| 940 | (dialog new-order) nil |
| 941 | (dialog dialog) |
| 942 | ((length new-order) int) |
| 943 | ((map 'vector #'(lambda (response) |
| 944 | (dialog-response-id dialog response nil t)) |
| 945 | new-order) (vector int))) |
| 946 | |
| 947 | |
| 948 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
| 949 | (progn |
| 950 | (defbinding %dialog-get-response-for-widget () int |
| 951 | (dialog dialog) |
| 952 | (widget widget)) |
| 953 | |
| 954 | (defun dialog-get-response-for-widget (dialog widget) |
| 955 | (dialog-find-response dialog (dialog-get-response-for-widget dialog widget)))) |
| 956 | |
| 957 | |
| 958 | (defmethod container-add ((dialog dialog) (child widget) &rest args) |
| 959 | (apply #'container-add (dialog-vbox dialog) child args)) |
| 960 | |
| 961 | |
| 962 | (defmethod container-remove ((dialog dialog) (child widget)) |
| 963 | (container-remove (dialog-vbox dialog) child)) |
| 964 | |
| 965 | (defmethod container-children ((dialog dialog)) |
| 966 | (container-children (dialog-vbox dialog))) |
| 967 | |
| 968 | (defmethod (setf container-children) (children (dialog dialog)) |
| 969 | (setf (container-children (dialog-vbox dialog)) children)) |
| 970 | |
| 971 | |
| 972 | ;;; Drawing Area |
| 973 | |
| 974 | (defun drawing-area-scroll (drawing-area dx dy) |
| 975 | (gdk:window-scroll (widget-window drawing-area) dx dy)) |
| 976 | |
| 977 | |
| 978 | ;;; Entry |
| 979 | |
| 980 | (defbinding entry-get-layout-offsets () nil |
| 981 | (entry entry) |
| 982 | (x int :out) |
| 983 | (y int :out)) |
| 984 | |
| 985 | (defbinding entry-layout-index-to-text-index () int |
| 986 | (entry entry) |
| 987 | (layout-index int)) |
| 988 | |
| 989 | (defbinding entry-text-index-to-layout-index () int |
| 990 | (entry entry) |
| 991 | (text-index int)) |
| 992 | |
| 993 | |
| 994 | ;;; Entry Completion |
| 995 | |
| 996 | (define-callback-marshal %entry-completion-match-callback boolean |
| 997 | (entry-completion string tree-iter)) |
| 998 | |
| 999 | (defbinding entry-completion-set-match-func (completion function) nil |
| 1000 | (completion entry-completion) |
| 1001 | (%entry-completion-match-callback callback) |
| 1002 | ((register-callback-function function) unsigned-int) |
| 1003 | (user-data-destroy-callback callback)) |
| 1004 | |
| 1005 | (defbinding entry-completion-complete () nil |
| 1006 | (completion entry-completion)) |
| 1007 | |
| 1008 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0") |
| 1009 | (defbinding entry-completion-get-completion-prefix () string |
| 1010 | (completion entry-completion)) |
| 1011 | |
| 1012 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1013 | (defbinding entry-completion-insert-prefix () nil |
| 1014 | (completion entry-completion)) |
| 1015 | |
| 1016 | (defbinding entry-completion-insert-action-text () nil |
| 1017 | (completion entry-completion) |
| 1018 | (index int) |
| 1019 | (text string)) |
| 1020 | |
| 1021 | (defbinding entry-completion-insert-action-markup () nil |
| 1022 | (completion entry-completion) |
| 1023 | (index int) |
| 1024 | (markup string)) |
| 1025 | |
| 1026 | (defbinding entry-completion-delete-action () nil |
| 1027 | (completion entry-completion) |
| 1028 | (index int)) |
| 1029 | |
| 1030 | |
| 1031 | ;;; File Chooser |
| 1032 | |
| 1033 | (defmethod initialize-instance ((file-chooser file-chooser) &rest initargs |
| 1034 | &key filter filters shortcut-folder |
| 1035 | shortcut-folders shortcut-folder-uti |
| 1036 | shortcut-folder-uris) |
| 1037 | (declare (ignore filter filters shortcut-folder shortcut-folders |
| 1038 | shortcut-folder-uti shortcut-folder-uris)) |
| 1039 | (prog1 |
| 1040 | (call-next-method) |
| 1041 | (initial-add file-chooser #'file-chooser-add-filter |
| 1042 | initargs :filer :filters) |
| 1043 | (initial-add file-chooser #'file-chooser-add-shortcut-folder |
| 1044 | initargs :shortcut-folder :shortcut-folders) |
| 1045 | (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri |
| 1046 | initargs :shortcut-folder-uri :shortcut-folders-uris))) |
| 1047 | |
| 1048 | |
| 1049 | (defbinding file-chooser-select-filename () boolean |
| 1050 | (file-chooser file-chooser) |
| 1051 | (filename string)) |
| 1052 | |
| 1053 | (defbinding file-chooser-unselect-filename () nil |
| 1054 | (file-chooser file-chooser) |
| 1055 | (filename string)) |
| 1056 | |
| 1057 | (defbinding file-chooser-select-all () boolean |
| 1058 | (file-chooser file-chooser)) |
| 1059 | |
| 1060 | (defbinding file-chooser-unselect-all () boolean |
| 1061 | (file-chooser file-chooser)) |
| 1062 | |
| 1063 | (defbinding file-chooser-get-filenames () (gslist string) |
| 1064 | (file-chooser file-chooser)) |
| 1065 | |
| 1066 | (defbinding file-chooser-select-uri () boolean |
| 1067 | (file-chooser file-chooser) |
| 1068 | (uri string)) |
| 1069 | |
| 1070 | (defbinding file-chooser-unselect-uri () nil |
| 1071 | (file-chooser file-chooser) |
| 1072 | (uri string)) |
| 1073 | |
| 1074 | (defbinding file-chooser-get-uris () (gslist string) |
| 1075 | (file-chooser file-chooser)) |
| 1076 | |
| 1077 | (defbinding file-chooser-add-filter () nil |
| 1078 | (file-chooser file-chooser) |
| 1079 | (filter file-filter)) |
| 1080 | |
| 1081 | (defbinding file-chooser-remove-filter () nil |
| 1082 | (file-chooser file-chooser) |
| 1083 | (filter file-filter)) |
| 1084 | |
| 1085 | (defbinding file-chooser-list-filters () (gslist file-filter) |
| 1086 | (file-chooser file-chooser)) |
| 1087 | |
| 1088 | (defbinding file-chooser-add-shortcut-folder () boolean |
| 1089 | (file-chooser file-chooser) |
| 1090 | (folder string) |
| 1091 | (nil null)) |
| 1092 | |
| 1093 | (defbinding file-chooser-remove-shortcut-folder () nil |
| 1094 | (file-chooser file-chooser) |
| 1095 | (folder string) |
| 1096 | (nil null)) |
| 1097 | |
| 1098 | (defbinding file-chooser-list-shortcut-folders () (gslist string) |
| 1099 | (file-chooser file-chooser)) |
| 1100 | |
| 1101 | (defbinding file-chooser-add-shortcut-folder-uri () boolean |
| 1102 | (file-chooser file-chooser) |
| 1103 | (uri string) |
| 1104 | (nil null)) |
| 1105 | |
| 1106 | (defbinding file-chooser-remove-shortcut-folder-uri () nil |
| 1107 | (file-chooser file-chooser) |
| 1108 | (uri string) |
| 1109 | (nil null)) |
| 1110 | |
| 1111 | (defbinding file-chooser-list-shortcut-folder-uris () (gslist string) |
| 1112 | (file-chooser file-chooser)) |
| 1113 | |
| 1114 | |
| 1115 | ;;; File Filter |
| 1116 | |
| 1117 | (defmethod initialize-instance ((file-filter file-filter) &rest initargs |
| 1118 | &key mime-type mime-types pattern patterns |
| 1119 | pixbuf-formats) |
| 1120 | (declare (ignore mime-type mime-types pattern patterns)) |
| 1121 | (prog1 |
| 1122 | (call-next-method) |
| 1123 | (when pixbuf-formats |
| 1124 | #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1125 | (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk") |
| 1126 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1127 | (file-filter-add-pixbuf-formats file-filter)) |
| 1128 | (initial-add file-filter #'file-filter-add-mime-type |
| 1129 | initargs :mime-type :mime-types) |
| 1130 | (initial-add file-filter #'file-filter-add-pattern |
| 1131 | initargs :pattern :patterns))) |
| 1132 | |
| 1133 | |
| 1134 | (defbinding file-filter-add-mime-type () nil |
| 1135 | (filter file-filter) |
| 1136 | (mime-type string)) |
| 1137 | |
| 1138 | (defbinding file-filter-add-pattern () nil |
| 1139 | (filter file-filter) |
| 1140 | (pattern string)) |
| 1141 | |
| 1142 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1143 | (defbinding file-filter-add-pixbuf-formats () nil |
| 1144 | (filter file-filter)) |
| 1145 | |
| 1146 | (define-callback-marshal %file-filter-callback boolean (file-filter-info)) |
| 1147 | |
| 1148 | (defbinding file-filter-add-custom (filter needed function) nil |
| 1149 | (filter file-filter) |
| 1150 | (needed file-filter-flags) |
| 1151 | (%file-filter-callback callback) |
| 1152 | ((register-callback-function function) unsigned-int) |
| 1153 | (user-data-destroy-callback callback)) |
| 1154 | |
| 1155 | (defbinding file-filter-get-needed () file-filter-flags |
| 1156 | (filter file-filter)) |
| 1157 | |
| 1158 | (defbinding file-filter-filter () boolean |
| 1159 | (filter file-filter) |
| 1160 | (filter-info file-filter-info)) |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | ;;; Image |
| 1165 | |
| 1166 | (defbinding image-set-from-file () nil |
| 1167 | (image image) |
| 1168 | (filename pathname)) |
| 1169 | |
| 1170 | (defmethod (setf image-pixmap) ((data vector) (image image)) |
| 1171 | (multiple-value-bind (pixmap mask) (gdk:pixmap-create data) |
| 1172 | (setf (image-pixmap image) pixmap) |
| 1173 | (setf (image-mask image) mask))) |
| 1174 | |
| 1175 | (defmethod initialize-instance ((image image) &rest initargs &key pixmap file) |
| 1176 | (cond |
| 1177 | ((typep pixmap 'vector) |
| 1178 | (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap) |
| 1179 | (apply #'call-next-method image :pixmap pixmap :mask mask initargs))) |
| 1180 | (file |
| 1181 | (prog1 |
| 1182 | (call-next-method) |
| 1183 | (image-set-from-file image file))) |
| 1184 | ((call-next-method)))) |
| 1185 | |
| 1186 | (defun create-image-widget (source &optional mask) |
| 1187 | (etypecase source |
| 1188 | (gdk:pixbuf (make-instance 'image :pixbuf source)) |
| 1189 | (string (make-instance 'image :stock source)) |
| 1190 | (pathname (make-instance 'image :file source)) |
| 1191 | ((or list vector) (make-instance 'image :pixmap source)) |
| 1192 | (gdk:pixmap (make-instance 'image :pixmap source :mask mask)))) |
| 1193 | |
| 1194 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
| 1195 | (defbinding image-clear () nil |
| 1196 | (image image)) |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | ;;; Image menu item |
| 1201 | |
| 1202 | (defmethod initialize-instance ((item image-menu-item) &rest initargs &key image) |
| 1203 | (if (and image (not (typep image 'widget))) |
| 1204 | (apply #'call-next-method item :image (create-image-widget image) initargs) |
| 1205 | (call-next-method))) |
| 1206 | |
| 1207 | |
| 1208 | (defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item)) |
| 1209 | (setf (slot-value item 'image) widget)) |
| 1210 | |
| 1211 | (defmethod (setf image-menu-item-image) (image (item image-menu-item)) |
| 1212 | (setf (image-menu-item-image item) (create-image-widget image))) |
| 1213 | |
| 1214 | |
| 1215 | ;;; Label |
| 1216 | |
| 1217 | (defmethod shared-initialize ((label label) names &key pattern) |
| 1218 | (declare (ignore names)) |
| 1219 | (call-next-method) |
| 1220 | (when pattern |
| 1221 | (setf (label-pattern label) pattern))) |
| 1222 | |
| 1223 | (defbinding label-get-layout-offsets () nil |
| 1224 | (label label) |
| 1225 | (x int :out) |
| 1226 | (y int :out)) |
| 1227 | |
| 1228 | (defbinding label-select-region () nil |
| 1229 | (label label) |
| 1230 | (start int) |
| 1231 | (end int)) |
| 1232 | |
| 1233 | (defbinding label-get-selection-bounds () boolean |
| 1234 | (label label) |
| 1235 | (start int :out) |
| 1236 | (end int :out)) |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | ;;; Radio button |
| 1241 | |
| 1242 | (defbinding %radio-button-get-group () pointer |
| 1243 | (radio-button radio-button)) |
| 1244 | |
| 1245 | (defbinding %radio-button-set-group () nil |
| 1246 | (radio-button radio-button) |
| 1247 | (group pointer)) |
| 1248 | |
| 1249 | (defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button)) |
| 1250 | "Add BUTTON1 to the group which BUTTON2 belongs to." |
| 1251 | (%radio-button-set-group button1 (%radio-button-get-group button2))) |
| 1252 | |
| 1253 | (defun %add-activate-callback (widget signal function object after) |
| 1254 | (if object |
| 1255 | (signal-connect widget signal |
| 1256 | #'(lambda (object) |
| 1257 | (when (slot-value widget 'active) |
| 1258 | (funcall function object (slot-value widget 'value)))) |
| 1259 | :object object :after after) |
| 1260 | (signal-connect widget signal |
| 1261 | #'(lambda () |
| 1262 | (when (slot-value widget 'active) |
| 1263 | (funcall function (slot-value widget 'value)))) |
| 1264 | :after after))) |
| 1265 | |
| 1266 | (defmethod activate-radio-widget ((button radio-button)) |
| 1267 | (signal-emit button 'clicked)) |
| 1268 | |
| 1269 | (defgeneric add-activate-callback (action function &key object after)) |
| 1270 | |
| 1271 | (defmethod add-activate-callback ((button radio-button) function &key object after) |
| 1272 | (%add-activate-callback button 'clicked function object after)) |
| 1273 | |
| 1274 | (defmethod initialize-instance ((button radio-button) &key group) |
| 1275 | (prog1 |
| 1276 | (call-next-method) |
| 1277 | (when group |
| 1278 | (add-to-radio-group button group)))) |
| 1279 | |
| 1280 | |
| 1281 | ;;; Item |
| 1282 | |
| 1283 | (defbinding item-select () nil |
| 1284 | (item item)) |
| 1285 | |
| 1286 | (defbinding item-deselect () nil |
| 1287 | (item item)) |
| 1288 | |
| 1289 | (defbinding item-toggle () nil |
| 1290 | (item item)) |
| 1291 | |
| 1292 | |
| 1293 | |
| 1294 | ;;; Menu item |
| 1295 | |
| 1296 | (defmethod initialize-instance ((item menu-item) &key label) |
| 1297 | (prog1 |
| 1298 | (call-next-method) |
| 1299 | (when label |
| 1300 | (setf (menu-item-label item) label)))) |
| 1301 | |
| 1302 | |
| 1303 | (defun (setf menu-item-label) (label menu-item) |
| 1304 | (make-instance 'accel-label |
| 1305 | :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item |
| 1306 | :use-underline (menu-item-use-underline-p menu-item) |
| 1307 | :visible t :parent menu-item) |
| 1308 | label) |
| 1309 | |
| 1310 | (defun menu-item-label (menu-item) |
| 1311 | (when (and (slot-boundp menu-item 'child) |
| 1312 | (typep (bin-child menu-item) 'label)) |
| 1313 | (label-label (bin-child menu-item)))) |
| 1314 | |
| 1315 | (defbinding menu-item-remove-submenu () nil |
| 1316 | (menu-item menu-item)) |
| 1317 | |
| 1318 | (defbinding menu-item-set-accel-path () nil |
| 1319 | (menu-item menu-item) |
| 1320 | (accel-path string)) |
| 1321 | |
| 1322 | (defbinding menu-item-select () nil |
| 1323 | (menu-item menu-item)) |
| 1324 | |
| 1325 | (defbinding menu-item-deselect () nil |
| 1326 | (menu-item menu-item)) |
| 1327 | |
| 1328 | (defbinding menu-item-activate () nil |
| 1329 | (menu-item menu-item)) |
| 1330 | |
| 1331 | (defbinding menu-item-toggle-size-request () nil |
| 1332 | (menu-item menu-item) |
| 1333 | (requisition int :out)) |
| 1334 | |
| 1335 | (defbinding menu-item-toggle-size-allocate () nil |
| 1336 | (menu-item menu-item) |
| 1337 | (allocation int)) |
| 1338 | |
| 1339 | |
| 1340 | ;;; Menu tool button |
| 1341 | |
| 1342 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1343 | (defbinding menu-tool-button-set-arrow-tooltip () nil |
| 1344 | (menu-tool-button menu-tool-button) |
| 1345 | (tooltips tooltips) |
| 1346 | (tip-text string) |
| 1347 | (tip-private string)) |
| 1348 | |
| 1349 | |
| 1350 | ;;; Message dialog |
| 1351 | |
| 1352 | (defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info) |
| 1353 | button buttons flags transient-parent) |
| 1354 | (let ((stock-buttons |
| 1355 | (cond |
| 1356 | ((and (not buttons) (not button)) |
| 1357 | (case message-type |
| 1358 | (:question :yes-no) |
| 1359 | (t :ok))) |
| 1360 | ((listp buttons) :none) |
| 1361 | (t buttons)))) |
| 1362 | (%message-dialog-new transient-parent flags message-type stock-buttons))) |
| 1363 | |
| 1364 | |
| 1365 | (defmethod shared-initialize ((dialog message-dialog) names &rest initargs |
| 1366 | &key message-type buttons button text |
| 1367 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1368 | secondary-text) |
| 1369 | (declare (ignore names)) |
| 1370 | (when text |
| 1371 | (message-dialog-set-markup dialog text)) |
| 1372 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1373 | (when secondary-text |
| 1374 | (message-dialog-format-secondary-markup dialog secondary-text)) |
| 1375 | (when (and (not buttons) (not button)) |
| 1376 | (loop |
| 1377 | for (key value) on initargs by #'cddr |
| 1378 | when (and (eq key :signal) (eq (first value) :close)) |
| 1379 | do (warn "Default button configuration changed from ~A to ~A" :close |
| 1380 | (if (eq message-type :question) :yes-no :ok)) |
| 1381 | (loop-finish))) |
| 1382 | (if (typep buttons 'buttons-type) |
| 1383 | (apply #'call-next-method dialog names (plist-remove :buttons initargs)) |
| 1384 | (call-next-method))) |
| 1385 | |
| 1386 | |
| 1387 | (defbinding %message-dialog-new () pointer |
| 1388 | (parent (or null window)) |
| 1389 | (flags dialog-flags) |
| 1390 | (type message-type) |
| 1391 | (buttons buttons-type) |
| 1392 | (nil null)) |
| 1393 | |
| 1394 | (defbinding message-dialog-set-markup () nil |
| 1395 | (message-dialog message-dialog) |
| 1396 | (markup string)) |
| 1397 | |
| 1398 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1399 | (defbinding message-dialog-format-secondary-text () nil |
| 1400 | (message-dialog message-dialog) |
| 1401 | (text string)) |
| 1402 | |
| 1403 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 1404 | (defbinding message-dialog-format-secondary-markup () nil |
| 1405 | (message-dialog message-dialog) |
| 1406 | (markup string)) |
| 1407 | |
| 1408 | |
| 1409 | |
| 1410 | ;;; Radio menu item |
| 1411 | |
| 1412 | (defbinding %radio-menu-item-get-group () pointer |
| 1413 | (radio-menu-item radio-menu-item)) |
| 1414 | |
| 1415 | (defbinding %radio-menu-item-set-group () nil |
| 1416 | (radio-menu-item radio-menu-item) |
| 1417 | (group pointer)) |
| 1418 | |
| 1419 | (defmethod activate-radio-widget ((item radio-menu-item)) |
| 1420 | (menu-item-activate item)) |
| 1421 | |
| 1422 | (defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item)) |
| 1423 | "Add ITEM1 to the group which ITEM2 belongs to." |
| 1424 | (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2))) |
| 1425 | |
| 1426 | (defmethod add-activate-callback ((item radio-menu-item) function &key object after) |
| 1427 | (%add-activate-callback item 'activate function object after)) |
| 1428 | |
| 1429 | (defmethod initialize-instance ((item radio-menu-item) &key group) |
| 1430 | (prog1 |
| 1431 | (call-next-method) |
| 1432 | (when group |
| 1433 | (add-to-radio-group item group)))) |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | ;;; Radio tool button |
| 1438 | |
| 1439 | (defbinding %radio-tool-button-get-group () pointer |
| 1440 | (radio-tool-button radio-tool-button)) |
| 1441 | |
| 1442 | (defbinding %radio-tool-button-set-group () nil |
| 1443 | (radio-tool-button radio-tool-button) |
| 1444 | (group pointer)) |
| 1445 | |
| 1446 | (defmethod activate-radio-widget ((button radio-tool-button)) |
| 1447 | (signal-emit button 'clicked)) |
| 1448 | |
| 1449 | (defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button)) |
| 1450 | "Add BUTTON1 to the group which BUTTON2 belongs to." |
| 1451 | (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2))) |
| 1452 | (defmethod add-activate-callback ((button radio-tool-button) function &key object after) |
| 1453 | (%add-activate-callback button 'clicked function object after)) |
| 1454 | |
| 1455 | (defmethod initialize-instance ((button radio-tool-button) &key group) |
| 1456 | (prog1 |
| 1457 | (call-next-method) |
| 1458 | (when group |
| 1459 | (add-to-radio-group button group)))) |
| 1460 | |
| 1461 | |
| 1462 | |
| 1463 | ;;; Toggle button |
| 1464 | |
| 1465 | (defbinding toggle-button-toggled () nil |
| 1466 | (toggle-button toggle-button)) |
| 1467 | |
| 1468 | |
| 1469 | ;;; Window |
| 1470 | |
| 1471 | (defmethod initialize-instance ((window window) &rest initargs |
| 1472 | &key display accel-group accel-groups) |
| 1473 | (declare (ignore accel-group accel-groups)) |
| 1474 | (prog1 |
| 1475 | (if display |
| 1476 | (apply #'call-next-method |
| 1477 | window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs) |
| 1478 | (call-next-method)) |
| 1479 | (initial-add window #'window-add-accel-group |
| 1480 | initargs :accel-group :accel-groups))) |
| 1481 | |
| 1482 | #-debug-ref-counting |
| 1483 | (defmethod print-object ((window window) stream) |
| 1484 | (if (and |
| 1485 | (proxy-valid-p window) |
| 1486 | (slot-boundp window 'title) |
| 1487 | (not (zerop (length (window-title window))))) |
| 1488 | (print-unreadable-object (window stream :type t :identity nil) |
| 1489 | (format stream "~S at 0x~X" |
| 1490 | (window-title window) (pointer-address (foreign-location window)))) |
| 1491 | (call-next-method))) |
| 1492 | |
| 1493 | (defbinding window-set-wmclass () nil |
| 1494 | (window window) |
| 1495 | (wmclass-name string) |
| 1496 | (wmclass-class string)) |
| 1497 | |
| 1498 | (defbinding window-add-accel-group () nil |
| 1499 | (window window) |
| 1500 | (accel-group accel-group)) |
| 1501 | |
| 1502 | (defbinding window-remove-accel-group () nil |
| 1503 | (window window) |
| 1504 | (accel-group accel-group)) |
| 1505 | |
| 1506 | (defbinding window-activate-focus () int |
| 1507 | (window window)) |
| 1508 | |
| 1509 | (defbinding window-activate-default () int |
| 1510 | (window window)) |
| 1511 | |
| 1512 | (defbinding window-set-default-size (window width height) int |
| 1513 | (window window) |
| 1514 | ((or width -1) int) |
| 1515 | ((or height -1) int)) |
| 1516 | |
| 1517 | (defbinding %window-set-geometry-hints () nil |
| 1518 | (window window) |
| 1519 | (widget (or widget null)) |
| 1520 | (geometry gdk:geometry) |
| 1521 | (geometry-mask gdk:window-hints)) |
| 1522 | |
| 1523 | (defun window-set-geometry-hints (window &key widget min-width min-height |
| 1524 | max-width max-height base-width base-height |
| 1525 | width-inc height-inc gravity |
| 1526 | aspect (min-aspect aspect) (max-aspect aspect)) |
| 1527 | (let ((geometry (make-instance 'gdk:geometry |
| 1528 | :min-width (or min-width -1) |
| 1529 | :min-height (or min-height -1) |
| 1530 | :max-width (or max-width -1) |
| 1531 | :max-height (or max-height -1) |
| 1532 | :base-width (or base-width 0) |
| 1533 | :base-height (or base-height 0) |
| 1534 | :width-inc (or width-inc 0) |
| 1535 | :height-inc (or height-inc 0) |
| 1536 | :min-aspect (or min-aspect 0) |
| 1537 | :max-aspect (or max-aspect 0))) |
| 1538 | (mask ())) |
| 1539 | (when (or min-width min-height) |
| 1540 | (push :min-size mask)) |
| 1541 | (when (or max-width max-height) |
| 1542 | (push :max-size mask)) |
| 1543 | (when (or base-width base-height) |
| 1544 | (push :base-size mask)) |
| 1545 | (when (or width-inc height-inc) |
| 1546 | (push :resize-inc mask)) |
| 1547 | (when (or min-aspect max-aspect) |
| 1548 | (push :aspect mask)) |
| 1549 | (when gravity |
| 1550 | (push :win-gravity mask) |
| 1551 | (setf (gdk:geometry-gravity geometry) gravity)) |
| 1552 | (%window-set-geometry-hints window widget geometry mask))) |
| 1553 | |
| 1554 | (defbinding window-list-toplevels () (glist (copy-of window)) |
| 1555 | "Returns a list of all existing toplevel windows.") |
| 1556 | |
| 1557 | (defbinding window-add-mnemonic (window key target) nil |
| 1558 | (window window) |
| 1559 | ((gdk:keyval-from-name key) unsigned-int) |
| 1560 | (target widget)) |
| 1561 | |
| 1562 | (defbinding window-remove-mnemonic (window key target) nil |
| 1563 | (window window) |
| 1564 | ((gdk:keyval-from-name key) unsigned-int) |
| 1565 | (target widget)) |
| 1566 | |
| 1567 | (defbinding window-mnemonic-activate (window key modifier) nil |
| 1568 | (window window) |
| 1569 | ((gdk:keyval-from-name key) unsigned-int) |
| 1570 | (modifier gdk:modifier-type)) |
| 1571 | |
| 1572 | (defbinding window-activate-key () boolean |
| 1573 | (window window) |
| 1574 | (event gdk:key-event)) |
| 1575 | |
| 1576 | (defbinding window-propagate-key-event () boolean |
| 1577 | (window window) |
| 1578 | (event gdk:key-event)) |
| 1579 | |
| 1580 | #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
| 1581 | (defbinding window-present () nil |
| 1582 | (window window)) |
| 1583 | |
| 1584 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
| 1585 | (progn |
| 1586 | (defbinding %window-present () nil |
| 1587 | (window window)) |
| 1588 | |
| 1589 | (defbinding %window-present-with-time () nil |
| 1590 | (window window) |
| 1591 | (timespamp unsigned-int)) |
| 1592 | |
| 1593 | (defun window-present (window &optional timestamp) |
| 1594 | (if timestamp |
| 1595 | (%window-present-with-time window timestamp) |
| 1596 | (%window-present window)))) |
| 1597 | |
| 1598 | (defbinding window-iconify () nil |
| 1599 | (window window)) |
| 1600 | |
| 1601 | (defbinding window-deiconify () nil |
| 1602 | (window window)) |
| 1603 | |
| 1604 | (defbinding window-stick () nil |
| 1605 | (window window)) |
| 1606 | |
| 1607 | (defbinding window-unstick () nil |
| 1608 | (window window)) |
| 1609 | |
| 1610 | (defbinding window-maximize () nil |
| 1611 | (window window)) |
| 1612 | |
| 1613 | (defbinding window-unmaximize () nil |
| 1614 | (window window)) |
| 1615 | |
| 1616 | (defbinding window-fullscreen () nil |
| 1617 | (window window)) |
| 1618 | |
| 1619 | (defbinding window-unfullscreen () nil |
| 1620 | (window window)) |
| 1621 | |
| 1622 | (defbinding window-set-keep-above () nil |
| 1623 | (window window) |
| 1624 | (setting boolean)) |
| 1625 | |
| 1626 | (defbinding window-set-keep-below () nil |
| 1627 | (window window) |
| 1628 | (setting boolean)) |
| 1629 | |
| 1630 | (defbinding window-begin-resize-drag () nil |
| 1631 | (window window) |
| 1632 | (edge gdk:window-edge) |
| 1633 | (button int) |
| 1634 | (root-x int) (root-y int) |
| 1635 | (timestamp unsigned-int)) |
| 1636 | |
| 1637 | (defbinding window-begin-move-drag () nil |
| 1638 | (window window) |
| 1639 | (edge gdk:window-edge) |
| 1640 | (button int) |
| 1641 | (root-x int) (root-y int) |
| 1642 | (timestamp unsigned-int)) |
| 1643 | |
| 1644 | (defbinding window-set-frame-dimensions () nil |
| 1645 | (window window) |
| 1646 | (left int) (top int) (rigth int) (bottom int)) |
| 1647 | |
| 1648 | (defbinding %window-get-default-size () nil |
| 1649 | (window window) |
| 1650 | (width int :out) |
| 1651 | (height int :out)) |
| 1652 | |
| 1653 | (defun window-get-default-size (window) |
| 1654 | (multiple-value-bind (width height) (%window-get-default-size window) |
| 1655 | (values (unless (= width -1) width) (unless (= height -1) height)))) |
| 1656 | |
| 1657 | (defbinding window-get-frame-dimensions () nil |
| 1658 | (window window) |
| 1659 | (left int :out) (top int :out) (rigth int :out) (bottom int :out)) |
| 1660 | |
| 1661 | (defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf)) |
| 1662 | (window window)) |
| 1663 | |
| 1664 | (defbinding window-get-position () nil |
| 1665 | (window window) |
| 1666 | (root-x int :out) |
| 1667 | (root-y int :out)) |
| 1668 | |
| 1669 | (defbinding window-get-size () nil |
| 1670 | (window window) |
| 1671 | (width int :out) |
| 1672 | (height int :out)) |
| 1673 | |
| 1674 | (defbinding window-move () nil |
| 1675 | (window window) |
| 1676 | (x int) |
| 1677 | (y int)) |
| 1678 | |
| 1679 | (defbinding window-parse-geometry () boolean |
| 1680 | (window window) |
| 1681 | (geometry string)) |
| 1682 | |
| 1683 | (defbinding window-reshow-with-initial-size () nil |
| 1684 | (window window)) |
| 1685 | |
| 1686 | (defbinding window-resize () nil |
| 1687 | (window window) |
| 1688 | (width int) |
| 1689 | (heigth int)) |
| 1690 | |
| 1691 | (defbinding (window-default-icon-list "gtk_window_get_default_icon_list") |
| 1692 | () (glist gdk:pixbuf)) |
| 1693 | |
| 1694 | (defun window-default-icon () |
| 1695 | (first (window-default-icon-list))) |
| 1696 | |
| 1697 | (defbinding %window-set-default-icon-list () nil |
| 1698 | (icons (glist gdk:pixbuf))) |
| 1699 | |
| 1700 | (defun (setf window-default-icon-list) (icons) |
| 1701 | (%window-set-default-icon-list icons) |
| 1702 | icons) |
| 1703 | |
| 1704 | (defbinding %window-set-default-icon () nil |
| 1705 | (icon gdk:pixbuf)) |
| 1706 | |
| 1707 | (defgeneric (setf window-default-icon) (icon)) |
| 1708 | |
| 1709 | (defmethod (setf window-default-icon) ((icon gdk:pixbuf)) |
| 1710 | (%window-set-default-icon icon) |
| 1711 | icon) |
| 1712 | |
| 1713 | (defgeneric (setf window-group) (group window)) |
| 1714 | |
| 1715 | (defmethod (setf window-group) ((group window-group) (window window)) |
| 1716 | (window-group-add-window group window) |
| 1717 | group) |
| 1718 | |
| 1719 | (defbinding %window-set-default-icon-from-file () boolean |
| 1720 | (filename pathname) |
| 1721 | (nil null)) |
| 1722 | |
| 1723 | (defmethod (setf window-default-icon) ((icon-file pathname)) |
| 1724 | (%window-set-default-icon-from-file icon-file) |
| 1725 | icon-file) |
| 1726 | |
| 1727 | (defbinding %window-set-icon-from-file () boolean |
| 1728 | (window window) |
| 1729 | (filename pathname) |
| 1730 | (nil null)) |
| 1731 | |
| 1732 | (defmethod (setf window-icon) ((icon-file pathname) (window window)) |
| 1733 | (%window-set-icon-from-file window icon-file) |
| 1734 | icon-file) |
| 1735 | |
| 1736 | (defbinding window-set-auto-startup-notification () nil |
| 1737 | (setting boolean)) |
| 1738 | |
| 1739 | (defbinding decorated-window-init () nil |
| 1740 | (window window)) |
| 1741 | |
| 1742 | (defbinding decorated-window-calculate-frame-size () nil |
| 1743 | (window window)) |
| 1744 | |
| 1745 | (defbinding decorated-window-set-title () nil |
| 1746 | (window window) |
| 1747 | (title string)) |
| 1748 | |
| 1749 | (defbinding decorated-window-move-resize-window () nil |
| 1750 | (window window) |
| 1751 | (x int) |
| 1752 | (y int) |
| 1753 | (width int) |
| 1754 | (heigth int)) |
| 1755 | |
| 1756 | |
| 1757 | ;;; Window group |
| 1758 | |
| 1759 | (defmethod initialize-instance ((window-group window-group) &rest initargs |
| 1760 | &key window windows) |
| 1761 | (declare (ignore window windows)) |
| 1762 | (prog1 |
| 1763 | (call-next-method) |
| 1764 | (initial-add window-group #'window-group-add-window |
| 1765 | initargs :window :windows))) |
| 1766 | |
| 1767 | |
| 1768 | (defbinding window-group-add-window () nil |
| 1769 | (window-group window-group) |
| 1770 | (window window)) |
| 1771 | |
| 1772 | (defbinding window-group-remove-window () nil |
| 1773 | (window-group window-group) |
| 1774 | (window window)) |
| 1775 | |
| 1776 | |
| 1777 | ;;; Scrolled window |
| 1778 | |
| 1779 | (defun (setf scrolled-window-scrollbar-policy) (policy window) |
| 1780 | (setf (scrolled-window-hscrollbar-policy window) policy) |
| 1781 | (setf (scrolled-window-vscrollbar-policy window) policy)) |
| 1782 | |
| 1783 | (defbinding scrolled-window-add-with-viewport () nil |
| 1784 | (scrolled-window scrolled-window) |
| 1785 | (child widget)) |
| 1786 | |
| 1787 | (defmethod shared-initialize ((window scrolled-window) names &key policy) |
| 1788 | (declare (ignore names)) |
| 1789 | (when policy |
| 1790 | (setf (slot-value window 'hscrollbar-policy) policy) |
| 1791 | (setf (slot-value window 'vscrollbar-policy) policy)) |
| 1792 | (call-next-method)) |
| 1793 | |
| 1794 | |
| 1795 | ;;; Statusbar |
| 1796 | |
| 1797 | (defbinding statusbar-get-context-id () unsigned-int |
| 1798 | (statusbar statusbar) |
| 1799 | (context-description string)) |
| 1800 | |
| 1801 | (defbinding statusbar-push () unsigned-int |
| 1802 | (statusbar statusbar) |
| 1803 | (context-id unsigned-int) |
| 1804 | (text string)) |
| 1805 | |
| 1806 | (defbinding statusbar-pop () nil |
| 1807 | (statusbar statusbar) |
| 1808 | (context-id unsigned-int)) |
| 1809 | |
| 1810 | (defbinding statusbar-remove () nil |
| 1811 | (statusbar statusbar) |
| 1812 | (context-id unsigned-int) |
| 1813 | (message-id unsigned-int)) |
| 1814 | |
| 1815 | |
| 1816 | |
| 1817 | ;;; Fixed |
| 1818 | |
| 1819 | (defbinding fixed-put () nil |
| 1820 | (fixed fixed) |
| 1821 | (widget widget) |
| 1822 | (x int) (y int)) |
| 1823 | |
| 1824 | (defbinding fixed-move () nil |
| 1825 | (fixed fixed) |
| 1826 | (widget widget) |
| 1827 | (x int) (y int)) |
| 1828 | |
| 1829 | |
| 1830 | |
| 1831 | ;;; Notebook |
| 1832 | |
| 1833 | (defun %ensure-notebook-position (notebook page) |
| 1834 | (etypecase page |
| 1835 | (position page) |
| 1836 | (widget (notebook-page-num notebook page t)))) |
| 1837 | |
| 1838 | (defun %ensure-notebook-child (notebook position) |
| 1839 | (typecase position |
| 1840 | (widget position) |
| 1841 | (t (notebook-get-nth-page notebook position)))) |
| 1842 | |
| 1843 | (defbinding (notebook-insert "gtk_notebook_insert_page_menu") |
| 1844 | (notebook position child &optional tab-label menu-label) nil |
| 1845 | (notebook notebook) |
| 1846 | (child widget) |
| 1847 | ((if (stringp tab-label) |
| 1848 | (make-instance 'label :label tab-label) |
| 1849 | tab-label) (or null widget)) |
| 1850 | ((if (stringp menu-label) |
| 1851 | (make-instance 'label :label menu-label) |
| 1852 | menu-label) (or null widget)) |
| 1853 | ((%ensure-notebook-position notebook position) position)) |
| 1854 | |
| 1855 | (defun notebook-append (notebook child &optional tab-label menu-label) |
| 1856 | (notebook-insert notebook :last child tab-label menu-label)) |
| 1857 | |
| 1858 | (defun notebook-prepend (notebook child &optional tab-label menu-label) |
| 1859 | (notebook-insert notebook :first child tab-label menu-label)) |
| 1860 | |
| 1861 | (defbinding notebook-remove-page (notebook page) nil |
| 1862 | (notebook notebook) |
| 1863 | ((%ensure-notebook-position notebook page) position)) |
| 1864 | |
| 1865 | (defbinding %notebook-page-num () int |
| 1866 | (notebook notebook) |
| 1867 | (child widget)) |
| 1868 | |
| 1869 | (defun notebook-page-num (notebook child &optional error-p) |
| 1870 | (let ((page-num (%notebook-page-num notebook child))) |
| 1871 | (if (= page-num -1) |
| 1872 | (when error-p |
| 1873 | (error "~A is not a page in ~A" child notebook)) |
| 1874 | page-num))) |
| 1875 | |
| 1876 | (defbinding notebook-next-page () nil |
| 1877 | (notebook notebook)) |
| 1878 | |
| 1879 | (defbinding notebook-prev-page () nil |
| 1880 | (notebook notebook)) |
| 1881 | |
| 1882 | (defbinding notebook-reorder-child (notebook child position) nil |
| 1883 | (notebook notebook) |
| 1884 | (child widget) |
| 1885 | ((%ensure-notebook-position notebook position) int)) |
| 1886 | |
| 1887 | (defbinding notebook-popup-enable () nil |
| 1888 | (notebook notebook)) |
| 1889 | |
| 1890 | (defbinding notebook-popup-disable () nil |
| 1891 | (notebook notebook)) |
| 1892 | |
| 1893 | (defbinding notebook-get-nth-page () widget |
| 1894 | (notebook notebook) |
| 1895 | (page position)) |
| 1896 | |
| 1897 | (defun %notebook-current-page (notebook) |
| 1898 | (when (slot-boundp notebook 'current-page-num) |
| 1899 | (notebook-get-nth-page notebook (notebook-current-page-num notebook)))) |
| 1900 | |
| 1901 | (defun (setf notebook-current-page) (page notebook) |
| 1902 | (setf (notebook-current-page-num notebook) (notebook-page-num notebook page))) |
| 1903 | |
| 1904 | (defbinding (notebook-tab-label "gtk_notebook_get_tab_label") |
| 1905 | (notebook page) widget |
| 1906 | (notebook notebook) |
| 1907 | ((%ensure-notebook-child notebook page) widget)) |
| 1908 | |
| 1909 | (defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text") |
| 1910 | (notebook page) (copy-of string) |
| 1911 | (notebook notebook) |
| 1912 | ((%ensure-notebook-child notebook page) widget)) |
| 1913 | |
| 1914 | (defbinding %notebook-set-tab-label () nil |
| 1915 | (notebook notebook) |
| 1916 | (page widget) |
| 1917 | (tab-label widget)) |
| 1918 | |
| 1919 | (defun (setf notebook-tab-label) (tab-label notebook page) |
| 1920 | (let ((widget (if (stringp tab-label) |
| 1921 | (make-instance 'label :label tab-label) |
| 1922 | tab-label))) |
| 1923 | (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget) |
| 1924 | widget)) |
| 1925 | |
| 1926 | |
| 1927 | (defbinding (notebook-menu-label "gtk_notebook_get_menu_label") |
| 1928 | (notebook page) widget |
| 1929 | (notebook notebook) |
| 1930 | ((%ensure-notebook-child notebook page) widget)) |
| 1931 | |
| 1932 | (defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text") |
| 1933 | (notebook page) (copy-of string) |
| 1934 | (notebook notebook) |
| 1935 | ((%ensure-notebook-child notebook page) widget)) |
| 1936 | |
| 1937 | (defbinding %notebook-set-menu-label () nil |
| 1938 | (notebook notebook) |
| 1939 | (page widget) |
| 1940 | (menu-label widget)) |
| 1941 | |
| 1942 | (defun (setf notebook-menu-label) (menu-label notebook page) |
| 1943 | (let ((widget (if (stringp menu-label) |
| 1944 | (make-instance 'label :label menu-label) |
| 1945 | menu-label))) |
| 1946 | (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget) |
| 1947 | widget)) |
| 1948 | |
| 1949 | |
| 1950 | (defbinding notebook-query-tab-label-packing (notebook page) nil |
| 1951 | (notebook notebook) |
| 1952 | ((%ensure-notebook-child notebook page) widget) |
| 1953 | (expand boolean :out) |
| 1954 | (fill boolean :out) |
| 1955 | (pack-type pack-type :out)) |
| 1956 | |
| 1957 | (defbinding notebook-set-tab-label-packing |
| 1958 | (notebook page expand fill pack-type) nil |
| 1959 | (notebook notebook) |
| 1960 | ((%ensure-notebook-child notebook page) widget) |
| 1961 | (expand boolean) |
| 1962 | (fill boolean) |
| 1963 | (pack-type pack-type)) |
| 1964 | |
| 1965 | |
| 1966 | |
| 1967 | ;;; Paned |
| 1968 | |
| 1969 | (defbinding paned-pack1 () nil |
| 1970 | (paned paned) |
| 1971 | (child widget) |
| 1972 | (resize boolean) |
| 1973 | (shrink boolean)) |
| 1974 | |
| 1975 | (defbinding paned-pack2 () nil |
| 1976 | (paned paned) |
| 1977 | (child widget) |
| 1978 | (resize boolean) |
| 1979 | (shrink boolean)) |
| 1980 | |
| 1981 | |
| 1982 | ;;; Layout |
| 1983 | |
| 1984 | (defbinding layout-put () nil |
| 1985 | (layout layout) |
| 1986 | (child widget) |
| 1987 | (x int) |
| 1988 | (y int)) |
| 1989 | |
| 1990 | (defbinding layout-move () nil |
| 1991 | (layout layout) |
| 1992 | (child widget) |
| 1993 | (x int) |
| 1994 | (y int)) |
| 1995 | |
| 1996 | (defbinding layout-set-size () nil |
| 1997 | (layout layout) |
| 1998 | (width unsigned-int) |
| 1999 | (height unsigned-int)) |
| 2000 | |
| 2001 | (defbinding layout-get-size () nil |
| 2002 | (layout layout) |
| 2003 | (width unsigned-int :out) |
| 2004 | (height unsigned-int :out)) |
| 2005 | |
| 2006 | |
| 2007 | ;;; Menu shell |
| 2008 | |
| 2009 | (defbinding menu-shell-insert (menu-shell menu-item position) nil |
| 2010 | (menu-shell menu-shell) |
| 2011 | (menu-item menu-item) |
| 2012 | ((case position |
| 2013 | (:first 0) |
| 2014 | (:last -1) |
| 2015 | (t position)) int)) |
| 2016 | |
| 2017 | (defun menu-shell-append (menu-shell menu-item) |
| 2018 | (menu-shell-insert menu-shell menu-item :last)) |
| 2019 | |
| 2020 | (defun menu-shell-prepend (menu-shell menu-item) |
| 2021 | (menu-shell-insert menu-shell menu-item :fisrt)) |
| 2022 | |
| 2023 | (defbinding menu-shell-deactivate () nil |
| 2024 | (menu-shell menu-shell)) |
| 2025 | |
| 2026 | (defbinding menu-shell-select-item () nil |
| 2027 | (menu-shell menu-shell) |
| 2028 | (menu-item menu-item)) |
| 2029 | |
| 2030 | (defbinding menu-shell-select-first () nil |
| 2031 | (menu-shell menu-shell) |
| 2032 | (search-sensitive boolean)) |
| 2033 | |
| 2034 | (defbinding menu-shell-deselect () nil |
| 2035 | (menu-shell menu-shell)) |
| 2036 | |
| 2037 | (defbinding menu-shell-activate-item () nil |
| 2038 | (menu-shell menu-shell) |
| 2039 | (menu-item menu-item) |
| 2040 | (fore-deactivate boolean)) |
| 2041 | |
| 2042 | (defbinding menu-shell-cancel () nil |
| 2043 | (menu-shell menu-shell)) |
| 2044 | |
| 2045 | |
| 2046 | ;;; Menu |
| 2047 | |
| 2048 | (defun %menu-position (menu child) |
| 2049 | (etypecase child |
| 2050 | (int child) |
| 2051 | (keyword (case child |
| 2052 | (:first 0) |
| 2053 | (:last -1) |
| 2054 | (t (error "Invalid position keyword: ~A" child)))) |
| 2055 | (widget (menu-child-position menu child)))) |
| 2056 | |
| 2057 | |
| 2058 | (defbinding menu-reorder-child (menu menu-item position) nil |
| 2059 | (menu menu) |
| 2060 | (menu-item menu-item) |
| 2061 | ((%menu-position menu position) int)) |
| 2062 | |
| 2063 | (defbinding menu-attach () nil |
| 2064 | (menu menu) |
| 2065 | (menu-item menu-item) |
| 2066 | (left-attach unsigned-int) |
| 2067 | (right-attach unsigned-int) |
| 2068 | (top-attach unsigned-int) |
| 2069 | (bottom-attach unsigned-int)) |
| 2070 | |
| 2071 | (define-callback-marshal %menu-position-callback nil |
| 2072 | (menu (x int) (y int) (push-in boolean))) |
| 2073 | |
| 2074 | (defbinding %menu-popup () nil |
| 2075 | (menu menu) |
| 2076 | (parent-menu-shell (or null menu-shell)) |
| 2077 | (parent-menu-item (or null menu-item)) |
| 2078 | (callback (or null callback)) |
| 2079 | (callback-id unsigned-int) |
| 2080 | (button unsigned-int) |
| 2081 | (activate-time (unsigned 32))) |
| 2082 | |
| 2083 | (defun menu-popup (menu button activate-time &key callback parent-menu-shell |
| 2084 | parent-menu-item) |
| 2085 | (if callback |
| 2086 | (with-callback-function (id callback) |
| 2087 | (%menu-popup |
| 2088 | menu parent-menu-shell parent-menu-item |
| 2089 | %menu-position-callback id button activate-time)) |
| 2090 | (%menu-popup |
| 2091 | menu parent-menu-shell parent-menu-item nil 0 button activate-time))) |
| 2092 | |
| 2093 | (defbinding menu-set-accel-path () nil |
| 2094 | (menu menu) |
| 2095 | (accel-path string)) |
| 2096 | |
| 2097 | (defbinding menu-reposition () nil |
| 2098 | (menu menu)) |
| 2099 | |
| 2100 | (defbinding menu-popdown () nil |
| 2101 | (menu menu)) |
| 2102 | |
| 2103 | (defun menu-child-position (menu child) |
| 2104 | (position child (container-children menu))) |
| 2105 | |
| 2106 | (defun menu-active-num (menu) |
| 2107 | (menu-child-position menu (menu-active menu))) |
| 2108 | |
| 2109 | (defbinding %menu-set-active () nil |
| 2110 | (menu menu) |
| 2111 | (index unsigned-int)) |
| 2112 | |
| 2113 | (defun (setf menu-active) (menu child) |
| 2114 | (%menu-set-active menu (%menu-position menu child)) |
| 2115 | child) |
| 2116 | |
| 2117 | (define-callback %menu-detach-callback nil ((widget widget) (menu menu)) |
| 2118 | (funcall (user-data menu 'detach-func) widget menu)) |
| 2119 | |
| 2120 | (defbinding %menu-attach-to-widget (menu widget) nil |
| 2121 | (menu menu) |
| 2122 | (widget widget) |
| 2123 | (%menu-detach-callback callback)) |
| 2124 | |
| 2125 | (defun menu-attach-to-widget (menu widget function) |
| 2126 | (setf (user-data menu 'detach-func) function) |
| 2127 | (%menu-attach-to-widget menu widget)) |
| 2128 | |
| 2129 | (defbinding menu-detach () nil |
| 2130 | (menu menu)) |
| 2131 | |
| 2132 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 2133 | (defbinding menu-get-for-attach-widget () (copy-of (glist widget)) |
| 2134 | (widget widget)) |
| 2135 | |
| 2136 | (defbinding menu-set-monitor () nil |
| 2137 | (menu menu) |
| 2138 | (monitor-num int)) |
| 2139 | |
| 2140 | |
| 2141 | ;;; Table |
| 2142 | |
| 2143 | (defbinding table-resize () nil |
| 2144 | (table table) |
| 2145 | (rows unsigned-int) |
| 2146 | (columns unsigned-int)) |
| 2147 | |
| 2148 | (defbinding table-attach (table child left right top bottom |
| 2149 | &key options x-options y-options |
| 2150 | (x-padding 0) (y-padding 0)) nil |
| 2151 | (table table) |
| 2152 | (child widget) |
| 2153 | (left unsigned-int) |
| 2154 | (right unsigned-int) |
| 2155 | (top unsigned-int) |
| 2156 | (bottom unsigned-int) |
| 2157 | ((append (mklist options) (mklist x-options)) attach-options) |
| 2158 | ((append (mklist options) (mklist y-options)) attach-options) |
| 2159 | (x-padding unsigned-int) |
| 2160 | (y-padding unsigned-int)) |
| 2161 | |
| 2162 | |
| 2163 | (defbinding %table-set-row-spacing () nil |
| 2164 | (table table) |
| 2165 | (row unsigned-int) |
| 2166 | (spacing unsigned-int)) |
| 2167 | |
| 2168 | (defbinding %table-set-row-spacings () nil |
| 2169 | (table table) |
| 2170 | (spacing unsigned-int)) |
| 2171 | |
| 2172 | (defun (setf table-row-spacing) (spacing table &optional row) |
| 2173 | (if row |
| 2174 | (%table-set-row-spacing table row spacing) |
| 2175 | (%table-set-row-spacings table spacing)) |
| 2176 | spacing) |
| 2177 | |
| 2178 | (defbinding %table-get-row-spacing () unsigned-int |
| 2179 | (table table) |
| 2180 | (row unsigned-int)) |
| 2181 | |
| 2182 | (defbinding %table-get-default-row-spacing () unsigned-int |
| 2183 | (table table)) |
| 2184 | |
| 2185 | (defun table-row-spacing (table &optional row) |
| 2186 | (if row |
| 2187 | (%table-get-row-spacing table row) |
| 2188 | (%table-get-default-row-spacing table))) |
| 2189 | |
| 2190 | |
| 2191 | (defbinding %table-set-col-spacing () nil |
| 2192 | (table table) |
| 2193 | (col unsigned-int) |
| 2194 | (spacing unsigned-int)) |
| 2195 | |
| 2196 | (defbinding %table-set-col-spacings () nil |
| 2197 | (table table) |
| 2198 | (spacing unsigned-int)) |
| 2199 | |
| 2200 | (defun (setf table-column-spacing) (spacing table &optional column) |
| 2201 | (if column |
| 2202 | (%table-set-col-spacing table column spacing) |
| 2203 | (%table-set-col-spacings table spacing)) |
| 2204 | spacing) |
| 2205 | |
| 2206 | (defun (setf table-col-spacing) (spacing table &optional col) |
| 2207 | (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead") |
| 2208 | (setf (table-column-spacing table col) spacing)) |
| 2209 | |
| 2210 | (defbinding %table-get-col-spacing () unsigned-int |
| 2211 | (table table) |
| 2212 | (col unsigned-int)) |
| 2213 | |
| 2214 | (defbinding %table-get-default-col-spacing () unsigned-int |
| 2215 | (table table)) |
| 2216 | |
| 2217 | (defun table-column-spacing (table &optional column) |
| 2218 | (if column |
| 2219 | (%table-get-col-spacing table column) |
| 2220 | (%table-get-default-col-spacing table))) |
| 2221 | |
| 2222 | (defun table-col-spacing (table &optional col) |
| 2223 | (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead") |
| 2224 | (table-column-spacing table col)) |
| 2225 | |
| 2226 | |
| 2227 | |
| 2228 | ;;; Toolbar |
| 2229 | |
| 2230 | (defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips) |
| 2231 | (if (eq tooltips t) |
| 2232 | (apply #'call-next-method toolbar |
| 2233 | :tooltips (make-instance 'tooltips) initargs) |
| 2234 | (call-next-method))) |
| 2235 | |
| 2236 | (defbinding %toolbar-insert () nil |
| 2237 | (toolbar toolbar) |
| 2238 | (tool-item tool-item) |
| 2239 | (position position)) |
| 2240 | |
| 2241 | (defun toolbar-insert (toolbar tool-item &optional (position :end)) |
| 2242 | (%toolbar-insert toolbar tool-item position) |
| 2243 | (%tool-item-update-tooltips tool-item)) |
| 2244 | |
| 2245 | (defbinding toolbar-get-item-index () int |
| 2246 | (toolbar toolbar) |
| 2247 | (item tool-item)) |
| 2248 | |
| 2249 | (defbinding toolbar-get-nth-item () tool-item |
| 2250 | (toolbar toolbar) |
| 2251 | (n int)) |
| 2252 | |
| 2253 | (defbinding toolbar-get-drop-index () int |
| 2254 | (toolbar toolbar) |
| 2255 | (x int) (y int)) |
| 2256 | |
| 2257 | (defbinding toolbar-set-drop-highlight-item () nil |
| 2258 | (toolbar toolbar) |
| 2259 | (tool-item tool-item) |
| 2260 | (index int)) |
| 2261 | |
| 2262 | |
| 2263 | ;;; Tool button |
| 2264 | |
| 2265 | (defmethod initialize-instance ((button tool-button) &rest initargs &key icon) |
| 2266 | (if (and icon (not (typep icon 'widget))) |
| 2267 | (apply #'call-next-method button :icon (create-image-widget icon) initargs) |
| 2268 | (call-next-method))) |
| 2269 | |
| 2270 | |
| 2271 | ;;; Tool item |
| 2272 | |
| 2273 | (defbinding tool-item-set-tooltip () nil |
| 2274 | (tool-item tool-item) |
| 2275 | (tooltips tooltips) |
| 2276 | (tip-text string) |
| 2277 | (tip-private string)) |
| 2278 | |
| 2279 | |
| 2280 | (defun %tool-item-update-tooltips (tool-item) |
| 2281 | (when (and |
| 2282 | (slot-boundp tool-item 'parent) |
| 2283 | (or |
| 2284 | (user-data-p tool-item 'tip-text) |
| 2285 | (user-data-p tool-item 'tip-private))) |
| 2286 | (tool-item-set-tooltip |
| 2287 | tool-item (toolbar-tooltips (widget-parent tool-item)) |
| 2288 | (or (user-data tool-item 'tip-text) "") |
| 2289 | (or (user-data tool-item 'tip-private) "")))) |
| 2290 | |
| 2291 | (defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item)) |
| 2292 | (setf (user-data tool-item 'tip-text) tip-text) |
| 2293 | (%tool-item-update-tooltips tool-item) |
| 2294 | tip-text) |
| 2295 | |
| 2296 | (defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item)) |
| 2297 | (setf (user-data tool-item 'tip-private) tip-private) |
| 2298 | (%tool-item-update-tooltips tool-item) |
| 2299 | tip-private) |
| 2300 | |
| 2301 | (defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args) |
| 2302 | (declare (ignore args)) |
| 2303 | (prog1 |
| 2304 | (call-next-method) |
| 2305 | (%tool-item-update-tooltips tool-item))) |
| 2306 | |
| 2307 | |
| 2308 | (defbinding tool-item-retrieve-proxy-menu-item () widget |
| 2309 | (tool-item tool-item)) |
| 2310 | |
| 2311 | (defbinding (tool-item-proxy-menu-item |
| 2312 | "gtk_tool_item_get_proxy_menu_item") () menu-item |
| 2313 | (tool-item tool-item) |
| 2314 | (menu-item-id string)) |
| 2315 | |
| 2316 | (defbinding %tool-item-set-proxy-menu-item () nil |
| 2317 | (tool-item tool-item) |
| 2318 | (menu-item-id string) |
| 2319 | (menu-item menu-item)) |
| 2320 | |
| 2321 | (defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item) |
| 2322 | (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item) |
| 2323 | menu-item) |
| 2324 | |
| 2325 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0") |
| 2326 | (defbinding tool-item-rebuild-menu () nil |
| 2327 | (tool-item tool-item)) |
| 2328 | |
| 2329 | |
| 2330 | ;;; Editable |
| 2331 | |
| 2332 | (defbinding editable-select-region (editable &optional (start 0) end) nil |
| 2333 | (editable editable) |
| 2334 | (start int) |
| 2335 | ((or end -1) int)) |
| 2336 | |
| 2337 | (defbinding editable-get-selection-bounds (editable) nil |
| 2338 | (editable editable) |
| 2339 | (start int :out) |
| 2340 | (end int :out)) |
| 2341 | |
| 2342 | (defbinding editable-insert-text (editable text &optional (position 0)) nil |
| 2343 | (editable editable) |
| 2344 | (text string) |
| 2345 | ((length text) int) |
| 2346 | (position position :in/out)) |
| 2347 | |
| 2348 | (defun editable-append-text (editable text) |
| 2349 | (editable-insert-text editable text nil)) |
| 2350 | |
| 2351 | (defun editable-prepend-text (editable text) |
| 2352 | (editable-insert-text editable text 0)) |
| 2353 | |
| 2354 | (defbinding editable-delete-text (editable &optional (start 0) end) nil |
| 2355 | (editable editable) |
| 2356 | (start int) |
| 2357 | ((or end -1) int)) |
| 2358 | |
| 2359 | (defbinding (editable-text "gtk_editable_get_chars") |
| 2360 | (editable &optional (start 0) end) string |
| 2361 | (editable editable) |
| 2362 | (start int) |
| 2363 | ((or end -1) int)) |
| 2364 | |
| 2365 | (defun (setf editable-text) (text editable) |
| 2366 | (if text |
| 2367 | (editable-delete-text |
| 2368 | editable |
| 2369 | (editable-insert-text editable text)) |
| 2370 | (editable-delete-text editable)) |
| 2371 | text) |
| 2372 | |
| 2373 | (defbinding editable-cut-clipboard () nil |
| 2374 | (editable editable)) |
| 2375 | |
| 2376 | (defbinding editable-copy-clipboard () nil |
| 2377 | (editable editable)) |
| 2378 | |
| 2379 | (defbinding editable-paste-clipboard () nil |
| 2380 | (editable editable)) |
| 2381 | |
| 2382 | (defbinding editable-delete-selection () nil |
| 2383 | (editable editable)) |
| 2384 | |
| 2385 | |
| 2386 | |
| 2387 | ;;; Spin button |
| 2388 | |
| 2389 | (defbinding spin-button-configure () nil |
| 2390 | (spin-button spin-button) |
| 2391 | (adjustment adjustment) |
| 2392 | (climb-rate double-float) |
| 2393 | (digits unsigned-int)) |
| 2394 | |
| 2395 | (defbinding spin-button-set-range () nil |
| 2396 | (spin-button spin-button) |
| 2397 | (min double-float) |
| 2398 | (max double-float)) |
| 2399 | |
| 2400 | (defbinding spin-button-get-range () nil |
| 2401 | (spin-button spin-button) |
| 2402 | (min double-float :out) |
| 2403 | (max double-float :out)) |
| 2404 | |
| 2405 | (defun spin-button-value-as-int (spin-button) |
| 2406 | (round (spin-button-value spin-button))) |
| 2407 | |
| 2408 | (defbinding %spin-button-spin () nil |
| 2409 | (spin-button spin-button) |
| 2410 | (direction spin-type) |
| 2411 | (increment double-float)) |
| 2412 | |
| 2413 | (defun spin-button-spin (spin-button value) |
| 2414 | (etypecase value |
| 2415 | (real (%spin-button-spin spin-button :user-defined value)) |
| 2416 | (spin-type (%spin-button-spin spin-button value 0)))) |
| 2417 | |
| 2418 | |
| 2419 | (defbinding spin-button-update () nil |
| 2420 | (spin-button spin-button)) |
| 2421 | |
| 2422 | |
| 2423 | |
| 2424 | ; ;;; Ruler |
| 2425 | |
| 2426 | (defbinding ruler-set-range () nil |
| 2427 | (ruler ruler) |
| 2428 | (lower single-float) |
| 2429 | (upper single-float) |
| 2430 | (position single-float) |
| 2431 | (max-size single-float)) |
| 2432 | |
| 2433 | (defbinding ruler-get-range () nil |
| 2434 | (ruler ruler) |
| 2435 | (lower single-float :out) |
| 2436 | (upper single-float :out) |
| 2437 | (position single-float :out) |
| 2438 | (max-size single-float :out)) |
| 2439 | |
| 2440 | |
| 2441 | |
| 2442 | ;;; Range |
| 2443 | |
| 2444 | (defun range-lower (range) |
| 2445 | (adjustment-lower (range-adjustment range))) |
| 2446 | |
| 2447 | (defun range-upper (range) |
| 2448 | (adjustment-upper (range-adjustment range))) |
| 2449 | |
| 2450 | (defun (setf range-lower) (value range) |
| 2451 | (setf (adjustment-lower (range-adjustment range)) value)) |
| 2452 | |
| 2453 | (defun (setf range-upper) (value range) |
| 2454 | (setf (adjustment-upper (range-adjustment range)) value)) |
| 2455 | |
| 2456 | (defun range-page-increment (range) |
| 2457 | (adjustment-page-increment (range-adjustment range))) |
| 2458 | |
| 2459 | (defun range-step-increment (range) |
| 2460 | (adjustment-step-increment (range-adjustment range))) |
| 2461 | |
| 2462 | (defun (setf range-page-increment) (value range) |
| 2463 | (setf (adjustment-page-increment (range-adjustment range)) value)) |
| 2464 | |
| 2465 | (defun (setf range-step-increment) (value range) |
| 2466 | (setf (adjustment-step-increment (range-adjustment range)) value)) |
| 2467 | |
| 2468 | (defbinding range-set-range () nil |
| 2469 | (range range) |
| 2470 | (lower double-float) |
| 2471 | (upper double-float)) |
| 2472 | |
| 2473 | (defbinding range-set-increments () nil |
| 2474 | (range range) |
| 2475 | (step double-float) |
| 2476 | (page double-float)) |
| 2477 | |
| 2478 | |
| 2479 | ;;; Scale |
| 2480 | |
| 2481 | (defbinding scale-get-layout-offsets () nil |
| 2482 | (scale scale) |
| 2483 | (x int :out) |
| 2484 | (y int :out)) |
| 2485 | |
| 2486 | |
| 2487 | ;;; Progress bar |
| 2488 | |
| 2489 | (defbinding progress-bar-pulse () nil |
| 2490 | (progress-bar progress-bar)) |
| 2491 | |
| 2492 | |
| 2493 | ;;; Size group |
| 2494 | |
| 2495 | (defmethod initialize-instance ((size-group size-group) &rest initargs |
| 2496 | &key widget widgets) |
| 2497 | (declare (ignore widget widgets)) |
| 2498 | (prog1 |
| 2499 | (call-next-method) |
| 2500 | (initial-add size-group #'size-group-add-widget |
| 2501 | initargs :widget :widgets))) |
| 2502 | |
| 2503 | |
| 2504 | (defbinding size-group-add-widget () nil |
| 2505 | (size-group size-group) |
| 2506 | (widget widget)) |
| 2507 | |
| 2508 | (defbinding size-group-remove-widget () nil |
| 2509 | (size-group size-group) |
| 2510 | (widget widget)) |
| 2511 | |
| 2512 | |
| 2513 | ;;; Stock items |
| 2514 | |
| 2515 | (defbinding %stock-item-copy () pointer |
| 2516 | (location pointer)) |
| 2517 | |
| 2518 | (defbinding %stock-item-free () nil |
| 2519 | (location pointer)) |
| 2520 | |
| 2521 | (defbinding stock-add (stock-item) nil |
| 2522 | (stock-item stock-item) |
| 2523 | (1 unsigned-int)) |
| 2524 | |
| 2525 | (defbinding stock-list-ids () (gslist string)) |
| 2526 | |
| 2527 | (defbinding %stock-lookup () boolean |
| 2528 | (stock-id string) |
| 2529 | (location pointer)) |
| 2530 | |
| 2531 | (defun stock-lookup (stock-id) |
| 2532 | (with-memory (stock-item (foreign-size (find-class 'stock-item))) |
| 2533 | (when (%stock-lookup stock-id stock-item) |
| 2534 | (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item))))) |
| 2535 | |
| 2536 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0") |
| 2537 | (progn |
| 2538 | (define-callback-marshal %stock-translate-callback string ((path string))) |
| 2539 | |
| 2540 | (defbinding (stock-set-translate-function "gtk_stock_set_translate_func") |
| 2541 | (domain function) nil |
| 2542 | (domain string) |
| 2543 | (%stock-translate-callback callback) |
| 2544 | ((register-callback-function function) unsigned-int) |
| 2545 | (user-data-destroy-callback callback))) |
| 2546 | |
| 2547 | |
| 2548 | ;;; Tooltip |
| 2549 | |
| 2550 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0") |
| 2551 | (progn |
| 2552 | (defbinding tooltip-set-markup () nil |
| 2553 | tooltip |
| 2554 | (markup string)) |
| 2555 | |
| 2556 | (defbinding tooltip-set-text () nil |
| 2557 | tooltip |
| 2558 | (text string)) |
| 2559 | |
| 2560 | (defbinding %tooltip-set-icon () nil |
| 2561 | tooltip |
| 2562 | (icon gdk:pixbuf)) |
| 2563 | |
| 2564 | (defbinding %tooltip-set-icon-from-stock () nil |
| 2565 | tooltip |
| 2566 | (stock-id string) |
| 2567 | icon-size) |
| 2568 | |
| 2569 | (defun tooltip-set-icon (tooltip icon &key (size :button)) |
| 2570 | (etypecase icon |
| 2571 | (gdk:pixbuf (%tooltip-set-icon tooltip icon)) |
| 2572 | (string (%tooltip-set-icon-from-stock tooltip icon size)))) |
| 2573 | |
| 2574 | (defbinding tooltip-set-custom () nil |
| 2575 | tooltip |
| 2576 | widget) |
| 2577 | |
| 2578 | (defbinding tooltip-trigger-tooltip-query (&optional (display (gdk:display-get-default))) nil |
| 2579 | (display gdk:display)) |
| 2580 | |
| 2581 | (defbinding tooltip-set-tip-area () nil |
| 2582 | tooltip |
| 2583 | gdk:rectangle)) |
| 2584 | |
| 2585 | |
| 2586 | |
| 2587 | ;;; Tooltips |
| 2588 | |
| 2589 | ;; GtkTooltips has been deprecated in favor of the new tooltip API |
| 2590 | ;; introduced in in GTK+ 2.12 |
| 2591 | |
| 2592 | (defbinding tooltips-enable () nil |
| 2593 | (tooltips tooltips)) |
| 2594 | |
| 2595 | (defbinding tooltips-disable () nil |
| 2596 | (tooltips tooltips)) |
| 2597 | |
| 2598 | (defun (setf tooltips-enabled-p) (enable tooltips) |
| 2599 | (if enable |
| 2600 | (tooltips-enable tooltips) |
| 2601 | (tooltips-disable tooltips))) |
| 2602 | |
| 2603 | (defbinding tooltips-set-tip () nil |
| 2604 | (tooltips tooltips) |
| 2605 | (widget widget) |
| 2606 | (tip-text string) |
| 2607 | (tip-private string)) |
| 2608 | |
| 2609 | (defbinding tooltips-data-get () tooltips-data |
| 2610 | (widget widget)) |
| 2611 | |
| 2612 | (defbinding tooltips-force-window () nil |
| 2613 | (tooltips tooltips)) |
| 2614 | |
| 2615 | (defbinding tooltips-get-info-from-tip-window () boolean |
| 2616 | (tip-window window) |
| 2617 | (tooltips tooltips :out) |
| 2618 | (current-widget widget :out)) |
| 2619 | |
| 2620 | |
| 2621 | ;;; Resource Files |
| 2622 | |
| 2623 | (defbinding rc-get-style () style |
| 2624 | (widget widget)) |
| 2625 | |
| 2626 | (defbinding rc-get-style-by-paths (&key path class-path class) style |
| 2627 | (path (or null string)) |
| 2628 | (class-path (or null string)) |
| 2629 | (class gtype)) |
| 2630 | |
| 2631 | (defbinding rc-parse () nil |
| 2632 | (filename pathname)) |
| 2633 | |
| 2634 | (defbinding rc-parse-string () nil |
| 2635 | (rc-string string)) |
| 2636 | |
| 2637 | (defbinding %rc-reparse-all () boolean) |
| 2638 | |
| 2639 | (defbinding %rc-reparse-all-for-settings () boolean |
| 2640 | (settings settings) |
| 2641 | (force-load-p boolean)) |
| 2642 | |
| 2643 | (defun rc-reparse-all (&optional setting force-load-p) |
| 2644 | (if setting |
| 2645 | (%rc-reparse-all-for-settings setting force-load-p) |
| 2646 | (%rc-reparse-all))) |
| 2647 | |
| 2648 | (defbinding rc-reset-styles () nil |
| 2649 | (settings settings)) |
| 2650 | |
| 2651 | (defbinding rc-add-default-file () nil |
| 2652 | (filename pathname)) |
| 2653 | |
| 2654 | (defbinding rc-get-default-files () |
| 2655 | (copy-of (null-terminated-vector (copy-of string)))) |
| 2656 | |
| 2657 | (defbinding rc-get-module-dir () string) |
| 2658 | |
| 2659 | (defbinding rc-get-im-module-path () string) |
| 2660 | |
| 2661 | (defbinding rc-get-im-module-file () string) |
| 2662 | |
| 2663 | (defbinding rc-get-theme-dir () string) |
| 2664 | |
| 2665 | |
| 2666 | ;;; Settings |
| 2667 | |
| 2668 | (defbinding (settings-get "gtk_settings_get_for_screen") |
| 2669 | (&optional (screen (gdk:display-get-default-screen))) settings |
| 2670 | (screen gdk:screen)) |
| 2671 | |
| 2672 | |
| 2673 | ;;; Plug and Socket |
| 2674 | |
| 2675 | (defbinding socket-add-id () nil |
| 2676 | (socket socket) |
| 2677 | (id gdk:native-window)) |
| 2678 | |
| 2679 | (defbinding %plug-new () pointer |
| 2680 | (id gdk:native-window)) |
| 2681 | |
| 2682 | (defmethod allocate-foreign ((plug plug) &key id) |
| 2683 | (%plug-new (or id 0))) |
| 2684 | |
| 2685 | |
| 2686 | ;;; Link button |
| 2687 | |
| 2688 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0") |
| 2689 | (progn |
| 2690 | (define-callback-marshal %link-button-uri-callback nil (link-button (link string))) |
| 2691 | |
| 2692 | (defbinding link-button-set-uri-hook (function) pointer |
| 2693 | (%link-button-uri-callback callback) |
| 2694 | ((register-callback-function function) unsigned-int) |
| 2695 | (user-data-destroy-callback callback))) |
| 2696 | |
| 2697 | |
| 2698 | ;;; Builder |
| 2699 | |
| 2700 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0") |
| 2701 | (progn |
| 2702 | (defmethod initialize-instance ((builder builder) &key interface |
| 2703 | (connect-signals t) (package *package*)) |
| 2704 | (call-next-method) |
| 2705 | (etypecase interface |
| 2706 | (null) |
| 2707 | (string (builder-add-from-string builder interface)) |
| 2708 | (pathname (builder-add-from-file builder interface))) |
| 2709 | (when connect-signals |
| 2710 | (builder-connect-signals builder package))) |
| 2711 | |
| 2712 | |
| 2713 | (defbinding builder-add-from-file () boolean |
| 2714 | builder |
| 2715 | pathname |
| 2716 | (nil gerror-signal :out)) |
| 2717 | |
| 2718 | (defbinding builder-add-from-string () boolean |
| 2719 | builder |
| 2720 | (buffer string) |
| 2721 | (-1 int) ; TODO: add gsize type |
| 2722 | (nil gerror-signal :out)) |
| 2723 | |
| 2724 | (defbinding builder-get-object () gobject |
| 2725 | builder |
| 2726 | (name string)) |
| 2727 | |
| 2728 | (defbinding builder-get-objects () (gslist gobject) |
| 2729 | builder) |
| 2730 | |
| 2731 | (defun intern-with-package-prefix (name default-package) |
| 2732 | (let ((pos (position #\: name))) |
| 2733 | (if pos |
| 2734 | (intern |
| 2735 | (string-upcase (subseq name (1+ pos))) |
| 2736 | (string-upcase (subseq name 0 pos))) |
| 2737 | (intern (string-upcase name) default-package)))) |
| 2738 | |
| 2739 | (define-callback %builder-connect-function nil |
| 2740 | (builder (object gobject) (signal-name string) (handler-name string) |
| 2741 | (connect-object gobject) connect-flags (package user-data-id)) |
| 2742 | (format t "Connect signal ~A for ~A to ~A in default package ~A with flags ~A~%" signal-name object handler-name (find-user-data package) connect-flags) |
| 2743 | (signal-connect |
| 2744 | object signal-name |
| 2745 | (intern-with-package-prefix handler-name (find-user-data package)) |
| 2746 | :object (or connect-object object) :after (find :after connect-flags))) |
| 2747 | |
| 2748 | (defbinding %builder-connect-signals-full (builder package) nil |
| 2749 | builder |
| 2750 | (%builder-connect-function callback) |
| 2751 | (package user-data-id)) |
| 2752 | |
| 2753 | (defun builder-connect-signals (builder &optional (package *package*)) |
| 2754 | (with-user-data (id package) |
| 2755 | (%builder-connect-signals-full builder id)))) |
| 2756 | |