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