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