chiark / gitweb /
Bug fix for COLOR-SELECTION
[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
4154981f 23;; $Id: gtk.lisp,v 1.88 2008-01-10 22:11:15 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
4154981f 709(defbinding color-selection-is-adjusting-p () boolean
0f476ab5 710 (colorsel color-selection))
711
4154981f 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))
0f476ab5 716
717
718;;; Color selection dialog -- no functions
719
720
721
1a1949c7 722;;;; Combo Box
0f476ab5 723
d76e9fca 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
1a1949c7 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
8ab0db90 762#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1a1949c7 763(defbinding combo-box-get-active-text () string
764 (combo-box combo-box))
0f476ab5 765
1a1949c7 766(defbinding combo-box-popup () nil
767 (combo-box combo-box))
0f476ab5 768
1a1949c7 769(defbinding combo-box-popdown () nil
770 (combo-box combo-box))
771
772
773
774;;;; Combo Box Entry
775
d76e9fca 776(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
1a1949c7 777 (call-next-method)
778 (unless model
779 (setf (combo-box-entry-text-column combo-box-entry) 0)))
0f476ab5 780
781
48da76bf 782;;;; Dialog
0f476ab5 783
c49be931 784(defmethod shared-initialize ((dialog dialog) names &rest initargs
785 &key button buttons)
8ab0db90 786 (declare (ignore names button buttons))
c49be931 787 (prog1
788 (call-next-method)
789 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
48da76bf 790
0f476ab5 791
14c94516 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)
8ab0db90 796 (let ((responses (user-data dialog 'responses)))
14c94516 797 (cond
798 ((and responses (position response responses :test #'equal)))
799 (create-p
1047e159 800 (cond
14c94516 801 (responses
802 (vector-push-extend response responses)
803 (1- (length responses)))
1047e159 804 (t
805 (setf
8ab0db90 806 (user-data dialog 'responses)
14c94516 807 (make-array 1 :adjustable t :fill-pointer t
808 :initial-element response))
1047e159 809 0)))
810 (error-p
14c94516 811 (error "Invalid response: ~A" response))))))
0f476ab5 812
14c94516 813(defun dialog-find-response (dialog id)
814 "Finds a symbolic response given a numeric id"
d314213c 815 (cond
816 ((not (numberp id)) id)
817 ((< id 0) (int-to-response-type id))
818 ((aref (user-data dialog 'responses) id))))
14c94516 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
4c371500 826(defmethod compute-signal-function ((dialog dialog) signal function object args)
827 (declare (ignore function object args))
14c94516 828 (let ((callback (call-next-method))
829 (id (dialog-response-id dialog signal)))
d314213c 830 (cond
831 (id
832 #'(lambda (dialog response)
833 (when (= response id)
834 (funcall callback dialog))))
6c4f81fc 835 ((string-equal signal "response")
d314213c 836 #'(lambda (dialog response)
837 (funcall callback dialog (dialog-find-response dialog response))))
838 (callback))))
0f476ab5 839
48da76bf 840(defbinding dialog-run () nil
841 (dialog dialog))
0f476ab5 842
14c94516 843(defbinding dialog-response (dialog response) nil
0f476ab5 844 (dialog dialog)
14c94516 845 ((dialog-response-id dialog response nil t) int))
0f476ab5 846
847
848(defbinding %dialog-add-button () button
849 (dialog dialog)
850 (text string)
14c94516 851 (response-id int))
0f476ab5 852
1047e159 853(defun dialog-add-button (dialog label &optional (response label)
854 &key default object after)
40b2615c 855 "Adds a button to the dialog."
14c94516 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)))
1047e159 861 (when (functionp response)
14c94516 862 (signal-connect dialog signal response :object object :after after))
1047e159 863 (when default
14c94516 864 (%dialog-set-default-response dialog id))
0f476ab5 865 button))
866
867
14c94516 868(defbinding %dialog-add-action-widget () nil
0f476ab5 869 (dialog dialog)
870 (action-widget widget)
14c94516 871 (response-id int))
0f476ab5 872
1047e159 873(defun dialog-add-action-widget (dialog widget &optional (response widget)
874 &key default object after)
14c94516 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)
1047e159 882 (when (functionp response)
14c94516 883 (signal-connect dialog signal response :object object :after after))
1047e159 884 (when default
7defde44 885 (setf (widget-can-default-p widget) t)
14c94516 886 (%dialog-set-default-response dialog id))
0f476ab5 887 widget))
0f476ab5 888
0f476ab5 889
48da76bf 890(defbinding %dialog-set-default-response () nil
891 (dialog dialog)
14c94516 892 (response-id int))
0f476ab5 893
14c94516 894(defun dialog-set-default-response (dialog response)
48da76bf 895 (%dialog-set-default-response
14c94516 896 dialog (dialog-response-id dialog response nil t)))
0f476ab5 897
14c94516 898(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
48da76bf 899 (dialog dialog)
14c94516 900 ((dialog-response-id dialog response nil t) int)
48da76bf 901 (sensitive boolean))
0f476ab5 902
8ab0db90 903#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
647c99e5 904(defbinding alternative-dialog-button-order-p (&optional screen) boolean
905 (screen (or null gdk:screen)))
40b2615c 906
8ab0db90 907#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
40b2615c 908(defbinding (dialog-set-alternative-button-order
5a87235c 909 "gtk_dialog_set_alternative_button_order_from_array")
910 (dialog new-order) nil
40b2615c 911 (dialog dialog)
912 ((length new-order) int)
14c94516 913 ((map 'vector #'(lambda (response)
914 (dialog-response-id dialog response nil t))
40b2615c 915 new-order) (vector int)))
0f476ab5 916
48da76bf 917
8ab0db90 918#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
bdc0e300 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
48da76bf 928(defmethod container-add ((dialog dialog) (child widget) &rest args)
1047e159 929 (apply #'container-add (dialog-vbox dialog) child args))
48da76bf 930
14c94516 931
48da76bf 932(defmethod container-remove ((dialog dialog) (child widget))
1047e159 933 (container-remove (dialog-vbox dialog) child))
0f476ab5 934
48da76bf 935(defmethod container-children ((dialog dialog))
1047e159 936 (container-children (dialog-vbox dialog)))
48da76bf 937
938(defmethod (setf container-children) (children (dialog dialog))
1047e159 939 (setf (container-children (dialog-vbox dialog)) children))
560af5c5 940
560af5c5 941
e3cdfeea 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
aaa6e6cb 948;;; Entry
560af5c5 949
aaa6e6cb 950(defbinding entry-get-layout-offsets () nil
951 (entry entry)
952 (x int :out)
953 (y int :out))
560af5c5 954
d76e9fca 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
560af5c5 963
f45fd227 964;;; Entry Completion
965
56ccd5b7 966(define-callback-marshal %entry-completion-match-callback boolean
967 (entry-completion string tree-iter))
f45fd227 968
969(defbinding entry-completion-set-match-func (completion function) nil
970 (completion entry-completion)
56ccd5b7 971 (%entry-completion-match-callback callback)
f45fd227 972 ((register-callback-function function) unsigned-int)
56ccd5b7 973 (user-data-destroy-callback callback))
f45fd227 974
975(defbinding entry-completion-complete () nil
976 (completion entry-completion))
977
3090d7d1 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
8ab0db90 982#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
f45fd227 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
68f519e0 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
8ab0db90 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))
68f519e0 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
8ab0db90 1112#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
68f519e0 1113(defbinding file-filter-add-pixbuf-formats () nil
647c99e5 1114 (filter file-filter))
68f519e0 1115
56ccd5b7 1116(define-callback-marshal %file-filter-callback boolean (file-filter-info))
68f519e0 1117
73572c12 1118(defbinding file-filter-add-custom (filter needed function) nil
68f519e0 1119 (filter file-filter)
1120 (needed file-filter-flags)
56ccd5b7 1121 (%file-filter-callback callback)
68f519e0 1122 ((register-callback-function function) unsigned-int)
56ccd5b7 1123 (user-data-destroy-callback callback))
68f519e0 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
1047e159 1134;;; Image
1135
1136(defbinding image-set-from-file () nil
1137 (image image)
1138 (filename pathname))
1139
d76e9fca 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))))
1047e159 1155
cb4bf772 1156(defun create-image-widget (source &optional mask)
d76e9fca 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))))
1047e159 1163
8ab0db90 1164#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
bdc0e300 1165(defbinding image-clear () nil
1166 (image image))
1167
1168
1047e159 1169
d76e9fca 1170;;; Image menu item
1047e159 1171
d76e9fca 1172(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1173 (if (and image (not (typep image 'widget)))
cb4bf772 1174 (apply #'call-next-method item :image (create-image-widget image) initargs)
d76e9fca 1175 (call-next-method)))
1047e159 1176
d76e9fca 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))
cb4bf772 1182 (setf (image-menu-item-image item) (create-image-widget image)))
1047e159 1183
560af5c5 1184
0f476ab5 1185;;; Label
560af5c5 1186
881fe3c3 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
aaa6e6cb 1193(defbinding label-get-layout-offsets () nil
1047e159 1194 (label label)
aaa6e6cb 1195 (x int :out)
1196 (y int :out))
1197
0f476ab5 1198(defbinding label-select-region () nil
1199 (label label)
1200 (start int)
1201 (end int))
560af5c5 1202
1047e159 1203(defbinding label-get-selection-bounds () boolean
aaa6e6cb 1204 (label label)
1205 (start int :out)
1206 (end int :out))
f36ca6af 1207
560af5c5 1208
1209
1210;;; Radio button
1211
e5b416f0 1212(defbinding %radio-button-get-group () pointer
d520140e 1213 (radio-button radio-button))
1214
bbaeff4b 1215(defbinding %radio-button-set-group () nil
d520140e 1216 (radio-button radio-button)
1217 (group pointer))
560af5c5 1218
cb4bf772 1219(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
d520140e 1220 "Add BUTTON1 to the group which BUTTON2 belongs to."
1221 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1222
a5522de5 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
c78ef85c 1239(defgeneric add-activate-callback (action function &key object after))
1240
a5522de5 1241(defmethod add-activate-callback ((button radio-button) function &key object after)
1242 (%add-activate-callback button 'clicked function object after))
1243
d76e9fca 1244(defmethod initialize-instance ((button radio-button) &key group)
1245 (prog1
1246 (call-next-method)
1247 (when group
cb4bf772 1248 (add-to-radio-group button group))))
560af5c5 1249
1250
560af5c5 1251;;; Item
1252
bbaeff4b 1253(defbinding item-select () nil
560af5c5 1254 (item item))
1255
bbaeff4b 1256(defbinding item-deselect () nil
560af5c5 1257 (item item))
1258
bbaeff4b 1259(defbinding item-toggle () nil
560af5c5 1260 (item item))
1261
1262
1263
1264;;; Menu item
1265
d76e9fca 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
f36ca6af 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
d76e9fca 1276 :use-underline (menu-item-use-underline-p menu-item)
1277 :visible t :parent menu-item)
f36ca6af 1278 label)
560af5c5 1279
f5b67f2b 1280(defun menu-item-label (menu-item)
d76e9fca 1281 (when (and (slot-boundp menu-item 'child)
1282 (typep (bin-child menu-item) 'label))
1283 (label-label (bin-child menu-item))))
f5b67f2b 1284
d76e9fca 1285(defbinding menu-item-remove-submenu () nil
f36ca6af 1286 (menu-item menu-item))
560af5c5 1287
f5b67f2b 1288(defbinding menu-item-set-accel-path () nil
1289 (menu-item menu-item)
1290 (accel-path string))
1291
bbaeff4b 1292(defbinding menu-item-select () nil
f36ca6af 1293 (menu-item menu-item))
560af5c5 1294
bbaeff4b 1295(defbinding menu-item-deselect () nil
f36ca6af 1296 (menu-item menu-item))
560af5c5 1297
bbaeff4b 1298(defbinding menu-item-activate () nil
f36ca6af 1299 (menu-item menu-item))
560af5c5 1300
f5b67f2b 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
560af5c5 1309
d76e9fca 1310;;; Menu tool button
1311
8ab0db90 1312#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
647c99e5 1313(defbinding menu-tool-button-set-arrow-tooltip () nil
d76e9fca 1314 (menu-tool-button menu-tool-button)
1315 (tooltips tooltips)
1316 (tip-text string)
1317 (tip-private string))
1318
1319
f4267180 1320;;; Message dialog
1321
9176d301 1322(defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
d314213c 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
3c0ed403 1336 &key message-type buttons button text
8ab0db90 1337 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1338 secondary-text)
9176d301 1339 (declare (ignore names))
7a2e0799 1340 (when text
1341 (message-dialog-set-markup dialog text))
8ab0db90 1342 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
7a2e0799 1343 (when secondary-text
1344 (message-dialog-format-secondary-markup dialog secondary-text))
3c0ed403 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)))
d314213c 1352 (if (typep buttons 'buttons-type)
1353 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1354 (call-next-method)))
f4267180 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)
7a2e0799 1362 (nil null))
f4267180 1363
1364(defbinding message-dialog-set-markup () nil
1365 (message-dialog message-dialog)
1366 (markup string))
1367
8ab0db90 1368#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
f4267180 1369(defbinding message-dialog-format-secondary-text () nil
1370 (message-dialog message-dialog)
1371 (text string))
1372
8ab0db90 1373#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
f4267180 1374(defbinding message-dialog-format-secondary-markup () nil
1375 (message-dialog message-dialog)
1376 (markup string))
1377
1378
560af5c5 1379
f36ca6af 1380;;; Radio menu item
560af5c5 1381
e5b416f0 1382(defbinding %radio-menu-item-get-group () pointer
d520140e 1383 (radio-menu-item radio-menu-item))
1384
bbaeff4b 1385(defbinding %radio-menu-item-set-group () nil
d520140e 1386 (radio-menu-item radio-menu-item)
1387 (group pointer))
1388
a5522de5 1389(defmethod activate-radio-widget ((item radio-menu-item))
1390 (menu-item-activate item))
1391
cb4bf772 1392(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
d520140e 1393 "Add ITEM1 to the group which ITEM2 belongs to."
1394 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1395
a5522de5 1396(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1397 (%add-activate-callback item 'activate function object after))
1398
d76e9fca 1399(defmethod initialize-instance ((item radio-menu-item) &key group)
f5b67f2b 1400 (prog1
1401 (call-next-method)
d76e9fca 1402 (when group
cb4bf772 1403 (add-to-radio-group item group))))
1404
d520140e 1405
560af5c5 1406
d76e9fca 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
a5522de5 1416(defmethod activate-radio-widget ((button radio-tool-button))
1417 (signal-emit button 'clicked))
1418
cb4bf772 1419(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
d76e9fca 1420 "Add BUTTON1 to the group which BUTTON2 belongs to."
1421 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
a5522de5 1422(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1423 (%add-activate-callback button 'clicked function object after))
d76e9fca 1424
1425(defmethod initialize-instance ((button radio-tool-button) &key group)
1426 (prog1
1427 (call-next-method)
1428 (when group
cb4bf772 1429 (add-to-radio-group button group))))
1430
d76e9fca 1431
560af5c5 1432
aaa6e6cb 1433;;; Toggle button
1434
1435(defbinding toggle-button-toggled () nil
1436 (toggle-button toggle-button))
1437
1438
560af5c5 1439;;; Window
1440
c49be931 1441(defmethod initialize-instance ((window window) &rest initargs
050f6c9f 1442 &key display accel-group accel-groups)
c49be931 1443 (declare (ignore accel-group accel-groups))
1444 (prog1
050f6c9f 1445 (if display
1446 (apply #'call-next-method
f5c99598 1447 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
050f6c9f 1448 (call-next-method))
c49be931 1449 (initial-add window #'window-add-accel-group
1450 initargs :accel-group :accel-groups)))
73d58e01 1451
5a87235c 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"
8ab0db90 1460 (window-title window) (pointer-address (foreign-location window))))
5a87235c 1461 (call-next-method)))
73d58e01 1462
7625ebd8 1463(defbinding window-set-wmclass () nil
560af5c5 1464 (window window)
1465 (wmclass-name string)
1466 (wmclass-class string))
1467
bbaeff4b 1468(defbinding window-add-accel-group () nil
560af5c5 1469 (window window)
1470 (accel-group accel-group))
1471
bbaeff4b 1472(defbinding window-remove-accel-group () nil
560af5c5 1473 (window window)
1474 (accel-group accel-group))
1475
bbaeff4b 1476(defbinding window-activate-focus () int
560af5c5 1477 (window window))
1478
bbaeff4b 1479(defbinding window-activate-default () int
560af5c5 1480 (window window))
1481
7625ebd8 1482(defbinding window-set-default-size (window width height) int
560af5c5 1483 (window window)
7625ebd8 1484 ((or width -1) int)
1485 ((or height -1) int))
560af5c5 1486
4d16221f 1487(defbinding %window-set-geometry-hints () nil
1488 (window window)
d29387c6 1489 (widget (or widget null))
4d16221f 1490 (geometry gdk:geometry)
1491 (geometry-mask gdk:window-hints))
1492
d29387c6 1493(defun window-set-geometry-hints (window &key widget min-width min-height
4d16221f 1494 max-width max-height base-width base-height
d29387c6 1495 width-inc height-inc gravity
1496 aspect (min-aspect aspect) (max-aspect aspect))
4d16221f 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)
d29387c6 1507 :max-aspect (or max-aspect 0)))
4d16221f 1508 (mask ()))
d29387c6 1509 (when (or min-width min-height)
4d16221f 1510 (push :min-size mask))
d29387c6 1511 (when (or max-width max-height)
4d16221f 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))
d29387c6 1519 (when gravity
1520 (push :win-gravity mask)
1521 (setf (gdk:geometry-gravity geometry) gravity))
1522 (%window-set-geometry-hints window widget geometry mask)))
560af5c5 1523
73d58e01 1524(defbinding window-list-toplevels () (glist (copy-of window))
1525 "Returns a list of all existing toplevel windows.")
7625ebd8 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
4d16221f 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
8ab0db90 1550#?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
7625ebd8 1551(defbinding window-present () nil
1552 (window window))
1553
8ab0db90 1554#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
bdc0e300 1555(progn
1556 (defbinding %window-present () nil
1557 (window window))
1558
6e8bf4cf 1559 (defbinding %window-present-with-time () nil
bdc0e300 1560 (window window)
1561 (timespamp unsigned-int))
1562
1563 (defun window-present (window &optional timestamp)
1564 (if timestamp
6e8bf4cf 1565 (%window-present-with-time window timestamp)
bdc0e300 1566 (%window-present window))))
1567
7625ebd8 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
4d16221f 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
7625ebd8 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)
9adccb27 1605 (timestamp unsigned-int))
7625ebd8 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)
9adccb27 1612 (timestamp unsigned-int))
7625ebd8 1613
1614(defbinding window-set-frame-dimensions () nil
1615 (window window)
1616 (left int) (top int) (rigth int) (bottom int))
1617
7625ebd8 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
190c2bcf 1631(defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
7625ebd8 1632 (window window))
1633
7625ebd8 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
4d16221f 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
c78ef85c 1677(defgeneric (setf window-default-icon) (icon))
1678
4d16221f 1679(defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1680 (%window-set-default-icon icon)
1681 icon)
1682
c78ef85c 1683(defgeneric (setf window-group) (group window))
1684
4d16221f 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
7625ebd8 1716 (window window)
4d16221f 1717 (title string))
7625ebd8 1718
4d16221f 1719(defbinding decorated-window-move-resize-window () nil
1720 (window window)
1721 (x int)
1722 (y int)
1723 (width int)
1724 (heigth int))
7625ebd8 1725
1726
4d16221f 1727;;; Window group
560af5c5 1728
4d16221f 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)))
560af5c5 1736
560af5c5 1737
4d16221f 1738(defbinding window-group-add-window () nil
1739 (window-group window-group)
1740 (window window))
560af5c5 1741
4d16221f 1742(defbinding window-group-remove-window () nil
1743 (window-group window-group)
1744 (window window))
560af5c5 1745
1746
f36ca6af 1747;;; Scrolled window
560af5c5 1748
560af5c5 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
bbaeff4b 1753(defbinding scrolled-window-add-with-viewport () nil
560af5c5 1754 (scrolled-window scrolled-window)
1755 (child widget))
1756
7a2e0799 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))
d520140e 1763
560af5c5 1764
f36ca6af 1765;;; Statusbar
560af5c5 1766
d76e9fca 1767(defbinding statusbar-get-context-id () unsigned-int
f36ca6af 1768 (statusbar statusbar)
1769 (context-description string))
560af5c5 1770
bbaeff4b 1771(defbinding statusbar-push () unsigned-int
f36ca6af 1772 (statusbar statusbar)
1773 (context-id unsigned-int)
1774 (text string))
560af5c5 1775
bbaeff4b 1776(defbinding statusbar-pop () nil
f36ca6af 1777 (statusbar statusbar)
1778 (context-id unsigned-int))
560af5c5 1779
bbaeff4b 1780(defbinding statusbar-remove () nil
f36ca6af 1781 (statusbar statusbar)
1782 (context-id unsigned-int)
1783 (message-id unsigned-int))
560af5c5 1784
560af5c5 1785
1786
1787;;; Fixed
1788
bbaeff4b 1789(defbinding fixed-put () nil
f36ca6af 1790 (fixed fixed)
1791 (widget widget)
f5b67f2b 1792 (x int) (y int))
560af5c5 1793
bbaeff4b 1794(defbinding fixed-move () nil
f36ca6af 1795 (fixed fixed)
1796 (widget widget)
f5b67f2b 1797 (x int) (y int))
560af5c5 1798
1799
1800
d520140e 1801;;; Notebook
560af5c5 1802
68f519e0 1803(defun %ensure-notebook-position (notebook page)
f5b67f2b 1804 (etypecase page
68f519e0 1805 (position page)
f5b67f2b 1806 (widget (notebook-page-num notebook page t))))
1807
68f519e0 1808(defun %ensure-notebook-child (notebook position)
f5b67f2b 1809 (typecase position
1810 (widget position)
68f519e0 1811 (t (notebook-get-nth-page notebook position))))
f5b67f2b 1812
1813(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
8ab0db90 1814 (notebook position child &optional tab-label menu-label) nil
f36ca6af 1815 (notebook notebook)
1816 (child widget)
1817 ((if (stringp tab-label)
f5b67f2b 1818 (make-instance 'label :label tab-label)
8ab0db90 1819 tab-label) (or null widget))
f36ca6af 1820 ((if (stringp menu-label)
f5b67f2b 1821 (make-instance 'label :label menu-label)
f36ca6af 1822 menu-label) (or null widget))
68f519e0 1823 ((%ensure-notebook-position notebook position) position))
560af5c5 1824
8ab0db90 1825(defun notebook-append (notebook child &optional tab-label menu-label)
f5b67f2b 1826 (notebook-insert notebook :last child tab-label menu-label))
560af5c5 1827
8ab0db90 1828(defun notebook-prepend (notebook child &optional tab-label menu-label)
f5b67f2b 1829 (notebook-insert notebook :first child tab-label menu-label))
560af5c5 1830
f5b67f2b 1831(defbinding notebook-remove-page (notebook page) nil
f36ca6af 1832 (notebook notebook)
68f519e0 1833 ((%ensure-notebook-position notebook page) position))
560af5c5 1834
bbaeff4b 1835(defbinding %notebook-page-num () int
f36ca6af 1836 (notebook notebook)
1837 (child widget))
1838
f5b67f2b 1839(defun notebook-page-num (notebook child &optional error-p)
f36ca6af 1840 (let ((page-num (%notebook-page-num notebook child)))
1841 (if (= page-num -1)
f5b67f2b 1842 (when error-p
68f519e0 1843 (error "~A is not a page in ~A" child notebook))
f36ca6af 1844 page-num)))
1845
bbaeff4b 1846(defbinding notebook-next-page () nil
f36ca6af 1847 (notebook notebook))
560af5c5 1848
bbaeff4b 1849(defbinding notebook-prev-page () nil
f36ca6af 1850 (notebook notebook))
1851
f5b67f2b 1852(defbinding notebook-reorder-child (notebook child position) nil
1853 (notebook notebook)
1854 (child widget)
bdc0e300 1855 ((%ensure-notebook-position notebook position) int))
f5b67f2b 1856
bbaeff4b 1857(defbinding notebook-popup-enable () nil
f36ca6af 1858 (notebook notebook))
1859
bbaeff4b 1860(defbinding notebook-popup-disable () nil
f36ca6af 1861 (notebook notebook))
1862
68f519e0 1863(defbinding notebook-get-nth-page () widget
f5b67f2b 1864 (notebook notebook)
68f519e0 1865 (page position))
f5b67f2b 1866
68f519e0 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))))
f5b67f2b 1870
1871(defun (setf notebook-current-page) (page notebook)
8ab0db90 1872 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
f5b67f2b 1873
1047e159 1874(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1875 (notebook page) widget
1876 (notebook notebook)
68f519e0 1877 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1878
1047e159 1879(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
6bb23851 1880 (notebook page) (copy-of string)
1047e159 1881 (notebook notebook)
68f519e0 1882 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1883
1047e159 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)))
68f519e0 1893 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1894 widget))
f5b67f2b 1895
f5b67f2b 1896
1047e159 1897(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1898 (notebook page) widget
1899 (notebook notebook)
68f519e0 1900 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1901
1047e159 1902(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
6bb23851 1903 (notebook page) (copy-of string)
1047e159 1904 (notebook notebook)
68f519e0 1905 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1906
1047e159 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)))
68f519e0 1916 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1917 widget))
f5b67f2b 1918
1919
1920(defbinding notebook-query-tab-label-packing (notebook page) nil
f36ca6af 1921 (notebook notebook)
bdc0e300 1922 ((%ensure-notebook-child notebook page) widget)
f36ca6af 1923 (expand boolean :out)
1924 (fill boolean :out)
1925 (pack-type pack-type :out))
1926
f5b67f2b 1927(defbinding notebook-set-tab-label-packing
1928 (notebook page expand fill pack-type) nil
f36ca6af 1929 (notebook notebook)
bdc0e300 1930 ((%ensure-notebook-child notebook page) widget)
f36ca6af 1931 (expand boolean)
1932 (fill boolean)
1933 (pack-type pack-type))
1934
560af5c5 1935
1936
d520140e 1937;;; Paned
560af5c5 1938
bbaeff4b 1939(defbinding paned-pack1 () nil
d520140e 1940 (paned paned)
1941 (child widget)
1942 (resize boolean)
1943 (shrink boolean))
560af5c5 1944
bbaeff4b 1945(defbinding paned-pack2 () nil
d520140e 1946 (paned paned)
1947 (child widget)
1948 (resize boolean)
1949 (shrink boolean))
560af5c5 1950
560af5c5 1951
d520140e 1952;;; Layout
560af5c5 1953
bbaeff4b 1954(defbinding layout-put () nil
d520140e 1955 (layout layout)
68f519e0 1956 (child widget)
d520140e 1957 (x int)
1958 (y int))
560af5c5 1959
bbaeff4b 1960(defbinding layout-move () nil
d520140e 1961 (layout layout)
68f519e0 1962 (child widget)
d520140e 1963 (x int)
1964 (y int))
560af5c5 1965
68f519e0 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))
560af5c5 1975
1976
560af5c5 1977;;; Menu shell
1978
f5b67f2b 1979(defbinding menu-shell-insert (menu-shell menu-item position) nil
f36ca6af 1980 (menu-shell menu-shell)
1981 (menu-item menu-item)
f5b67f2b 1982 ((case position
1983 (:first 0)
1984 (:last -1)
1985 (t position)) int))
560af5c5 1986
f36ca6af 1987(defun menu-shell-append (menu-shell menu-item)
f5b67f2b 1988 (menu-shell-insert menu-shell menu-item :last))
560af5c5 1989
f36ca6af 1990(defun menu-shell-prepend (menu-shell menu-item)
f5b67f2b 1991 (menu-shell-insert menu-shell menu-item :fisrt))
560af5c5 1992
bbaeff4b 1993(defbinding menu-shell-deactivate () nil
f36ca6af 1994 (menu-shell menu-shell))
560af5c5 1995
bbaeff4b 1996(defbinding menu-shell-select-item () nil
f36ca6af 1997 (menu-shell menu-shell)
1998 (menu-item menu-item))
560af5c5 1999
d76e9fca 2000(defbinding menu-shell-select-first () nil
2001 (menu-shell menu-shell)
2002 (search-sensitive boolean))
2003
bbaeff4b 2004(defbinding menu-shell-deselect () nil
f36ca6af 2005 (menu-shell menu-shell))
560af5c5 2006
bbaeff4b 2007(defbinding menu-shell-activate-item () nil
f36ca6af 2008 (menu-shell menu-shell)
2009 (menu-item menu-item)
2010 (fore-deactivate boolean))
560af5c5 2011
d76e9fca 2012(defbinding menu-shell-cancel () nil
2013 (menu-shell menu-shell))
560af5c5 2014
2015
f5b67f2b 2016;;; Menu
560af5c5 2017
f5b67f2b 2018(defun %menu-position (menu child)
2019 (etypecase child
2020 (int child)
2021 (keyword (case child
2022 (:first 0)
2023 (:last -1)
1047e159 2024 (t (error "Invalid position keyword: ~A" child))))
f5b67f2b 2025 (widget (menu-child-position menu child))))
560af5c5 2026
2027
f5b67f2b 2028(defbinding menu-reorder-child (menu menu-item position) nil
2029 (menu menu)
2030 (menu-item menu-item)
2031 ((%menu-position menu position) int))
560af5c5 2032
d76e9fca 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
56ccd5b7 2041(define-callback-marshal %menu-position-callback nil
2042 (menu (x int) (y int) (push-in boolean)))
560af5c5 2043
f5b67f2b 2044(defbinding %menu-popup () nil
2045 (menu menu)
2046 (parent-menu-shell (or null menu-shell))
2047 (parent-menu-item (or null menu-item))
56ccd5b7 2048 (callback (or null callback))
f5b67f2b 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
1a1949c7 2056 (with-callback-function (id callback)
2057 (%menu-popup
2058 menu parent-menu-shell parent-menu-item
56ccd5b7 2059 %menu-position-callback id button activate-time))
f5b67f2b 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))
560af5c5 2066
bbaeff4b 2067(defbinding menu-reposition () nil
f36ca6af 2068 (menu menu))
560af5c5 2069
bbaeff4b 2070(defbinding menu-popdown () nil
f36ca6af 2071 (menu menu))
560af5c5 2072
f5b67f2b 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
bbaeff4b 2079(defbinding %menu-set-active () nil
f36ca6af 2080 (menu menu)
2081 (index unsigned-int))
560af5c5 2082
f5b67f2b 2083(defun (setf menu-active) (menu child)
2084 (%menu-set-active menu (%menu-position menu child))
2085 child)
d520140e 2086
56ccd5b7 2087(define-callback %menu-detach-callback nil ((widget widget) (menu menu))
8ab0db90 2088 (funcall (user-data menu 'detach-func) widget menu))
d76e9fca 2089
5a87235c 2090(defbinding %menu-attach-to-widget (menu widget) nil
d76e9fca 2091 (menu menu)
2092 (widget widget)
56ccd5b7 2093 (%menu-detach-callback callback))
d76e9fca 2094
2095(defun menu-attach-to-widget (menu widget function)
8ab0db90 2096 (setf (user-data menu 'detach-func) function)
d76e9fca 2097 (%menu-attach-to-widget menu widget))
2098
2099(defbinding menu-detach () nil
2100 (menu menu))
2101
8ab0db90 2102#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
d76e9fca 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))
560af5c5 2109
2110
f36ca6af 2111;;; Table
560af5c5 2112
bbaeff4b 2113(defbinding table-resize () nil
f36ca6af 2114 (table table)
2115 (rows unsigned-int)
2116 (columns unsigned-int))
560af5c5 2117
bbaeff4b 2118(defbinding table-attach (table child left right top bottom
c49be931 2119 &key options x-options y-options
2120 (x-padding 0) (y-padding 0)) nil
f36ca6af 2121 (table table)
2122 (child widget)
2123 (left unsigned-int)
2124 (right unsigned-int)
2125 (top unsigned-int)
2126 (bottom unsigned-int)
c49be931 2127 ((append (mklist options) (mklist x-options)) attach-options)
2128 ((append (mklist options) (mklist y-options)) attach-options)
f36ca6af 2129 (x-padding unsigned-int)
2130 (y-padding unsigned-int))
2131
e5b416f0 2132
bbaeff4b 2133(defbinding %table-set-row-spacing () nil
f36ca6af 2134 (table table)
2135 (row unsigned-int)
2136 (spacing unsigned-int))
2137
e5b416f0 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))
f36ca6af 2146 spacing)
2147
e5b416f0 2148(defbinding %table-get-row-spacing () unsigned-int
f36ca6af 2149 (table table)
e5b416f0 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
f36ca6af 2160
bbaeff4b 2161(defbinding %table-set-col-spacing () nil
f36ca6af 2162 (table table)
2163 (col unsigned-int)
2164 (spacing unsigned-int))
2165
e5b416f0 2166(defbinding %table-set-col-spacings () nil
2167 (table table)
2168 (spacing unsigned-int))
2169
e3cdfeea 2170(defun (setf table-column-spacing) (spacing table &optional column)
2171 (if column
2172 (%table-set-col-spacing table column spacing)
e5b416f0 2173 (%table-set-col-spacings table spacing))
f36ca6af 2174 spacing)
2175
e3cdfeea 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
e5b416f0 2180(defbinding %table-get-col-spacing () unsigned-int
f36ca6af 2181 (table table)
e5b416f0 2182 (col unsigned-int))
2183
2184(defbinding %table-get-default-col-spacing () unsigned-int
2185 (table table))
2186
e3cdfeea 2187(defun table-column-spacing (table &optional column)
2188 (if column
2189 (%table-get-col-spacing table column)
e5b416f0 2190 (%table-get-default-col-spacing table)))
2191
e3cdfeea 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
e5b416f0 2196
f36ca6af 2197
2198;;; Toolbar
2199
cb4bf772 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)))
560af5c5 2205
cb4bf772 2206(defbinding %toolbar-insert () nil
f5b67f2b 2207 (toolbar toolbar)
cb4bf772 2208 (tool-item tool-item)
2209 (position position))
f36ca6af 2210
cb4bf772 2211(defun toolbar-insert (toolbar tool-item &optional (position :end))
2212 (%toolbar-insert toolbar tool-item position)
2213 (%tool-item-update-tooltips tool-item))
f5b67f2b 2214
cb4bf772 2215(defbinding toolbar-get-item-index () int
2216 (toolbar toolbar)
2217 (item tool-item))
f36ca6af 2218
cb4bf772 2219(defbinding toolbar-get-nth-item () tool-item
2220 (toolbar toolbar)
2221 (n int))
f36ca6af 2222
cb4bf772 2223(defbinding toolbar-get-drop-index () int
2224 (toolbar toolbar)
2225 (x int) (y int))
f36ca6af 2226
cb4bf772 2227(defbinding toolbar-set-drop-highlight-item () nil
2228 (toolbar toolbar)
2229 (tool-item tool-item)
2230 (index int))
f36ca6af 2231
560af5c5 2232
cb4bf772 2233;;; Tool button
560af5c5 2234
cb4bf772 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)))
560af5c5 2239
2240
cb4bf772 2241;;; Tool item
560af5c5 2242
cb4bf772 2243(defbinding tool-item-set-tooltip () nil
2244 (tool-item tool-item)
2245 (tooltips tooltips)
2246 (tip-text string)
2247 (tip-private string))
560af5c5 2248
560af5c5 2249
cb4bf772 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)))
560af5c5 2276
d76e9fca 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
8ab0db90 2295#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
d76e9fca 2296(defbinding tool-item-rebuild-menu () nil
2297 (tool-item tool-item))
2298
2299
bbaeff4b 2300;;; Editable
1047e159 2301
bbaeff4b 2302(defbinding editable-select-region (editable &optional (start 0) end) nil
f36ca6af 2303 (editable editable)
2304 (start int)
2305 ((or end -1) int))
560af5c5 2306
1047e159 2307(defbinding editable-get-selection-bounds (editable) nil
2308 (editable editable)
2309 (start int :out)
2310 (end int :out))
2311
d76e9fca 2312(defbinding editable-insert-text (editable text &optional (position 0)) nil
f36ca6af 2313 (editable editable)
2314 (text string)
2315 ((length text) int)
8ab0db90 2316 (position position :in/out))
560af5c5 2317
f36ca6af 2318(defun editable-append-text (editable text)
2319 (editable-insert-text editable text nil))
560af5c5 2320
f36ca6af 2321(defun editable-prepend-text (editable text)
2322 (editable-insert-text editable text 0))
560af5c5 2323
bbaeff4b 2324(defbinding editable-delete-text (editable &optional (start 0) end) nil
f36ca6af 2325 (editable editable)
2326 (start int)
2327 ((or end -1) int))
560af5c5 2328
bbaeff4b 2329(defbinding (editable-text "gtk_editable_get_chars")
f36ca6af 2330 (editable &optional (start 0) end) string
2331 (editable editable)
2332 (start int)
2333 ((or end -1) int))
560af5c5 2334
f36ca6af 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)
560af5c5 2342
bbaeff4b 2343(defbinding editable-cut-clipboard () nil
f36ca6af 2344 (editable editable))
560af5c5 2345
bbaeff4b 2346(defbinding editable-copy-clipboard () nil
f36ca6af 2347 (editable editable))
560af5c5 2348
bbaeff4b 2349(defbinding editable-paste-clipboard () nil
f36ca6af 2350 (editable editable))
560af5c5 2351
bbaeff4b 2352(defbinding editable-delete-selection () nil
f36ca6af 2353 (editable editable))
560af5c5 2354
560af5c5 2355
560af5c5 2356
f36ca6af 2357;;; Spin button
560af5c5 2358
d76e9fca 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
f36ca6af 2375(defun spin-button-value-as-int (spin-button)
2376 (round (spin-button-value spin-button)))
560af5c5 2377
510fbcc1 2378(defbinding %spin-button-spin () nil
f36ca6af 2379 (spin-button spin-button)
2380 (direction spin-type)
510fbcc1 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
560af5c5 2388
bbaeff4b 2389(defbinding spin-button-update () nil
f36ca6af 2390 (spin-button spin-button))
560af5c5 2391
2392
2393
2394; ;;; Ruler
2395
bbaeff4b 2396(defbinding ruler-set-range () nil
f36ca6af 2397 (ruler ruler)
2398 (lower single-float)
2399 (upper single-float)
2400 (position single-float)
2401 (max-size single-float))
560af5c5 2402
68f519e0 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))
560af5c5 2409
560af5c5 2410
560af5c5 2411
d520140e 2412;;; Range
560af5c5 2413
1047e159 2414(defun range-lower (range)
2415 (adjustment-lower (range-adjustment range)))
560af5c5 2416
1047e159 2417(defun range-upper (range)
2418 (adjustment-upper (range-adjustment range)))
560af5c5 2419
1047e159 2420(defun (setf range-lower) (value range)
2421 (setf (adjustment-lower (range-adjustment range)) value))
560af5c5 2422
1047e159 2423(defun (setf range-upper) (value range)
2424 (setf (adjustment-upper (range-adjustment range)) value))
560af5c5 2425
1047e159 2426(defun range-page-increment (range)
2427 (adjustment-page-increment (range-adjustment range)))
560af5c5 2428
1047e159 2429(defun range-step-increment (range)
2430 (adjustment-step-increment (range-adjustment range)))
560af5c5 2431
1047e159 2432(defun (setf range-page-increment) (value range)
2433 (setf (adjustment-page-increment (range-adjustment range)) value))
560af5c5 2434
1047e159 2435(defun (setf range-step-increment) (value range)
2436 (setf (adjustment-step-increment (range-adjustment range)) value))
560af5c5 2437
1047e159 2438(defbinding range-set-range () nil
d520140e 2439 (range range)
1047e159 2440 (lower double-float)
2441 (upper double-float))
560af5c5 2442
1047e159 2443(defbinding range-set-increments () nil
d520140e 2444 (range range)
1047e159 2445 (step double-float)
2446 (page double-float))
560af5c5 2447
560af5c5 2448
d520140e 2449;;; Scale
560af5c5 2450
68f519e0 2451(defbinding scale-get-layout-offsets () nil
2452 (scale scale)
2453 (x int :out)
2454 (y int :out))
560af5c5 2455
560af5c5 2456
d520140e 2457;;; Progress bar
560af5c5 2458
bbaeff4b 2459(defbinding progress-bar-pulse () nil
d520140e 2460 (progress-bar progress-bar))
560af5c5 2461
2462
c49be931 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
560af5c5 2482
f5b67f2b 2483;;; Stock items
2484
73d58e01 2485(defbinding %stock-item-copy () pointer
2486 (location pointer))
2487
2488(defbinding %stock-item-free () nil
2489 (location pointer))
f5b67f2b 2490
73d58e01 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)
8ab0db90 2502 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
0c5f20d9 2503 (when (%stock-lookup stock-id stock-item)
2504 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
560af5c5 2505
8ab0db90 2506#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
0c5f20d9 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
00485707 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
0c5f20d9 2551
560af5c5 2552
00485707 2553;;; Tooltips
2554
2555;; GtkTooltips has been deprecated in favor of the new tooltip API
2556;; introduced in in GTK+ 2.12
560af5c5 2557
bbaeff4b 2558(defbinding tooltips-enable () nil
d520140e 2559 (tooltips tooltips))
560af5c5 2560
bbaeff4b 2561(defbinding tooltips-disable () nil
d520140e 2562 (tooltips tooltips))
560af5c5 2563
e5b416f0 2564(defun (setf tooltips-enabled-p) (enable tooltips)
2565 (if enable
2566 (tooltips-enable tooltips)
2567 (tooltips-disable tooltips)))
2568
bbaeff4b 2569(defbinding tooltips-set-tip () nil
d520140e 2570 (tooltips tooltips)
2571 (widget widget)
2572 (tip-text string)
2573 (tip-private string))
560af5c5 2574
d76e9fca 2575(defbinding tooltips-data-get () tooltips-data
2576 (widget widget))
2577
bbaeff4b 2578(defbinding tooltips-force-window () nil
d520140e 2579 (tooltips tooltips))
560af5c5 2580
d76e9fca 2581(defbinding tooltips-get-info-from-tip-window () boolean
2582 (tip-window window)
2583 (tooltips tooltips :out)
2584 (current-widget widget :out))
560af5c5 2585
2586
c1c0746b 2587;;; Resource Files
560af5c5 2588
61f0bf53 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))
560af5c5 2596
61f0bf53 2597(defbinding rc-parse () nil
2598 (filename pathname))
560af5c5 2599
bbaeff4b 2600(defbinding rc-parse-string () nil
d520140e 2601 (rc-string string))
560af5c5 2602
61f0bf53 2603(defbinding %rc-reparse-all () boolean)
560af5c5 2604
61f0bf53 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)))
4007604e 2650
2651
4007604e 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)))
00485707 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