chiark / gitweb /
Unified API for all types of radio objects.
[clg] / gtk / gtk.lisp
CommitLineData
560af5c5 1;; Common Lisp bindings for GTK+ v2.0
bbaeff4b 2;; Copyright (C) 1999-2001 Espen S. Johnsen <esj@stud.cs.uit.no>
560af5c5 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
a5522de5 18;; $Id: gtk.lisp,v 1.41 2005-04-19 08:11:39 espen Exp $
560af5c5 19
20
21(in-package "GTK")
22
23;;; Gtk version
24
6bb23851 25(defbinding check-version () (copy-of string)
560af5c5 26 (required-major unsigned-int)
27 (required-minor unsigned-int)
28 (required-micro unsigned-int))
29
bbaeff4b 30(defbinding query-version () nil
560af5c5 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
6bb23851 42(defbinding get-default-language () (copy-of pango:language))
560af5c5 43
44
9adccb27 45;;;; Initalization
46
a5522de5 47(defbinding (gtk-init "gtk_parse_args") () boolean
9adccb27 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)
a5522de5 56 (unless (gtk-init)
57 (error "Initialization of GTK+ failed."))
9adccb27 58 (prog1
59 (gdk:display-open display)
73572c12 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))))
9adccb27 64
65
667a112b 66;;; Misc
67
68(defbinding grab-add () nil
69 (widget widget))
70
7abdba43 71(defbinding grab-get-current () widget)
667a112b 72
73(defbinding grab-remove () nil
74 (widget widget))
75
76
647c99e5 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
0f476ab5 95;;; Acccel group
560af5c5 96
31700e82 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
73572c12 149(defbinding accelerator-valid-p (key &optional modifiers) boolean
31700e82 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)
560af5c5 180
1047e159 181
560af5c5 182;;; Acccel label
183
bbaeff4b 184(defbinding accel-label-refetch () boolean
560af5c5 185 (accel-label accel-label))
186
187
31700e82 188
189;;; Accel map
190
a5522de5 191;(defbinding (accel-map-init "_gtk_accel_map_init") () nil)
192
31700e82 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
d76e9fca 232;;; Accessible
233
234(defbinding accessible-connect-widget-destroyed () nil
235 (accessible accessible))
236
237
0f476ab5 238;;; Adjustment
560af5c5 239
d76e9fca 240(defmethod initialize-instance ((adjustment adjustment) &key value)
1047e159 241 (prog1
242 (call-next-method)
243 ;; we need to make sure that the value is set last, otherwise it
d76e9fca 244 ;; may be outside current limits and ignored
1047e159 245 (when value
246 (setf (slot-value adjustment 'value) value))))
247
248
0f476ab5 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))
560af5c5 259
0f476ab5 260
68f519e0 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
0f476ab5 285;;; Aspect frame
286
287
288;;; Bin
560af5c5 289
290(defun (setf bin-child) (child bin)
0f476ab5 291 (when-bind (current-child (bin-child bin))
292 (container-remove bin current-child))
560af5c5 293 (container-add bin child)
294 child)
295
14c94516 296(defmethod compute-signal-function ((bin bin) signal function object)
297 (declare (ignore signal))
298 (if (eq object :child)
cb4bf772 299 #'(lambda (&rest args)
300 (apply function (bin-child bin) (rest args)))
301 (call-next-method)))
0f476ab5 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
d76e9fca 320(defun box-pack (box child &key end (expand t) (fill t) (padding 0))
1a1949c7 321 (if end
f5b67f2b 322 (box-pack-end box child expand fill padding)
323 (box-pack-start box child expand fill padding)))
0f476ab5 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
560af5c5 348;;; Button
349
d76e9fca 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
bbaeff4b 356(defbinding button-pressed () nil
560af5c5 357 (button button))
358
0f476ab5 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
d76e9fca 395(defbinding calendar-get-date () nil
0f476ab5 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
0f476ab5 408;;; Check menu item
409
410(defbinding check-menu-item-toggled () nil
411 (check-menu-item check-menu-item))
412
413
0f476ab5 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
1a1949c7 426;;;; Combo Box
0f476ab5 427
d76e9fca 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
1a1949c7 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))
0f476ab5 469
1a1949c7 470(defbinding combo-box-popup () nil
471 (combo-box combo-box))
0f476ab5 472
1a1949c7 473(defbinding combo-box-popdown () nil
474 (combo-box combo-box))
475
476
477
478;;;; Combo Box Entry
479
d76e9fca 480(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
1a1949c7 481 (call-next-method)
482 (unless model
483 (setf (combo-box-entry-text-column combo-box-entry) 0)))
0f476ab5 484
485
48da76bf 486;;;; Dialog
0f476ab5 487
c49be931 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)))
48da76bf 494
0f476ab5 495
14c94516 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
1047e159 504 (cond
14c94516 505 (responses
506 (vector-push-extend response responses)
507 (1- (length responses)))
1047e159 508 (t
509 (setf
14c94516 510 (object-data dialog 'responses)
511 (make-array 1 :adjustable t :fill-pointer t
512 :initial-element response))
1047e159 513 0)))
514 (error-p
14c94516 515 (error "Invalid response: ~A" response))))))
0f476ab5 516
14c94516 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)))
0f476ab5 538
48da76bf 539(defbinding dialog-run () nil
540 (dialog dialog))
0f476ab5 541
14c94516 542(defbinding dialog-response (dialog response) nil
0f476ab5 543 (dialog dialog)
14c94516 544 ((dialog-response-id dialog response nil t) int))
0f476ab5 545
546
547(defbinding %dialog-add-button () button
548 (dialog dialog)
549 (text string)
14c94516 550 (response-id int))
0f476ab5 551
1047e159 552(defun dialog-add-button (dialog label &optional (response label)
553 &key default object after)
40b2615c 554 "Adds a button to the dialog."
14c94516 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)))
1047e159 560 (when (functionp response)
14c94516 561 (signal-connect dialog signal response :object object :after after))
1047e159 562 (when default
14c94516 563 (%dialog-set-default-response dialog id))
0f476ab5 564 button))
565
566
14c94516 567(defbinding %dialog-add-action-widget () nil
0f476ab5 568 (dialog dialog)
569 (action-widget widget)
14c94516 570 (response-id int))
0f476ab5 571
1047e159 572(defun dialog-add-action-widget (dialog widget &optional (response widget)
573 &key default object after)
14c94516 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)
1047e159 581 (when (functionp response)
14c94516 582 (signal-connect dialog signal response :object object :after after))
1047e159 583 (when default
14c94516 584 (%dialog-set-default-response dialog id))
0f476ab5 585 widget))
0f476ab5 586
0f476ab5 587
48da76bf 588(defbinding %dialog-set-default-response () nil
589 (dialog dialog)
14c94516 590 (response-id int))
0f476ab5 591
14c94516 592(defun dialog-set-default-response (dialog response)
48da76bf 593 (%dialog-set-default-response
14c94516 594 dialog (dialog-response-id dialog response nil t)))
0f476ab5 595
14c94516 596(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
48da76bf 597 (dialog dialog)
14c94516 598 ((dialog-response-id dialog response nil t) int)
48da76bf 599 (sensitive boolean))
0f476ab5 600
40b2615c 601#+gtk2.6
647c99e5 602(defbinding alternative-dialog-button-order-p (&optional screen) boolean
603 (screen (or null gdk:screen)))
40b2615c 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)
14c94516 611 ((map 'vector #'(lambda (response)
612 (dialog-response-id dialog response nil t))
40b2615c 613 new-order) (vector int)))
0f476ab5 614
48da76bf 615
616(defmethod container-add ((dialog dialog) (child widget) &rest args)
1047e159 617 (apply #'container-add (dialog-vbox dialog) child args))
48da76bf 618
14c94516 619
48da76bf 620(defmethod container-remove ((dialog dialog) (child widget))
1047e159 621 (container-remove (dialog-vbox dialog) child))
0f476ab5 622
48da76bf 623(defmethod container-children ((dialog dialog))
1047e159 624 (container-children (dialog-vbox dialog)))
48da76bf 625
626(defmethod (setf container-children) (children (dialog dialog))
1047e159 627 (setf (container-children (dialog-vbox dialog)) children))
560af5c5 628
560af5c5 629
aaa6e6cb 630;;; Entry
560af5c5 631
aaa6e6cb 632(defbinding entry-get-layout-offsets () nil
633 (entry entry)
634 (x int :out)
635 (y int :out))
560af5c5 636
d76e9fca 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
560af5c5 645
f45fd227 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)
73572c12 655 ((callback user-data-destroy-func) pointer))
f45fd227 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
68f519e0 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
647c99e5 790 (filter file-filter))
68f519e0 791
792(def-callback-marshal %file-filter-func (boolean file-filter-info))
793
73572c12 794(defbinding file-filter-add-custom (filter needed function) nil
68f519e0 795 (filter file-filter)
796 (needed file-filter-flags)
797 ((callback %file-filter-func) pointer)
798 ((register-callback-function function) unsigned-int)
73572c12 799 ((callback user-data-destroy-func) pointer))
68f519e0 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
1047e159 810;;; Image
811
812(defbinding image-set-from-file () nil
813 (image image)
814 (filename pathname))
815
d76e9fca 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))))
1047e159 831
cb4bf772 832(defun create-image-widget (source &optional mask)
d76e9fca 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))))
1047e159 839
1047e159 840
d76e9fca 841;;; Image menu item
1047e159 842
d76e9fca 843(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
844 (if (and image (not (typep image 'widget)))
cb4bf772 845 (apply #'call-next-method item :image (create-image-widget image) initargs)
d76e9fca 846 (call-next-method)))
1047e159 847
d76e9fca 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))
cb4bf772 853 (setf (image-menu-item-image item) (create-image-widget image)))
1047e159 854
560af5c5 855
0f476ab5 856;;; Label
560af5c5 857
881fe3c3 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
aaa6e6cb 864(defbinding label-get-layout-offsets () nil
1047e159 865 (label label)
aaa6e6cb 866 (x int :out)
867 (y int :out))
868
0f476ab5 869(defbinding label-select-region () nil
870 (label label)
871 (start int)
872 (end int))
560af5c5 873
1047e159 874(defbinding label-get-selection-bounds () boolean
aaa6e6cb 875 (label label)
876 (start int :out)
877 (end int :out))
f36ca6af 878
560af5c5 879
880
881;;; Radio button
882
e5b416f0 883(defbinding %radio-button-get-group () pointer
d520140e 884 (radio-button radio-button))
885
bbaeff4b 886(defbinding %radio-button-set-group () nil
d520140e 887 (radio-button radio-button)
888 (group pointer))
560af5c5 889
cb4bf772 890(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
d520140e 891 "Add BUTTON1 to the group which BUTTON2 belongs to."
892 (%radio-button-set-group button1 (%radio-button-get-group button2)))
893
a5522de5 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
d76e9fca 913(defmethod initialize-instance ((button radio-button) &key group)
914 (prog1
915 (call-next-method)
916 (when group
cb4bf772 917 (add-to-radio-group button group))))
560af5c5 918
919
560af5c5 920;;; Item
921
bbaeff4b 922(defbinding item-select () nil
560af5c5 923 (item item))
924
bbaeff4b 925(defbinding item-deselect () nil
560af5c5 926 (item item))
927
bbaeff4b 928(defbinding item-toggle () nil
560af5c5 929 (item item))
930
931
932
933;;; Menu item
934
d76e9fca 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
f36ca6af 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
d76e9fca 945 :use-underline (menu-item-use-underline-p menu-item)
946 :visible t :parent menu-item)
f36ca6af 947 label)
560af5c5 948
f5b67f2b 949(defun menu-item-label (menu-item)
d76e9fca 950 (when (and (slot-boundp menu-item 'child)
951 (typep (bin-child menu-item) 'label))
952 (label-label (bin-child menu-item))))
f5b67f2b 953
d76e9fca 954(defbinding menu-item-remove-submenu () nil
f36ca6af 955 (menu-item menu-item))
560af5c5 956
f5b67f2b 957(defbinding menu-item-set-accel-path () nil
958 (menu-item menu-item)
959 (accel-path string))
960
bbaeff4b 961(defbinding menu-item-select () nil
f36ca6af 962 (menu-item menu-item))
560af5c5 963
bbaeff4b 964(defbinding menu-item-deselect () nil
f36ca6af 965 (menu-item menu-item))
560af5c5 966
bbaeff4b 967(defbinding menu-item-activate () nil
f36ca6af 968 (menu-item menu-item))
560af5c5 969
f5b67f2b 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
560af5c5 978
d76e9fca 979;;; Menu tool button
980
981#+gtk2.6
647c99e5 982(defbinding menu-tool-button-set-arrow-tooltip () nil
d76e9fca 983 (menu-tool-button menu-tool-button)
984 (tooltips tooltips)
985 (tip-text string)
986 (tip-private string))
987
988
f4267180 989;;; Message dialog
990
7a2e0799 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)
f4267180 995 (setf
996 (slot-value dialog 'location)
7a2e0799 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))
f4267180 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)
7a2e0799 1011 (nil null))
f4267180 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
560af5c5 1028
f36ca6af 1029;;; Radio menu item
560af5c5 1030
e5b416f0 1031(defbinding %radio-menu-item-get-group () pointer
d520140e 1032 (radio-menu-item radio-menu-item))
1033
bbaeff4b 1034(defbinding %radio-menu-item-set-group () nil
d520140e 1035 (radio-menu-item radio-menu-item)
1036 (group pointer))
1037
a5522de5 1038(defmethod activate-radio-widget ((item radio-menu-item))
1039 (menu-item-activate item))
1040
cb4bf772 1041(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
d520140e 1042 "Add ITEM1 to the group which ITEM2 belongs to."
1043 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1044
a5522de5 1045(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1046 (%add-activate-callback item 'activate function object after))
1047
d76e9fca 1048(defmethod initialize-instance ((item radio-menu-item) &key group)
f5b67f2b 1049 (prog1
1050 (call-next-method)
d76e9fca 1051 (when group
cb4bf772 1052 (add-to-radio-group item group))))
1053
d520140e 1054
560af5c5 1055
d76e9fca 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
a5522de5 1065(defmethod activate-radio-widget ((button radio-tool-button))
1066 (signal-emit button 'clicked))
1067
cb4bf772 1068(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
d76e9fca 1069 "Add BUTTON1 to the group which BUTTON2 belongs to."
1070 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
a5522de5 1071(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1072 (%add-activate-callback button 'clicked function object after))
d76e9fca 1073
1074(defmethod initialize-instance ((button radio-tool-button) &key group)
1075 (prog1
1076 (call-next-method)
1077 (when group
cb4bf772 1078 (add-to-radio-group button group))))
1079
d76e9fca 1080
560af5c5 1081
aaa6e6cb 1082;;; Toggle button
1083
1084(defbinding toggle-button-toggled () nil
1085 (toggle-button toggle-button))
1086
1087
560af5c5 1088;;; Window
1089
c49be931 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)))
73d58e01 1097
1098
7625ebd8 1099(defbinding window-set-wmclass () nil
560af5c5 1100 (window window)
1101 (wmclass-name string)
1102 (wmclass-class string))
1103
bbaeff4b 1104(defbinding window-add-accel-group () nil
560af5c5 1105 (window window)
1106 (accel-group accel-group))
1107
bbaeff4b 1108(defbinding window-remove-accel-group () nil
560af5c5 1109 (window window)
1110 (accel-group accel-group))
1111
bbaeff4b 1112(defbinding window-activate-focus () int
560af5c5 1113 (window window))
1114
bbaeff4b 1115(defbinding window-activate-default () int
560af5c5 1116 (window window))
1117
7625ebd8 1118(defbinding window-set-default-size (window width height) int
560af5c5 1119 (window window)
7625ebd8 1120 ((or width -1) int)
1121 ((or height -1) int))
560af5c5 1122
4d16221f 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)))
560af5c5 1158
73d58e01 1159(defbinding window-list-toplevels () (glist (copy-of window))
1160 "Returns a list of all existing toplevel windows.")
7625ebd8 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
4d16221f 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
7625ebd8 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
4d16221f 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
7625ebd8 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)
9adccb27 1225 (timestamp unsigned-int))
7625ebd8 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)
9adccb27 1232 (timestamp unsigned-int))
7625ebd8 1233
1234(defbinding window-set-frame-dimensions () nil
1235 (window window)
1236 (left int) (top int) (rigth int) (bottom int))
1237
7625ebd8 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
7625ebd8 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
4d16221f 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
7625ebd8 1332 (window window)
4d16221f 1333 (title string))
7625ebd8 1334
4d16221f 1335(defbinding decorated-window-move-resize-window () nil
1336 (window window)
1337 (x int)
1338 (y int)
1339 (width int)
1340 (heigth int))
7625ebd8 1341
1342
4d16221f 1343;;; Window group
560af5c5 1344
4d16221f 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)))
560af5c5 1352
560af5c5 1353
4d16221f 1354(defbinding window-group-add-window () nil
1355 (window-group window-group)
1356 (window window))
560af5c5 1357
4d16221f 1358(defbinding window-group-remove-window () nil
1359 (window-group window-group)
1360 (window window))
560af5c5 1361
1362
f36ca6af 1363;;; Scrolled window
560af5c5 1364
560af5c5 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
bbaeff4b 1369(defbinding scrolled-window-add-with-viewport () nil
560af5c5 1370 (scrolled-window scrolled-window)
1371 (child widget))
1372
7a2e0799 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))
d520140e 1379
560af5c5 1380
f36ca6af 1381;;; Statusbar
560af5c5 1382
d76e9fca 1383(defbinding statusbar-get-context-id () unsigned-int
f36ca6af 1384 (statusbar statusbar)
1385 (context-description string))
560af5c5 1386
bbaeff4b 1387(defbinding statusbar-push () unsigned-int
f36ca6af 1388 (statusbar statusbar)
1389 (context-id unsigned-int)
1390 (text string))
560af5c5 1391
bbaeff4b 1392(defbinding statusbar-pop () nil
f36ca6af 1393 (statusbar statusbar)
1394 (context-id unsigned-int))
560af5c5 1395
bbaeff4b 1396(defbinding statusbar-remove () nil
f36ca6af 1397 (statusbar statusbar)
1398 (context-id unsigned-int)
1399 (message-id unsigned-int))
560af5c5 1400
560af5c5 1401
1402
1403;;; Fixed
1404
bbaeff4b 1405(defbinding fixed-put () nil
f36ca6af 1406 (fixed fixed)
1407 (widget widget)
f5b67f2b 1408 (x int) (y int))
560af5c5 1409
bbaeff4b 1410(defbinding fixed-move () nil
f36ca6af 1411 (fixed fixed)
1412 (widget widget)
f5b67f2b 1413 (x int) (y int))
560af5c5 1414
1415
1416
d520140e 1417;;; Notebook
560af5c5 1418
68f519e0 1419(defun %ensure-notebook-position (notebook page)
f5b67f2b 1420 (etypecase page
68f519e0 1421 (position page)
f5b67f2b 1422 (widget (notebook-page-num notebook page t))))
1423
68f519e0 1424(defun %ensure-notebook-child (notebook position)
f5b67f2b 1425 (typecase position
1426 (widget position)
68f519e0 1427 (t (notebook-get-nth-page notebook position))))
f5b67f2b 1428
1429(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
f36ca6af 1430 (notebook position child tab-label &optional menu-label) nil
1431 (notebook notebook)
1432 (child widget)
1433 ((if (stringp tab-label)
f5b67f2b 1434 (make-instance 'label :label tab-label)
f36ca6af 1435 tab-label) widget)
1436 ((if (stringp menu-label)
f5b67f2b 1437 (make-instance 'label :label menu-label)
f36ca6af 1438 menu-label) (or null widget))
68f519e0 1439 ((%ensure-notebook-position notebook position) position))
560af5c5 1440
f5b67f2b 1441(defun notebook-append (notebook child tab-label &optional menu-label)
1442 (notebook-insert notebook :last child tab-label menu-label))
560af5c5 1443
f5b67f2b 1444(defun notebook-prepend (notebook child tab-label &optional menu-label)
1445 (notebook-insert notebook :first child tab-label menu-label))
560af5c5 1446
f5b67f2b 1447(defbinding notebook-remove-page (notebook page) nil
f36ca6af 1448 (notebook notebook)
68f519e0 1449 ((%ensure-notebook-position notebook page) position))
560af5c5 1450
bbaeff4b 1451(defbinding %notebook-page-num () int
f36ca6af 1452 (notebook notebook)
1453 (child widget))
1454
f5b67f2b 1455(defun notebook-page-num (notebook child &optional error-p)
f36ca6af 1456 (let ((page-num (%notebook-page-num notebook child)))
1457 (if (= page-num -1)
f5b67f2b 1458 (when error-p
68f519e0 1459 (error "~A is not a page in ~A" child notebook))
f36ca6af 1460 page-num)))
1461
bbaeff4b 1462(defbinding notebook-next-page () nil
f36ca6af 1463 (notebook notebook))
560af5c5 1464
bbaeff4b 1465(defbinding notebook-prev-page () nil
f36ca6af 1466 (notebook notebook))
1467
f5b67f2b 1468(defbinding notebook-reorder-child (notebook child position) nil
1469 (notebook notebook)
1470 (child widget)
1471 ((%notebook-position notebook position) int))
1472
bbaeff4b 1473(defbinding notebook-popup-enable () nil
f36ca6af 1474 (notebook notebook))
1475
bbaeff4b 1476(defbinding notebook-popup-disable () nil
f36ca6af 1477 (notebook notebook))
1478
68f519e0 1479(defbinding notebook-get-nth-page () widget
f5b67f2b 1480 (notebook notebook)
68f519e0 1481 (page position))
f5b67f2b 1482
68f519e0 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))))
f5b67f2b 1486
1487(defun (setf notebook-current-page) (page notebook)
68f519e0 1488 (setf (notebook-current-page notebook) (notebook-page-num notebook page)))
f5b67f2b 1489
1047e159 1490(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1491 (notebook page) widget
1492 (notebook notebook)
68f519e0 1493 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1494
1047e159 1495(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
6bb23851 1496 (notebook page) (copy-of string)
1047e159 1497 (notebook notebook)
68f519e0 1498 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1499
1047e159 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)))
68f519e0 1509 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1510 widget))
f5b67f2b 1511
f5b67f2b 1512
1047e159 1513(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1514 (notebook page) widget
1515 (notebook notebook)
68f519e0 1516 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1517
1047e159 1518(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
6bb23851 1519 (notebook page) (copy-of string)
1047e159 1520 (notebook notebook)
68f519e0 1521 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1522
1047e159 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)))
68f519e0 1532 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1533 widget))
f5b67f2b 1534
1535
1536(defbinding notebook-query-tab-label-packing (notebook page) nil
f36ca6af 1537 (notebook notebook)
f5b67f2b 1538 ((%notebook-child notebook page) widget)
f36ca6af 1539 (expand boolean :out)
1540 (fill boolean :out)
1541 (pack-type pack-type :out))
1542
f5b67f2b 1543(defbinding notebook-set-tab-label-packing
1544 (notebook page expand fill pack-type) nil
f36ca6af 1545 (notebook notebook)
f5b67f2b 1546 ((%notebook-child notebook page) widget)
f36ca6af 1547 (expand boolean)
1548 (fill boolean)
1549 (pack-type pack-type))
1550
560af5c5 1551
1552
d520140e 1553;;; Paned
560af5c5 1554
bbaeff4b 1555(defbinding paned-pack1 () nil
d520140e 1556 (paned paned)
1557 (child widget)
1558 (resize boolean)
1559 (shrink boolean))
560af5c5 1560
bbaeff4b 1561(defbinding paned-pack2 () nil
d520140e 1562 (paned paned)
1563 (child widget)
1564 (resize boolean)
1565 (shrink boolean))
560af5c5 1566
560af5c5 1567
d520140e 1568;;; Layout
560af5c5 1569
bbaeff4b 1570(defbinding layout-put () nil
d520140e 1571 (layout layout)
68f519e0 1572 (child widget)
d520140e 1573 (x int)
1574 (y int))
560af5c5 1575
bbaeff4b 1576(defbinding layout-move () nil
d520140e 1577 (layout layout)
68f519e0 1578 (child widget)
d520140e 1579 (x int)
1580 (y int))
560af5c5 1581
68f519e0 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))
560af5c5 1591
1592
560af5c5 1593;;; Menu shell
1594
f5b67f2b 1595(defbinding menu-shell-insert (menu-shell menu-item position) nil
f36ca6af 1596 (menu-shell menu-shell)
1597 (menu-item menu-item)
f5b67f2b 1598 ((case position
1599 (:first 0)
1600 (:last -1)
1601 (t position)) int))
560af5c5 1602
f36ca6af 1603(defun menu-shell-append (menu-shell menu-item)
f5b67f2b 1604 (menu-shell-insert menu-shell menu-item :last))
560af5c5 1605
f36ca6af 1606(defun menu-shell-prepend (menu-shell menu-item)
f5b67f2b 1607 (menu-shell-insert menu-shell menu-item :fisrt))
560af5c5 1608
bbaeff4b 1609(defbinding menu-shell-deactivate () nil
f36ca6af 1610 (menu-shell menu-shell))
560af5c5 1611
bbaeff4b 1612(defbinding menu-shell-select-item () nil
f36ca6af 1613 (menu-shell menu-shell)
1614 (menu-item menu-item))
560af5c5 1615
d76e9fca 1616(defbinding menu-shell-select-first () nil
1617 (menu-shell menu-shell)
1618 (search-sensitive boolean))
1619
bbaeff4b 1620(defbinding menu-shell-deselect () nil
f36ca6af 1621 (menu-shell menu-shell))
560af5c5 1622
bbaeff4b 1623(defbinding menu-shell-activate-item () nil
f36ca6af 1624 (menu-shell menu-shell)
1625 (menu-item menu-item)
1626 (fore-deactivate boolean))
560af5c5 1627
d76e9fca 1628(defbinding menu-shell-cancel () nil
1629 (menu-shell menu-shell))
560af5c5 1630
1631
f5b67f2b 1632;;; Menu
560af5c5 1633
f5b67f2b 1634(defun %menu-position (menu child)
1635 (etypecase child
1636 (int child)
1637 (keyword (case child
1638 (:first 0)
1639 (:last -1)
1047e159 1640 (t (error "Invalid position keyword: ~A" child))))
f5b67f2b 1641 (widget (menu-child-position menu child))))
560af5c5 1642
1643
f5b67f2b 1644(defbinding menu-reorder-child (menu menu-item position) nil
1645 (menu menu)
1646 (menu-item menu-item)
1647 ((%menu-position menu position) int))
560af5c5 1648
d76e9fca 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)))
560af5c5 1658
f5b67f2b 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
1a1949c7 1671 (with-callback-function (id callback)
1672 (%menu-popup
1673 menu parent-menu-shell parent-menu-item
d76e9fca 1674 (callback %menu-position-func) id button activate-time))
f5b67f2b 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))
560af5c5 1681
bbaeff4b 1682(defbinding menu-reposition () nil
f36ca6af 1683 (menu menu))
560af5c5 1684
bbaeff4b 1685(defbinding menu-popdown () nil
f36ca6af 1686 (menu menu))
560af5c5 1687
f5b67f2b 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
bbaeff4b 1694(defbinding %menu-set-active () nil
f36ca6af 1695 (menu menu)
1696 (index unsigned-int))
560af5c5 1697
f5b67f2b 1698(defun (setf menu-active) (menu child)
1699 (%menu-set-active menu (%menu-position menu child))
1700 child)
d520140e 1701
d76e9fca 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))
560af5c5 1724
1725
f36ca6af 1726;;; Table
560af5c5 1727
bbaeff4b 1728(defbinding table-resize () nil
f36ca6af 1729 (table table)
1730 (rows unsigned-int)
1731 (columns unsigned-int))
560af5c5 1732
bbaeff4b 1733(defbinding table-attach (table child left right top bottom
c49be931 1734 &key options x-options y-options
1735 (x-padding 0) (y-padding 0)) nil
f36ca6af 1736 (table table)
1737 (child widget)
1738 (left unsigned-int)
1739 (right unsigned-int)
1740 (top unsigned-int)
1741 (bottom unsigned-int)
c49be931 1742 ((append (mklist options) (mklist x-options)) attach-options)
1743 ((append (mklist options) (mklist y-options)) attach-options)
f36ca6af 1744 (x-padding unsigned-int)
1745 (y-padding unsigned-int))
1746
e5b416f0 1747
bbaeff4b 1748(defbinding %table-set-row-spacing () nil
f36ca6af 1749 (table table)
1750 (row unsigned-int)
1751 (spacing unsigned-int))
1752
e5b416f0 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))
f36ca6af 1761 spacing)
1762
e5b416f0 1763(defbinding %table-get-row-spacing () unsigned-int
f36ca6af 1764 (table table)
e5b416f0 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
f36ca6af 1775
bbaeff4b 1776(defbinding %table-set-col-spacing () nil
f36ca6af 1777 (table table)
1778 (col unsigned-int)
1779 (spacing unsigned-int))
1780
e5b416f0 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))
f36ca6af 1789 spacing)
1790
e5b416f0 1791(defbinding %table-get-col-spacing () unsigned-int
f36ca6af 1792 (table table)
e5b416f0 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
f36ca6af 1804
1805;;; Toolbar
1806
cb4bf772 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)))
560af5c5 1812
cb4bf772 1813(defbinding %toolbar-insert () nil
f5b67f2b 1814 (toolbar toolbar)
cb4bf772 1815 (tool-item tool-item)
1816 (position position))
f36ca6af 1817
cb4bf772 1818(defun toolbar-insert (toolbar tool-item &optional (position :end))
1819 (%toolbar-insert toolbar tool-item position)
1820 (%tool-item-update-tooltips tool-item))
f5b67f2b 1821
cb4bf772 1822(defbinding toolbar-get-item-index () int
1823 (toolbar toolbar)
1824 (item tool-item))
f36ca6af 1825
cb4bf772 1826(defbinding toolbar-get-nth-item () tool-item
1827 (toolbar toolbar)
1828 (n int))
f36ca6af 1829
cb4bf772 1830(defbinding toolbar-get-drop-index () int
1831 (toolbar toolbar)
1832 (x int) (y int))
f36ca6af 1833
cb4bf772 1834(defbinding toolbar-set-drop-highlight-item () nil
1835 (toolbar toolbar)
1836 (tool-item tool-item)
1837 (index int))
f36ca6af 1838
560af5c5 1839
cb4bf772 1840;;; Tool button
560af5c5 1841
cb4bf772 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)))
560af5c5 1846
1847
cb4bf772 1848;;; Tool item
560af5c5 1849
cb4bf772 1850(defbinding tool-item-set-tooltip () nil
1851 (tool-item tool-item)
1852 (tooltips tooltips)
1853 (tip-text string)
1854 (tip-private string))
560af5c5 1855
560af5c5 1856
cb4bf772 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)))
560af5c5 1883
d76e9fca 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
bbaeff4b 1907;;; Editable
1047e159 1908
bbaeff4b 1909(defbinding editable-select-region (editable &optional (start 0) end) nil
f36ca6af 1910 (editable editable)
1911 (start int)
1912 ((or end -1) int))
560af5c5 1913
1047e159 1914(defbinding editable-get-selection-bounds (editable) nil
1915 (editable editable)
1916 (start int :out)
1917 (end int :out))
1918
d76e9fca 1919(defbinding editable-insert-text (editable text &optional (position 0)) nil
f36ca6af 1920 (editable editable)
1921 (text string)
1922 ((length text) int)
34fe0ead 1923 (position position :in-out))
560af5c5 1924
f36ca6af 1925(defun editable-append-text (editable text)
1926 (editable-insert-text editable text nil))
560af5c5 1927
f36ca6af 1928(defun editable-prepend-text (editable text)
1929 (editable-insert-text editable text 0))
560af5c5 1930
bbaeff4b 1931(defbinding editable-delete-text (editable &optional (start 0) end) nil
f36ca6af 1932 (editable editable)
1933 (start int)
1934 ((or end -1) int))
560af5c5 1935
bbaeff4b 1936(defbinding (editable-text "gtk_editable_get_chars")
f36ca6af 1937 (editable &optional (start 0) end) string
1938 (editable editable)
1939 (start int)
1940 ((or end -1) int))
560af5c5 1941
f36ca6af 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)
560af5c5 1949
bbaeff4b 1950(defbinding editable-cut-clipboard () nil
f36ca6af 1951 (editable editable))
560af5c5 1952
bbaeff4b 1953(defbinding editable-copy-clipboard () nil
f36ca6af 1954 (editable editable))
560af5c5 1955
bbaeff4b 1956(defbinding editable-paste-clipboard () nil
f36ca6af 1957 (editable editable))
560af5c5 1958
bbaeff4b 1959(defbinding editable-delete-selection () nil
f36ca6af 1960 (editable editable))
560af5c5 1961
560af5c5 1962
560af5c5 1963
f36ca6af 1964;;; Spin button
560af5c5 1965
d76e9fca 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
f36ca6af 1982(defun spin-button-value-as-int (spin-button)
1983 (round (spin-button-value spin-button)))
560af5c5 1984
510fbcc1 1985(defbinding %spin-button-spin () nil
f36ca6af 1986 (spin-button spin-button)
1987 (direction spin-type)
510fbcc1 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
560af5c5 1995
bbaeff4b 1996(defbinding spin-button-update () nil
f36ca6af 1997 (spin-button spin-button))
560af5c5 1998
1999
2000
2001; ;;; Ruler
2002
bbaeff4b 2003(defbinding ruler-set-range () nil
f36ca6af 2004 (ruler ruler)
2005 (lower single-float)
2006 (upper single-float)
2007 (position single-float)
2008 (max-size single-float))
560af5c5 2009
68f519e0 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))
560af5c5 2016
560af5c5 2017
560af5c5 2018
d520140e 2019;;; Range
560af5c5 2020
1047e159 2021(defun range-lower (range)
2022 (adjustment-lower (range-adjustment range)))
560af5c5 2023
1047e159 2024(defun range-upper (range)
2025 (adjustment-upper (range-adjustment range)))
560af5c5 2026
1047e159 2027(defun (setf range-lower) (value range)
2028 (setf (adjustment-lower (range-adjustment range)) value))
560af5c5 2029
1047e159 2030(defun (setf range-upper) (value range)
2031 (setf (adjustment-upper (range-adjustment range)) value))
560af5c5 2032
1047e159 2033(defun range-page-increment (range)
2034 (adjustment-page-increment (range-adjustment range)))
560af5c5 2035
1047e159 2036(defun range-step-increment (range)
2037 (adjustment-step-increment (range-adjustment range)))
560af5c5 2038
1047e159 2039(defun (setf range-page-increment) (value range)
2040 (setf (adjustment-page-increment (range-adjustment range)) value))
560af5c5 2041
1047e159 2042(defun (setf range-step-increment) (value range)
2043 (setf (adjustment-step-increment (range-adjustment range)) value))
560af5c5 2044
1047e159 2045(defbinding range-set-range () nil
d520140e 2046 (range range)
1047e159 2047 (lower double-float)
2048 (upper double-float))
560af5c5 2049
1047e159 2050(defbinding range-set-increments () nil
d520140e 2051 (range range)
1047e159 2052 (step double-float)
2053 (page double-float))
560af5c5 2054
560af5c5 2055
d520140e 2056;;; Scale
560af5c5 2057
68f519e0 2058(defbinding scale-get-layout-offsets () nil
2059 (scale scale)
2060 (x int :out)
2061 (y int :out))
560af5c5 2062
560af5c5 2063
d520140e 2064;;; Progress bar
560af5c5 2065
bbaeff4b 2066(defbinding progress-bar-pulse () nil
d520140e 2067 (progress-bar progress-bar))
560af5c5 2068
2069
c49be931 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
560af5c5 2089
f5b67f2b 2090;;; Stock items
2091
73d58e01 2092(defbinding %stock-item-copy () pointer
2093 (location pointer))
2094
2095(defbinding %stock-item-free () nil
2096 (location pointer))
f5b67f2b 2097
73d58e01 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))))
560af5c5 2121
2122
2123;;; Tooltips
2124
bbaeff4b 2125(defbinding tooltips-enable () nil
d520140e 2126 (tooltips tooltips))
560af5c5 2127
bbaeff4b 2128(defbinding tooltips-disable () nil
d520140e 2129 (tooltips tooltips))
560af5c5 2130
e5b416f0 2131(defun (setf tooltips-enabled-p) (enable tooltips)
2132 (if enable
2133 (tooltips-enable tooltips)
2134 (tooltips-disable tooltips)))
2135
bbaeff4b 2136(defbinding tooltips-set-tip () nil
d520140e 2137 (tooltips tooltips)
2138 (widget widget)
2139 (tip-text string)
2140 (tip-private string))
560af5c5 2141
d76e9fca 2142(defbinding tooltips-data-get () tooltips-data
2143 (widget widget))
2144
bbaeff4b 2145(defbinding tooltips-force-window () nil
d520140e 2146 (tooltips tooltips))
560af5c5 2147
d76e9fca 2148(defbinding tooltips-get-info-from-tip-window () boolean
2149 (tip-window window)
2150 (tooltips tooltips :out)
2151 (current-widget widget :out))
560af5c5 2152
2153
d520140e 2154;;; Rc
560af5c5 2155
bbaeff4b 2156(defbinding rc-add-default-file (filename) nil
d520140e 2157 ((namestring (truename filename)) string))
560af5c5 2158
bbaeff4b 2159(defbinding rc-parse (filename) nil
d520140e 2160 ((namestring (truename filename)) string))
560af5c5 2161
bbaeff4b 2162(defbinding rc-parse-string () nil
d520140e 2163 (rc-string string))
560af5c5 2164
bbaeff4b 2165(defbinding rc-reparse-all () nil)
560af5c5 2166
bbaeff4b 2167(defbinding rc-get-style () style
d520140e 2168 (widget widget))