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