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