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