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