Added new binding ENTRY-COMPLETION-GET-COMPLETION-PREFIX
[clg] / gtk / gtk.lisp
CommitLineData
55212af1 1;; Common Lisp bindings for GTK+ v2.x
f957f519 2;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net>
0d07716f 3;;
55212af1 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:
0d07716f 11;;
55212af1 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
0d07716f 14;;
55212af1 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.
0d07716f 22
93c531f0 23;; $Id: gtk.lisp,v 1.87 2008/01/02 15:57:57 espen Exp $
0d07716f 24
25
26(in-package "GTK")
27
28;;; Gtk version
29
84967144 30(defbinding check-version () (copy-of string)
0d07716f 31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
34
a60bd055 35(defbinding query-version () nil
0d07716f 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
e69138cc 47(defun clg-version ()
15421c36 48 "clg 0.93")
0d07716f 49
50
5233fe44 51;;;; Initalization and display handling
6baf860c 52
6e21e828 53(defparameter *event-poll-interval* 10000) ; in microseconds
54
55
30628c63 56(defbinding (gtk-init "gtk_parse_args") () boolean
6baf860c 57 "Initializes the library without opening the display."
58 (nil null)
59 (nil null))
60
6e21e828 61(defun clg-init (&optional display multi-threading-p)
62 "Initializes the system and starts event handling."
6baf860c 63 (unless (gdk:display-get-default)
92afacae 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
6e21e828 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")))
6b465328 77 (gdk:ensure-display display t))
6e21e828 78
f957f519 79(defun clg-init-with-threading (&optional display)
6e21e828 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
6006b229 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))))))
6e21e828 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)))
57fa233b 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)))
6e21e828 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."))
72cb3e1f 190 (gdk:threads-init)
6e21e828 191 (let ((main-running (sb-thread:make-waitqueue)))
192 (gdk:with-global-lock
193 (setf *main-thread*
194 (sb-thread:make-thread
195 #'(lambda ()
6e21e828 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")
57fa233b 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"))))))
6e21e828 214
215#-sb-thread
216(defmacro within-main-loop (&body body)
217 `(progn ,@body))
92afacae 218
6baf860c 219
00a8d921 220
3c1925ed 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
6baf860c 229
17707159 230;;; Misc
231
232(defbinding grab-add () nil
233 (widget widget))
234
3a476d4e 235(defbinding grab-get-current () widget)
17707159 236
237(defbinding grab-remove () nil
238 (widget widget))
239
e69138cc 240(defbinding get-default-language () (copy-of pango:language))
241
17707159 242
1448a84f 243;;; About dialog
244
f957f519 245#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1448a84f 246(progn
a92553bd 247 (define-callback-marshal %about-dialog-activate-link-callback nil
248 (about-dialog (link string)))
1448a84f 249
250 (defbinding about-dialog-set-email-hook (function) nil
a92553bd 251 (%about-dialog-activate-link-callback callback)
1448a84f 252 ((register-callback-function function) unsigned-int)
a92553bd 253 (user-data-destroy-callback callback))
1448a84f 254
255 (defbinding about-dialog-set-url-hook (function) nil
a92553bd 256 (%about-dialog-activate-link-callback callback)
1448a84f 257 ((register-callback-function function) unsigned-int)
a92553bd 258 (user-data-destroy-callback callback)))
1448a84f 259
260
d404b3af 261;;; Acccel group
0d07716f 262
213cf4d0 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)
7b6c693b 271 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 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)
f957f519 279 ((make-callback-closure function) gclosure :in/return))
213cf4d0 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
7b6c693b 294 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 295 (%accel-group-disconnect-key group key modifiers)))))
296
7b6c693b 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
213cf4d0 317(defbinding accel-group-lock () nil
318 (accel-group accel-group))
319
320(defbinding accel-group-unlock () nil
321 (accel-group accel-group))
322
7b6c693b 323(defbinding accel-group-from-accel-closure () accel-group
324 (closure gclosure))
325
213cf4d0 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)
7b6c693b 332 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 333 (%accel-groups-activate object key modifiers)))
334
3f2c422a 335(defbinding accel-groups-from-object () (gslist accel-group)
213cf4d0 336 (object gobject))
337
3d36c5d6 338(defbinding accelerator-valid-p (key &optional modifiers) boolean
213cf4d0 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
7b6c693b 347(defgeneric parse-accelerator (accelerator))
348
349(defmethod parse-accelerator ((accelerator string))
213cf4d0 350 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
351 (if (zerop key)
352 (error "Invalid accelerator: ~A" accelerator)
353 (values key modifiers))))
354
7b6c693b 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
213cf4d0 376(defbinding accelerator-name () string
377 (key unsigned-int)
378 (modifiers gdk:modifier-type))
379
f957f519 380#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
213cf4d0 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)
0d07716f 392
eb4f580c 393
0d07716f 394;;; Acccel label
395
7b6c693b 396(defbinding accel-label-get-accel-width () unsigned-int
397 (accel-label accel-label))
398
a60bd055 399(defbinding accel-label-refetch () boolean
0d07716f 400 (accel-label accel-label))
401
402
213cf4d0 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)
7b6c693b 412 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 413 (%accel-map-add-entry path key modifiers)))
414
7b6c693b 415(defbinding %accel-map-lookup-entry () boolean
213cf4d0 416 (path string)
f957f519 417 ((make-instance 'accel-key) accel-key :in/return))
7b6c693b 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)))))
213cf4d0 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)
7b6c693b 434 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 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
a92553bd 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)
7b6c693b 446
447(defbinding %accel-map-foreach (callback-id) nil
448 (callback-id unsigned-int)
a92553bd 449 (%accel-map-foreach-callback callback))
7b6c693b 450
451(defbinding %accel-map-foreach-unfiltered (callback-id) nil
452 (callback-id unsigned-int)
a92553bd 453 (%accel-map-foreach-callback callback))
7b6c693b 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
213cf4d0 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
7b6c693b 474;;; Accessibility
14eaa563 475
476(defbinding accessible-connect-widget-destroyed () nil
477 (accessible accessible))
478
479
d404b3af 480;;; Adjustment
0d07716f 481
14eaa563 482(defmethod initialize-instance ((adjustment adjustment) &key value)
eb4f580c 483 (prog1
484 (call-next-method)
485 ;; we need to make sure that the value is set last, otherwise it
14eaa563 486 ;; may be outside current limits and ignored
eb4f580c 487 (when value
488 (setf (slot-value adjustment 'value) value))))
489
490
d404b3af 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))
0d07716f 501
d404b3af 502
49043b9a 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
b5b970e8 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
4d0c34e5 558 (defbinding assistant-set-forward-page-func (assistant function) nil
b5b970e8 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
d404b3af 577;;; Aspect frame
578
579
580;;; Bin
0d07716f 581
582(defun (setf bin-child) (child bin)
d404b3af 583 (when-bind (current-child (bin-child bin))
584 (container-remove bin current-child))
0d07716f 585 (container-add bin child)
586 child)
587
a68868d1 588(defmethod compute-signal-function ((bin bin) signal function object args)
d79b3413 589 (declare (ignore signal))
590 (if (eq object :child)
a68868d1 591 #'(lambda (&rest emission-args)
592 (apply function (bin-child bin) (nconc (rest emission-args) args)))
9617dc95 593 (call-next-method)))
d404b3af 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
14eaa563 612(defun box-pack (box child &key end (expand t) (fill t) (padding 0))
4886872c 613 (if end
378b3c5f 614 (box-pack-end box child expand fill padding)
615 (box-pack-start box child expand fill padding)))
d404b3af 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
0d07716f 640;;; Button
641
14eaa563 642(defmethod initialize-instance ((button button) &rest initargs &key stock)
643 (if stock
f957f519 644 (apply #'call-next-method button
645 :label stock :use-stock t :use-underline t initargs)
14eaa563 646 (call-next-method)))
647
648
a60bd055 649(defbinding button-pressed () nil
0d07716f 650 (button button))
651
d404b3af 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
14eaa563 688(defbinding calendar-get-date () nil
d404b3af 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
d404b3af 701;;; Check menu item
702
703(defbinding check-menu-item-toggled () nil
704 (check-menu-item check-menu-item))
705
706
d404b3af 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
4886872c 719;;;; Combo Box
d404b3af 720
14eaa563 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
4886872c 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
f957f519 759#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
4886872c 760(defbinding combo-box-get-active-text () string
761 (combo-box combo-box))
d404b3af 762
4886872c 763(defbinding combo-box-popup () nil
764 (combo-box combo-box))
d404b3af 765
4886872c 766(defbinding combo-box-popdown () nil
767 (combo-box combo-box))
768
769
770
771;;;; Combo Box Entry
772
14eaa563 773(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
4886872c 774 (call-next-method)
775 (unless model
776 (setf (combo-box-entry-text-column combo-box-entry) 0)))
d404b3af 777
778
0ebef6c1 779;;;; Dialog
d404b3af 780
362f1795 781(defmethod shared-initialize ((dialog dialog) names &rest initargs
782 &key button buttons)
f957f519 783 (declare (ignore names button buttons))
362f1795 784 (prog1
785 (call-next-method)
786 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
0ebef6c1 787
d404b3af 788
d79b3413 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)
f957f519 793 (let ((responses (user-data dialog 'responses)))
d79b3413 794 (cond
795 ((and responses (position response responses :test #'equal)))
796 (create-p
eb4f580c 797 (cond
d79b3413 798 (responses
799 (vector-push-extend response responses)
800 (1- (length responses)))
eb4f580c 801 (t
802 (setf
f957f519 803 (user-data dialog 'responses)
d79b3413 804 (make-array 1 :adjustable t :fill-pointer t
805 :initial-element response))
eb4f580c 806 0)))
807 (error-p
d79b3413 808 (error "Invalid response: ~A" response))))))
d404b3af 809
d79b3413 810(defun dialog-find-response (dialog id)
811 "Finds a symbolic response given a numeric id"
36df51ae 812 (cond
813 ((not (numberp id)) id)
814 ((< id 0) (int-to-response-type id))
815 ((aref (user-data dialog 'responses) id))))
d79b3413 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
a68868d1 823(defmethod compute-signal-function ((dialog dialog) signal function object args)
824 (declare (ignore function object args))
d79b3413 825 (let ((callback (call-next-method))
826 (id (dialog-response-id dialog signal)))
36df51ae 827 (cond
828 (id
829 #'(lambda (dialog response)
830 (when (= response id)
831 (funcall callback dialog))))
e67c4de7 832 ((string-equal signal "response")
36df51ae 833 #'(lambda (dialog response)
834 (funcall callback dialog (dialog-find-response dialog response))))
835 (callback))))
d404b3af 836
0ebef6c1 837(defbinding dialog-run () nil
838 (dialog dialog))
d404b3af 839
d79b3413 840(defbinding dialog-response (dialog response) nil
d404b3af 841 (dialog dialog)
d79b3413 842 ((dialog-response-id dialog response nil t) int))
d404b3af 843
844
845(defbinding %dialog-add-button () button
846 (dialog dialog)
847 (text string)
d79b3413 848 (response-id int))
d404b3af 849
eb4f580c 850(defun dialog-add-button (dialog label &optional (response label)
851 &key default object after)
fe67c0ec 852 "Adds a button to the dialog."
d79b3413 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)))
eb4f580c 858 (when (functionp response)
d79b3413 859 (signal-connect dialog signal response :object object :after after))
eb4f580c 860 (when default
d79b3413 861 (%dialog-set-default-response dialog id))
d404b3af 862 button))
863
864
d79b3413 865(defbinding %dialog-add-action-widget () nil
d404b3af 866 (dialog dialog)
867 (action-widget widget)
d79b3413 868 (response-id int))
d404b3af 869
eb4f580c 870(defun dialog-add-action-widget (dialog widget &optional (response widget)
871 &key default object after)
d79b3413 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)
eb4f580c 879 (when (functionp response)
d79b3413 880 (signal-connect dialog signal response :object object :after after))
eb4f580c 881 (when default
c2c4f44a 882 (setf (widget-can-default-p widget) t)
d79b3413 883 (%dialog-set-default-response dialog id))
d404b3af 884 widget))
d404b3af 885
d404b3af 886
0ebef6c1 887(defbinding %dialog-set-default-response () nil
888 (dialog dialog)
d79b3413 889 (response-id int))
d404b3af 890
d79b3413 891(defun dialog-set-default-response (dialog response)
0ebef6c1 892 (%dialog-set-default-response
d79b3413 893 dialog (dialog-response-id dialog response nil t)))
d404b3af 894
d79b3413 895(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
0ebef6c1 896 (dialog dialog)
d79b3413 897 ((dialog-response-id dialog response nil t) int)
0ebef6c1 898 (sensitive boolean))
d404b3af 899
f957f519 900#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1448a84f 901(defbinding alternative-dialog-button-order-p (&optional screen) boolean
902 (screen (or null gdk:screen)))
fe67c0ec 903
f957f519 904#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
fe67c0ec 905(defbinding (dialog-set-alternative-button-order
405b4406 906 "gtk_dialog_set_alternative_button_order_from_array")
907 (dialog new-order) nil
fe67c0ec 908 (dialog dialog)
909 ((length new-order) int)
d79b3413 910 ((map 'vector #'(lambda (response)
911 (dialog-response-id dialog response nil t))
fe67c0ec 912 new-order) (vector int)))
d404b3af 913
0ebef6c1 914
f957f519 915#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
92ba85d4 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
0ebef6c1 925(defmethod container-add ((dialog dialog) (child widget) &rest args)
eb4f580c 926 (apply #'container-add (dialog-vbox dialog) child args))
0ebef6c1 927
d79b3413 928
0ebef6c1 929(defmethod container-remove ((dialog dialog) (child widget))
eb4f580c 930 (container-remove (dialog-vbox dialog) child))
d404b3af 931
0ebef6c1 932(defmethod container-children ((dialog dialog))
eb4f580c 933 (container-children (dialog-vbox dialog)))
0ebef6c1 934
935(defmethod (setf container-children) (children (dialog dialog))
eb4f580c 936 (setf (container-children (dialog-vbox dialog)) children))
0d07716f 937
0d07716f 938
5233fe44 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
c2c4a7e9 945;;; Entry
0d07716f 946
c2c4a7e9 947(defbinding entry-get-layout-offsets () nil
948 (entry entry)
949 (x int :out)
950 (y int :out))
0d07716f 951
14eaa563 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
0d07716f 960
a03a718a 961;;; Entry Completion
962
a92553bd 963(define-callback-marshal %entry-completion-match-callback boolean
964 (entry-completion string tree-iter))
a03a718a 965
966(defbinding entry-completion-set-match-func (completion function) nil
967 (completion entry-completion)
a92553bd 968 (%entry-completion-match-callback callback)
a03a718a 969 ((register-callback-function function) unsigned-int)
a92553bd 970 (user-data-destroy-callback callback))
a03a718a 971
972(defbinding entry-completion-complete () nil
973 (completion entry-completion))
974
93c531f0 975#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
976(defbinding entry-completion-get-completion-prefix () string
977 (completion entry-completion))
978
f957f519 979#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
a03a718a 980(defbinding entry-completion-insert-prefix () nil
981 (completion entry-completion))
982
983(defbinding entry-completion-insert-action-text () nil
984 (completion entry-completion)
985 (index int)
986 (text string))
987
988(defbinding entry-completion-insert-action-markup () nil
989 (completion entry-completion)
990 (index int)
991 (markup string))
992
993(defbinding entry-completion-delete-action () nil
994 (completion entry-completion)
995 (index int))
996
997
49043b9a 998;;; File Chooser
999
1000(defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
1001 &key filter filters shortcut-folder
1002 shortcut-folders shortcut-folder-uti
1003 shortcut-folder-uris)
1004 (declare (ignore filter filters shortcut-folder shortcut-folders
1005 shortcut-folder-uti shortcut-folder-uris))
1006 (prog1
1007 (call-next-method)
1008 (initial-add file-chooser #'file-chooser-add-filter
1009 initargs :filer :filters)
1010 (initial-add file-chooser #'file-chooser-add-shortcut-folder
1011 initargs :shortcut-folder :shortcut-folders)
1012 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
1013 initargs :shortcut-folder-uri :shortcut-folders-uris)))
1014
1015
1016(defbinding file-chooser-select-filename () boolean
1017 (file-chooser file-chooser)
1018 (filename string))
1019
1020(defbinding file-chooser-unselect-filename () nil
1021 (file-chooser file-chooser)
1022 (filename string))
1023
1024(defbinding file-chooser-select-all () boolean
1025 (file-chooser file-chooser))
1026
1027(defbinding file-chooser-unselect-all () boolean
1028 (file-chooser file-chooser))
1029
1030(defbinding file-chooser-get-filenames () (gslist string)
1031 (file-chooser file-chooser))
1032
1033(defbinding file-chooser-select-uri () boolean
1034 (file-chooser file-chooser)
1035 (uri string))
1036
1037(defbinding file-chooser-unselect-uri () nil
1038 (file-chooser file-chooser)
1039 (uri string))
1040
1041(defbinding file-chooser-get-uris () (gslist string)
1042 (file-chooser file-chooser))
1043
1044(defbinding file-chooser-add-filter () nil
1045 (file-chooser file-chooser)
1046 (filter file-filter))
1047
1048(defbinding file-chooser-remove-filter () nil
1049 (file-chooser file-chooser)
1050 (filter file-filter))
1051
1052(defbinding file-chooser-list-filters () (gslist file-filter)
1053 (file-chooser file-chooser))
1054
1055(defbinding file-chooser-add-shortcut-folder () boolean
1056 (file-chooser file-chooser)
1057 (folder string)
1058 (nil null))
1059
1060(defbinding file-chooser-remove-shortcut-folder () nil
1061 (file-chooser file-chooser)
1062 (folder string)
1063 (nil null))
1064
1065(defbinding file-chooser-list-shortcut-folders () (gslist string)
1066 (file-chooser file-chooser))
1067
1068(defbinding file-chooser-add-shortcut-folder-uri () boolean
1069 (file-chooser file-chooser)
1070 (uri string)
1071 (nil null))
1072
1073(defbinding file-chooser-remove-shortcut-folder-uri () nil
1074 (file-chooser file-chooser)
1075 (uri string)
1076 (nil null))
1077
1078(defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
1079 (file-chooser file-chooser))
1080
1081
1082;;; File Filter
1083
1084(defmethod initialize-instance ((file-filter file-filter) &rest initargs
1085 &key mime-type mime-types pattern patterns
1086 pixbuf-formats)
1087 (declare (ignore mime-type mime-types pattern patterns))
1088 (prog1
1089 (call-next-method)
1090 (when pixbuf-formats
f957f519 1091 #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1092 (warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
1093 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1094 (file-filter-add-pixbuf-formats file-filter))
49043b9a 1095 (initial-add file-filter #'file-filter-add-mime-type
1096 initargs :mime-type :mime-types)
1097 (initial-add file-filter #'file-filter-add-pattern
1098 initargs :pattern :patterns)))
1099
1100
1101(defbinding file-filter-add-mime-type () nil
1102 (filter file-filter)
1103 (mime-type string))
1104
1105(defbinding file-filter-add-pattern () nil
1106 (filter file-filter)
1107 (pattern string))
1108
f957f519 1109#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
49043b9a 1110(defbinding file-filter-add-pixbuf-formats () nil
1448a84f 1111 (filter file-filter))
49043b9a 1112
a92553bd 1113(define-callback-marshal %file-filter-callback boolean (file-filter-info))
49043b9a 1114
3d36c5d6 1115(defbinding file-filter-add-custom (filter needed function) nil
49043b9a 1116 (filter file-filter)
1117 (needed file-filter-flags)
a92553bd 1118 (%file-filter-callback callback)
49043b9a 1119 ((register-callback-function function) unsigned-int)
a92553bd 1120 (user-data-destroy-callback callback))
49043b9a 1121
1122(defbinding file-filter-get-needed () file-filter-flags
1123 (filter file-filter))
1124
1125(defbinding file-filter-filter () boolean
1126 (filter file-filter)
1127 (filter-info file-filter-info))
1128
1129
1130
eb4f580c 1131;;; Image
1132
1133(defbinding image-set-from-file () nil
1134 (image image)
1135 (filename pathname))
1136
14eaa563 1137(defmethod (setf image-pixmap) ((data vector) (image image))
1138 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
1139 (setf (image-pixmap image) pixmap)
1140 (setf (image-mask image) mask)))
1141
1142(defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
1143 (cond
1144 ((typep pixmap 'vector)
1145 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
1146 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
1147 (file
1148 (prog1
1149 (call-next-method)
1150 (image-set-from-file image file)))
1151 ((call-next-method))))
eb4f580c 1152
9617dc95 1153(defun create-image-widget (source &optional mask)
14eaa563 1154 (etypecase source
1155 (gdk:pixbuf (make-instance 'image :pixbuf source))
1156 (string (make-instance 'image :stock source))
1157 (pathname (make-instance 'image :file source))
1158 ((or list vector) (make-instance 'image :pixmap source))
1159 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
eb4f580c 1160
f957f519 1161#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
92ba85d4 1162(defbinding image-clear () nil
1163 (image image))
1164
1165
eb4f580c 1166
14eaa563 1167;;; Image menu item
eb4f580c 1168
14eaa563 1169(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1170 (if (and image (not (typep image 'widget)))
9617dc95 1171 (apply #'call-next-method item :image (create-image-widget image) initargs)
14eaa563 1172 (call-next-method)))
eb4f580c 1173
14eaa563 1174
1175(defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
1176 (setf (slot-value item 'image) widget))
1177
1178(defmethod (setf image-menu-item-image) (image (item image-menu-item))
9617dc95 1179 (setf (image-menu-item-image item) (create-image-widget image)))
eb4f580c 1180
0d07716f 1181
d404b3af 1182;;; Label
0d07716f 1183
29aa1cc3 1184(defmethod shared-initialize ((label label) names &key pattern)
1185 (declare (ignore names))
1186 (call-next-method)
1187 (when pattern
1188 (setf (label-pattern label) pattern)))
1189
c2c4a7e9 1190(defbinding label-get-layout-offsets () nil
eb4f580c 1191 (label label)
c2c4a7e9 1192 (x int :out)
1193 (y int :out))
1194
d404b3af 1195(defbinding label-select-region () nil
1196 (label label)
1197 (start int)
1198 (end int))
0d07716f 1199
eb4f580c 1200(defbinding label-get-selection-bounds () boolean
c2c4a7e9 1201 (label label)
1202 (start int :out)
1203 (end int :out))
30481825 1204
0d07716f 1205
1206
1207;;; Radio button
1208
dd392521 1209(defbinding %radio-button-get-group () pointer
2afcd8bd 1210 (radio-button radio-button))
1211
a60bd055 1212(defbinding %radio-button-set-group () nil
2afcd8bd 1213 (radio-button radio-button)
1214 (group pointer))
0d07716f 1215
9617dc95 1216(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
2afcd8bd 1217 "Add BUTTON1 to the group which BUTTON2 belongs to."
1218 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1219
30628c63 1220(defun %add-activate-callback (widget signal function object after)
1221 (if object
1222 (signal-connect widget signal
1223 #'(lambda (object)
1224 (when (slot-value widget 'active)
1225 (funcall function object (slot-value widget 'value))))
1226 :object object :after after)
1227 (signal-connect widget signal
1228 #'(lambda ()
1229 (when (slot-value widget 'active)
1230 (funcall function (slot-value widget 'value))))
1231 :after after)))
1232
1233(defmethod activate-radio-widget ((button radio-button))
1234 (signal-emit button 'clicked))
1235
4a8bb854 1236(defgeneric add-activate-callback (action function &key object after))
1237
30628c63 1238(defmethod add-activate-callback ((button radio-button) function &key object after)
1239 (%add-activate-callback button 'clicked function object after))
1240
14eaa563 1241(defmethod initialize-instance ((button radio-button) &key group)
1242 (prog1
1243 (call-next-method)
1244 (when group
9617dc95 1245 (add-to-radio-group button group))))
0d07716f 1246
1247
0d07716f 1248;;; Item
1249
a60bd055 1250(defbinding item-select () nil
0d07716f 1251 (item item))
1252
a60bd055 1253(defbinding item-deselect () nil
0d07716f 1254 (item item))
1255
a60bd055 1256(defbinding item-toggle () nil
0d07716f 1257 (item item))
1258
1259
1260
1261;;; Menu item
1262
14eaa563 1263(defmethod initialize-instance ((item menu-item) &key label)
1264 (prog1
1265 (call-next-method)
1266 (when label
1267 (setf (menu-item-label item) label))))
1268
1269
30481825 1270(defun (setf menu-item-label) (label menu-item)
1271 (make-instance 'accel-label
1272 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
14eaa563 1273 :use-underline (menu-item-use-underline-p menu-item)
1274 :visible t :parent menu-item)
30481825 1275 label)
0d07716f 1276
378b3c5f 1277(defun menu-item-label (menu-item)
14eaa563 1278 (when (and (slot-boundp menu-item 'child)
1279 (typep (bin-child menu-item) 'label))
1280 (label-label (bin-child menu-item))))
378b3c5f 1281
14eaa563 1282(defbinding menu-item-remove-submenu () nil
30481825 1283 (menu-item menu-item))
0d07716f 1284
378b3c5f 1285(defbinding menu-item-set-accel-path () nil
1286 (menu-item menu-item)
1287 (accel-path string))
1288
a60bd055 1289(defbinding menu-item-select () nil
30481825 1290 (menu-item menu-item))
0d07716f 1291
a60bd055 1292(defbinding menu-item-deselect () nil
30481825 1293 (menu-item menu-item))
0d07716f 1294
a60bd055 1295(defbinding menu-item-activate () nil
30481825 1296 (menu-item menu-item))
0d07716f 1297
378b3c5f 1298(defbinding menu-item-toggle-size-request () nil
1299 (menu-item menu-item)
1300 (requisition int :out))
1301
1302(defbinding menu-item-toggle-size-allocate () nil
1303 (menu-item menu-item)
1304 (allocation int))
1305
0d07716f 1306
14eaa563 1307;;; Menu tool button
1308
f957f519 1309#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1448a84f 1310(defbinding menu-tool-button-set-arrow-tooltip () nil
14eaa563 1311 (menu-tool-button menu-tool-button)
1312 (tooltips tooltips)
1313 (tip-text string)
1314 (tip-private string))
1315
1316
30e8a60a 1317;;; Message dialog
1318
39db92d4 1319(defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
36df51ae 1320 button buttons flags transient-parent)
1321 (let ((stock-buttons
1322 (cond
1323 ((and (not buttons) (not button))
1324 (case message-type
1325 (:question :yes-no)
1326 (t :ok)))
1327 ((listp buttons) :none)
1328 (t buttons))))
1329 (%message-dialog-new transient-parent flags message-type stock-buttons)))
1330
1331
1332(defmethod shared-initialize ((dialog message-dialog) names &rest initargs
d453ba38 1333 &key message-type buttons button text
f957f519 1334 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1335 secondary-text)
39db92d4 1336 (declare (ignore names))
4c308d58 1337 (when text
1338 (message-dialog-set-markup dialog text))
f957f519 1339 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
4c308d58 1340 (when secondary-text
1341 (message-dialog-format-secondary-markup dialog secondary-text))
d453ba38 1342 (when (and (not buttons) (not button))
1343 (loop
1344 for (key value) on initargs by #'cddr
1345 when (and (eq key :signal) (eq (first value) :close))
1346 do (warn "Default button configuration changed from ~A to ~A" :close
1347 (if (eq message-type :question) :yes-no :ok))
1348 (loop-finish)))
36df51ae 1349 (if (typep buttons 'buttons-type)
1350 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1351 (call-next-method)))
30e8a60a 1352
1353
1354(defbinding %message-dialog-new () pointer
1355 (parent (or null window))
1356 (flags dialog-flags)
1357 (type message-type)
1358 (buttons buttons-type)
4c308d58 1359 (nil null))
30e8a60a 1360
1361(defbinding message-dialog-set-markup () nil
1362 (message-dialog message-dialog)
1363 (markup string))
1364
f957f519 1365#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
30e8a60a 1366(defbinding message-dialog-format-secondary-text () nil
1367 (message-dialog message-dialog)
1368 (text string))
1369
f957f519 1370#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
30e8a60a 1371(defbinding message-dialog-format-secondary-markup () nil
1372 (message-dialog message-dialog)
1373 (markup string))
1374
1375
0d07716f 1376
30481825 1377;;; Radio menu item
0d07716f 1378
dd392521 1379(defbinding %radio-menu-item-get-group () pointer
2afcd8bd 1380 (radio-menu-item radio-menu-item))
1381
a60bd055 1382(defbinding %radio-menu-item-set-group () nil
2afcd8bd 1383 (radio-menu-item radio-menu-item)
1384 (group pointer))
1385
30628c63 1386(defmethod activate-radio-widget ((item radio-menu-item))
1387 (menu-item-activate item))
1388
9617dc95 1389(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
2afcd8bd 1390 "Add ITEM1 to the group which ITEM2 belongs to."
1391 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1392
30628c63 1393(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1394 (%add-activate-callback item 'activate function object after))
1395
14eaa563 1396(defmethod initialize-instance ((item radio-menu-item) &key group)
378b3c5f 1397 (prog1
1398 (call-next-method)
14eaa563 1399 (when group
9617dc95 1400 (add-to-radio-group item group))))
1401
2afcd8bd 1402
0d07716f 1403
14eaa563 1404;;; Radio tool button
1405
1406(defbinding %radio-tool-button-get-group () pointer
1407 (radio-tool-button radio-tool-button))
1408
1409(defbinding %radio-tool-button-set-group () nil
1410 (radio-tool-button radio-tool-button)
1411 (group pointer))
1412
30628c63 1413(defmethod activate-radio-widget ((button radio-tool-button))
1414 (signal-emit button 'clicked))
1415
9617dc95 1416(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
14eaa563 1417 "Add BUTTON1 to the group which BUTTON2 belongs to."
1418 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
30628c63 1419(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1420 (%add-activate-callback button 'clicked function object after))
14eaa563 1421
1422(defmethod initialize-instance ((button radio-tool-button) &key group)
1423 (prog1
1424 (call-next-method)
1425 (when group
9617dc95 1426 (add-to-radio-group button group))))
1427
14eaa563 1428
0d07716f 1429
c2c4a7e9 1430;;; Toggle button
1431
1432(defbinding toggle-button-toggled () nil
1433 (toggle-button toggle-button))
1434
1435
0d07716f 1436;;; Window
1437
362f1795 1438(defmethod initialize-instance ((window window) &rest initargs
6e21e828 1439 &key display accel-group accel-groups)
362f1795 1440 (declare (ignore accel-group accel-groups))
1441 (prog1
6e21e828 1442 (if display
1443 (apply #'call-next-method
6b465328 1444 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
6e21e828 1445 (call-next-method))
362f1795 1446 (initial-add window #'window-add-accel-group
1447 initargs :accel-group :accel-groups)))
99821988 1448
405b4406 1449#-debug-ref-counting
1450(defmethod print-object ((window window) stream)
1451 (if (and
1452 (proxy-valid-p window)
1453 (slot-boundp window 'title)
1454 (not (zerop (length (window-title window)))))
1455 (print-unreadable-object (window stream :type t :identity nil)
1456 (format stream "~S at 0x~X"
f957f519 1457 (window-title window) (pointer-address (foreign-location window))))
405b4406 1458 (call-next-method)))
99821988 1459
304cfb76 1460(defbinding window-set-wmclass () nil
0d07716f 1461 (window window)
1462 (wmclass-name string)
1463 (wmclass-class string))
1464
a60bd055 1465(defbinding window-add-accel-group () nil
0d07716f 1466 (window window)
1467 (accel-group accel-group))
1468
a60bd055 1469(defbinding window-remove-accel-group () nil
0d07716f 1470 (window window)
1471 (accel-group accel-group))
1472
a60bd055 1473(defbinding window-activate-focus () int
0d07716f 1474 (window window))
1475
a60bd055 1476(defbinding window-activate-default () int
0d07716f 1477 (window window))
1478
304cfb76 1479(defbinding window-set-default-size (window width height) int
0d07716f 1480 (window window)
304cfb76 1481 ((or width -1) int)
1482 ((or height -1) int))
0d07716f 1483
4eed43f1 1484(defbinding %window-set-geometry-hints () nil
1485 (window window)
d8dd2e76 1486 (widget (or widget null))
4eed43f1 1487 (geometry gdk:geometry)
1488 (geometry-mask gdk:window-hints))
1489
d8dd2e76 1490(defun window-set-geometry-hints (window &key widget min-width min-height
4eed43f1 1491 max-width max-height base-width base-height
d8dd2e76 1492 width-inc height-inc gravity
1493 aspect (min-aspect aspect) (max-aspect aspect))
4eed43f1 1494 (let ((geometry (make-instance 'gdk:geometry
1495 :min-width (or min-width -1)
1496 :min-height (or min-height -1)
1497 :max-width (or max-width -1)
1498 :max-height (or max-height -1)
1499 :base-width (or base-width 0)
1500 :base-height (or base-height 0)
1501 :width-inc (or width-inc 0)
1502 :height-inc (or height-inc 0)
1503 :min-aspect (or min-aspect 0)
d8dd2e76 1504 :max-aspect (or max-aspect 0)))
4eed43f1 1505 (mask ()))
d8dd2e76 1506 (when (or min-width min-height)
4eed43f1 1507 (push :min-size mask))
d8dd2e76 1508 (when (or max-width max-height)
4eed43f1 1509 (push :max-size mask))
1510 (when (or base-width base-height)
1511 (push :base-size mask))
1512 (when (or width-inc height-inc)
1513 (push :resize-inc mask))
1514 (when (or min-aspect max-aspect)
1515 (push :aspect mask))
d8dd2e76 1516 (when gravity
1517 (push :win-gravity mask)
1518 (setf (gdk:geometry-gravity geometry) gravity))
1519 (%window-set-geometry-hints window widget geometry mask)))
0d07716f 1520
99821988 1521(defbinding window-list-toplevels () (glist (copy-of window))
1522 "Returns a list of all existing toplevel windows.")
304cfb76 1523
1524(defbinding window-add-mnemonic (window key target) nil
1525 (window window)
1526 ((gdk:keyval-from-name key) unsigned-int)
1527 (target widget))
1528
1529(defbinding window-remove-mnemonic (window key target) nil
1530 (window window)
1531 ((gdk:keyval-from-name key) unsigned-int)
1532 (target widget))
1533
1534(defbinding window-mnemonic-activate (window key modifier) nil
1535 (window window)
1536 ((gdk:keyval-from-name key) unsigned-int)
1537 (modifier gdk:modifier-type))
1538
4eed43f1 1539(defbinding window-activate-key () boolean
1540 (window window)
1541 (event gdk:key-event))
1542
1543(defbinding window-propagate-key-event () boolean
1544 (window window)
1545 (event gdk:key-event))
1546
f957f519 1547#?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
304cfb76 1548(defbinding window-present () nil
1549 (window window))
1550
f957f519 1551#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
92ba85d4 1552(progn
1553 (defbinding %window-present () nil
1554 (window window))
1555
12cae344 1556 (defbinding %window-present-with-time () nil
92ba85d4 1557 (window window)
1558 (timespamp unsigned-int))
1559
1560 (defun window-present (window &optional timestamp)
1561 (if timestamp
12cae344 1562 (%window-present-with-time window timestamp)
92ba85d4 1563 (%window-present window))))
1564
304cfb76 1565(defbinding window-iconify () nil
1566 (window window))
1567
1568(defbinding window-deiconify () nil
1569 (window window))
1570
1571(defbinding window-stick () nil
1572 (window window))
1573
1574(defbinding window-unstick () nil
1575 (window window))
1576
1577(defbinding window-maximize () nil
1578 (window window))
1579
1580(defbinding window-unmaximize () nil
1581 (window window))
1582
4eed43f1 1583(defbinding window-fullscreen () nil
1584 (window window))
1585
1586(defbinding window-unfullscreen () nil
1587 (window window))
1588
1589(defbinding window-set-keep-above () nil
1590 (window window)
1591 (setting boolean))
1592
1593(defbinding window-set-keep-below () nil
1594 (window window)
1595 (setting boolean))
1596
304cfb76 1597(defbinding window-begin-resize-drag () nil
1598 (window window)
1599 (edge gdk:window-edge)
1600 (button int)
1601 (root-x int) (root-y int)
6baf860c 1602 (timestamp unsigned-int))
304cfb76 1603
1604(defbinding window-begin-move-drag () nil
1605 (window window)
1606 (edge gdk:window-edge)
1607 (button int)
1608 (root-x int) (root-y int)
6baf860c 1609 (timestamp unsigned-int))
304cfb76 1610
1611(defbinding window-set-frame-dimensions () nil
1612 (window window)
1613 (left int) (top int) (rigth int) (bottom int))
1614
304cfb76 1615(defbinding %window-get-default-size () nil
1616 (window window)
1617 (width int :out)
1618 (height int :out))
1619
1620(defun window-get-default-size (window)
1621 (multiple-value-bind (width height) (%window-get-default-size window)
1622 (values (unless (= width -1) width) (unless (= height -1) height))))
1623
1624(defbinding window-get-frame-dimensions () nil
1625 (window window)
1626 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1627
ad98b596 1628(defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
304cfb76 1629 (window window))
1630
304cfb76 1631(defbinding window-get-position () nil
1632 (window window)
1633 (root-x int :out)
1634 (root-y int :out))
1635
1636(defbinding window-get-size () nil
1637 (window window)
1638 (width int :out)
1639 (height int :out))
1640
1641(defbinding window-move () nil
1642 (window window)
1643 (x int)
1644 (y int))
1645
1646(defbinding window-parse-geometry () boolean
1647 (window window)
1648 (geometry string))
1649
1650(defbinding window-reshow-with-initial-size () nil
1651 (window window))
1652
1653(defbinding window-resize () nil
1654 (window window)
1655 (width int)
1656 (heigth int))
1657
4eed43f1 1658(defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1659 () (glist gdk:pixbuf))
1660
1661(defun window-default-icon ()
1662 (first (window-default-icon-list)))
1663
1664(defbinding %window-set-default-icon-list () nil
1665 (icons (glist gdk:pixbuf)))
1666
1667(defun (setf window-default-icon-list) (icons)
1668 (%window-set-default-icon-list icons)
1669 icons)
1670
1671(defbinding %window-set-default-icon () nil
1672 (icons (glist gdk:pixbuf)))
1673
4a8bb854 1674(defgeneric (setf window-default-icon) (icon))
1675
4eed43f1 1676(defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1677 (%window-set-default-icon icon)
1678 icon)
1679
4a8bb854 1680(defgeneric (setf window-group) (group window))
1681
4eed43f1 1682(defmethod (setf window-group) ((group window-group) (window window))
1683 (window-group-add-window group window)
1684 group)
1685
1686(defbinding %window-set-default-icon-from-file () boolean
1687 (filename pathname)
1688 (nil null))
1689
1690(defmethod (setf window-default-icon) ((icon-file pathname))
1691 (%window-set-default-icon-from-file icon-file)
1692 icon-file)
1693
1694(defbinding %window-set-icon-from-file () boolean
1695 (window window)
1696 (filename pathname)
1697 (nil null))
1698
1699(defmethod (setf window-icon) ((icon-file pathname) (window window))
1700 (%window-set-icon-from-file window icon-file)
1701 icon-file)
1702
1703(defbinding window-set-auto-startup-notification () nil
1704 (setting boolean))
1705
1706(defbinding decorated-window-init () nil
1707 (window window))
1708
1709(defbinding decorated-window-calculate-frame-size () nil
1710 (window window))
1711
1712(defbinding decorated-window-set-title () nil
304cfb76 1713 (window window)
4eed43f1 1714 (title string))
304cfb76 1715
4eed43f1 1716(defbinding decorated-window-move-resize-window () nil
1717 (window window)
1718 (x int)
1719 (y int)
1720 (width int)
1721 (heigth int))
304cfb76 1722
1723
4eed43f1 1724;;; Window group
0d07716f 1725
4eed43f1 1726(defmethod initialize-instance ((window-group window-group) &rest initargs
1727 &key window windows)
1728 (declare (ignore window windows))
1729 (prog1
1730 (call-next-method)
1731 (initial-add window-group #'window-group-add-window
1732 initargs :window :windows)))
0d07716f 1733
0d07716f 1734
4eed43f1 1735(defbinding window-group-add-window () nil
1736 (window-group window-group)
1737 (window window))
0d07716f 1738
4eed43f1 1739(defbinding window-group-remove-window () nil
1740 (window-group window-group)
1741 (window window))
0d07716f 1742
1743
30481825 1744;;; Scrolled window
0d07716f 1745
0d07716f 1746(defun (setf scrolled-window-scrollbar-policy) (policy window)
1747 (setf (scrolled-window-hscrollbar-policy window) policy)
1748 (setf (scrolled-window-vscrollbar-policy window) policy))
1749
a60bd055 1750(defbinding scrolled-window-add-with-viewport () nil
0d07716f 1751 (scrolled-window scrolled-window)
1752 (child widget))
1753
4c308d58 1754(defmethod shared-initialize ((window scrolled-window) names &key policy)
1755 (declare (ignore names))
1756 (when policy
1757 (setf (slot-value window 'hscrollbar-policy) policy)
1758 (setf (slot-value window 'vscrollbar-policy) policy))
1759 (call-next-method))
2afcd8bd 1760
0d07716f 1761
30481825 1762;;; Statusbar
0d07716f 1763
14eaa563 1764(defbinding statusbar-get-context-id () unsigned-int
30481825 1765 (statusbar statusbar)
1766 (context-description string))
0d07716f 1767
a60bd055 1768(defbinding statusbar-push () unsigned-int
30481825 1769 (statusbar statusbar)
1770 (context-id unsigned-int)
1771 (text string))
0d07716f 1772
a60bd055 1773(defbinding statusbar-pop () nil
30481825 1774 (statusbar statusbar)
1775 (context-id unsigned-int))
0d07716f 1776
a60bd055 1777(defbinding statusbar-remove () nil
30481825 1778 (statusbar statusbar)
1779 (context-id unsigned-int)
1780 (message-id unsigned-int))
0d07716f 1781
0d07716f 1782
1783
1784;;; Fixed
1785
a60bd055 1786(defbinding fixed-put () nil
30481825 1787 (fixed fixed)
1788 (widget widget)
378b3c5f 1789 (x int) (y int))
0d07716f 1790
a60bd055 1791(defbinding fixed-move () nil
30481825 1792 (fixed fixed)
1793 (widget widget)
378b3c5f 1794 (x int) (y int))
0d07716f 1795
1796
1797
2afcd8bd 1798;;; Notebook
0d07716f 1799
49043b9a 1800(defun %ensure-notebook-position (notebook page)
378b3c5f 1801 (etypecase page
49043b9a 1802 (position page)
378b3c5f 1803 (widget (notebook-page-num notebook page t))))
1804
49043b9a 1805(defun %ensure-notebook-child (notebook position)
378b3c5f 1806 (typecase position
1807 (widget position)
49043b9a 1808 (t (notebook-get-nth-page notebook position))))
378b3c5f 1809
1810(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
f957f519 1811 (notebook position child &optional tab-label menu-label) nil
30481825 1812 (notebook notebook)
1813 (child widget)
1814 ((if (stringp tab-label)
378b3c5f 1815 (make-instance 'label :label tab-label)
f957f519 1816 tab-label) (or null widget))
30481825 1817 ((if (stringp menu-label)
378b3c5f 1818 (make-instance 'label :label menu-label)
30481825 1819 menu-label) (or null widget))
49043b9a 1820 ((%ensure-notebook-position notebook position) position))
0d07716f 1821
f957f519 1822(defun notebook-append (notebook child &optional tab-label menu-label)
378b3c5f 1823 (notebook-insert notebook :last child tab-label menu-label))
0d07716f 1824
f957f519 1825(defun notebook-prepend (notebook child &optional tab-label menu-label)
378b3c5f 1826 (notebook-insert notebook :first child tab-label menu-label))
0d07716f 1827
378b3c5f 1828(defbinding notebook-remove-page (notebook page) nil
30481825 1829 (notebook notebook)
49043b9a 1830 ((%ensure-notebook-position notebook page) position))
0d07716f 1831
a60bd055 1832(defbinding %notebook-page-num () int
30481825 1833 (notebook notebook)
1834 (child widget))
1835
378b3c5f 1836(defun notebook-page-num (notebook child &optional error-p)
30481825 1837 (let ((page-num (%notebook-page-num notebook child)))
1838 (if (= page-num -1)
378b3c5f 1839 (when error-p
49043b9a 1840 (error "~A is not a page in ~A" child notebook))
30481825 1841 page-num)))
1842
a60bd055 1843(defbinding notebook-next-page () nil
30481825 1844 (notebook notebook))
0d07716f 1845
a60bd055 1846(defbinding notebook-prev-page () nil
30481825 1847 (notebook notebook))
1848
378b3c5f 1849(defbinding notebook-reorder-child (notebook child position) nil
1850 (notebook notebook)
1851 (child widget)
92ba85d4 1852 ((%ensure-notebook-position notebook position) int))
378b3c5f 1853
a60bd055 1854(defbinding notebook-popup-enable () nil
30481825 1855 (notebook notebook))
1856
a60bd055 1857(defbinding notebook-popup-disable () nil
30481825 1858 (notebook notebook))
1859
49043b9a 1860(defbinding notebook-get-nth-page () widget
378b3c5f 1861 (notebook notebook)
49043b9a 1862 (page position))
378b3c5f 1863
49043b9a 1864(defun %notebook-current-page (notebook)
1865 (when (slot-boundp notebook 'current-page-num)
1866 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
378b3c5f 1867
1868(defun (setf notebook-current-page) (page notebook)
f957f519 1869 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
378b3c5f 1870
eb4f580c 1871(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1872 (notebook page) widget
1873 (notebook notebook)
49043b9a 1874 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1875
eb4f580c 1876(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
84967144 1877 (notebook page) (copy-of string)
eb4f580c 1878 (notebook notebook)
49043b9a 1879 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1880
eb4f580c 1881(defbinding %notebook-set-tab-label () nil
1882 (notebook notebook)
1883 (page widget)
1884 (tab-label widget))
1885
1886(defun (setf notebook-tab-label) (tab-label notebook page)
1887 (let ((widget (if (stringp tab-label)
1888 (make-instance 'label :label tab-label)
1889 tab-label)))
49043b9a 1890 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
eb4f580c 1891 widget))
378b3c5f 1892
378b3c5f 1893
eb4f580c 1894(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1895 (notebook page) widget
1896 (notebook notebook)
49043b9a 1897 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1898
eb4f580c 1899(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
84967144 1900 (notebook page) (copy-of string)
eb4f580c 1901 (notebook notebook)
49043b9a 1902 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1903
eb4f580c 1904(defbinding %notebook-set-menu-label () nil
1905 (notebook notebook)
1906 (page widget)
1907 (menu-label widget))
1908
1909(defun (setf notebook-menu-label) (menu-label notebook page)
1910 (let ((widget (if (stringp menu-label)
1911 (make-instance 'label :label menu-label)
1912 menu-label)))
49043b9a 1913 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
eb4f580c 1914 widget))
378b3c5f 1915
1916
1917(defbinding notebook-query-tab-label-packing (notebook page) nil
30481825 1918 (notebook notebook)
92ba85d4 1919 ((%ensure-notebook-child notebook page) widget)
30481825 1920 (expand boolean :out)
1921 (fill boolean :out)
1922 (pack-type pack-type :out))
1923
378b3c5f 1924(defbinding notebook-set-tab-label-packing
1925 (notebook page expand fill pack-type) nil
30481825 1926 (notebook notebook)
92ba85d4 1927 ((%ensure-notebook-child notebook page) widget)
30481825 1928 (expand boolean)
1929 (fill boolean)
1930 (pack-type pack-type))
1931
0d07716f 1932
1933
2afcd8bd 1934;;; Paned
0d07716f 1935
a60bd055 1936(defbinding paned-pack1 () nil
2afcd8bd 1937 (paned paned)
1938 (child widget)
1939 (resize boolean)
1940 (shrink boolean))
0d07716f 1941
a60bd055 1942(defbinding paned-pack2 () nil
2afcd8bd 1943 (paned paned)
1944 (child widget)
1945 (resize boolean)
1946 (shrink boolean))
0d07716f 1947
0d07716f 1948
2afcd8bd 1949;;; Layout
0d07716f 1950
a60bd055 1951(defbinding layout-put () nil
2afcd8bd 1952 (layout layout)
49043b9a 1953 (child widget)
2afcd8bd 1954 (x int)
1955 (y int))
0d07716f 1956
a60bd055 1957(defbinding layout-move () nil
2afcd8bd 1958 (layout layout)
49043b9a 1959 (child widget)
2afcd8bd 1960 (x int)
1961 (y int))
0d07716f 1962
49043b9a 1963(defbinding layout-set-size () nil
1964 (layout layout)
1965 (width unsigned-int)
1966 (height unsigned-int))
1967
1968(defbinding layout-get-size () nil
1969 (layout layout)
1970 (width unsigned-int :out)
1971 (height unsigned-int :out))
0d07716f 1972
1973
0d07716f 1974;;; Menu shell
1975
378b3c5f 1976(defbinding menu-shell-insert (menu-shell menu-item position) nil
30481825 1977 (menu-shell menu-shell)
1978 (menu-item menu-item)
378b3c5f 1979 ((case position
1980 (:first 0)
1981 (:last -1)
1982 (t position)) int))
0d07716f 1983
30481825 1984(defun menu-shell-append (menu-shell menu-item)
378b3c5f 1985 (menu-shell-insert menu-shell menu-item :last))
0d07716f 1986
30481825 1987(defun menu-shell-prepend (menu-shell menu-item)
378b3c5f 1988 (menu-shell-insert menu-shell menu-item :fisrt))
0d07716f 1989
a60bd055 1990(defbinding menu-shell-deactivate () nil
30481825 1991 (menu-shell menu-shell))
0d07716f 1992
a60bd055 1993(defbinding menu-shell-select-item () nil
30481825 1994 (menu-shell menu-shell)
1995 (menu-item menu-item))
0d07716f 1996
14eaa563 1997(defbinding menu-shell-select-first () nil
1998 (menu-shell menu-shell)
1999 (search-sensitive boolean))
2000
a60bd055 2001(defbinding menu-shell-deselect () nil
30481825 2002 (menu-shell menu-shell))
0d07716f 2003
a60bd055 2004(defbinding menu-shell-activate-item () nil
30481825 2005 (menu-shell menu-shell)
2006 (menu-item menu-item)
2007 (fore-deactivate boolean))
0d07716f 2008
14eaa563 2009(defbinding menu-shell-cancel () nil
2010 (menu-shell menu-shell))
0d07716f 2011
2012
378b3c5f 2013;;; Menu
0d07716f 2014
378b3c5f 2015(defun %menu-position (menu child)
2016 (etypecase child
2017 (int child)
2018 (keyword (case child
2019 (:first 0)
2020 (:last -1)
eb4f580c 2021 (t (error "Invalid position keyword: ~A" child))))
378b3c5f 2022 (widget (menu-child-position menu child))))
0d07716f 2023
2024
378b3c5f 2025(defbinding menu-reorder-child (menu menu-item position) nil
2026 (menu menu)
2027 (menu-item menu-item)
2028 ((%menu-position menu position) int))
0d07716f 2029
14eaa563 2030(defbinding menu-attach () nil
2031 (menu menu)
2032 (menu-item menu-item)
2033 (left-attach unsigned-int)
2034 (right-attach unsigned-int)
2035 (top-attach unsigned-int)
2036 (bottom-attach unsigned-int))
2037
a92553bd 2038(define-callback-marshal %menu-position-callback nil
2039 (menu (x int) (y int) (push-in boolean)))
0d07716f 2040
378b3c5f 2041(defbinding %menu-popup () nil
2042 (menu menu)
2043 (parent-menu-shell (or null menu-shell))
2044 (parent-menu-item (or null menu-item))
a92553bd 2045 (callback (or null callback))
378b3c5f 2046 (callback-id unsigned-int)
2047 (button unsigned-int)
2048 (activate-time (unsigned 32)))
2049
2050(defun menu-popup (menu button activate-time &key callback parent-menu-shell
2051 parent-menu-item)
2052 (if callback
4886872c 2053 (with-callback-function (id callback)
2054 (%menu-popup
2055 menu parent-menu-shell parent-menu-item
a92553bd 2056 %menu-position-callback id button activate-time))
378b3c5f 2057 (%menu-popup
2058 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
2059
2060(defbinding menu-set-accel-path () nil
2061 (menu menu)
2062 (accel-path string))
0d07716f 2063
a60bd055 2064(defbinding menu-reposition () nil
30481825 2065 (menu menu))
0d07716f 2066
a60bd055 2067(defbinding menu-popdown () nil
30481825 2068 (menu menu))
0d07716f 2069
378b3c5f 2070(defun menu-child-position (menu child)
2071 (position child (container-children menu)))
2072
2073(defun menu-active-num (menu)
2074 (menu-child-position menu (menu-active menu)))
2075
a60bd055 2076(defbinding %menu-set-active () nil
30481825 2077 (menu menu)
2078 (index unsigned-int))
0d07716f 2079
378b3c5f 2080(defun (setf menu-active) (menu child)
2081 (%menu-set-active menu (%menu-position menu child))
2082 child)
2afcd8bd 2083
a92553bd 2084(define-callback %menu-detach-callback nil ((widget widget) (menu menu))
f957f519 2085 (funcall (user-data menu 'detach-func) widget menu))
14eaa563 2086
405b4406 2087(defbinding %menu-attach-to-widget (menu widget) nil
14eaa563 2088 (menu menu)
2089 (widget widget)
a92553bd 2090 (%menu-detach-callback callback))
14eaa563 2091
2092(defun menu-attach-to-widget (menu widget function)
f957f519 2093 (setf (user-data menu 'detach-func) function)
14eaa563 2094 (%menu-attach-to-widget menu widget))
2095
2096(defbinding menu-detach () nil
2097 (menu menu))
2098
f957f519 2099#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
14eaa563 2100(defbinding menu-get-for-attach-widget () (copy-of (glist widget))
2101 (widget widget))
2102
2103(defbinding menu-set-monitor () nil
2104 (menu menu)
2105 (monitor-num int))
0d07716f 2106
2107
30481825 2108;;; Table
0d07716f 2109
a60bd055 2110(defbinding table-resize () nil
30481825 2111 (table table)
2112 (rows unsigned-int)
2113 (columns unsigned-int))
0d07716f 2114
a60bd055 2115(defbinding table-attach (table child left right top bottom
362f1795 2116 &key options x-options y-options
2117 (x-padding 0) (y-padding 0)) nil
30481825 2118 (table table)
2119 (child widget)
2120 (left unsigned-int)
2121 (right unsigned-int)
2122 (top unsigned-int)
2123 (bottom unsigned-int)
362f1795 2124 ((append (mklist options) (mklist x-options)) attach-options)
2125 ((append (mklist options) (mklist y-options)) attach-options)
30481825 2126 (x-padding unsigned-int)
2127 (y-padding unsigned-int))
2128
dd392521 2129
a60bd055 2130(defbinding %table-set-row-spacing () nil
30481825 2131 (table table)
2132 (row unsigned-int)
2133 (spacing unsigned-int))
2134
dd392521 2135(defbinding %table-set-row-spacings () nil
2136 (table table)
2137 (spacing unsigned-int))
2138
2139(defun (setf table-row-spacing) (spacing table &optional row)
2140 (if row
2141 (%table-set-row-spacing table row spacing)
2142 (%table-set-row-spacings table spacing))
30481825 2143 spacing)
2144
dd392521 2145(defbinding %table-get-row-spacing () unsigned-int
30481825 2146 (table table)
dd392521 2147 (row unsigned-int))
2148
2149(defbinding %table-get-default-row-spacing () unsigned-int
2150 (table table))
2151
2152(defun table-row-spacing (table &optional row)
2153 (if row
2154 (%table-get-row-spacing table row)
2155 (%table-get-default-row-spacing table)))
2156
30481825 2157
a60bd055 2158(defbinding %table-set-col-spacing () nil
30481825 2159 (table table)
2160 (col unsigned-int)
2161 (spacing unsigned-int))
2162
dd392521 2163(defbinding %table-set-col-spacings () nil
2164 (table table)
2165 (spacing unsigned-int))
2166
5233fe44 2167(defun (setf table-column-spacing) (spacing table &optional column)
2168 (if column
2169 (%table-set-col-spacing table column spacing)
dd392521 2170 (%table-set-col-spacings table spacing))
30481825 2171 spacing)
2172
5233fe44 2173(defun (setf table-col-spacing) (spacing table &optional col)
2174 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2175 (setf (table-column-spacing table col) spacing))
2176
dd392521 2177(defbinding %table-get-col-spacing () unsigned-int
30481825 2178 (table table)
dd392521 2179 (col unsigned-int))
2180
2181(defbinding %table-get-default-col-spacing () unsigned-int
2182 (table table))
2183
5233fe44 2184(defun table-column-spacing (table &optional column)
2185 (if column
2186 (%table-get-col-spacing table column)
dd392521 2187 (%table-get-default-col-spacing table)))
2188
5233fe44 2189(defun table-col-spacing (table &optional col)
2190 (warn "TABLE-COL-SPACING is deprecatet, use TABLE-COLUMN-SPACING instead")
2191 (table-column-spacing table col))
2192
dd392521 2193
30481825 2194
2195;;; Toolbar
2196
9617dc95 2197(defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
2198 (if (eq tooltips t)
2199 (apply #'call-next-method toolbar
2200 :tooltips (make-instance 'tooltips) initargs)
2201 (call-next-method)))
0d07716f 2202
9617dc95 2203(defbinding %toolbar-insert () nil
378b3c5f 2204 (toolbar toolbar)
9617dc95 2205 (tool-item tool-item)
2206 (position position))
30481825 2207
9617dc95 2208(defun toolbar-insert (toolbar tool-item &optional (position :end))
2209 (%toolbar-insert toolbar tool-item position)
2210 (%tool-item-update-tooltips tool-item))
378b3c5f 2211
9617dc95 2212(defbinding toolbar-get-item-index () int
2213 (toolbar toolbar)
2214 (item tool-item))
30481825 2215
9617dc95 2216(defbinding toolbar-get-nth-item () tool-item
2217 (toolbar toolbar)
2218 (n int))
30481825 2219
9617dc95 2220(defbinding toolbar-get-drop-index () int
2221 (toolbar toolbar)
2222 (x int) (y int))
30481825 2223
9617dc95 2224(defbinding toolbar-set-drop-highlight-item () nil
2225 (toolbar toolbar)
2226 (tool-item tool-item)
2227 (index int))
30481825 2228
0d07716f 2229
9617dc95 2230;;; Tool button
0d07716f 2231
9617dc95 2232(defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
2233 (if (and icon (not (typep icon 'widget)))
2234 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
2235 (call-next-method)))
0d07716f 2236
2237
9617dc95 2238;;; Tool item
0d07716f 2239
9617dc95 2240(defbinding tool-item-set-tooltip () nil
2241 (tool-item tool-item)
2242 (tooltips tooltips)
2243 (tip-text string)
2244 (tip-private string))
0d07716f 2245
0d07716f 2246
9617dc95 2247(defun %tool-item-update-tooltips (tool-item)
2248 (when (and
2249 (slot-boundp tool-item 'parent)
2250 (or
2251 (user-data-p tool-item 'tip-text)
2252 (user-data-p tool-item 'tip-private)))
2253 (tool-item-set-tooltip
2254 tool-item (toolbar-tooltips (widget-parent tool-item))
2255 (or (user-data tool-item 'tip-text) "")
2256 (or (user-data tool-item 'tip-private) ""))))
2257
2258(defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
2259 (setf (user-data tool-item 'tip-text) tip-text)
2260 (%tool-item-update-tooltips tool-item)
2261 tip-text)
2262
2263(defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
2264 (setf (user-data tool-item 'tip-private) tip-private)
2265 (%tool-item-update-tooltips tool-item)
2266 tip-private)
2267
2268(defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
2269 (declare (ignore args))
2270 (prog1
2271 (call-next-method)
2272 (%tool-item-update-tooltips tool-item)))
0d07716f 2273
14eaa563 2274
2275(defbinding tool-item-retrieve-proxy-menu-item () widget
2276 (tool-item tool-item))
2277
2278(defbinding (tool-item-proxy-menu-item
2279 "gtk_tool_item_get_proxy_menu_item") () menu-item
2280 (tool-item tool-item)
2281 (menu-item-id string))
2282
2283(defbinding %tool-item-set-proxy-menu-item () nil
2284 (tool-item tool-item)
2285 (menu-item-id string)
2286 (menu-item menu-item))
2287
2288(defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2289 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2290 menu-item)
2291
f957f519 2292#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
14eaa563 2293(defbinding tool-item-rebuild-menu () nil
2294 (tool-item tool-item))
2295
2296
a60bd055 2297;;; Editable
eb4f580c 2298
a60bd055 2299(defbinding editable-select-region (editable &optional (start 0) end) nil
30481825 2300 (editable editable)
2301 (start int)
2302 ((or end -1) int))
0d07716f 2303
eb4f580c 2304(defbinding editable-get-selection-bounds (editable) nil
2305 (editable editable)
2306 (start int :out)
2307 (end int :out))
2308
14eaa563 2309(defbinding editable-insert-text (editable text &optional (position 0)) nil
30481825 2310 (editable editable)
2311 (text string)
2312 ((length text) int)
f957f519 2313 (position position :in/out))
0d07716f 2314
30481825 2315(defun editable-append-text (editable text)
2316 (editable-insert-text editable text nil))
0d07716f 2317
30481825 2318(defun editable-prepend-text (editable text)
2319 (editable-insert-text editable text 0))
0d07716f 2320
a60bd055 2321(defbinding editable-delete-text (editable &optional (start 0) end) nil
30481825 2322 (editable editable)
2323 (start int)
2324 ((or end -1) int))
0d07716f 2325
a60bd055 2326(defbinding (editable-text "gtk_editable_get_chars")
30481825 2327 (editable &optional (start 0) end) string
2328 (editable editable)
2329 (start int)
2330 ((or end -1) int))
0d07716f 2331
30481825 2332(defun (setf editable-text) (text editable)
2333 (if text
2334 (editable-delete-text
2335 editable
2336 (editable-insert-text editable text))
2337 (editable-delete-text editable))
2338 text)
0d07716f 2339
a60bd055 2340(defbinding editable-cut-clipboard () nil
30481825 2341 (editable editable))
0d07716f 2342
a60bd055 2343(defbinding editable-copy-clipboard () nil
30481825 2344 (editable editable))
0d07716f 2345
a60bd055 2346(defbinding editable-paste-clipboard () nil
30481825 2347 (editable editable))
0d07716f 2348
a60bd055 2349(defbinding editable-delete-selection () nil
30481825 2350 (editable editable))
0d07716f 2351
0d07716f 2352
0d07716f 2353
30481825 2354;;; Spin button
0d07716f 2355
14eaa563 2356(defbinding spin-button-configure () nil
2357 (spin-button spin-button)
2358 (adjustment adjustment)
2359 (climb-rate double-float)
2360 (digits unsigned-int))
2361
2362(defbinding spin-button-set-range () nil
2363 (spin-button spin-button)
2364 (min double-float)
2365 (max double-float))
2366
2367(defbinding spin-button-get-range () nil
2368 (spin-button spin-button)
2369 (min double-float :out)
2370 (max double-float :out))
2371
30481825 2372(defun spin-button-value-as-int (spin-button)
2373 (round (spin-button-value spin-button)))
0d07716f 2374
45314d76 2375(defbinding %spin-button-spin () nil
30481825 2376 (spin-button spin-button)
2377 (direction spin-type)
45314d76 2378 (increment double-float))
2379
2380(defun spin-button-spin (spin-button value)
2381 (etypecase value
2382 (real (%spin-button-spin spin-button :spin-user-defined value))
2383 (spin-type (%spin-button-spin spin-button value 0))))
2384
0d07716f 2385
a60bd055 2386(defbinding spin-button-update () nil
30481825 2387 (spin-button spin-button))
0d07716f 2388
2389
2390
2391; ;;; Ruler
2392
a60bd055 2393(defbinding ruler-set-range () nil
30481825 2394 (ruler ruler)
2395 (lower single-float)
2396 (upper single-float)
2397 (position single-float)
2398 (max-size single-float))
0d07716f 2399
49043b9a 2400(defbinding ruler-get-range () nil
2401 (ruler ruler)
2402 (lower single-float :out)
2403 (upper single-float :out)
2404 (position single-float :out)
2405 (max-size single-float :out))
0d07716f 2406
0d07716f 2407
0d07716f 2408
2afcd8bd 2409;;; Range
0d07716f 2410
eb4f580c 2411(defun range-lower (range)
2412 (adjustment-lower (range-adjustment range)))
0d07716f 2413
eb4f580c 2414(defun range-upper (range)
2415 (adjustment-upper (range-adjustment range)))
0d07716f 2416
eb4f580c 2417(defun (setf range-lower) (value range)
2418 (setf (adjustment-lower (range-adjustment range)) value))
0d07716f 2419
eb4f580c 2420(defun (setf range-upper) (value range)
2421 (setf (adjustment-upper (range-adjustment range)) value))
0d07716f 2422
eb4f580c 2423(defun range-page-increment (range)
2424 (adjustment-page-increment (range-adjustment range)))
0d07716f 2425
eb4f580c 2426(defun range-step-increment (range)
2427 (adjustment-step-increment (range-adjustment range)))
0d07716f 2428
eb4f580c 2429(defun (setf range-page-increment) (value range)
2430 (setf (adjustment-page-increment (range-adjustment range)) value))
0d07716f 2431
eb4f580c 2432(defun (setf range-step-increment) (value range)
2433 (setf (adjustment-step-increment (range-adjustment range)) value))
0d07716f 2434
eb4f580c 2435(defbinding range-set-range () nil
2afcd8bd 2436 (range range)
eb4f580c 2437 (lower double-float)
2438 (upper double-float))
0d07716f 2439
eb4f580c 2440(defbinding range-set-increments () nil
2afcd8bd 2441 (range range)
eb4f580c 2442 (step double-float)
2443 (page double-float))
0d07716f 2444
0d07716f 2445
2afcd8bd 2446;;; Scale
0d07716f 2447
49043b9a 2448(defbinding scale-get-layout-offsets () nil
2449 (scale scale)
2450 (x int :out)
2451 (y int :out))
0d07716f 2452
0d07716f 2453
2afcd8bd 2454;;; Progress bar
0d07716f 2455
a60bd055 2456(defbinding progress-bar-pulse () nil
2afcd8bd 2457 (progress-bar progress-bar))
0d07716f 2458
2459
362f1795 2460;;; Size group
2461
2462(defmethod initialize-instance ((size-group size-group) &rest initargs
2463 &key widget widgets)
2464 (declare (ignore widget widgets))
2465 (prog1
2466 (call-next-method)
2467 (initial-add size-group #'size-group-add-widget
2468 initargs :widget :widgets)))
2469
2470
2471(defbinding size-group-add-widget () nil
2472 (size-group size-group)
2473 (widget widget))
2474
2475(defbinding size-group-remove-widget () nil
2476 (size-group size-group)
2477 (widget widget))
2478
0d07716f 2479
378b3c5f 2480;;; Stock items
2481
99821988 2482(defbinding %stock-item-copy () pointer
2483 (location pointer))
2484
2485(defbinding %stock-item-free () nil
2486 (location pointer))
378b3c5f 2487
99821988 2488(defbinding stock-add (stock-item) nil
2489 (stock-item stock-item)
2490 (1 unsigned-int))
2491
2492(defbinding stock-list-ids () (gslist string))
2493
2494(defbinding %stock-lookup () boolean
2495 (stock-id string)
2496 (location pointer))
2497
2498(defun stock-lookup (stock-id)
f957f519 2499 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
66984e02 2500 (when (%stock-lookup stock-id stock-item)
2501 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
0d07716f 2502
f957f519 2503#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
66984e02 2504(progn
2505 (define-callback-marshal %stock-translate-callback string ((path string)))
2506
2507 (defbinding (stock-set-translate-function "gtk_stock_set_translate_func")
2508 (domain function) nil
2509 (domain string)
2510 (%stock-translate-callback callback)
2511 ((register-callback-function function) unsigned-int)
2512 (user-data-destroy-callback callback)))
2513
ff1b3ff2 2514
2515;;; Tooltip
2516
2517;; #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2518;; (progn
2519;; (defbinding %tooltip-set-markup () nil
2520;; tooltip
2521;; (markup string))
2522
2523;; (defbinding %tooltip-set-text () nil
2524;; tooltip
2525;; (text string))
2526
2527;; (defbinding %tooltip-set-icon () nil
2528;; tooltip
2529;; (icon gdk:pixbuf))
2530
2531;; (defbinding %tooltip-set-from-stock-icon () nil
2532;; tooltip
2533;; (stock-id string)
2534;; icon-size)
2535
2536;; (defbinding %tooltip-set-custom () nil
2537;; tooltip
2538;; widget)
2539
2540;; (defun tooltip-set (tooltip value &key (markup t) (icon-size :button))
2541;; (etypecase value
2542;; (string (if markup
2543;; (tooltip-set-markup tooltip value)
2544;; (tooltip-set-text tooltip value)))
2545;; (pixbuf (tooltip-set-icon tooltip value))
2546;; (keyword (tooltip-set-icon-from-stock tooltip value icon-size))
2547
66984e02 2548
0d07716f 2549
ff1b3ff2 2550;;; Tooltips
2551
2552;; GtkTooltips has been deprecated in favor of the new tooltip API
2553;; introduced in in GTK+ 2.12
0d07716f 2554
a60bd055 2555(defbinding tooltips-enable () nil
2afcd8bd 2556 (tooltips tooltips))
0d07716f 2557
a60bd055 2558(defbinding tooltips-disable () nil
2afcd8bd 2559 (tooltips tooltips))
0d07716f 2560
dd392521 2561(defun (setf tooltips-enabled-p) (enable tooltips)
2562 (if enable
2563 (tooltips-enable tooltips)
2564 (tooltips-disable tooltips)))
2565
a60bd055 2566(defbinding tooltips-set-tip () nil
2afcd8bd 2567 (tooltips tooltips)
2568 (widget widget)
2569 (tip-text string)
2570 (tip-private string))
0d07716f 2571
14eaa563 2572(defbinding tooltips-data-get () tooltips-data
2573 (widget widget))
2574
a60bd055 2575(defbinding tooltips-force-window () nil
2afcd8bd 2576 (tooltips tooltips))
0d07716f 2577
14eaa563 2578(defbinding tooltips-get-info-from-tip-window () boolean
2579 (tip-window window)
2580 (tooltips tooltips :out)
2581 (current-widget widget :out))
0d07716f 2582
2583
e69138cc 2584;;; Resource Files
0d07716f 2585
17163f4e 2586(defbinding rc-get-style () style
2587 (widget widget))
2588
2589(defbinding rc-get-style-by-paths (&key path class-path class) style
2590 (path (or null string))
2591 (class-path (or null string))
2592 (class gtype))
0d07716f 2593
17163f4e 2594(defbinding rc-parse () nil
2595 (filename pathname))
0d07716f 2596
a60bd055 2597(defbinding rc-parse-string () nil
2afcd8bd 2598 (rc-string string))
0d07716f 2599
17163f4e 2600(defbinding %rc-reparse-all () boolean)
0d07716f 2601
17163f4e 2602(defbinding %rc-reparse-all-for-settings () boolean
2603 (settings settings)
2604 (force-load-p boolean))
2605
2606(defun rc-reparse-all (&optional setting force-load-p)
2607 (if setting
2608 (%rc-reparse-all-for-settings setting force-load-p)
2609 (%rc-reparse-all)))
2610
2611(defbinding rc-reset-styles () nil
2612 (settings settings))
2613
2614(defbinding rc-add-default-file () nil
2615 (filename pathname))
2616
2617(defbinding rc-get-default-files ()
2618 (copy-of (null-terminated-vector (copy-of string))))
2619
2620(defbinding rc-get-module-dir () string)
2621
2622(defbinding rc-get-im-module-path () string)
2623
2624(defbinding rc-get-im-module-file () string)
2625
2626(defbinding rc-get-theme-dir () string)
2627
2628
2629;;; Settings
2630
2631(defbinding (settings-get "gtk_settings_get_for_screen")
2632 (&optional (screen (gdk:display-get-default-screen))) settings
2633 (screen gdk:screen))
2634
2635
2636;;; Plug and Socket
2637
2638(defbinding socket-add-id () nil
2639 (socket socket)
2640 (id gdk:native-window))
2641
2642(defbinding %plug-new () pointer
2643 (id gdk:native-window))
2644
2645(defmethod allocate-foreign ((plug plug) &key id)
2646 (%plug-new (or id 0)))
14ac49ee 2647
2648
14ac49ee 2649;;; Link button
2650
2651#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
2652(progn
2653 (define-callback-marshal %link-button-uri-callback nil (link-button (link string)))
2654
2655 (defbinding link-button-set-uri-hook (function) pointer
2656 (%link-button-uri-callback callback)
2657 ((register-callback-function function) unsigned-int)
2658 (user-data-destroy-callback callback)))
ff1b3ff2 2659
2660
2661;;; Builder
2662
2663#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.12.0")
2664(progn
2665 (defmethod initialize-instance ((builder builder) &key interface
2666 (connect-signals t) (package *package*))
2667 (call-next-method)
2668 (etypecase interface
2669 (null)
2670 (string (builder-add-from-string builder interface))
2671 (pathname (builder-add-from-file builder interface)))
2672 (when connect-signals
2673 (builder-connect-signals builder package)))
2674
2675
2676 (defbinding builder-add-from-file () boolean
2677 builder
2678 pathname
2679 (nil gerror-signal :out))
2680
2681 (defbinding builder-add-from-string () boolean
2682 builder
2683 (buffer string)
2684 (-1 int) ; TODO: add gsize type
2685 (nil gerror-signal :out))
2686
2687 (defbinding builder-get-object () gobject
2688 builder
2689 (name string))
2690
2691 (defbinding builder-get-objects () (gslist gobject)
2692 builder)
2693
2694 (defun intern-with-package-prefix (name default-package)
2695 (let ((pos (position #\: name)))
2696 (if pos
2697 (intern
2698 (string-upcase (subseq name (1+ pos)))
2699 (string-upcase (subseq name 0 pos)))
2700 (intern (string-upcase name) default-package))))
2701
2702 (define-callback %builder-connect-function nil
2703 (builder (object gobject) (signal-name string) (handler-name string)
2704 (connect-object gobject) connect-flags (package user-data-id))
2705 (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)
2706 (signal-connect
2707 object signal-name
2708 (intern-with-package-prefix handler-name (find-user-data package))
2709 :object (or connect-object object) :after (find :after connect-flags)))
2710
2711 (defbinding %builder-connect-signals-full (builder package) nil
2712 builder
2713 (%builder-connect-function callback)
2714 (package user-data-id))
2715
2716 (defun builder-connect-signals (builder &optional (package *package*))
2717 (with-user-data (id package)
2718 (%builder-connect-signals-full builder id))))
2719