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