chiark / gitweb /
Added new binding ENTRY-COMPLETION-GET-COMPLETION-PREFIX
[clg] / gtk / gtk.lisp
CommitLineData
112ac1d3 1;; Common Lisp bindings for GTK+ v2.x
8ab0db90 2;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net>
560af5c5 3;;
112ac1d3 4;; Permission is hereby granted, free of charge, to any person obtaining
5;; a copy of this software and associated documentation files (the
6;; "Software"), to deal in the Software without restriction, including
7;; without limitation the rights to use, copy, modify, merge, publish,
8;; distribute, sublicense, and/or sell copies of the Software, and to
9;; permit persons to whom the Software is furnished to do so, subject to
10;; the following conditions:
560af5c5 11;;
112ac1d3 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
560af5c5 14;;
112ac1d3 15;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
560af5c5 22
3090d7d1 23;; $Id: gtk.lisp,v 1.87 2008-01-02 15:57:57 espen Exp $
560af5c5 24
25
26(in-package "GTK")
27
28;;; Gtk version
29
6bb23851 30(defbinding check-version () (copy-of string)
560af5c5 31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
34
bbaeff4b 35(defbinding query-version () nil
560af5c5 36 (major unsigned-int :out)
37 (minor unsigned-int :out)
38 (micro unsigned-int :out))
39
40(defun gtk-version ()
41 (multiple-value-bind (major minor micro)
42 (query-version)
43 (if (zerop micro)
44 (format nil "Gtk+ v~A.~A" major minor)
45 (format nil "Gtk+ v~A.~A.~A" major minor micro))))
46
c1c0746b 47(defun clg-version ()
904a03a9 48 "clg 0.93")
560af5c5 49
50
e3cdfeea 51;;;; Initalization and display handling
9adccb27 52
050f6c9f 53(defparameter *event-poll-interval* 10000) ; in microseconds
54
55
a5522de5 56(defbinding (gtk-init "gtk_parse_args") () boolean
9adccb27 57 "Initializes the library without opening the display."
58 (nil null)
59 (nil null))
60
050f6c9f 61(defun clg-init (&optional display multi-threading-p)
62 "Initializes the system and starts event handling."
9adccb27 63 (unless (gdk:display-get-default)
76fe8daf 64 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
65 (progn
66 #+sbcl(sb-int:set-floating-point-modes :traps nil)
67 #+cmu(ext:set-floating-point-modes :traps nil))
68
050f6c9f 69 (gdk:gdk-init)
70 (unless (gtk-init)
71 (error "Initialization of GTK+ failed."))
72
73 (if (not multi-threading-p)
74 (%init-async-event-handling display)
75 #+sb-thread(%init-multi-threaded-event-handling display)
76 #-sb-thread(error "Multi threading not supported on this platform")))
f5c99598 77 (gdk:ensure-display display t))
050f6c9f 78
8ab0db90 79(defun clg-init-with-threading (&optional display)
050f6c9f 80 (clg-init display t))
81
82
83#?(sbcl>= 1 0 6)
84;; A very minimal implementation of CLISP's socket-status
85(defun socket-status (socket seconds microseconds)
86 (sb-alien:with-alien ((read-fds (sb-alien:struct sb-unix:fd-set)))
87 (let ((fd (sb-sys:fd-stream-fd (car socket))))
88 (sb-unix:fd-zero read-fds)
89 (sb-unix:fd-set fd read-fds)
90
24a63041 91 (let ((num-fds-changed
92 (sb-unix:unix-fast-select
93 (1+ fd) (sb-alien:addr read-fds) nil nil
94 seconds microseconds)))
95 (unless (or (not num-fds-changed) (zerop num-fds-changed))
96 (if (peek-char nil (car socket) nil)
97 :input
98 :eof))))))
050f6c9f 99
100(defun %init-async-event-handling (display)
101 (let ((style #?(or (featurep :cmu) (sbcl< 1 0 6)) :fd-handler
102 #?-(or (featurep :cmu) (sbcl< 1 0 6)) nil))
103 (when (and
104 (find-package "SWANK")
105 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style)))
f1900d33 106 (error "When running clg in Slime, the communication style ~S must be used in combination with asynchronous event handling on this platform. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information." style)))
050f6c9f 107
108 #?(or (featurep :cmu) (sbcl< 1 0 6))
109 (progn
110 (signal-connect (gdk:display-manager) 'display-opened
111 #'(lambda (display)
112 (let ((fd (gdk:display-connection-number display)))
113 (unless (< fd 0)
114 (let ((handler (add-fd-handler
115 (gdk:display-connection-number display)
116 :input #'main-iterate-all)))
117 (signal-connect display 'closed
118 #'(lambda (is-error-p)
119 (declare (ignore is-error-p))
120 (remove-fd-handler handler))))))))
121 (setq *periodic-polling-function* #'main-iterate-all)
122 (setq *max-event-to-sec* 0)
123 (setq *max-event-to-usec* *event-poll-interval*))
124
125 #+(and clisp readline)
126 ;; Readline will call the event hook at most ten times per second
127 (setf readline:event-hook #'main-iterate-all)
128
129 #?-(or (featurep :cmu) (sbcl< 1 0 6))
130 ;; When running in Slime we need to hook into the Swank server
131 ;; to handle events asynchronously.
132 (if (find-package "SWANK")
133 (let ((read-from-emacs (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK")))
134 (stream (funcall (find-symbol "CONNECTION.SOCKET-IO" "SWANK") (symbol-value (find-symbol "*EMACS-CONNECTION*" "SWANK")))))
135 (setf (symbol-function (find-symbol "READ-FROM-EMACS" "SWANK"))
136 #'(lambda ()
137 (loop
138 (case (socket-status (cons stream :input) 0 *event-poll-interval*)
139 ((:input :eof) (return (funcall read-from-emacs)))
140 (otherwise (main-iterate-all)))))))
141 #-(and clisp readline)
142 (warn "Asynchronous event handling not supported on this platform. An explicit main loop has to be started."))
143
144 (gdk:display-open display))
145
146#+sb-thread
147(progn
148 (defvar *main-thread* nil)
149
150 ;; Hopefully, when threading support is added to the Win32 port of
151 ;; SBCL in the future, this will work just out of the box.
152 #+win32
153 (let ((done (sb-thread:make-waitqueue))
154 (functions ())
155 (results ()))
156
157 ;; In Win32 all GDK calls have to be made from the main loop
158 ;; thread, so we add a timeout function which will poll for code and
159 ;; execute it.
160
161 (defun funcall-in-main (function)
162 (if (or
163 (not *main-thread*)
164 (eq sb-thread:*current-thread* *main-thread*))
165 (funcall function)
166 (gdk:with-global-lock
167 (push function functions)
168 (sb-thread:condition-wait done gdk:*global-lock*)
169 (pop results))))
170
171 ;; Will lock REPL on error, need to be fixed!
172 (defun %funcall-in-main-poll ()
173 (when functions
174 (loop
175 for n from 0
176 while functions
177 do (push (funcall (pop functions)) results)
178 finally (sb-thread:condition-notify done n)))
179 t))
180
181 (defmacro within-main-loop (&body body)
182 #-win32 `(gdk:with-global-lock ,@body)
183 #+win32 `(funcall-in-main #'(lambda () ,@body)))
184
185 (defun %init-multi-threaded-event-handling (display)
186 (when (and
187 (find-package "SWANK")
188 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) :spawn)))
189 (error "When running clg in Slime, the communication style :spawn must be used in combination with multi threaded event handling. See the README file and <http://common-lisp.net/project/slime/doc/html/slime_45.html> for more information."))
b808fe1b 190 (gdk:threads-init)
050f6c9f 191 (let ((main-running (sb-thread:make-waitqueue)))
192 (gdk:with-global-lock
193 (setf *main-thread*
194 (sb-thread:make-thread
195 #'(lambda ()
050f6c9f 196 (gdk:with-global-lock
197 (gdk:display-open display)
198 #+win32(gdk:timeout-add-with-lock (/ *event-poll-interval* 1000)
199 #'%funcall-in-main-poll)
200 (sb-thread:condition-notify main-running)
201 (main)))
202 :name "gtk event loop"))
203 (sb-thread:condition-wait main-running gdk:*global-lock*)))
204
205 ;; We need to hook into the Swank server to protect calls to GDK properly.
206 ;; This will *only* protect code entered directly in the REPL.
207 (when (find-package "SWANK")
f1900d33 208 (let ((repl-eval-hook (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
209 (if repl-eval-hook
210 (push #'(lambda (form)
211 (within-main-loop (eval form)))
212 (symbol-value (find-symbol "*SLIME-REPL-EVAL-HOOKS*" "SWANK")))
213 (warn "Your version of Slime does not have *SLIME-REPL-EVAL-HOOKS* so all calls to Gtk+ functions have to be explicit protected by wrapping them in a WITHIN-MAIN-LOOP form"))))))
050f6c9f 214
215#-sb-thread
216(defmacro within-main-loop (&body body)
217 `(progn ,@body))
76fe8daf 218
9adccb27 219
18b84c80 220
db85b082 221;;; Generic functions
222
223(defgeneric add-to-radio-group (item1 item2))
224(defgeneric activate-radio-widget (item))
225(defgeneric (setf tool-item-tip-text) (tip-text tool-item))
226(defgeneric (setf tool-item-tip-private) (tip-private tool-item))
227
228
9adccb27 229
667a112b 230;;; Misc
231
232(defbinding grab-add () nil
233 (widget widget))
234
7abdba43 235(defbinding grab-get-current () widget)
667a112b 236
237(defbinding grab-remove () nil
238 (widget widget))
239
c1c0746b 240(defbinding get-default-language () (copy-of pango:language))
241
667a112b 242
647c99e5 243;;; About dialog
244
8ab0db90 245#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
647c99e5 246(progn
56ccd5b7 247 (define-callback-marshal %about-dialog-activate-link-callback nil
248 (about-dialog (link string)))
647c99e5 249
250 (defbinding about-dialog-set-email-hook (function) nil
56ccd5b7 251 (%about-dialog-activate-link-callback callback)
647c99e5 252 ((register-callback-function function) unsigned-int)
56ccd5b7 253 (user-data-destroy-callback callback))
647c99e5 254
255 (defbinding about-dialog-set-url-hook (function) nil
56ccd5b7 256 (%about-dialog-activate-link-callback callback)
647c99e5 257 ((register-callback-function function) unsigned-int)
56ccd5b7 258 (user-data-destroy-callback callback)))
647c99e5 259
260
0f476ab5 261;;; Acccel group
560af5c5 262
31700e82 263(defbinding %accel-group-connect () nil
264 (accel-group accel-group)
265 (key unsigned-int)
266 (modifiers gdk:modifier-type)
267 (flags accel-flags)
268 (gclosure gclosure))
269
270(defun accel-group-connect (group accelerator function &optional flags)
eacab64f 271 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 272 (let ((gclosure (make-callback-closure function)))
273 (%accel-group-connect group key modifiers flags gclosure)
274 gclosure)))
275
276(defbinding accel-group-connect-by-path (group path function) nil
277 (group accel-group)
278 (path string)
8ab0db90 279 ((make-callback-closure function) gclosure :in/return))
31700e82 280
281(defbinding %accel-group-disconnect (group gclosure) boolean
282 (group accel-group)
283 (gclosure gclosure))
284
285(defbinding %accel-group-disconnect-key () boolean
286 (group accel-group)
287 (key unsigned-int)
288 (modifiers gdk:modifier-type))
289
290(defun accel-group-disconnect (group accelerator)
291 (etypecase accelerator
292 (gclosure (%accel-group-disconnect group accelerator))
293 (string
eacab64f 294 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 295 (%accel-group-disconnect-key group key modifiers)))))
296
eacab64f 297(defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
298 (accel-group accel-group)
299 (key unsigned-int)
300 (modifiers gdk:modifier-type)
301 (n int :out))
302
303(defun accel-group-query (accel-group accelerator)
304 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
305 (%accel-group-query accel-group key modifiers)))
306
307(defbinding %accel-group-activate () boolean
308 (accel-group accel-group)
309 (acceleratable gobject)
310 (key unsigned-int)
311 (modifiers gdk:modifier-type))
312
313(defun accel-group-activate (accel-group acceleratable accelerator)
314 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
315 (%accel-group-activate accel-group acceleratable key modifiers)))
316
31700e82 317(defbinding accel-group-lock () nil
318 (accel-group accel-group))
319
320(defbinding accel-group-unlock () nil
321 (accel-group accel-group))
322
eacab64f 323(defbinding accel-group-from-accel-closure () accel-group
324 (closure gclosure))
325
31700e82 326(defbinding %accel-groups-activate () boolean
327 (object gobject)
328 (key unsigned-int)
329 (modifiers gdk:modifier-type))
330
331(defun accel-groups-activate (object accelerator)
eacab64f 332 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 333 (%accel-groups-activate object key modifiers)))
334
eba2d996 335(defbinding accel-groups-from-object () (gslist accel-group)
31700e82 336 (object gobject))
337
73572c12 338(defbinding accelerator-valid-p (key &optional modifiers) boolean
31700e82 339 (key unsigned-int)
340 (modifiers gdk:modifier-type))
341
342(defbinding %accelerator-parse () nil
343 (accelerator string)
344 (key unsigned-int :out)
345 (modifiers gdk:modifier-type :out))
346
eacab64f 347(defgeneric parse-accelerator (accelerator))
348
349(defmethod parse-accelerator ((accelerator string))
31700e82 350 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
351 (if (zerop key)
352 (error "Invalid accelerator: ~A" accelerator)
353 (values key modifiers))))
354
eacab64f 355(defmethod parse-accelerator ((accelerator cons))
356 (destructuring-bind (key modifiers) accelerator
357 (values
358 (etypecase key
359 (integer key)
360 (string
361 (or
362 (gdk:keyval-from-name key)
363 (error "Invalid key name: ~A" key)))
364 (character (parse-accelerator key)))
365 modifiers)))
366
367(defmethod parse-accelerator ((key integer))
368 key)
369
370(defmethod parse-accelerator ((key character))
371 (or
372 (gdk:keyval-from-name (string key))
373 (error "Invalid key name: ~A" key)))
374
375
31700e82 376(defbinding accelerator-name () string
377 (key unsigned-int)
378 (modifiers gdk:modifier-type))
379
8ab0db90 380#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
31700e82 381(defbinding accelerator-get-label () string
382 (key unsigned-int)
383 (modifiers gdk:modifier-type))
384
385(defbinding %accelerator-set-default-mod-mask () nil
386 (default-modifiers gdk:modifier-type))
387
388(defun (setf accelerator-default-modifier-mask) (default-modifiers)
389 (%accelerator-set-default-mod-mask default-modifiers))
390
391(defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
560af5c5 392
1047e159 393
560af5c5 394;;; Acccel label
395
eacab64f 396(defbinding accel-label-get-accel-width () unsigned-int
397 (accel-label accel-label))
398
bbaeff4b 399(defbinding accel-label-refetch () boolean
560af5c5 400 (accel-label accel-label))
401
402
31700e82 403
404;;; Accel map
405
406(defbinding %accel-map-add-entry () nil
407 (path string)
408 (key unsigned-int)
409 (modifiers gdk:modifier-type))
410
411(defun accel-map-add-entry (path accelerator)
eacab64f 412 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 413 (%accel-map-add-entry path key modifiers)))
414
eacab64f 415(defbinding %accel-map-lookup-entry () boolean
31700e82 416 (path string)
8ab0db90 417 ((make-instance 'accel-key) accel-key :in/return))
eacab64f 418
419(defun accel-map-lookup-entry (path)
420 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
421 (when found-p
422 (values
423 (slot-value accel-key 'key)
424 (slot-value accel-key 'modifiers)
425 (slot-value accel-key 'flags)))))
31700e82 426
427(defbinding %accel-map-change-entry () boolean
428 (path string)
429 (key unsigned-int)
430 (modifiers gdk:modifier-type)
431 (replace boolean))
432
433(defun accel-map-change-entry (path accelerator &optional replace)
eacab64f 434 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 435 (%accel-map-change-entry path key modifiers replace)))
436
437(defbinding accel-map-load () nil
438 (filename pathname))
439
440(defbinding accel-map-save () nil
441 (filename pathname))
442
56ccd5b7 443(define-callback-marshal %accel-map-foreach-callback nil
444 ((accel-path string) (key unsigned-int)
445 (modifiers gdk:modifier-type) (changed boolean)) :callback-id :first)
eacab64f 446
447(defbinding %accel-map-foreach (callback-id) nil
448 (callback-id unsigned-int)
56ccd5b7 449 (%accel-map-foreach-callback callback))
eacab64f 450
451(defbinding %accel-map-foreach-unfiltered (callback-id) nil
452 (callback-id unsigned-int)
56ccd5b7 453 (%accel-map-foreach-callback callback))
eacab64f 454
455(defun accel-map-foreach (function &optional (filter-p t))
456 (with-callback-function (id function)
457 (if filter-p
458 (%accel-map-foreach id)
459 (%accel-map-foreach-unfiltered id))))
460
461(defbinding accel-map-add-filter () nil
462 (filter string))
463
31700e82 464(defbinding accel-map-get () accel-map)
465
466(defbinding accel-map-lock-path () nil
467 (path string))
468
469(defbinding accel-map-unlock-path () nil
470 (path string))
471
472
473
eacab64f 474;;; Accessibility
d76e9fca 475
476(defbinding accessible-connect-widget-destroyed () nil
477 (accessible accessible))
478
479
0f476ab5 480;;; Adjustment
560af5c5 481
d76e9fca 482(defmethod initialize-instance ((adjustment adjustment) &key value)
1047e159 483 (prog1
484 (call-next-method)
485 ;; we need to make sure that the value is set last, otherwise it
d76e9fca 486 ;; may be outside current limits and ignored
1047e159 487 (when value
488 (setf (slot-value adjustment 'value) value))))
489
490
0f476ab5 491(defbinding adjustment-changed () nil
492 (adjustment adjustment))
493
494(defbinding adjustment-value-changed () nil
495 (adjustment adjustment))
496
497(defbinding adjustment-clamp-page () nil
498 (adjustment adjustment)
499 (lower single-float)
500 (upper single-float))
560af5c5 501
0f476ab5 502
68f519e0 503;;; Alignment
504
505(defbinding alignment-set () nil
506 (alognment alignment)
507 (x-align single-float)
508 (y-align single-float)
509 (x-scale single-float)
510 (y-scale single-float))
511
512(defbinding alignment-get-padding () nil
513 (alognment alignment)
514 (top unsigned-int :out)
515 (bottom unsigned-int :out)
516 (left unsigned-int :out)
517 (right unsigned-int :out))
518
519(defbinding alignment-set-padding () nil
520 (alognment alignment)
521 (top unsigned-int)
522 (bottom unsigned-int)
523 (left unsigned-int)
524 (right unsigned-int))
525
526
7d2f9e31 527;;; Assistant
528
529#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0")
530(progn
531 (defbinding assistant-get-nth-page () widget
532 (assistant assistant)
533 (page-num int))
534
535 (defbinding %assistant-insert-page () int
536 (assistant assistant)
537 (page widget)
538 (pos int))
539
540 (defun assistant-insert-page (assistant page position &rest child-args)
541 (let ((pos (case position
542 (:first 0)
543 (:last -1)
544 (t position))))
545 (prog1
546 (%assistant-insert-page assistant page pos)
547 (init-child-slots assistant page child-args))))
548
549 (defun assistant-append-page (assistant page &rest child-args)
550 (apply #'assistant-insert-page assistant page :last child-args))
551
552 (defun assistant-prepend-page (assistant page &rest child-args)
553 (apply #'assistant-insert-page assistant page :first child-args))
554
555 (define-callback-marshal %assistant-page-func-callback int
556 ((current-page int)))
557
a5bc508c 558 (defbinding assistant-set-forward-page-func (assistant function) nil
7d2f9e31 559 (assistant assistant)
560 (%assistant-page-func-callback callback)
561 ((register-callback-function function) pointer-data)
562 (user-data-destroy-callback callback))
563
564 (defbinding assistant-add-action-widget () nil
565 (assistant assistant)
566 (child widget))
567
568 (defbinding assistant-remove-action-widget () nil
569 (assistant assistant)
570 (child widget))
571
572 (defbinding assistant-update-buttons-state () nil
573 (assistant assistant)))
574
575
576
0f476ab5 577;;; Aspect frame
578
579
580;;; Bin
560af5c5 581
582(defun (setf bin-child) (child bin)
0f476ab5 583 (when-bind (current-child (bin-child bin))
584 (container-remove bin current-child))
560af5c5 585 (container-add bin child)
586 child)
587
4c371500 588(defmethod compute-signal-function ((bin bin) signal function object args)
14c94516 589 (declare (ignore signal))
590 (if (eq object :child)
4c371500 591 #'(lambda (&rest emission-args)
592 (apply function (bin-child bin) (nconc (rest emission-args) args)))
cb4bf772 593 (call-next-method)))
0f476ab5 594
595
596;;; Box
597
598(defbinding box-pack-start () nil
599 (box box)
600 (child widget)
601 (expand boolean)
602 (fill boolean)
603 (padding unsigned-int))
604
605(defbinding box-pack-end () nil
606 (box box)
607 (child widget)
608 (expand boolean)
609 (fill boolean)
610 (padding unsigned-int))
611
d76e9fca 612(defun box-pack (box child &key end (expand t) (fill t) (padding 0))
1a1949c7 613 (if end
f5b67f2b 614 (box-pack-end box child expand fill padding)
615 (box-pack-start box child expand fill padding)))
0f476ab5 616
617(defbinding box-reorder-child () nil
618 (box box)
619 (child widget)
620 (position int))
621
622(defbinding box-query-child-packing () nil
623 (box box)
624 (child widget)
625 (expand boolean :out)
626 (fill boolean :out)
627 (padding unsigned-int :out)
628 (pack-type pack-type :out))
629
630(defbinding box-set-child-packing () nil
631 (box box)
632 (child widget)
633 (expand boolean)
634 (fill boolean)
635 (padding unsigned-int)
636 (pack-type pack-type))
637
638
639
560af5c5 640;;; Button
641
d76e9fca 642(defmethod initialize-instance ((button button) &rest initargs &key stock)
643 (if stock
8ab0db90 644 (apply #'call-next-method button
645 :label stock :use-stock t :use-underline t initargs)
d76e9fca 646 (call-next-method)))
647
648
bbaeff4b 649(defbinding button-pressed () nil
560af5c5 650 (button button))
651
0f476ab5 652(defbinding button-released () nil
653 (button button))
654
655(defbinding button-clicked () nil
656 (button button))
657
658(defbinding button-enter () nil
659 (button button))
660
661(defbinding button-leave () nil
662 (button button))
663
664
665
666;;; Calendar
667
668(defbinding calendar-select-month () int
669 (calendar calendar)
670 (month unsigned-int)
671 (year unsigned-int))
672
673(defbinding calendar-select-day () nil
674 (calendar calendar)
675 (day unsigned-int))
676
677(defbinding calendar-mark-day () int
678 (calendar calendar)
679 (day unsigned-int))
680
681(defbinding calendar-unmark-day () int
682 (calendar calendar)
683 (day unsigned-int))
684
685(defbinding calendar-clear-marks () nil
686 (calendar calendar))
687
d76e9fca 688(defbinding calendar-get-date () nil
0f476ab5 689 (calendar calendar)
690 (year unsigned-int :out)
691 (month unsigned-int :out)
692 (day unsigned-int :out))
693
694(defbinding calendar-freeze () nil
695 (calendar calendar))
696
697(defbinding calendar-thaw () nil
698 (calendar calendar))
699
700
0f476ab5 701;;; Check menu item
702
703(defbinding check-menu-item-toggled () nil
704 (check-menu-item check-menu-item))
705
706
0f476ab5 707;;; Color selection
708
709(defbinding (color-selection-is-adjusting-p
710 "gtk_color_selection_is_adjusting") () boolean
711 (colorsel color-selection))
712
713
714
715;;; Color selection dialog -- no functions
716
717
718
1a1949c7 719;;;; Combo Box
0f476ab5 720
d76e9fca 721(defmethod initialize-instance ((combo-box combo-box) &rest initargs
722 &key model content active)
723 (remf initargs :active)
724 (if model
725 (apply #'call-next-method combo-box initargs)
726 (progn
727 (apply #'call-next-method combo-box
728 :model (make-instance 'list-store :column-types '(string))
729 initargs)
730 (unless (typep combo-box 'combo-box-entry)
731 (let ((cell (make-instance 'cell-renderer-text)))
732 (cell-layout-pack combo-box cell :expand t)
733 (cell-layout-add-attribute combo-box cell :text 0)))))
734 (when content
735 (mapc #'(lambda (text)
736 (combo-box-append-text combo-box text))
737 content))
738 (when active
739 (setf (combo-box-active combo-box) active)))
740
1a1949c7 741
742;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
743;; (when active
744;; (signal-emit combo-box 'changed)))
745
746(defbinding combo-box-append-text () nil
747 (combo-box combo-box)
748 (text string))
749
750(defbinding combo-box-insert-text () nil
751 (combo-box combo-box)
752 (position int)
753 (text string))
754
755(defbinding combo-box-prepend-text () nil
756 (combo-box combo-box)
757 (text string))
758
8ab0db90 759#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1a1949c7 760(defbinding combo-box-get-active-text () string
761 (combo-box combo-box))
0f476ab5 762
1a1949c7 763(defbinding combo-box-popup () nil
764 (combo-box combo-box))
0f476ab5 765
1a1949c7 766(defbinding combo-box-popdown () nil
767 (combo-box combo-box))
768
769
770
771;;;; Combo Box Entry
772
d76e9fca 773(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
1a1949c7 774 (call-next-method)
775 (unless model
776 (setf (combo-box-entry-text-column combo-box-entry) 0)))
0f476ab5 777
778
48da76bf 779;;;; Dialog
0f476ab5 780
c49be931 781(defmethod shared-initialize ((dialog dialog) names &rest initargs
782 &key button buttons)
8ab0db90 783 (declare (ignore names button buttons))
c49be931 784 (prog1
785 (call-next-method)
786 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
48da76bf 787
0f476ab5 788
14c94516 789(defun dialog-response-id (dialog response &optional create-p error-p)
790 "Returns a numeric response id"
791 (if (typep response 'response-type)
792 (response-type-to-int response)
8ab0db90 793 (let ((responses (user-data dialog 'responses)))
14c94516 794 (cond
795 ((and responses (position response responses :test #'equal)))
796 (create-p
1047e159 797 (cond
14c94516 798 (responses
799 (vector-push-extend response responses)
800 (1- (length responses)))
1047e159 801 (t
802 (setf
8ab0db90 803 (user-data dialog 'responses)
14c94516 804 (make-array 1 :adjustable t :fill-pointer t
805 :initial-element response))
1047e159 806 0)))
807 (error-p
14c94516 808 (error "Invalid response: ~A" response))))))
0f476ab5 809
14c94516 810(defun dialog-find-response (dialog id)
811 "Finds a symbolic response given a numeric id"
d314213c 812 (cond
813 ((not (numberp id)) id)
814 ((< id 0) (int-to-response-type id))
815 ((aref (user-data dialog 'responses) id))))
14c94516 816
817
818(defmethod compute-signal-id ((dialog dialog) signal)
819 (if (dialog-response-id dialog signal)
820 (ensure-signal-id 'response dialog)
821 (call-next-method)))
822
4c371500 823(defmethod compute-signal-function ((dialog dialog) signal function object args)
824 (declare (ignore function object args))
14c94516 825 (let ((callback (call-next-method))
826 (id (dialog-response-id dialog signal)))
d314213c 827 (cond
828 (id
829 #'(lambda (dialog response)
830 (when (= response id)
831 (funcall callback dialog))))
6c4f81fc 832 ((string-equal signal "response")
d314213c 833 #'(lambda (dialog response)
834 (funcall callback dialog (dialog-find-response dialog response))))
835 (callback))))
0f476ab5 836
48da76bf 837(defbinding dialog-run () nil
838 (dialog dialog))
0f476ab5 839
14c94516 840(defbinding dialog-response (dialog response) nil
0f476ab5 841 (dialog dialog)
14c94516 842 ((dialog-response-id dialog response nil t) int))
0f476ab5 843
844
845(defbinding %dialog-add-button () button
846 (dialog dialog)
847 (text string)
14c94516 848 (response-id int))
0f476ab5 849
1047e159 850(defun dialog-add-button (dialog label &optional (response label)
851 &key default object after)
40b2615c 852 "Adds a button to the dialog."
14c94516 853 (let* ((signal (if (functionp response)
854 label
855 response))
856 (id (dialog-response-id dialog signal t))
857 (button (%dialog-add-button dialog label id)))
1047e159 858 (when (functionp response)
14c94516 859 (signal-connect dialog signal response :object object :after after))
1047e159 860 (when default
14c94516 861 (%dialog-set-default-response dialog id))
0f476ab5 862 button))
863
864
14c94516 865(defbinding %dialog-add-action-widget () nil
0f476ab5 866 (dialog dialog)
867 (action-widget widget)
14c94516 868 (response-id int))
0f476ab5 869
1047e159 870(defun dialog-add-action-widget (dialog widget &optional (response widget)
871 &key default object after)
14c94516 872 (let* ((signal (if (functionp response)
873 widget
874 response))
875 (id (dialog-response-id dialog signal t)))
876 (unless (widget-hidden-p widget)
877 (widget-show widget))
878 (%dialog-add-action-widget dialog widget id)
1047e159 879 (when (functionp response)
14c94516 880 (signal-connect dialog signal response :object object :after after))
1047e159 881 (when default
7defde44 882 (setf (widget-can-default-p widget) t)
14c94516 883 (%dialog-set-default-response dialog id))
0f476ab5 884 widget))
0f476ab5 885
0f476ab5 886
48da76bf 887(defbinding %dialog-set-default-response () nil
888 (dialog dialog)
14c94516 889 (response-id int))
0f476ab5 890
14c94516 891(defun dialog-set-default-response (dialog response)
48da76bf 892 (%dialog-set-default-response
14c94516 893 dialog (dialog-response-id dialog response nil t)))
0f476ab5 894
14c94516 895(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
48da76bf 896 (dialog dialog)
14c94516 897 ((dialog-response-id dialog response nil t) int)
48da76bf 898 (sensitive boolean))
0f476ab5 899
8ab0db90 900#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
647c99e5 901(defbinding alternative-dialog-button-order-p (&optional screen) boolean
902 (screen (or null gdk:screen)))
40b2615c 903
8ab0db90 904#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
40b2615c 905(defbinding (dialog-set-alternative-button-order
5a87235c 906 "gtk_dialog_set_alternative_button_order_from_array")
907 (dialog new-order) nil
40b2615c 908 (dialog dialog)
909 ((length new-order) int)
14c94516 910 ((map 'vector #'(lambda (response)
911 (dialog-response-id dialog response nil t))
40b2615c 912 new-order) (vector int)))
0f476ab5 913
48da76bf 914
8ab0db90 915#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
bdc0e300 916(progn
917 (defbinding %dialog-get-response-for-widget () int
918 (dialog dialog)
919 (widget widget))
920
921 (defun dialog-get-response-for-widget (dialog widget)
922 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
923
924
48da76bf 925(defmethod container-add ((dialog dialog) (child widget) &rest args)
1047e159 926 (apply #'container-add (dialog-vbox dialog) child args))
48da76bf 927
14c94516 928
48da76bf 929(defmethod container-remove ((dialog dialog) (child widget))
1047e159 930 (container-remove (dialog-vbox dialog) child))
0f476ab5 931
48da76bf 932(defmethod container-children ((dialog dialog))
1047e159 933 (container-children (dialog-vbox dialog)))
48da76bf 934
935(defmethod (setf container-children) (children (dialog dialog))
1047e159 936 (setf (container-children (dialog-vbox dialog)) children))
560af5c5 937
560af5c5 938
e3cdfeea 939;;; Drawing Area
940
941(defun drawing-area-scroll (drawing-area dx dy)
942 (gdk:window-scroll (widget-window drawing-area) dx dy))
943
944
aaa6e6cb 945;;; Entry
560af5c5 946
aaa6e6cb 947(defbinding entry-get-layout-offsets () nil
948 (entry entry)
949 (x int :out)
950 (y int :out))
560af5c5 951
d76e9fca 952(defbinding entry-layout-index-to-text-index () int
953 (entry entry)
954 (layout-index int))
955
956(defbinding entry-text-index-to-layout-index () int
957 (entry entry)
958 (text-index int))
959
560af5c5 960
f45fd227 961;;; Entry Completion
962
56ccd5b7 963(define-callback-marshal %entry-completion-match-callback boolean
964 (entry-completion string tree-iter))
f45fd227 965
966(defbinding entry-completion-set-match-func (completion function) nil
967 (completion entry-completion)
56ccd5b7 968 (%entry-completion-match-callback callback)
f45fd227 969 ((register-callback-function function) unsigned-int)
56ccd5b7 970 (user-data-destroy-callback callback))
f45fd227 971
972(defbinding entry-completion-complete () nil
973 (completion entry-completion))
974
3090d7d1 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
8ab0db90 979#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
f45fd227 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
68f519e0 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
8ab0db90 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))
68f519e0 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
8ab0db90 1109#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
68f519e0 1110(defbinding file-filter-add-pixbuf-formats () nil
647c99e5 1111 (filter file-filter))
68f519e0 1112
56ccd5b7 1113(define-callback-marshal %file-filter-callback boolean (file-filter-info))
68f519e0 1114
73572c12 1115(defbinding file-filter-add-custom (filter needed function) nil
68f519e0 1116 (filter file-filter)
1117 (needed file-filter-flags)
56ccd5b7 1118 (%file-filter-callback callback)
68f519e0 1119 ((register-callback-function function) unsigned-int)
56ccd5b7 1120 (user-data-destroy-callback callback))
68f519e0 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
1047e159 1131;;; Image
1132
1133(defbinding image-set-from-file () nil
1134 (image image)
1135 (filename pathname))
1136
d76e9fca 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))))
1047e159 1152
cb4bf772 1153(defun create-image-widget (source &optional mask)
d76e9fca 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))))
1047e159 1160
8ab0db90 1161#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
bdc0e300 1162(defbinding image-clear () nil
1163 (image image))
1164
1165
1047e159 1166
d76e9fca 1167;;; Image menu item
1047e159 1168
d76e9fca 1169(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1170 (if (and image (not (typep image 'widget)))
cb4bf772 1171 (apply #'call-next-method item :image (create-image-widget image) initargs)
d76e9fca 1172 (call-next-method)))
1047e159 1173
d76e9fca 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))
cb4bf772 1179 (setf (image-menu-item-image item) (create-image-widget image)))
1047e159 1180
560af5c5 1181
0f476ab5 1182;;; Label
560af5c5 1183
881fe3c3 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
aaa6e6cb 1190(defbinding label-get-layout-offsets () nil
1047e159 1191 (label label)
aaa6e6cb 1192 (x int :out)
1193 (y int :out))
1194
0f476ab5 1195(defbinding label-select-region () nil
1196 (label label)
1197 (start int)
1198 (end int))
560af5c5 1199
1047e159 1200(defbinding label-get-selection-bounds () boolean
aaa6e6cb 1201 (label label)
1202 (start int :out)
1203 (end int :out))
f36ca6af 1204
560af5c5 1205
1206
1207;;; Radio button
1208
e5b416f0 1209(defbinding %radio-button-get-group () pointer
d520140e 1210 (radio-button radio-button))
1211
bbaeff4b 1212(defbinding %radio-button-set-group () nil
d520140e 1213 (radio-button radio-button)
1214 (group pointer))
560af5c5 1215
cb4bf772 1216(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
d520140e 1217 "Add BUTTON1 to the group which BUTTON2 belongs to."
1218 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1219
a5522de5 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
c78ef85c 1236(defgeneric add-activate-callback (action function &key object after))
1237
a5522de5 1238(defmethod add-activate-callback ((button radio-button) function &key object after)
1239 (%add-activate-callback button 'clicked function object after))
1240
d76e9fca 1241(defmethod initialize-instance ((button radio-button) &key group)
1242 (prog1
1243 (call-next-method)
1244 (when group
cb4bf772 1245 (add-to-radio-group button group))))
560af5c5 1246
1247
560af5c5 1248;;; Item
1249
bbaeff4b 1250(defbinding item-select () nil
560af5c5 1251 (item item))
1252
bbaeff4b 1253(defbinding item-deselect () nil
560af5c5 1254 (item item))
1255
bbaeff4b 1256(defbinding item-toggle () nil
560af5c5 1257 (item item))
1258
1259
1260
1261;;; Menu item
1262
d76e9fca 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
f36ca6af 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
d76e9fca 1273 :use-underline (menu-item-use-underline-p menu-item)
1274 :visible t :parent menu-item)
f36ca6af 1275 label)
560af5c5 1276
f5b67f2b 1277(defun menu-item-label (menu-item)
d76e9fca 1278 (when (and (slot-boundp menu-item 'child)
1279 (typep (bin-child menu-item) 'label))
1280 (label-label (bin-child menu-item))))
f5b67f2b 1281
d76e9fca 1282(defbinding menu-item-remove-submenu () nil
f36ca6af 1283 (menu-item menu-item))
560af5c5 1284
f5b67f2b 1285(defbinding menu-item-set-accel-path () nil
1286 (menu-item menu-item)
1287 (accel-path string))
1288
bbaeff4b 1289(defbinding menu-item-select () nil
f36ca6af 1290 (menu-item menu-item))
560af5c5 1291
bbaeff4b 1292(defbinding menu-item-deselect () nil
f36ca6af 1293 (menu-item menu-item))
560af5c5 1294
bbaeff4b 1295(defbinding menu-item-activate () nil
f36ca6af 1296 (menu-item menu-item))
560af5c5 1297
f5b67f2b 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
560af5c5 1306
d76e9fca 1307;;; Menu tool button
1308
8ab0db90 1309#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
647c99e5 1310(defbinding menu-tool-button-set-arrow-tooltip () nil
d76e9fca 1311 (menu-tool-button menu-tool-button)
1312 (tooltips tooltips)
1313 (tip-text string)
1314 (tip-private string))
1315
1316
f4267180 1317;;; Message dialog
1318
9176d301 1319(defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
d314213c 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
3c0ed403 1333 &key message-type buttons button text
8ab0db90 1334 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1335 secondary-text)
9176d301 1336 (declare (ignore names))
7a2e0799 1337 (when text
1338 (message-dialog-set-markup dialog text))
8ab0db90 1339 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
7a2e0799 1340 (when secondary-text
1341 (message-dialog-format-secondary-markup dialog secondary-text))
3c0ed403 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)))
d314213c 1349 (if (typep buttons 'buttons-type)
1350 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1351 (call-next-method)))
f4267180 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)
7a2e0799 1359 (nil null))
f4267180 1360
1361(defbinding message-dialog-set-markup () nil
1362 (message-dialog message-dialog)
1363 (markup string))
1364
8ab0db90 1365#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
f4267180 1366(defbinding message-dialog-format-secondary-text () nil
1367 (message-dialog message-dialog)
1368 (text string))
1369
8ab0db90 1370#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
f4267180 1371(defbinding message-dialog-format-secondary-markup () nil
1372 (message-dialog message-dialog)
1373 (markup string))
1374
1375
560af5c5 1376
f36ca6af 1377;;; Radio menu item
560af5c5 1378
e5b416f0 1379(defbinding %radio-menu-item-get-group () pointer
d520140e 1380 (radio-menu-item radio-menu-item))
1381
bbaeff4b 1382(defbinding %radio-menu-item-set-group () nil
d520140e 1383 (radio-menu-item radio-menu-item)
1384 (group pointer))
1385
a5522de5 1386(defmethod activate-radio-widget ((item radio-menu-item))
1387 (menu-item-activate item))
1388
cb4bf772 1389(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
d520140e 1390 "Add ITEM1 to the group which ITEM2 belongs to."
1391 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1392
a5522de5 1393(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1394 (%add-activate-callback item 'activate function object after))
1395
d76e9fca 1396(defmethod initialize-instance ((item radio-menu-item) &key group)
f5b67f2b 1397 (prog1
1398 (call-next-method)
d76e9fca 1399 (when group
cb4bf772 1400 (add-to-radio-group item group))))
1401
d520140e 1402
560af5c5 1403
d76e9fca 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
a5522de5 1413(defmethod activate-radio-widget ((button radio-tool-button))
1414 (signal-emit button 'clicked))
1415
cb4bf772 1416(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
d76e9fca 1417 "Add BUTTON1 to the group which BUTTON2 belongs to."
1418 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
a5522de5 1419(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1420 (%add-activate-callback button 'clicked function object after))
d76e9fca 1421
1422(defmethod initialize-instance ((button radio-tool-button) &key group)
1423 (prog1
1424 (call-next-method)
1425 (when group
cb4bf772 1426 (add-to-radio-group button group))))
1427
d76e9fca 1428
560af5c5 1429
aaa6e6cb 1430;;; Toggle button
1431
1432(defbinding toggle-button-toggled () nil
1433 (toggle-button toggle-button))
1434
1435
560af5c5 1436;;; Window
1437
c49be931 1438(defmethod initialize-instance ((window window) &rest initargs
050f6c9f 1439 &key display accel-group accel-groups)
c49be931 1440 (declare (ignore accel-group accel-groups))
1441 (prog1
050f6c9f 1442 (if display
1443 (apply #'call-next-method
f5c99598 1444 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
050f6c9f 1445 (call-next-method))
c49be931 1446 (initial-add window #'window-add-accel-group
1447 initargs :accel-group :accel-groups)))
73d58e01 1448
5a87235c 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"
8ab0db90 1457 (window-title window) (pointer-address (foreign-location window))))
5a87235c 1458 (call-next-method)))
73d58e01 1459
7625ebd8 1460(defbinding window-set-wmclass () nil
560af5c5 1461 (window window)
1462 (wmclass-name string)
1463 (wmclass-class string))
1464
bbaeff4b 1465(defbinding window-add-accel-group () nil
560af5c5 1466 (window window)
1467 (accel-group accel-group))
1468
bbaeff4b 1469(defbinding window-remove-accel-group () nil
560af5c5 1470 (window window)
1471 (accel-group accel-group))
1472
bbaeff4b 1473(defbinding window-activate-focus () int
560af5c5 1474 (window window))
1475
bbaeff4b 1476(defbinding window-activate-default () int
560af5c5 1477 (window window))
1478
7625ebd8 1479(defbinding window-set-default-size (window width height) int
560af5c5 1480 (window window)
7625ebd8 1481 ((or width -1) int)
1482 ((or height -1) int))
560af5c5 1483
4d16221f 1484(defbinding %window-set-geometry-hints () nil
1485 (window window)
d29387c6 1486 (widget (or widget null))
4d16221f 1487 (geometry gdk:geometry)
1488 (geometry-mask gdk:window-hints))
1489
d29387c6 1490(defun window-set-geometry-hints (window &key widget min-width min-height
4d16221f 1491 max-width max-height base-width base-height
d29387c6 1492 width-inc height-inc gravity
1493 aspect (min-aspect aspect) (max-aspect aspect))
4d16221f 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)
d29387c6 1504 :max-aspect (or max-aspect 0)))
4d16221f 1505 (mask ()))
d29387c6 1506 (when (or min-width min-height)
4d16221f 1507 (push :min-size mask))
d29387c6 1508 (when (or max-width max-height)
4d16221f 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))
d29387c6 1516 (when gravity
1517 (push :win-gravity mask)
1518 (setf (gdk:geometry-gravity geometry) gravity))
1519 (%window-set-geometry-hints window widget geometry mask)))
560af5c5 1520
73d58e01 1521(defbinding window-list-toplevels () (glist (copy-of window))
1522 "Returns a list of all existing toplevel windows.")
7625ebd8 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
4d16221f 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
8ab0db90 1547#?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
7625ebd8 1548(defbinding window-present () nil
1549 (window window))
1550
8ab0db90 1551#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
bdc0e300 1552(progn
1553 (defbinding %window-present () nil
1554 (window window))
1555
6e8bf4cf 1556 (defbinding %window-present-with-time () nil
bdc0e300 1557 (window window)
1558 (timespamp unsigned-int))
1559
1560 (defun window-present (window &optional timestamp)
1561 (if timestamp
6e8bf4cf 1562 (%window-present-with-time window timestamp)
bdc0e300 1563 (%window-present window))))
1564
7625ebd8 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
4d16221f 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
7625ebd8 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)
9adccb27 1602 (timestamp unsigned-int))
7625ebd8 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)
9adccb27 1609 (timestamp unsigned-int))
7625ebd8 1610
1611(defbinding window-set-frame-dimensions () nil
1612 (window window)
1613 (left int) (top int) (rigth int) (bottom int))
1614
7625ebd8 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
190c2bcf 1628(defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
7625ebd8 1629 (window window))
1630
7625ebd8 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
4d16221f 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
c78ef85c 1674(defgeneric (setf window-default-icon) (icon))
1675
4d16221f 1676(defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1677 (%window-set-default-icon icon)
1678 icon)
1679
c78ef85c 1680(defgeneric (setf window-group) (group window))
1681
4d16221f 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
7625ebd8 1713 (window window)
4d16221f 1714 (title string))
7625ebd8 1715
4d16221f 1716(defbinding decorated-window-move-resize-window () nil
1717 (window window)
1718 (x int)
1719 (y int)
1720 (width int)
1721 (heigth int))
7625ebd8 1722
1723
4d16221f 1724;;; Window group
560af5c5 1725
4d16221f 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)))
560af5c5 1733
560af5c5 1734
4d16221f 1735(defbinding window-group-add-window () nil
1736 (window-group window-group)
1737 (window window))
560af5c5 1738
4d16221f 1739(defbinding window-group-remove-window () nil
1740 (window-group window-group)
1741 (window window))
560af5c5 1742
1743
f36ca6af 1744;;; Scrolled window
560af5c5 1745
560af5c5 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
bbaeff4b 1750(defbinding scrolled-window-add-with-viewport () nil
560af5c5 1751 (scrolled-window scrolled-window)
1752 (child widget))
1753
7a2e0799 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))
d520140e 1760
560af5c5 1761
f36ca6af 1762;;; Statusbar
560af5c5 1763
d76e9fca 1764(defbinding statusbar-get-context-id () unsigned-int
f36ca6af 1765 (statusbar statusbar)
1766 (context-description string))
560af5c5 1767
bbaeff4b 1768(defbinding statusbar-push () unsigned-int
f36ca6af 1769 (statusbar statusbar)
1770 (context-id unsigned-int)
1771 (text string))
560af5c5 1772
bbaeff4b 1773(defbinding statusbar-pop () nil
f36ca6af 1774 (statusbar statusbar)
1775 (context-id unsigned-int))
560af5c5 1776
bbaeff4b 1777(defbinding statusbar-remove () nil
f36ca6af 1778 (statusbar statusbar)
1779 (context-id unsigned-int)
1780 (message-id unsigned-int))
560af5c5 1781
560af5c5 1782
1783
1784;;; Fixed
1785
bbaeff4b 1786(defbinding fixed-put () nil
f36ca6af 1787 (fixed fixed)
1788 (widget widget)
f5b67f2b 1789 (x int) (y int))
560af5c5 1790
bbaeff4b 1791(defbinding fixed-move () nil
f36ca6af 1792 (fixed fixed)
1793 (widget widget)
f5b67f2b 1794 (x int) (y int))
560af5c5 1795
1796
1797
d520140e 1798;;; Notebook
560af5c5 1799
68f519e0 1800(defun %ensure-notebook-position (notebook page)
f5b67f2b 1801 (etypecase page
68f519e0 1802 (position page)
f5b67f2b 1803 (widget (notebook-page-num notebook page t))))
1804
68f519e0 1805(defun %ensure-notebook-child (notebook position)
f5b67f2b 1806 (typecase position
1807 (widget position)
68f519e0 1808 (t (notebook-get-nth-page notebook position))))
f5b67f2b 1809
1810(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
8ab0db90 1811 (notebook position child &optional tab-label menu-label) nil
f36ca6af 1812 (notebook notebook)
1813 (child widget)
1814 ((if (stringp tab-label)
f5b67f2b 1815 (make-instance 'label :label tab-label)
8ab0db90 1816 tab-label) (or null widget))
f36ca6af 1817 ((if (stringp menu-label)
f5b67f2b 1818 (make-instance 'label :label menu-label)
f36ca6af 1819 menu-label) (or null widget))
68f519e0 1820 ((%ensure-notebook-position notebook position) position))
560af5c5 1821
8ab0db90 1822(defun notebook-append (notebook child &optional tab-label menu-label)
f5b67f2b 1823 (notebook-insert notebook :last child tab-label menu-label))
560af5c5 1824
8ab0db90 1825(defun notebook-prepend (notebook child &optional tab-label menu-label)
f5b67f2b 1826 (notebook-insert notebook :first child tab-label menu-label))
560af5c5 1827
f5b67f2b 1828(defbinding notebook-remove-page (notebook page) nil
f36ca6af 1829 (notebook notebook)
68f519e0 1830 ((%ensure-notebook-position notebook page) position))
560af5c5 1831
bbaeff4b 1832(defbinding %notebook-page-num () int
f36ca6af 1833 (notebook notebook)
1834 (child widget))
1835
f5b67f2b 1836(defun notebook-page-num (notebook child &optional error-p)
f36ca6af 1837 (let ((page-num (%notebook-page-num notebook child)))
1838 (if (= page-num -1)
f5b67f2b 1839 (when error-p
68f519e0 1840 (error "~A is not a page in ~A" child notebook))
f36ca6af 1841 page-num)))
1842
bbaeff4b 1843(defbinding notebook-next-page () nil
f36ca6af 1844 (notebook notebook))
560af5c5 1845
bbaeff4b 1846(defbinding notebook-prev-page () nil
f36ca6af 1847 (notebook notebook))
1848
f5b67f2b 1849(defbinding notebook-reorder-child (notebook child position) nil
1850 (notebook notebook)
1851 (child widget)
bdc0e300 1852 ((%ensure-notebook-position notebook position) int))
f5b67f2b 1853
bbaeff4b 1854(defbinding notebook-popup-enable () nil
f36ca6af 1855 (notebook notebook))
1856
bbaeff4b 1857(defbinding notebook-popup-disable () nil
f36ca6af 1858 (notebook notebook))
1859
68f519e0 1860(defbinding notebook-get-nth-page () widget
f5b67f2b 1861 (notebook notebook)
68f519e0 1862 (page position))
f5b67f2b 1863
68f519e0 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))))
f5b67f2b 1867
1868(defun (setf notebook-current-page) (page notebook)
8ab0db90 1869 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
f5b67f2b 1870
1047e159 1871(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1872 (notebook page) widget
1873 (notebook notebook)
68f519e0 1874 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1875
1047e159 1876(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
6bb23851 1877 (notebook page) (copy-of string)
1047e159 1878 (notebook notebook)
68f519e0 1879 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1880
1047e159 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)))
68f519e0 1890 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1891 widget))
f5b67f2b 1892
f5b67f2b 1893
1047e159 1894(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1895 (notebook page) widget
1896 (notebook notebook)
68f519e0 1897 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1898
1047e159 1899(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
6bb23851 1900 (notebook page) (copy-of string)
1047e159 1901 (notebook notebook)
68f519e0 1902 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1903
1047e159 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)))
68f519e0 1913 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1914 widget))
f5b67f2b 1915
1916
1917(defbinding notebook-query-tab-label-packing (notebook page) nil
f36ca6af 1918 (notebook notebook)
bdc0e300 1919 ((%ensure-notebook-child notebook page) widget)
f36ca6af 1920 (expand boolean :out)
1921 (fill boolean :out)
1922 (pack-type pack-type :out))
1923
f5b67f2b 1924(defbinding notebook-set-tab-label-packing
1925 (notebook page expand fill pack-type) nil
f36ca6af 1926 (notebook notebook)
bdc0e300 1927 ((%ensure-notebook-child notebook page) widget)
f36ca6af 1928 (expand boolean)
1929 (fill boolean)
1930 (pack-type pack-type))
1931
560af5c5 1932
1933
d520140e 1934;;; Paned
560af5c5 1935
bbaeff4b 1936(defbinding paned-pack1 () nil
d520140e 1937 (paned paned)
1938 (child widget)
1939 (resize boolean)
1940 (shrink boolean))
560af5c5 1941
bbaeff4b 1942(defbinding paned-pack2 () nil
d520140e 1943 (paned paned)
1944 (child widget)
1945 (resize boolean)
1946 (shrink boolean))
560af5c5 1947
560af5c5 1948
d520140e 1949;;; Layout
560af5c5 1950
bbaeff4b 1951(defbinding layout-put () nil
d520140e 1952 (layout layout)
68f519e0 1953 (child widget)
d520140e 1954 (x int)
1955 (y int))
560af5c5 1956
bbaeff4b 1957(defbinding layout-move () nil
d520140e 1958 (layout layout)
68f519e0 1959 (child widget)
d520140e 1960 (x int)
1961 (y int))
560af5c5 1962
68f519e0 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))
560af5c5 1972
1973
560af5c5 1974;;; Menu shell
1975
f5b67f2b 1976(defbinding menu-shell-insert (menu-shell menu-item position) nil
f36ca6af 1977 (menu-shell menu-shell)
1978 (menu-item menu-item)
f5b67f2b 1979 ((case position
1980 (:first 0)
1981 (:last -1)
1982 (t position)) int))
560af5c5 1983
f36ca6af 1984(defun menu-shell-append (menu-shell menu-item)
f5b67f2b 1985 (menu-shell-insert menu-shell menu-item :last))
560af5c5 1986
f36ca6af 1987(defun menu-shell-prepend (menu-shell menu-item)
f5b67f2b 1988 (menu-shell-insert menu-shell menu-item :fisrt))
560af5c5 1989
bbaeff4b 1990(defbinding menu-shell-deactivate () nil
f36ca6af 1991 (menu-shell menu-shell))
560af5c5 1992
bbaeff4b 1993(defbinding menu-shell-select-item () nil
f36ca6af 1994 (menu-shell menu-shell)
1995 (menu-item menu-item))
560af5c5 1996
d76e9fca 1997(defbinding menu-shell-select-first () nil
1998 (menu-shell menu-shell)
1999 (search-sensitive boolean))
2000
bbaeff4b 2001(defbinding menu-shell-deselect () nil
f36ca6af 2002 (menu-shell menu-shell))
560af5c5 2003
bbaeff4b 2004(defbinding menu-shell-activate-item () nil
f36ca6af 2005 (menu-shell menu-shell)
2006 (menu-item menu-item)
2007 (fore-deactivate boolean))
560af5c5 2008
d76e9fca 2009(defbinding menu-shell-cancel () nil
2010 (menu-shell menu-shell))
560af5c5 2011
2012
f5b67f2b 2013;;; Menu
560af5c5 2014
f5b67f2b 2015(defun %menu-position (menu child)
2016 (etypecase child
2017 (int child)
2018 (keyword (case child
2019 (:first 0)
2020 (:last -1)
1047e159 2021 (t (error "Invalid position keyword: ~A" child))))
f5b67f2b 2022 (widget (menu-child-position menu child))))
560af5c5 2023
2024
f5b67f2b 2025(defbinding menu-reorder-child (menu menu-item position) nil
2026 (menu menu)
2027 (menu-item menu-item)
2028 ((%menu-position menu position) int))
560af5c5 2029
d76e9fca 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
56ccd5b7 2038(define-callback-marshal %menu-position-callback nil
2039 (menu (x int) (y int) (push-in boolean)))
560af5c5 2040
f5b67f2b 2041(defbinding %menu-popup () nil
2042 (menu menu)
2043 (parent-menu-shell (or null menu-shell))
2044 (parent-menu-item (or null menu-item))
56ccd5b7 2045 (callback (or null callback))
f5b67f2b 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
1a1949c7 2053 (with-callback-function (id callback)
2054 (%menu-popup
2055 menu parent-menu-shell parent-menu-item
56ccd5b7 2056 %menu-position-callback id button activate-time))
f5b67f2b 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))
560af5c5 2063
bbaeff4b 2064(defbinding menu-reposition () nil
f36ca6af 2065 (menu menu))
560af5c5 2066
bbaeff4b 2067(defbinding menu-popdown () nil
f36ca6af 2068 (menu menu))
560af5c5 2069
f5b67f2b 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
bbaeff4b 2076(defbinding %menu-set-active () nil
f36ca6af 2077 (menu menu)
2078 (index unsigned-int))
560af5c5 2079
f5b67f2b 2080(defun (setf menu-active) (menu child)
2081 (%menu-set-active menu (%menu-position menu child))
2082 child)
d520140e 2083
56ccd5b7 2084(define-callback %menu-detach-callback nil ((widget widget) (menu menu))
8ab0db90 2085 (funcall (user-data menu 'detach-func) widget menu))
d76e9fca 2086
5a87235c 2087(defbinding %menu-attach-to-widget (menu widget) nil
d76e9fca 2088 (menu menu)
2089 (widget widget)
56ccd5b7 2090 (%menu-detach-callback callback))
d76e9fca 2091
2092(defun menu-attach-to-widget (menu widget function)
8ab0db90 2093 (setf (user-data menu 'detach-func) function)
d76e9fca 2094 (%menu-attach-to-widget menu widget))
2095
2096(defbinding menu-detach () nil
2097 (menu menu))
2098
8ab0db90 2099#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
d76e9fca 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))
560af5c5 2106
2107
f36ca6af 2108;;; Table
560af5c5 2109
bbaeff4b 2110(defbinding table-resize () nil
f36ca6af 2111 (table table)
2112 (rows unsigned-int)
2113 (columns unsigned-int))
560af5c5 2114
bbaeff4b 2115(defbinding table-attach (table child left right top bottom
c49be931 2116 &key options x-options y-options
2117 (x-padding 0) (y-padding 0)) nil
f36ca6af 2118 (table table)
2119 (child widget)
2120 (left unsigned-int)
2121 (right unsigned-int)
2122 (top unsigned-int)
2123 (bottom unsigned-int)
c49be931 2124 ((append (mklist options) (mklist x-options)) attach-options)
2125 ((append (mklist options) (mklist y-options)) attach-options)
f36ca6af 2126 (x-padding unsigned-int)
2127 (y-padding unsigned-int))
2128
e5b416f0 2129
bbaeff4b 2130(defbinding %table-set-row-spacing () nil
f36ca6af 2131 (table table)
2132 (row unsigned-int)
2133 (spacing unsigned-int))
2134
e5b416f0 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))
f36ca6af 2143 spacing)
2144
e5b416f0 2145(defbinding %table-get-row-spacing () unsigned-int
f36ca6af 2146 (table table)
e5b416f0 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
f36ca6af 2157
bbaeff4b 2158(defbinding %table-set-col-spacing () nil
f36ca6af 2159 (table table)
2160 (col unsigned-int)
2161 (spacing unsigned-int))
2162
e5b416f0 2163(defbinding %table-set-col-spacings () nil
2164 (table table)
2165 (spacing unsigned-int))
2166
e3cdfeea 2167(defun (setf table-column-spacing) (spacing table &optional column)
2168 (if column
2169 (%table-set-col-spacing table column spacing)
e5b416f0 2170 (%table-set-col-spacings table spacing))
f36ca6af 2171 spacing)
2172
e3cdfeea 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
e5b416f0 2177(defbinding %table-get-col-spacing () unsigned-int
f36ca6af 2178 (table table)
e5b416f0 2179 (col unsigned-int))
2180
2181(defbinding %table-get-default-col-spacing () unsigned-int
2182 (table table))
2183
e3cdfeea 2184(defun table-column-spacing (table &optional column)
2185 (if column
2186 (%table-get-col-spacing table column)
e5b416f0 2187 (%table-get-default-col-spacing table)))
2188
e3cdfeea 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
e5b416f0 2193
f36ca6af 2194
2195;;; Toolbar
2196
cb4bf772 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)))
560af5c5 2202
cb4bf772 2203(defbinding %toolbar-insert () nil
f5b67f2b 2204 (toolbar toolbar)
cb4bf772 2205 (tool-item tool-item)
2206 (position position))
f36ca6af 2207
cb4bf772 2208(defun toolbar-insert (toolbar tool-item &optional (position :end))
2209 (%toolbar-insert toolbar tool-item position)
2210 (%tool-item-update-tooltips tool-item))
f5b67f2b 2211
cb4bf772 2212(defbinding toolbar-get-item-index () int
2213 (toolbar toolbar)
2214 (item tool-item))
f36ca6af 2215
cb4bf772 2216(defbinding toolbar-get-nth-item () tool-item
2217 (toolbar toolbar)
2218 (n int))
f36ca6af 2219
cb4bf772 2220(defbinding toolbar-get-drop-index () int
2221 (toolbar toolbar)
2222 (x int) (y int))
f36ca6af 2223
cb4bf772 2224(defbinding toolbar-set-drop-highlight-item () nil
2225 (toolbar toolbar)
2226 (tool-item tool-item)
2227 (index int))
f36ca6af 2228
560af5c5 2229
cb4bf772 2230;;; Tool button
560af5c5 2231
cb4bf772 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)))
560af5c5 2236
2237
cb4bf772 2238;;; Tool item
560af5c5 2239
cb4bf772 2240(defbinding tool-item-set-tooltip () nil
2241 (tool-item tool-item)
2242 (tooltips tooltips)
2243 (tip-text string)
2244 (tip-private string))
560af5c5 2245
560af5c5 2246
cb4bf772 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)))
560af5c5 2273
d76e9fca 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
8ab0db90 2292#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
d76e9fca 2293(defbinding tool-item-rebuild-menu () nil
2294 (tool-item tool-item))
2295
2296
bbaeff4b 2297;;; Editable
1047e159 2298
bbaeff4b 2299(defbinding editable-select-region (editable &optional (start 0) end) nil
f36ca6af 2300 (editable editable)
2301 (start int)
2302 ((or end -1) int))
560af5c5 2303
1047e159 2304(defbinding editable-get-selection-bounds (editable) nil
2305 (editable editable)
2306 (start int :out)
2307 (end int :out))
2308
d76e9fca 2309(defbinding editable-insert-text (editable text &optional (position 0)) nil
f36ca6af 2310 (editable editable)
2311 (text string)
2312 ((length text) int)
8ab0db90 2313 (position position :in/out))
560af5c5 2314
f36ca6af 2315(defun editable-append-text (editable text)
2316 (editable-insert-text editable text nil))
560af5c5 2317
f36ca6af 2318(defun editable-prepend-text (editable text)
2319 (editable-insert-text editable text 0))
560af5c5 2320
bbaeff4b 2321(defbinding editable-delete-text (editable &optional (start 0) end) nil
f36ca6af 2322 (editable editable)
2323 (start int)
2324 ((or end -1) int))
560af5c5 2325
bbaeff4b 2326(defbinding (editable-text "gtk_editable_get_chars")
f36ca6af 2327 (editable &optional (start 0) end) string
2328 (editable editable)
2329 (start int)
2330 ((or end -1) int))
560af5c5 2331
f36ca6af 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)
560af5c5 2339
bbaeff4b 2340(defbinding editable-cut-clipboard () nil
f36ca6af 2341 (editable editable))
560af5c5 2342
bbaeff4b 2343(defbinding editable-copy-clipboard () nil
f36ca6af 2344 (editable editable))
560af5c5 2345
bbaeff4b 2346(defbinding editable-paste-clipboard () nil
f36ca6af 2347 (editable editable))
560af5c5 2348
bbaeff4b 2349(defbinding editable-delete-selection () nil
f36ca6af 2350 (editable editable))
560af5c5 2351
560af5c5 2352
560af5c5 2353
f36ca6af 2354;;; Spin button
560af5c5 2355
d76e9fca 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
f36ca6af 2372(defun spin-button-value-as-int (spin-button)
2373 (round (spin-button-value spin-button)))
560af5c5 2374
510fbcc1 2375(defbinding %spin-button-spin () nil
f36ca6af 2376 (spin-button spin-button)
2377 (direction spin-type)
510fbcc1 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
560af5c5 2385
bbaeff4b 2386(defbinding spin-button-update () nil
f36ca6af 2387 (spin-button spin-button))
560af5c5 2388
2389
2390
2391; ;;; Ruler
2392
bbaeff4b 2393(defbinding ruler-set-range () nil
f36ca6af 2394 (ruler ruler)
2395 (lower single-float)
2396 (upper single-float)
2397 (position single-float)
2398 (max-size single-float))
560af5c5 2399
68f519e0 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))
560af5c5 2406
560af5c5 2407
560af5c5 2408
d520140e 2409;;; Range
560af5c5 2410
1047e159 2411(defun range-lower (range)
2412 (adjustment-lower (range-adjustment range)))
560af5c5 2413
1047e159 2414(defun range-upper (range)
2415 (adjustment-upper (range-adjustment range)))
560af5c5 2416
1047e159 2417(defun (setf range-lower) (value range)
2418 (setf (adjustment-lower (range-adjustment range)) value))
560af5c5 2419
1047e159 2420(defun (setf range-upper) (value range)
2421 (setf (adjustment-upper (range-adjustment range)) value))
560af5c5 2422
1047e159 2423(defun range-page-increment (range)
2424 (adjustment-page-increment (range-adjustment range)))
560af5c5 2425
1047e159 2426(defun range-step-increment (range)
2427 (adjustment-step-increment (range-adjustment range)))
560af5c5 2428
1047e159 2429(defun (setf range-page-increment) (value range)
2430 (setf (adjustment-page-increment (range-adjustment range)) value))
560af5c5 2431
1047e159 2432(defun (setf range-step-increment) (value range)
2433 (setf (adjustment-step-increment (range-adjustment range)) value))
560af5c5 2434
1047e159 2435(defbinding range-set-range () nil
d520140e 2436 (range range)
1047e159 2437 (lower double-float)
2438 (upper double-float))
560af5c5 2439
1047e159 2440(defbinding range-set-increments () nil
d520140e 2441 (range range)
1047e159 2442 (step double-float)
2443 (page double-float))
560af5c5 2444
560af5c5 2445
d520140e 2446;;; Scale
560af5c5 2447
68f519e0 2448(defbinding scale-get-layout-offsets () nil
2449 (scale scale)
2450 (x int :out)
2451 (y int :out))
560af5c5 2452
560af5c5 2453
d520140e 2454;;; Progress bar
560af5c5 2455
bbaeff4b 2456(defbinding progress-bar-pulse () nil
d520140e 2457 (progress-bar progress-bar))
560af5c5 2458
2459
c49be931 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
560af5c5 2479
f5b67f2b 2480;;; Stock items
2481
73d58e01 2482(defbinding %stock-item-copy () pointer
2483 (location pointer))
2484
2485(defbinding %stock-item-free () nil
2486 (location pointer))
f5b67f2b 2487
73d58e01 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)
8ab0db90 2499 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
0c5f20d9 2500 (when (%stock-lookup stock-id stock-item)
2501 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
560af5c5 2502
8ab0db90 2503#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
0c5f20d9 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
00485707 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
0c5f20d9 2548
560af5c5 2549
00485707 2550;;; Tooltips
2551
2552;; GtkTooltips has been deprecated in favor of the new tooltip API
2553;; introduced in in GTK+ 2.12
560af5c5 2554
bbaeff4b 2555(defbinding tooltips-enable () nil
d520140e 2556 (tooltips tooltips))
560af5c5 2557
bbaeff4b 2558(defbinding tooltips-disable () nil
d520140e 2559 (tooltips tooltips))
560af5c5 2560
e5b416f0 2561(defun (setf tooltips-enabled-p) (enable tooltips)
2562 (if enable
2563 (tooltips-enable tooltips)
2564 (tooltips-disable tooltips)))
2565
bbaeff4b 2566(defbinding tooltips-set-tip () nil
d520140e 2567 (tooltips tooltips)
2568 (widget widget)
2569 (tip-text string)
2570 (tip-private string))
560af5c5 2571
d76e9fca 2572(defbinding tooltips-data-get () tooltips-data
2573 (widget widget))
2574
bbaeff4b 2575(defbinding tooltips-force-window () nil
d520140e 2576 (tooltips tooltips))
560af5c5 2577
d76e9fca 2578(defbinding tooltips-get-info-from-tip-window () boolean
2579 (tip-window window)
2580 (tooltips tooltips :out)
2581 (current-widget widget :out))
560af5c5 2582
2583
c1c0746b 2584;;; Resource Files
560af5c5 2585
61f0bf53 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))
560af5c5 2593
61f0bf53 2594(defbinding rc-parse () nil
2595 (filename pathname))
560af5c5 2596
bbaeff4b 2597(defbinding rc-parse-string () nil
d520140e 2598 (rc-string string))
560af5c5 2599
61f0bf53 2600(defbinding %rc-reparse-all () boolean)
560af5c5 2601
61f0bf53 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)))
4007604e 2647
2648
4007604e 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)))
00485707 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