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