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