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