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