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