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