gtk/gtk.lisp: Make (dialog-run) return the response symbolically.
[clg] / gtk / gtk.lisp
CommitLineData
55212af1 1;; Common Lisp bindings for GTK+ v2.x
f957f519 2;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net>
0d07716f 3;;
55212af1 4;; Permission is hereby granted, free of charge, to any person obtaining
5;; a copy of this software and associated documentation files (the
6;; "Software"), to deal in the Software without restriction, including
7;; without limitation the rights to use, copy, modify, merge, publish,
8;; distribute, sublicense, and/or sell copies of the Software, and to
9;; permit persons to whom the Software is furnished to do so, subject to
10;; the following conditions:
0d07716f 11;;
55212af1 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
0d07716f 14;;
55212af1 15;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0d07716f 22
c5e634c2 23;; $Id: gtk.lisp,v 1.98 2008/11/25 22:11:08 espen Exp $
0d07716f 24
25
26(in-package "GTK")
27
28;;; Gtk version
29
84967144 30(defbinding check-version () (copy-of string)
0d07716f 31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
34
a60bd055 35(defbinding query-version () nil
0d07716f 36 (major unsigned-int :out)
37 (minor unsigned-int :out)
38 (micro unsigned-int :out))
39
40(defun gtk-version ()
41 (multiple-value-bind (major minor micro)
42 (query-version)
43 (if (zerop micro)
44 (format nil "Gtk+ v~A.~A" major minor)
45 (format nil "Gtk+ v~A.~A.~A" major minor micro))))
46
e69138cc 47(defun clg-version ()
66b1c1c2 48 "clg 0.94")
0d07716f 49
50
5233fe44 51;;;; Initalization and display handling
6baf860c 52
1e1c3903 53(defparameter *event-polling-interval* 0.01)
6e21e828 54
1e1c3903 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)))))
6e21e828 59
30628c63 60(defbinding (gtk-init "gtk_parse_args") () boolean
6baf860c 61 "Initializes the library without opening the display."
62 (nil null)
63 (nil null))
64
6e21e828 65(defun clg-init (&optional display multi-threading-p)
66 "Initializes the system and starts event handling."
6baf860c 67 (unless (gdk:display-get-default)
92afacae 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
6e21e828 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")))
6b465328 81 (gdk:ensure-display display t))
6e21e828 82
f957f519 83(defun clg-init-with-threading (&optional display)
6e21e828 84 (clg-init display t))
85
86
1e1c3903 87#?(and (sbcl>= 1 0 6) (sbcl< 1 0 15 6))
6e21e828 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
6006b229 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))))))
6e21e828 103
104(defun %init-async-event-handling (display)
1e1c3903 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))
6e21e828 108 (when (and
109 (find-package "SWANK")
110 (not (eq (symbol-value (find-symbol "*COMMUNICATION-STYLE*" "SWANK")) style)))
8fd1f417 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)))
6e21e828 112
e983ac1b 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
1e1c3903 126 #?(or (featurep :cmu) (sbcl< 1 0 6) (sbcl>= 1 0 15 6))
6e21e828 127 (progn
6e21e828 128 (setq *periodic-polling-function* #'main-iterate-all)
1e1c3903 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*))
6e21e828 134
1e1c3903 135 #?(or (featurep :clisp) (and (sbcl>= 1 0 6) (sbcl< 1 0 15 6)))
e983ac1b 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))))
6e21e828 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."))
72cb3e1f 218 (gdk:threads-init)
6e21e828 219 (let ((main-running (sb-thread:make-waitqueue)))
220 (gdk:with-global-lock
221 (setf *main-thread*
222 (sb-thread:make-thread
223 #'(lambda ()
6e21e828 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")
57fa233b 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"))))))
6e21e828 242
243#-sb-thread
244(defmacro within-main-loop (&body body)
245 `(progn ,@body))
92afacae 246
6baf860c 247
00a8d921 248
3c1925ed 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
6baf860c 257
17707159 258;;; Misc
259
260(defbinding grab-add () nil
261 (widget widget))
262
3a476d4e 263(defbinding grab-get-current () widget)
17707159 264
265(defbinding grab-remove () nil
266 (widget widget))
267
e69138cc 268(defbinding get-default-language () (copy-of pango:language))
269
17707159 270
1448a84f 271;;; About dialog
272
f957f519 273#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1448a84f 274(progn
a92553bd 275 (define-callback-marshal %about-dialog-activate-link-callback nil
276 (about-dialog (link string)))
1448a84f 277
278 (defbinding about-dialog-set-email-hook (function) nil
a92553bd 279 (%about-dialog-activate-link-callback callback)
1448a84f 280 ((register-callback-function function) unsigned-int)
a92553bd 281 (user-data-destroy-callback callback))
1448a84f 282
283 (defbinding about-dialog-set-url-hook (function) nil
a92553bd 284 (%about-dialog-activate-link-callback callback)
1448a84f 285 ((register-callback-function function) unsigned-int)
a92553bd 286 (user-data-destroy-callback callback)))
1448a84f 287
288
d404b3af 289;;; Acccel group
0d07716f 290
213cf4d0 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)
7b6c693b 299 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 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)
f957f519 307 ((make-callback-closure function) gclosure :in/return))
213cf4d0 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
7b6c693b 322 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 323 (%accel-group-disconnect-key group key modifiers)))))
324
7b6c693b 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
213cf4d0 345(defbinding accel-group-lock () nil
346 (accel-group accel-group))
347
348(defbinding accel-group-unlock () nil
349 (accel-group accel-group))
350
7b6c693b 351(defbinding accel-group-from-accel-closure () accel-group
352 (closure gclosure))
353
213cf4d0 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)
7b6c693b 360 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 361 (%accel-groups-activate object key modifiers)))
362
3f2c422a 363(defbinding accel-groups-from-object () (gslist accel-group)
213cf4d0 364 (object gobject))
365
3d36c5d6 366(defbinding accelerator-valid-p (key &optional modifiers) boolean
213cf4d0 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
7b6c693b 375(defgeneric parse-accelerator (accelerator))
376
377(defmethod parse-accelerator ((accelerator string))
213cf4d0 378 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
379 (if (zerop key)
380 (error "Invalid accelerator: ~A" accelerator)
381 (values key modifiers))))
382
7b6c693b 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
213cf4d0 404(defbinding accelerator-name () string
405 (key unsigned-int)
406 (modifiers gdk:modifier-type))
407
f957f519 408#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
213cf4d0 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)
0d07716f 420
eb4f580c 421
0d07716f 422;;; Acccel label
423
7b6c693b 424(defbinding accel-label-get-accel-width () unsigned-int
425 (accel-label accel-label))
426
a60bd055 427(defbinding accel-label-refetch () boolean
0d07716f 428 (accel-label accel-label))
429
430
213cf4d0 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)
7b6c693b 440 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 441 (%accel-map-add-entry path key modifiers)))
442
7b6c693b 443(defbinding %accel-map-lookup-entry () boolean
213cf4d0 444 (path string)
f957f519 445 ((make-instance 'accel-key) accel-key :in/return))
7b6c693b 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)))))
213cf4d0 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)
7b6c693b 462 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 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
a92553bd 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)
7b6c693b 474
475(defbinding %accel-map-foreach (callback-id) nil
476 (callback-id unsigned-int)
a92553bd 477 (%accel-map-foreach-callback callback))
7b6c693b 478
479(defbinding %accel-map-foreach-unfiltered (callback-id) nil
480 (callback-id unsigned-int)
a92553bd 481 (%accel-map-foreach-callback callback))
7b6c693b 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
213cf4d0 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
7b6c693b 502;;; Accessibility
14eaa563 503
504(defbinding accessible-connect-widget-destroyed () nil
505 (accessible accessible))
506
507
d404b3af 508;;; Adjustment
0d07716f 509
14eaa563 510(defmethod initialize-instance ((adjustment adjustment) &key value)
eb4f580c 511 (prog1
512 (call-next-method)
513 ;; we need to make sure that the value is set last, otherwise it
14eaa563 514 ;; may be outside current limits and ignored
eb4f580c 515 (when value
516 (setf (slot-value adjustment 'value) value))))
517
518
d404b3af 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))
0d07716f 529
d404b3af 530
49043b9a 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
b5b970e8 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
4d0c34e5 586 (defbinding assistant-set-forward-page-func (assistant function) nil
b5b970e8 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
d404b3af 605;;; Aspect frame
606
607
608;;; Bin
0d07716f 609
610(defun (setf bin-child) (child bin)
d404b3af 611 (when-bind (current-child (bin-child bin))
612 (container-remove bin current-child))
0d07716f 613 (container-add bin child)
614 child)
615
a68868d1 616(defmethod compute-signal-function ((bin bin) signal function object args)
d79b3413 617 (declare (ignore signal))
618 (if (eq object :child)
bedf7b84 619 #'(lambda (bin &rest emission-args)
620 (apply function (bin-child bin) (nconc emission-args args)))
9617dc95 621 (call-next-method)))
d404b3af 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
14eaa563 640(defun box-pack (box child &key end (expand t) (fill t) (padding 0))
4886872c 641 (if end
378b3c5f 642 (box-pack-end box child expand fill padding)
643 (box-pack-start box child expand fill padding)))
d404b3af 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
0d07716f 668;;; Button
669
14eaa563 670(defmethod initialize-instance ((button button) &rest initargs &key stock)
671 (if stock
f957f519 672 (apply #'call-next-method button
673 :label stock :use-stock t :use-underline t initargs)
14eaa563 674 (call-next-method)))
675
676
a60bd055 677(defbinding button-pressed () nil
0d07716f 678 (button button))
679
d404b3af 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
14eaa563 716(defbinding calendar-get-date () nil
d404b3af 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
d404b3af 729;;; Check menu item
730
731(defbinding check-menu-item-toggled () nil
732 (check-menu-item check-menu-item))
733
734
d404b3af 735;;; Color selection
736
4e79d27c 737(defbinding color-selection-is-adjusting-p () boolean
d404b3af 738 (colorsel color-selection))
739
4e79d27c 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))
d404b3af 744
745
746;;; Color selection dialog -- no functions
747
748
749
4886872c 750;;;; Combo Box
d404b3af 751
14eaa563 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
4886872c 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
f957f519 790#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
c5e634c2 791(defbinding combo-box-get-active-text () (or null string)
4886872c 792 (combo-box combo-box))
d404b3af 793
4886872c 794(defbinding combo-box-popup () nil
795 (combo-box combo-box))
d404b3af 796
4886872c 797(defbinding combo-box-popdown () nil
798 (combo-box combo-box))
799
800
801
802;;;; Combo Box Entry
803
14eaa563 804(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
4886872c 805 (call-next-method)
806 (unless model
807 (setf (combo-box-entry-text-column combo-box-entry) 0)))
d404b3af 808
809
0ebef6c1 810;;;; Dialog
d404b3af 811
362f1795 812(defmethod shared-initialize ((dialog dialog) names &rest initargs
813 &key button buttons)
f957f519 814 (declare (ignore names button buttons))
362f1795 815 (prog1
816 (call-next-method)
817 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
0ebef6c1 818
d404b3af 819
d79b3413 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)
f957f519 824 (let ((responses (user-data dialog 'responses)))
d79b3413 825 (cond
826 ((and responses (position response responses :test #'equal)))
827 (create-p
eb4f580c 828 (cond
d79b3413 829 (responses
830 (vector-push-extend response responses)
831 (1- (length responses)))
eb4f580c 832 (t
833 (setf
f957f519 834 (user-data dialog 'responses)
d79b3413 835 (make-array 1 :adjustable t :fill-pointer t
836 :initial-element response))
eb4f580c 837 0)))
838 (error-p
d79b3413 839 (error "Invalid response: ~A" response))))))
d404b3af 840
d79b3413 841(defun dialog-find-response (dialog id)
842 "Finds a symbolic response given a numeric id"
36df51ae 843 (cond
844 ((not (numberp id)) id)
845 ((< id 0) (int-to-response-type id))
846 ((aref (user-data dialog 'responses) id))))
d79b3413 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
a68868d1 854(defmethod compute-signal-function ((dialog dialog) signal function object args)
855 (declare (ignore function object args))
d79b3413 856 (let ((callback (call-next-method))
857 (id (dialog-response-id dialog signal)))
36df51ae 858 (cond
859 (id
860 #'(lambda (dialog response)
861 (when (= response id)
862 (funcall callback dialog))))
e67c4de7 863 ((string-equal signal "response")
36df51ae 864 #'(lambda (dialog response)
865 (funcall callback dialog (dialog-find-response dialog response))))
866 (callback))))
d404b3af 867
aaa24d14 868(defbinding %dialog-run () int
0ebef6c1 869 (dialog dialog))
aaa24d14
MW
870(defun dialog-run (dialog)
871 (dialog-find-response dialog (%dialog-run dialog)))
d404b3af 872
d79b3413 873(defbinding dialog-response (dialog response) nil
d404b3af 874 (dialog dialog)
d79b3413 875 ((dialog-response-id dialog response nil t) int))
d404b3af 876
877
878(defbinding %dialog-add-button () button
879 (dialog dialog)
880 (text string)
d79b3413 881 (response-id int))
d404b3af 882
eb4f580c 883(defun dialog-add-button (dialog label &optional (response label)
884 &key default object after)
fe67c0ec 885 "Adds a button to the dialog."
d79b3413 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)))
eb4f580c 891 (when (functionp response)
d79b3413 892 (signal-connect dialog signal response :object object :after after))
eb4f580c 893 (when default
d79b3413 894 (%dialog-set-default-response dialog id))
d404b3af 895 button))
896
897
d79b3413 898(defbinding %dialog-add-action-widget () nil
d404b3af 899 (dialog dialog)
900 (action-widget widget)
d79b3413 901 (response-id int))
d404b3af 902
eb4f580c 903(defun dialog-add-action-widget (dialog widget &optional (response widget)
904 &key default object after)
d79b3413 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)
eb4f580c 912 (when (functionp response)
d79b3413 913 (signal-connect dialog signal response :object object :after after))
eb4f580c 914 (when default
c2c4f44a 915 (setf (widget-can-default-p widget) t)
d79b3413 916 (%dialog-set-default-response dialog id))
d404b3af 917 widget))
d404b3af 918
d404b3af 919
0ebef6c1 920(defbinding %dialog-set-default-response () nil
921 (dialog dialog)
d79b3413 922 (response-id int))
d404b3af 923
d79b3413 924(defun dialog-set-default-response (dialog response)
0ebef6c1 925 (%dialog-set-default-response
d79b3413 926 dialog (dialog-response-id dialog response nil t)))
d404b3af 927
d79b3413 928(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
0ebef6c1 929 (dialog dialog)
d79b3413 930 ((dialog-response-id dialog response nil t) int)
0ebef6c1 931 (sensitive boolean))
d404b3af 932
f957f519 933#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1448a84f 934(defbinding alternative-dialog-button-order-p (&optional screen) boolean
935 (screen (or null gdk:screen)))
fe67c0ec 936
f957f519 937#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
fe67c0ec 938(defbinding (dialog-set-alternative-button-order
405b4406 939 "gtk_dialog_set_alternative_button_order_from_array")
940 (dialog new-order) nil
fe67c0ec 941 (dialog dialog)
942 ((length new-order) int)
d79b3413 943 ((map 'vector #'(lambda (response)
944 (dialog-response-id dialog response nil t))
fe67c0ec 945 new-order) (vector int)))
d404b3af 946
0ebef6c1 947
f957f519 948#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
92ba85d4 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
0ebef6c1 958(defmethod container-add ((dialog dialog) (child widget) &rest args)
eb4f580c 959 (apply #'container-add (dialog-vbox dialog) child args))
0ebef6c1 960
d79b3413 961
0ebef6c1 962(defmethod container-remove ((dialog dialog) (child widget))
eb4f580c 963 (container-remove (dialog-vbox dialog) child))
d404b3af 964
0ebef6c1 965(defmethod container-children ((dialog dialog))
eb4f580c 966 (container-children (dialog-vbox dialog)))
0ebef6c1 967
968(defmethod (setf container-children) (children (dialog dialog))
eb4f580c 969 (setf (container-children (dialog-vbox dialog)) children))
0d07716f 970
0d07716f 971
5233fe44 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
c2c4a7e9 978;;; Entry
0d07716f 979
c2c4a7e9 980(defbinding entry-get-layout-offsets () nil
981 (entry entry)
982 (x int :out)
983 (y int :out))
0d07716f 984
14eaa563 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
0d07716f 993
a03a718a 994;;; Entry Completion
995
a92553bd 996(define-callback-marshal %entry-completion-match-callback boolean
997 (entry-completion string tree-iter))
a03a718a 998
999(defbinding entry-completion-set-match-func (completion function) nil
1000 (completion entry-completion)
a92553bd 1001 (%entry-completion-match-callback callback)
a03a718a 1002 ((register-callback-function function) unsigned-int)
a92553bd 1003 (user-data-destroy-callback callback))
a03a718a 1004
1005(defbinding entry-completion-complete () nil
1006 (completion entry-completion))
1007
93c531f0 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
f957f519 1012#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
a03a718a 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
49043b9a 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
f957f519 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))
49043b9a 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
f957f519 1142#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
49043b9a 1143(defbinding file-filter-add-pixbuf-formats () nil
1448a84f 1144 (filter file-filter))
49043b9a 1145
a92553bd 1146(define-callback-marshal %file-filter-callback boolean (file-filter-info))
49043b9a 1147
3d36c5d6 1148(defbinding file-filter-add-custom (filter needed function) nil
49043b9a 1149 (filter file-filter)
1150 (needed file-filter-flags)
a92553bd 1151 (%file-filter-callback callback)
49043b9a 1152 ((register-callback-function function) unsigned-int)
a92553bd 1153 (user-data-destroy-callback callback))
49043b9a 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
eb4f580c 1164;;; Image
1165
1166(defbinding image-set-from-file () nil
1167 (image image)
1168 (filename pathname))
1169
14eaa563 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))))
eb4f580c 1185
9617dc95 1186(defun create-image-widget (source &optional mask)
14eaa563 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))))
eb4f580c 1193
f957f519 1194#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
92ba85d4 1195(defbinding image-clear () nil
1196 (image image))
1197
1198
eb4f580c 1199
14eaa563 1200;;; Image menu item
eb4f580c 1201
14eaa563 1202(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
1203 (if (and image (not (typep image 'widget)))
9617dc95 1204 (apply #'call-next-method item :image (create-image-widget image) initargs)
14eaa563 1205 (call-next-method)))
eb4f580c 1206
14eaa563 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))
9617dc95 1212 (setf (image-menu-item-image item) (create-image-widget image)))
eb4f580c 1213
0d07716f 1214
d404b3af 1215;;; Label
0d07716f 1216
29aa1cc3 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
c2c4a7e9 1223(defbinding label-get-layout-offsets () nil
eb4f580c 1224 (label label)
c2c4a7e9 1225 (x int :out)
1226 (y int :out))
1227
d404b3af 1228(defbinding label-select-region () nil
1229 (label label)
1230 (start int)
1231 (end int))
0d07716f 1232
eb4f580c 1233(defbinding label-get-selection-bounds () boolean
c2c4a7e9 1234 (label label)
1235 (start int :out)
1236 (end int :out))
30481825 1237
0d07716f 1238
1239
1240;;; Radio button
1241
dd392521 1242(defbinding %radio-button-get-group () pointer
2afcd8bd 1243 (radio-button radio-button))
1244
a60bd055 1245(defbinding %radio-button-set-group () nil
2afcd8bd 1246 (radio-button radio-button)
1247 (group pointer))
0d07716f 1248
9617dc95 1249(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
2afcd8bd 1250 "Add BUTTON1 to the group which BUTTON2 belongs to."
1251 (%radio-button-set-group button1 (%radio-button-get-group button2)))
1252
30628c63 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
4a8bb854 1269(defgeneric add-activate-callback (action function &key object after))
1270
30628c63 1271(defmethod add-activate-callback ((button radio-button) function &key object after)
1272 (%add-activate-callback button 'clicked function object after))
1273
14eaa563 1274(defmethod initialize-instance ((button radio-button) &key group)
1275 (prog1
1276 (call-next-method)
1277 (when group
9617dc95 1278 (add-to-radio-group button group))))
0d07716f 1279
1280
0d07716f 1281;;; Item
1282
a60bd055 1283(defbinding item-select () nil
0d07716f 1284 (item item))
1285
a60bd055 1286(defbinding item-deselect () nil
0d07716f 1287 (item item))
1288
a60bd055 1289(defbinding item-toggle () nil
0d07716f 1290 (item item))
1291
1292
1293
1294;;; Menu item
1295
14eaa563 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
30481825 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
14eaa563 1306 :use-underline (menu-item-use-underline-p menu-item)
1307 :visible t :parent menu-item)
30481825 1308 label)
0d07716f 1309
378b3c5f 1310(defun menu-item-label (menu-item)
14eaa563 1311 (when (and (slot-boundp menu-item 'child)
1312 (typep (bin-child menu-item) 'label))
1313 (label-label (bin-child menu-item))))
378b3c5f 1314
14eaa563 1315(defbinding menu-item-remove-submenu () nil
30481825 1316 (menu-item menu-item))
0d07716f 1317
378b3c5f 1318(defbinding menu-item-set-accel-path () nil
1319 (menu-item menu-item)
1320 (accel-path string))
1321
a60bd055 1322(defbinding menu-item-select () nil
30481825 1323 (menu-item menu-item))
0d07716f 1324
a60bd055 1325(defbinding menu-item-deselect () nil
30481825 1326 (menu-item menu-item))
0d07716f 1327
a60bd055 1328(defbinding menu-item-activate () nil
30481825 1329 (menu-item menu-item))
0d07716f 1330
378b3c5f 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
0d07716f 1339
14eaa563 1340;;; Menu tool button
1341
f957f519 1342#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1448a84f 1343(defbinding menu-tool-button-set-arrow-tooltip () nil
14eaa563 1344 (menu-tool-button menu-tool-button)
1345 (tooltips tooltips)
1346 (tip-text string)
1347 (tip-private string))
1348
1349
30e8a60a 1350;;; Message dialog
1351
39db92d4 1352(defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
36df51ae 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
d453ba38 1366 &key message-type buttons button text
f957f519 1367 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
1368 secondary-text)
39db92d4 1369 (declare (ignore names))
4c308d58 1370 (when text
1371 (message-dialog-set-markup dialog text))
f957f519 1372 #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
4c308d58 1373 (when secondary-text
1374 (message-dialog-format-secondary-markup dialog secondary-text))
d453ba38 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)))
36df51ae 1382 (if (typep buttons 'buttons-type)
1383 (apply #'call-next-method dialog names (plist-remove :buttons initargs))
1384 (call-next-method)))
30e8a60a 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)
4c308d58 1392 (nil null))
30e8a60a 1393
1394(defbinding message-dialog-set-markup () nil
1395 (message-dialog message-dialog)
1396 (markup string))
1397
f957f519 1398#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
30e8a60a 1399(defbinding message-dialog-format-secondary-text () nil
1400 (message-dialog message-dialog)
1401 (text string))
1402
f957f519 1403#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
30e8a60a 1404(defbinding message-dialog-format-secondary-markup () nil
1405 (message-dialog message-dialog)
1406 (markup string))
1407
1408
0d07716f 1409
30481825 1410;;; Radio menu item
0d07716f 1411
dd392521 1412(defbinding %radio-menu-item-get-group () pointer
2afcd8bd 1413 (radio-menu-item radio-menu-item))
1414
a60bd055 1415(defbinding %radio-menu-item-set-group () nil
2afcd8bd 1416 (radio-menu-item radio-menu-item)
1417 (group pointer))
1418
30628c63 1419(defmethod activate-radio-widget ((item radio-menu-item))
1420 (menu-item-activate item))
1421
9617dc95 1422(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
2afcd8bd 1423 "Add ITEM1 to the group which ITEM2 belongs to."
1424 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1425
30628c63 1426(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1427 (%add-activate-callback item 'activate function object after))
1428
14eaa563 1429(defmethod initialize-instance ((item radio-menu-item) &key group)
378b3c5f 1430 (prog1
1431 (call-next-method)
14eaa563 1432 (when group
9617dc95 1433 (add-to-radio-group item group))))
1434
2afcd8bd 1435
0d07716f 1436
14eaa563 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
30628c63 1446(defmethod activate-radio-widget ((button radio-tool-button))
1447 (signal-emit button 'clicked))
1448
9617dc95 1449(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
14eaa563 1450 "Add BUTTON1 to the group which BUTTON2 belongs to."
1451 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
30628c63 1452(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1453 (%add-activate-callback button 'clicked function object after))
14eaa563 1454
1455(defmethod initialize-instance ((button radio-tool-button) &key group)
1456 (prog1
1457 (call-next-method)
1458 (when group
9617dc95 1459 (add-to-radio-group button group))))
1460
14eaa563 1461
0d07716f 1462
c2c4a7e9 1463;;; Toggle button
1464
1465(defbinding toggle-button-toggled () nil
1466 (toggle-button toggle-button))
1467
1468
0d07716f 1469;;; Window
1470
362f1795 1471(defmethod initialize-instance ((window window) &rest initargs
6e21e828 1472 &key display accel-group accel-groups)
362f1795 1473 (declare (ignore accel-group accel-groups))
1474 (prog1
6e21e828 1475 (if display
1476 (apply #'call-next-method
6b465328 1477 window :screen (gdk:display-get-default-screen (gdk:ensure-display display)) initargs)
6e21e828 1478 (call-next-method))
362f1795 1479 (initial-add window #'window-add-accel-group
1480 initargs :accel-group :accel-groups)))
99821988 1481
405b4406 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"
f957f519 1490 (window-title window) (pointer-address (foreign-location window))))
405b4406 1491 (call-next-method)))
99821988 1492
304cfb76 1493(defbinding window-set-wmclass () nil
0d07716f 1494 (window window)
1495 (wmclass-name string)
1496 (wmclass-class string))
1497
a60bd055 1498(defbinding window-add-accel-group () nil
0d07716f 1499 (window window)
1500 (accel-group accel-group))
1501
a60bd055 1502(defbinding window-remove-accel-group () nil
0d07716f 1503 (window window)
1504 (accel-group accel-group))
1505
a60bd055 1506(defbinding window-activate-focus () int
0d07716f 1507 (window window))
1508
a60bd055 1509(defbinding window-activate-default () int
0d07716f 1510 (window window))
1511
304cfb76 1512(defbinding window-set-default-size (window width height) int
0d07716f 1513 (window window)
304cfb76 1514 ((or width -1) int)
1515 ((or height -1) int))
0d07716f 1516
4eed43f1 1517(defbinding %window-set-geometry-hints () nil
1518 (window window)
d8dd2e76 1519 (widget (or widget null))
4eed43f1 1520 (geometry gdk:geometry)
1521 (geometry-mask gdk:window-hints))
1522
d8dd2e76 1523(defun window-set-geometry-hints (window &key widget min-width min-height
4eed43f1 1524 max-width max-height base-width base-height
d8dd2e76 1525 width-inc height-inc gravity
1526 aspect (min-aspect aspect) (max-aspect aspect))
4eed43f1 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)
d8dd2e76 1537 :max-aspect (or max-aspect 0)))
4eed43f1 1538 (mask ()))
d8dd2e76 1539 (when (or min-width min-height)
4eed43f1 1540 (push :min-size mask))
d8dd2e76 1541 (when (or max-width max-height)
4eed43f1 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))
d8dd2e76 1549 (when gravity
1550 (push :win-gravity mask)
1551 (setf (gdk:geometry-gravity geometry) gravity))
1552 (%window-set-geometry-hints window widget geometry mask)))
0d07716f 1553
99821988 1554(defbinding window-list-toplevels () (glist (copy-of window))
1555 "Returns a list of all existing toplevel windows.")
304cfb76 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
4eed43f1 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
f957f519 1580#?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
304cfb76 1581(defbinding window-present () nil
1582 (window window))
1583
f957f519 1584#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
92ba85d4 1585(progn
1586 (defbinding %window-present () nil
1587 (window window))
1588
12cae344 1589 (defbinding %window-present-with-time () nil
92ba85d4 1590 (window window)
1591 (timespamp unsigned-int))
1592
1593 (defun window-present (window &optional timestamp)
1594 (if timestamp
12cae344 1595 (%window-present-with-time window timestamp)
92ba85d4 1596 (%window-present window))))
1597
304cfb76 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
4eed43f1 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
304cfb76 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)
6baf860c 1635 (timestamp unsigned-int))
304cfb76 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)
6baf860c 1642 (timestamp unsigned-int))
304cfb76 1643
1644(defbinding window-set-frame-dimensions () nil
1645 (window window)
1646 (left int) (top int) (rigth int) (bottom int))
1647
304cfb76 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
ad98b596 1661(defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
304cfb76 1662 (window window))
1663
304cfb76 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
4eed43f1 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
94858129 1705 (icon gdk:pixbuf))
4eed43f1 1706
4a8bb854 1707(defgeneric (setf window-default-icon) (icon))
1708
4eed43f1 1709(defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1710 (%window-set-default-icon icon)
1711 icon)
1712
4a8bb854 1713(defgeneric (setf window-group) (group window))
1714
4eed43f1 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
304cfb76 1746 (window window)
4eed43f1 1747 (title string))
304cfb76 1748
4eed43f1 1749(defbinding decorated-window-move-resize-window () nil
1750 (window window)
1751 (x int)
1752 (y int)
1753 (width int)
1754 (heigth int))
304cfb76 1755
1756
4eed43f1 1757;;; Window group
0d07716f 1758
4eed43f1 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)))
0d07716f 1766
0d07716f 1767
4eed43f1 1768(defbinding window-group-add-window () nil
1769 (window-group window-group)
1770 (window window))
0d07716f 1771
4eed43f1 1772(defbinding window-group-remove-window () nil
1773 (window-group window-group)
1774 (window window))
0d07716f 1775
1776
30481825 1777;;; Scrolled window
0d07716f 1778
0d07716f 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
a60bd055 1783(defbinding scrolled-window-add-with-viewport () nil
0d07716f 1784 (scrolled-window scrolled-window)
1785 (child widget))
1786
4c308d58 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))
2afcd8bd 1793
0d07716f 1794
30481825 1795;;; Statusbar
0d07716f 1796
14eaa563 1797(defbinding statusbar-get-context-id () unsigned-int
30481825 1798 (statusbar statusbar)
1799 (context-description string))
0d07716f 1800
a60bd055 1801(defbinding statusbar-push () unsigned-int
30481825 1802 (statusbar statusbar)
1803 (context-id unsigned-int)
1804 (text string))
0d07716f 1805
a60bd055 1806(defbinding statusbar-pop () nil
30481825 1807 (statusbar statusbar)
1808 (context-id unsigned-int))
0d07716f 1809
a60bd055 1810(defbinding statusbar-remove () nil
30481825 1811 (statusbar statusbar)
1812 (context-id unsigned-int)
1813 (message-id unsigned-int))
0d07716f 1814
0d07716f 1815
1816
1817;;; Fixed
1818
a60bd055 1819(defbinding fixed-put () nil
30481825 1820 (fixed fixed)
1821 (widget widget)
378b3c5f 1822 (x int) (y int))
0d07716f 1823
a60bd055 1824(defbinding fixed-move () nil
30481825 1825 (fixed fixed)
1826 (widget widget)
378b3c5f 1827 (x int) (y int))
0d07716f 1828
1829
1830
2afcd8bd 1831;;; Notebook
0d07716f 1832
49043b9a 1833(defun %ensure-notebook-position (notebook page)
378b3c5f 1834 (etypecase page
49043b9a 1835 (position page)
378b3c5f 1836 (widget (notebook-page-num notebook page t))))
1837
49043b9a 1838(defun %ensure-notebook-child (notebook position)
378b3c5f 1839 (typecase position
1840 (widget position)
49043b9a 1841 (t (notebook-get-nth-page notebook position))))
378b3c5f 1842
1843(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
f957f519 1844 (notebook position child &optional tab-label menu-label) nil
30481825 1845 (notebook notebook)
1846 (child widget)
1847 ((if (stringp tab-label)
378b3c5f 1848 (make-instance 'label :label tab-label)
f957f519 1849 tab-label) (or null widget))
30481825 1850 ((if (stringp menu-label)
378b3c5f 1851 (make-instance 'label :label menu-label)
30481825 1852 menu-label) (or null widget))
49043b9a 1853 ((%ensure-notebook-position notebook position) position))
0d07716f 1854
f957f519 1855(defun notebook-append (notebook child &optional tab-label menu-label)
378b3c5f 1856 (notebook-insert notebook :last child tab-label menu-label))
0d07716f 1857
f957f519 1858(defun notebook-prepend (notebook child &optional tab-label menu-label)
378b3c5f 1859 (notebook-insert notebook :first child tab-label menu-label))
0d07716f 1860
378b3c5f 1861(defbinding notebook-remove-page (notebook page) nil
30481825 1862 (notebook notebook)
49043b9a 1863 ((%ensure-notebook-position notebook page) position))
0d07716f 1864
a60bd055 1865(defbinding %notebook-page-num () int
30481825 1866 (notebook notebook)
1867 (child widget))
1868
378b3c5f 1869(defun notebook-page-num (notebook child &optional error-p)
30481825 1870 (let ((page-num (%notebook-page-num notebook child)))
1871 (if (= page-num -1)
378b3c5f 1872 (when error-p
49043b9a 1873 (error "~A is not a page in ~A" child notebook))
30481825 1874 page-num)))
1875
a60bd055 1876(defbinding notebook-next-page () nil
30481825 1877 (notebook notebook))
0d07716f 1878
a60bd055 1879(defbinding notebook-prev-page () nil
30481825 1880 (notebook notebook))
1881
378b3c5f 1882(defbinding notebook-reorder-child (notebook child position) nil
1883 (notebook notebook)
1884 (child widget)
92ba85d4 1885 ((%ensure-notebook-position notebook position) int))
378b3c5f 1886
a60bd055 1887(defbinding notebook-popup-enable () nil
30481825 1888 (notebook notebook))
1889
a60bd055 1890(defbinding notebook-popup-disable () nil
30481825 1891 (notebook notebook))
1892
49043b9a 1893(defbinding notebook-get-nth-page () widget
378b3c5f 1894 (notebook notebook)
49043b9a 1895 (page position))
378b3c5f 1896
49043b9a 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))))
378b3c5f 1900
1901(defun (setf notebook-current-page) (page notebook)
f957f519 1902 (setf (notebook-current-page-num notebook) (notebook-page-num notebook page)))
378b3c5f 1903
eb4f580c 1904(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1905 (notebook page) widget
1906 (notebook notebook)
49043b9a 1907 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1908
eb4f580c 1909(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
84967144 1910 (notebook page) (copy-of string)
eb4f580c 1911 (notebook notebook)
49043b9a 1912 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1913
eb4f580c 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)))
49043b9a 1923 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
eb4f580c 1924 widget))
378b3c5f 1925
378b3c5f 1926
eb4f580c 1927(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1928 (notebook page) widget
1929 (notebook notebook)
49043b9a 1930 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1931
eb4f580c 1932(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
84967144 1933 (notebook page) (copy-of string)
eb4f580c 1934 (notebook notebook)
49043b9a 1935 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1936
eb4f580c 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)))
49043b9a 1946 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
eb4f580c 1947 widget))
378b3c5f 1948
1949
1950(defbinding notebook-query-tab-label-packing (notebook page) nil
30481825 1951 (notebook notebook)
92ba85d4 1952 ((%ensure-notebook-child notebook page) widget)
30481825 1953 (expand boolean :out)
1954 (fill boolean :out)
1955 (pack-type pack-type :out))
1956
378b3c5f 1957(defbinding notebook-set-tab-label-packing
1958 (notebook page expand fill pack-type) nil
30481825 1959 (notebook notebook)
92ba85d4 1960 ((%ensure-notebook-child notebook page) widget)
30481825 1961 (expand boolean)
1962 (fill boolean)
1963 (pack-type pack-type))
1964
0d07716f 1965
1966
2afcd8bd 1967;;; Paned
0d07716f 1968
a60bd055 1969(defbinding paned-pack1 () nil
2afcd8bd 1970 (paned paned)
1971 (child widget)
1972 (resize boolean)
1973 (shrink boolean))
0d07716f 1974
a60bd055 1975(defbinding paned-pack2 () nil
2afcd8bd 1976 (paned paned)
1977 (child widget)
1978 (resize boolean)
1979 (shrink boolean))
0d07716f 1980
0d07716f 1981
2afcd8bd 1982;;; Layout
0d07716f 1983
a60bd055 1984(defbinding layout-put () nil
2afcd8bd 1985 (layout layout)
49043b9a 1986 (child widget)
2afcd8bd 1987 (x int)
1988 (y int))
0d07716f 1989
a60bd055 1990(defbinding layout-move () nil
2afcd8bd 1991 (layout layout)
49043b9a 1992 (child widget)
2afcd8bd 1993 (x int)
1994 (y int))
0d07716f 1995
49043b9a 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))
0d07716f 2005
2006
0d07716f 2007;;; Menu shell
2008
378b3c5f 2009(defbinding menu-shell-insert (menu-shell menu-item position) nil
30481825 2010 (menu-shell menu-shell)
2011 (menu-item menu-item)
378b3c5f 2012 ((case position
2013 (:first 0)
2014 (:last -1)
2015 (t position)) int))
0d07716f 2016
30481825 2017(defun menu-shell-append (menu-shell menu-item)
378b3c5f 2018 (menu-shell-insert menu-shell menu-item :last))
0d07716f 2019
30481825 2020(defun menu-shell-prepend (menu-shell menu-item)
378b3c5f 2021 (menu-shell-insert menu-shell menu-item :fisrt))
0d07716f 2022
a60bd055 2023(defbinding menu-shell-deactivate () nil
30481825 2024 (menu-shell menu-shell))
0d07716f 2025
a60bd055 2026(defbinding menu-shell-select-item () nil
30481825 2027 (menu-shell menu-shell)
2028 (menu-item menu-item))
0d07716f 2029
14eaa563 2030(defbinding menu-shell-select-first () nil
2031 (menu-shell menu-shell)
2032 (search-sensitive boolean))
2033
a60bd055 2034(defbinding menu-shell-deselect () nil
30481825 2035 (menu-shell menu-shell))
0d07716f 2036
a60bd055 2037(defbinding menu-shell-activate-item () nil
30481825 2038 (menu-shell menu-shell)
2039 (menu-item menu-item)
2040 (fore-deactivate boolean))
0d07716f 2041
14eaa563 2042(defbinding menu-shell-cancel () nil
2043 (menu-shell menu-shell))
0d07716f 2044
2045
378b3c5f 2046;;; Menu
0d07716f 2047
378b3c5f 2048(defun %menu-position (menu child)
2049 (etypecase child
2050 (int child)
2051 (keyword (case child
2052 (:first 0)
2053 (:last -1)
eb4f580c 2054 (t (error "Invalid position keyword: ~A" child))))
378b3c5f 2055 (widget (menu-child-position menu child))))
0d07716f 2056
2057
378b3c5f 2058(defbinding menu-reorder-child (menu menu-item position) nil
2059 (menu menu)
2060 (menu-item menu-item)
2061 ((%menu-position menu position) int))
0d07716f 2062
14eaa563 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
a92553bd 2071(define-callback-marshal %menu-position-callback nil
2072 (menu (x int) (y int) (push-in boolean)))
0d07716f 2073
378b3c5f 2074(defbinding %menu-popup () nil
2075 (menu menu)
2076 (parent-menu-shell (or null menu-shell))
2077 (parent-menu-item (or null menu-item))
a92553bd 2078 (callback (or null callback))
378b3c5f 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
4886872c 2086 (with-callback-function (id callback)
2087 (%menu-popup
2088 menu parent-menu-shell parent-menu-item
a92553bd 2089 %menu-position-callback id button activate-time))
378b3c5f 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))
0d07716f 2096
a60bd055 2097(defbinding menu-reposition () nil
30481825 2098 (menu menu))
0d07716f 2099
a60bd055 2100(defbinding menu-popdown () nil
30481825 2101 (menu menu))
0d07716f 2102
378b3c5f 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
a60bd055 2109(defbinding %menu-set-active () nil
30481825 2110 (menu menu)
2111 (index unsigned-int))
0d07716f 2112
378b3c5f 2113(defun (setf menu-active) (menu child)
2114 (%menu-set-active menu (%menu-position menu child))
2115 child)
2afcd8bd 2116
a92553bd 2117(define-callback %menu-detach-callback nil ((widget widget) (menu menu))
f957f519 2118 (funcall (user-data menu 'detach-func) widget menu))
14eaa563 2119
405b4406 2120(defbinding %menu-attach-to-widget (menu widget) nil
14eaa563 2121 (menu menu)
2122 (widget widget)
a92553bd 2123 (%menu-detach-callback callback))
14eaa563 2124
2125(defun menu-attach-to-widget (menu widget function)
f957f519 2126 (setf (user-data menu 'detach-func) function)
14eaa563 2127 (%menu-attach-to-widget menu widget))
2128
2129(defbinding menu-detach () nil
2130 (menu menu))
2131
f957f519 2132#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
14eaa563 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))
0d07716f 2139
2140
30481825 2141;;; Table
0d07716f 2142
a60bd055 2143(defbinding table-resize () nil
30481825 2144 (table table)
2145 (rows unsigned-int)
2146 (columns unsigned-int))
0d07716f 2147
a60bd055 2148(defbinding table-attach (table child left right top bottom
362f1795 2149 &key options x-options y-options
2150 (x-padding 0) (y-padding 0)) nil
30481825 2151 (table table)
2152 (child widget)
2153 (left unsigned-int)
2154 (right unsigned-int)
2155 (top unsigned-int)
2156 (bottom unsigned-int)
362f1795 2157 ((append (mklist options) (mklist x-options)) attach-options)
2158 ((append (mklist options) (mklist y-options)) attach-options)
30481825 2159 (x-padding unsigned-int)
2160 (y-padding unsigned-int))
2161
dd392521 2162
a60bd055 2163(defbinding %table-set-row-spacing () nil
30481825 2164 (table table)
2165 (row unsigned-int)
2166 (spacing unsigned-int))
2167
dd392521 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))
30481825 2176 spacing)
2177
dd392521 2178(defbinding %table-get-row-spacing () unsigned-int
30481825 2179 (table table)
dd392521 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
30481825 2190
a60bd055 2191(defbinding %table-set-col-spacing () nil
30481825 2192 (table table)
2193 (col unsigned-int)
2194 (spacing unsigned-int))
2195
dd392521 2196(defbinding %table-set-col-spacings () nil
2197 (table table)
2198 (spacing unsigned-int))
2199
5233fe44 2200(defun (setf table-column-spacing) (spacing table &optional column)
2201 (if column
2202 (%table-set-col-spacing table column spacing)
dd392521 2203 (%table-set-col-spacings table spacing))
30481825 2204 spacing)
2205
5233fe44 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
dd392521 2210(defbinding %table-get-col-spacing () unsigned-int
30481825 2211 (table table)
dd392521 2212 (col unsigned-int))
2213
2214(defbinding %table-get-default-col-spacing () unsigned-int
2215 (table table))
2216
5233fe44 2217(defun table-column-spacing (table &optional column)
2218 (if column
2219 (%table-get-col-spacing table column)
dd392521 2220 (%table-get-default-col-spacing table)))
2221
5233fe44 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
dd392521 2226
30481825 2227
2228;;; Toolbar
2229
9617dc95 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)))
0d07716f 2235
9617dc95 2236(defbinding %toolbar-insert () nil
378b3c5f 2237 (toolbar toolbar)
9617dc95 2238 (tool-item tool-item)
2239 (position position))
30481825 2240
9617dc95 2241(defun toolbar-insert (toolbar tool-item &optional (position :end))
2242 (%toolbar-insert toolbar tool-item position)
2243 (%tool-item-update-tooltips tool-item))
378b3c5f 2244
9617dc95 2245(defbinding toolbar-get-item-index () int
2246 (toolbar toolbar)
2247 (item tool-item))
30481825 2248
9617dc95 2249(defbinding toolbar-get-nth-item () tool-item
2250 (toolbar toolbar)
2251 (n int))
30481825 2252
9617dc95 2253(defbinding toolbar-get-drop-index () int
2254 (toolbar toolbar)
2255 (x int) (y int))
30481825 2256
9617dc95 2257(defbinding toolbar-set-drop-highlight-item () nil
2258 (toolbar toolbar)
2259 (tool-item tool-item)
2260 (index int))
30481825 2261
0d07716f 2262
9617dc95 2263;;; Tool button
0d07716f 2264
9617dc95 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)))
0d07716f 2269
2270
9617dc95 2271;;; Tool item
0d07716f 2272
9617dc95 2273(defbinding tool-item-set-tooltip () nil
2274 (tool-item tool-item)
2275 (tooltips tooltips)
2276 (tip-text string)
2277 (tip-private string))
0d07716f 2278
0d07716f 2279
9617dc95 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)))
0d07716f 2306
14eaa563 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
f957f519 2325#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.6.0")
14eaa563 2326(defbinding tool-item-rebuild-menu () nil
2327 (tool-item tool-item))
2328
2329
a60bd055 2330;;; Editable
eb4f580c 2331
a60bd055 2332(defbinding editable-select-region (editable &optional (start 0) end) nil
30481825 2333 (editable editable)
2334 (start int)
2335 ((or end -1) int))
0d07716f 2336
eb4f580c 2337(defbinding editable-get-selection-bounds (editable) nil
2338 (editable editable)
2339 (start int :out)
2340 (end int :out))
2341
14eaa563 2342(defbinding editable-insert-text (editable text &optional (position 0)) nil
30481825 2343 (editable editable)
2344 (text string)
2345 ((length text) int)
f957f519 2346 (position position :in/out))
0d07716f 2347
30481825 2348(defun editable-append-text (editable text)
2349 (editable-insert-text editable text nil))
0d07716f 2350
30481825 2351(defun editable-prepend-text (editable text)
2352 (editable-insert-text editable text 0))
0d07716f 2353
a60bd055 2354(defbinding editable-delete-text (editable &optional (start 0) end) nil
30481825 2355 (editable editable)
2356 (start int)
2357 ((or end -1) int))
0d07716f 2358
a60bd055 2359(defbinding (editable-text "gtk_editable_get_chars")
30481825 2360 (editable &optional (start 0) end) string
2361 (editable editable)
2362 (start int)
2363 ((or end -1) int))
0d07716f 2364
30481825 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)
0d07716f 2372
a60bd055 2373(defbinding editable-cut-clipboard () nil
30481825 2374 (editable editable))
0d07716f 2375
a60bd055 2376(defbinding editable-copy-clipboard () nil
30481825 2377 (editable editable))
0d07716f 2378
a60bd055 2379(defbinding editable-paste-clipboard () nil
30481825 2380 (editable editable))
0d07716f 2381
a60bd055 2382(defbinding editable-delete-selection () nil
30481825 2383 (editable editable))
0d07716f 2384
0d07716f 2385
0d07716f 2386
30481825 2387;;; Spin button
0d07716f 2388
14eaa563 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
30481825 2405(defun spin-button-value-as-int (spin-button)
2406 (round (spin-button-value spin-button)))
0d07716f 2407
45314d76 2408(defbinding %spin-button-spin () nil
30481825 2409 (spin-button spin-button)
2410 (direction spin-type)
45314d76 2411 (increment double-float))
2412
2413(defun spin-button-spin (spin-button value)
2414 (etypecase value
66b1c1c2 2415 (real (%spin-button-spin spin-button :user-defined value))
45314d76 2416 (spin-type (%spin-button-spin spin-button value 0))))
2417
0d07716f 2418
a60bd055 2419(defbinding spin-button-update () nil
30481825 2420 (spin-button spin-button))
0d07716f 2421
2422
2423
2424; ;;; Ruler
2425
a60bd055 2426(defbinding ruler-set-range () nil
30481825 2427 (ruler ruler)
2428 (lower single-float)
2429 (upper single-float)
2430 (position single-float)
2431 (max-size single-float))
0d07716f 2432
49043b9a 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))
0d07716f 2439
0d07716f 2440
0d07716f 2441
2afcd8bd 2442;;; Range
0d07716f 2443
eb4f580c 2444(defun range-lower (range)
2445 (adjustment-lower (range-adjustment range)))
0d07716f 2446
eb4f580c 2447(defun range-upper (range)
2448 (adjustment-upper (range-adjustment range)))
0d07716f 2449
eb4f580c 2450(defun (setf range-lower) (value range)
2451 (setf (adjustment-lower (range-adjustment range)) value))
0d07716f 2452
eb4f580c 2453(defun (setf range-upper) (value range)
2454 (setf (adjustment-upper (range-adjustment range)) value))
0d07716f 2455
eb4f580c 2456(defun range-page-increment (range)
2457 (adjustment-page-increment (range-adjustment range)))
0d07716f 2458
eb4f580c 2459(defun range-step-increment (range)
2460 (adjustment-step-increment (range-adjustment range)))
0d07716f 2461
eb4f580c 2462(defun (setf range-page-increment) (value range)
2463 (setf (adjustment-page-increment (range-adjustment range)) value))
0d07716f 2464
eb4f580c 2465(defun (setf range-step-increment) (value range)
2466 (setf (adjustment-step-increment (range-adjustment range)) value))
0d07716f 2467
eb4f580c 2468(defbinding range-set-range () nil
2afcd8bd 2469 (range range)
eb4f580c 2470 (lower double-float)
2471 (upper double-float))
0d07716f 2472
eb4f580c 2473(defbinding range-set-increments () nil
2afcd8bd 2474 (range range)
eb4f580c 2475 (step double-float)
2476 (page double-float))
0d07716f 2477
0d07716f 2478
2afcd8bd 2479;;; Scale
0d07716f 2480
49043b9a 2481(defbinding scale-get-layout-offsets () nil
2482 (scale scale)
2483 (x int :out)
2484 (y int :out))
0d07716f 2485
0d07716f 2486
2afcd8bd 2487;;; Progress bar
0d07716f 2488
a60bd055 2489(defbinding progress-bar-pulse () nil
2afcd8bd 2490 (progress-bar progress-bar))
0d07716f 2491
2492
362f1795 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
0d07716f 2512
378b3c5f 2513;;; Stock items
2514
99821988 2515(defbinding %stock-item-copy () pointer
2516 (location pointer))
2517
2518(defbinding %stock-item-free () nil
2519 (location pointer))
378b3c5f 2520
99821988 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)
f957f519 2532 (with-memory (stock-item (foreign-size (find-class 'stock-item)))
66984e02 2533 (when (%stock-lookup stock-id stock-item)
2534 (ensure-proxy-instance 'stock-item (%stock-item-copy stock-item)))))
0d07716f 2535
f957f519 2536#?(pkg-exists-p "gtk+-2.0" :atleast-version "2.8.0")
66984e02 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
ff1b3ff2 2547
2548;;; Tooltip
2549
bca64b37 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))
ff1b3ff2 2584
66984e02 2585
0d07716f 2586
ff1b3ff2 2587;;; Tooltips
2588
2589;; GtkTooltips has been deprecated in favor of the new tooltip API
2590;; introduced in in GTK+ 2.12
0d07716f 2591
a60bd055 2592(defbinding tooltips-enable () nil
2afcd8bd 2593 (tooltips tooltips))
0d07716f 2594
a60bd055 2595(defbinding tooltips-disable () nil
2afcd8bd 2596 (tooltips tooltips))
0d07716f 2597
dd392521 2598(defun (setf tooltips-enabled-p) (enable tooltips)
2599 (if enable
2600 (tooltips-enable tooltips)
2601 (tooltips-disable tooltips)))
2602
a60bd055 2603(defbinding tooltips-set-tip () nil
2afcd8bd 2604 (tooltips tooltips)
2605 (widget widget)
2606 (tip-text string)
2607 (tip-private string))
0d07716f 2608
14eaa563 2609(defbinding tooltips-data-get () tooltips-data
2610 (widget widget))
2611
a60bd055 2612(defbinding tooltips-force-window () nil
2afcd8bd 2613 (tooltips tooltips))
0d07716f 2614
14eaa563 2615(defbinding tooltips-get-info-from-tip-window () boolean
2616 (tip-window window)
2617 (tooltips tooltips :out)
2618 (current-widget widget :out))
0d07716f 2619
2620
e69138cc 2621;;; Resource Files
0d07716f 2622
17163f4e 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))
0d07716f 2630
17163f4e 2631(defbinding rc-parse () nil
2632 (filename pathname))
0d07716f 2633
a60bd055 2634(defbinding rc-parse-string () nil
2afcd8bd 2635 (rc-string string))
0d07716f 2636
17163f4e 2637(defbinding %rc-reparse-all () boolean)
0d07716f 2638
17163f4e 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)))
14ac49ee 2684
2685
14ac49ee 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)))
ff1b3ff2 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