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