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