Changed CONTAINER-ADD and CONTAINER-REMOVE into generic functions
[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
7625ebd8 18;; $Id: gtk.lisp,v 1.10 2002-03-24 21:54:06 espen Exp $
560af5c5 19
20
21(in-package "GTK")
22
23;;; Gtk version
24
bbaeff4b 25(defbinding check-version () 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
0f476ab5 42(defbinding get-default-language () string)
560af5c5 43
44
0f476ab5 45;;; Acccel group
560af5c5 46
47
48;;; Acccel label
49
bbaeff4b 50(defbinding accel-label-refetch () boolean
560af5c5 51 (accel-label accel-label))
52
53
0f476ab5 54;;; Adjustment
560af5c5 55
0f476ab5 56(defbinding adjustment-changed () nil
57 (adjustment adjustment))
58
59(defbinding adjustment-value-changed () nil
60 (adjustment adjustment))
61
62(defbinding adjustment-clamp-page () nil
63 (adjustment adjustment)
64 (lower single-float)
65 (upper single-float))
560af5c5 66
0f476ab5 67
68
69;;; Alignment -- no functions
70;;; Arrow -- no functions
71
72
73
74;;; Aspect frame
75
76
77;;; Bin
560af5c5 78
79(defun (setf bin-child) (child bin)
0f476ab5 80 (when-bind (current-child (bin-child bin))
81 (container-remove bin current-child))
560af5c5 82 (container-add bin child)
83 child)
84
f36ca6af 85
0f476ab5 86
87;;; Button box -- no functions
88
89
90;;; Binding
91
92
93
94;;; Box
95
96(defbinding box-pack-start () nil
97 (box box)
98 (child widget)
99 (expand boolean)
100 (fill boolean)
101 (padding unsigned-int))
102
103(defbinding box-pack-end () nil
104 (box box)
105 (child widget)
106 (expand boolean)
107 (fill boolean)
108 (padding unsigned-int))
109
110(defun box-pack (box child &key (pack :start) (expand t) (fill t) (padding 0))
111 (if (eq pack :start)
112 (box-pack-start box child expand fill padding)
113 (box-pack-end box child expand fill padding)))
114
115(defbinding box-reorder-child () nil
116 (box box)
117 (child widget)
118 (position int))
119
120(defbinding box-query-child-packing () nil
121 (box box)
122 (child widget)
123 (expand boolean :out)
124 (fill boolean :out)
125 (padding unsigned-int :out)
126 (pack-type pack-type :out))
127
128(defbinding box-set-child-packing () nil
129 (box box)
130 (child widget)
131 (expand boolean)
132 (fill boolean)
133 (padding unsigned-int)
134 (pack-type pack-type))
135
136
137
560af5c5 138;;; Button
139
bbaeff4b 140(defbinding button-pressed () nil
560af5c5 141 (button button))
142
0f476ab5 143(defbinding button-released () nil
144 (button button))
145
146(defbinding button-clicked () nil
147 (button button))
148
149(defbinding button-enter () nil
150 (button button))
151
152(defbinding button-leave () nil
153 (button button))
154
155
156
157;;; Calendar
158
159(defbinding calendar-select-month () int
160 (calendar calendar)
161 (month unsigned-int)
162 (year unsigned-int))
163
164(defbinding calendar-select-day () nil
165 (calendar calendar)
166 (day unsigned-int))
167
168(defbinding calendar-mark-day () int
169 (calendar calendar)
170 (day unsigned-int))
171
172(defbinding calendar-unmark-day () int
173 (calendar calendar)
174 (day unsigned-int))
175
176(defbinding calendar-clear-marks () nil
177 (calendar calendar))
178
179(defbinding calendar-display-options () nil
180 (calendar calendar)
181 (options calendar-display-options))
182
183(defbinding (calendar-date "gtk_calendar_get_date") () nil
184 (calendar calendar)
185 (year unsigned-int :out)
186 (month unsigned-int :out)
187 (day unsigned-int :out))
188
189(defbinding calendar-freeze () nil
190 (calendar calendar))
191
192(defbinding calendar-thaw () nil
193 (calendar calendar))
194
195
196
197;;; Cell editable
198
199
200
201;;; Cell renderer
202
203
204
205;;; Cell renderer pixbuf -- no functions
206
207
208
209;;; Cell renderer text
210
211
212
213;;; Cell renderer toggle -- no functions
214
215
216
217;;; Check button -- no functions
218
219
220
221;;; Check menu item
222
223(defbinding check-menu-item-toggled () nil
224 (check-menu-item check-menu-item))
225
226
227
228;;; Clipboard
229
230
231;;; Color selection
232
233(defbinding (color-selection-is-adjusting-p
234 "gtk_color_selection_is_adjusting") () boolean
235 (colorsel color-selection))
236
237
238
239;;; Color selection dialog -- no functions
240
241
242
243;;; Combo
244
245(defbinding combo-set-value-in-list () nil
246 (combo combo)
247 (value boolean)
248 (ok-if-empty boolean))
249
250(defbinding combo-set-item-string () nil
251 (combo combo)
252 (item item)
253 (item-value string))
254
255(defbinding combo-set-popdown-strings () nil
256 (combo combo)
257 (strings (glist string)))
258
259(defbinding combo-disable-activate () nil
260 (combo combo))
261
262
263
48da76bf 264;;;; Dialog
0f476ab5 265
48da76bf 266(defmethod shared-initialize ((dialog dialog) names &rest initargs)
267 (call-next-method)
0f476ab5 268 (dolist (button-definition (get-all initargs :button))
48da76bf 269 (apply #'dialog-add-button dialog button-definition)))
270
0f476ab5 271
272(defvar %*response-id-key* (gensym))
273
48da76bf 274(defun %dialog-find-response-id-num (dialog response-id &optional create-p error-p)
0f476ab5 275 (or
276 (cadr (assoc response-id (rest (type-expand-1 'response-type))))
277 (let* ((response-ids (object-data dialog %*response-id-key*))
278 (response-id-num (position response-id response-ids)))
279 (cond
280 (response-id-num)
281 (create-p
282 (cond
283 (response-ids
284 (setf (cdr (last response-ids)) (list response-id))
285 (1- (length response-ids)))
286 (t
287 (setf (object-data dialog %*response-id-key*) (list response-id))
288 0)))
48da76bf 289 (error-p
290 (error "Invalid response: ~A" response-id))))))
0f476ab5 291
292(defun %dialog-find-response-id (dialog response-id-num)
293 (if (< response-id-num 0)
294 (car
295 (rassoc
296 (list response-id-num)
297 (rest (type-expand-1 'response-type)) :test #'equalp))
298 (nth response-id-num (object-data dialog %*response-id-key*))))
299
300
48da76bf 301(defmethod signal-connect ((dialog dialog) signal function &key object after)
302 (let ((response-id-num (%dialog-find-response-id-num dialog signal)))
303 (cond
304 (response-id-num
305 (call-next-method
306 dialog 'response
307 #'(lambda (dialog id)
308 (when (= id response-id-num)
309 (cond
310 ((eq object t) (funcall function dialog))
311 (object (funcall function object))
312 (t (funcall function)))))
313 :object t :after after))
0f476ab5 314 (t
48da76bf 315 (call-next-method)))))
0f476ab5 316
317
48da76bf 318(defbinding dialog-run () nil
319 (dialog dialog))
0f476ab5 320
48da76bf 321(defbinding dialog-response (dialog response-id) nil
0f476ab5 322 (dialog dialog)
48da76bf 323 ((%dialog-find-response-id-num dialog response-id nil t) int))
0f476ab5 324
325
326(defbinding %dialog-add-button () button
327 (dialog dialog)
328 (text string)
329 (response-id-num int))
330
331(defun dialog-add-button (dialog label &optional response-id default-p)
332 (let* ((response-id-num
333 (if response-id
334 (%dialog-find-response-id-num dialog response-id t)
335 (length (object-data dialog %*response-id-key*))))
336 (button (%dialog-add-button dialog label response-id-num)))
337 (unless response-id
338 (%dialog-find-response-id-num dialog button t))
339 (when default-p
340 (%dialog-set-default-response dialog response-id-num))
341 button))
342
343
344(defbinding %dialog-add-action-widget () button
345 (dialog dialog)
346 (action-widget widget)
347 (response-id-num int))
348
349(defun dialog-add-action-widget (dialog widget &optional (response-id widget)
350 default-p)
351 (let ((response-id-num (%dialog-find-response-id-num dialog response-id t)))
352 (%dialog-add-action-widget dialog widget response-id-num)
353 (when default-p
354 (%dialog-set-default-response dialog response-id-num))
355 widget))
0f476ab5 356
0f476ab5 357
48da76bf 358(defbinding %dialog-set-default-response () nil
359 (dialog dialog)
360 (response-id-num int))
0f476ab5 361
48da76bf 362(defun dialog-set-default-response (dialog response-id)
363 (%dialog-set-default-response
364 dialog (%dialog-find-response-id-num dialog response-id nil t)))
0f476ab5 365
48da76bf 366(defbinding dialog-set-response-sensitive (dialog response-id sensitive) nil
367 (dialog dialog)
368 ((%dialog-find-response-id-num dialog response-id nil t) int)
369 (sensitive boolean))
0f476ab5 370
371
48da76bf 372;; Addition dialog functions
373
374(defmethod container-add ((dialog dialog) (child widget) &rest args)
375 (apply #'container-add (slot-value dialog 'main-area) child args))
376
377(defmethod container-remove ((dialog dialog) (child widget))
378 (container-remove (slot-value dialog 'main-area) child))
0f476ab5 379
48da76bf 380(defmethod container-children ((dialog dialog))
381 (container-children (dialog-main-area dialog)))
382
383(defmethod (setf container-children) (children (dialog dialog))
384 (setf (container-children (dialog-main-area dialog)) children))
560af5c5 385
560af5c5 386
560af5c5 387
48da76bf 388;;; Drawing area -- no functions
560af5c5 389
390
391
392;;; Toggle button
393
bbaeff4b 394(defbinding toggle-button-toggled () nil
560af5c5 395 (toggle-button toggle-button))
396
397
0f476ab5 398;;; Label
560af5c5 399
0f476ab5 400(defbinding label-select-region () nil
401 (label label)
402 (start int)
403 (end int))
560af5c5 404
f36ca6af 405
560af5c5 406
407
408;;; Radio button
409
e5b416f0 410(defbinding %radio-button-get-group () pointer
d520140e 411 (radio-button radio-button))
412
bbaeff4b 413(defbinding %radio-button-set-group () nil
d520140e 414 (radio-button radio-button)
415 (group pointer))
560af5c5 416
d520140e 417(defun radio-button-add-to-group (button1 button2)
418 "Add BUTTON1 to the group which BUTTON2 belongs to."
419 (%radio-button-set-group button1 (%radio-button-get-group button2)))
420
e5b416f0 421
d520140e 422(defmethod initialize-instance ((button radio-button)
e5b416f0 423 &rest initargs &key group-with)
424 (declare (ignore initargs))
d520140e 425 (call-next-method)
e5b416f0 426 (when group-with
427 (radio-button-add-to-group item group-with)))
560af5c5 428
429
430;;; Option menu
431
bbaeff4b 432(defbinding %option-menu-set-menu () nil
f36ca6af 433 (option-menu option-menu)
434 (menu widget))
560af5c5 435
bbaeff4b 436(defbinding %option-menu-remove-menu () nil
f36ca6af 437 (option-menu option-menu))
560af5c5 438
f36ca6af 439(defun (setf option-menu-menu) (menu option-menu)
440 (if (not menu)
441 (%option-menu-remove-menu option-menu)
442 (%option-menu-set-menu option-menu menu))
443 menu)
560af5c5 444
445
446
447;;; Item
448
bbaeff4b 449(defbinding item-select () nil
560af5c5 450 (item item))
451
bbaeff4b 452(defbinding item-deselect () nil
560af5c5 453 (item item))
454
bbaeff4b 455(defbinding item-toggle () nil
560af5c5 456 (item item))
457
458
459
460;;; Menu item
461
f36ca6af 462(defun (setf menu-item-label) (label menu-item)
463 (make-instance 'accel-label
464 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
465 :visible t :parent menu-item)
466 label)
560af5c5 467
bbaeff4b 468(defbinding %menu-item-set-submenu () nil
f36ca6af 469 (menu-item menu-item)
470 (submenu menu))
560af5c5 471
bbaeff4b 472(defbinding %menu-item-remove-submenu () nil
f36ca6af 473 (menu-item menu-item))
560af5c5 474
f36ca6af 475(defun (setf menu-item-submenu) (submenu menu-item)
476 (if (not submenu)
477 (%menu-item-remove-submenu menu-item)
478 (%menu-item-set-submenu menu-item submenu))
479 submenu)
560af5c5 480
bbaeff4b 481(defbinding menu-item-select () nil
f36ca6af 482 (menu-item menu-item))
560af5c5 483
bbaeff4b 484(defbinding menu-item-deselect () nil
f36ca6af 485 (menu-item menu-item))
560af5c5 486
bbaeff4b 487(defbinding menu-item-activate () nil
f36ca6af 488 (menu-item menu-item))
560af5c5 489
560af5c5 490
491
f36ca6af 492;;; Radio menu item
560af5c5 493
e5b416f0 494(defbinding %radio-menu-item-get-group () pointer
d520140e 495 (radio-menu-item radio-menu-item))
496
bbaeff4b 497(defbinding %radio-menu-item-set-group () nil
d520140e 498 (radio-menu-item radio-menu-item)
499 (group pointer))
500
d520140e 501(defun radio-menu-item-add-to-group (item1 item2)
502 "Add ITEM1 to the group which ITEM2 belongs to."
503 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
504
505(defmethod initialize-instance ((item radio-menu-item)
e5b416f0 506 &rest initargs &key group-with)
507 (declare (ignore initargs))
d520140e 508 (call-next-method)
e5b416f0 509 (when group-with
510 (radio-menu-item-add-to-group item group-with)))
d520140e 511
560af5c5 512
513
560af5c5 514;;; Window
515
7625ebd8 516(defbinding window-set-wmclass () nil
560af5c5 517 (window window)
518 (wmclass-name string)
519 (wmclass-class string))
520
bbaeff4b 521(defbinding window-add-accel-group () nil
560af5c5 522 (window window)
523 (accel-group accel-group))
524
bbaeff4b 525(defbinding window-remove-accel-group () nil
560af5c5 526 (window window)
527 (accel-group accel-group))
528
bbaeff4b 529(defbinding window-activate-focus () int
560af5c5 530 (window window))
531
bbaeff4b 532(defbinding window-activate-default () int
560af5c5 533 (window window))
534
7625ebd8 535(defbinding window-set-default-size (window width height) int
560af5c5 536 (window window)
7625ebd8 537 ((or width -1) int)
538 ((or height -1) int))
560af5c5 539
bbaeff4b 540;(defbinding window-set-geometry-hints)
560af5c5 541
7625ebd8 542(defbinding window-list-toplevels () (glist window))
543
544(defbinding window-add-mnemonic (window key target) nil
545 (window window)
546 ((gdk:keyval-from-name key) unsigned-int)
547 (target widget))
548
549(defbinding window-remove-mnemonic (window key target) nil
550 (window window)
551 ((gdk:keyval-from-name key) unsigned-int)
552 (target widget))
553
554(defbinding window-mnemonic-activate (window key modifier) nil
555 (window window)
556 ((gdk:keyval-from-name key) unsigned-int)
557 (modifier gdk:modifier-type))
558
559(defbinding window-present () nil
560 (window window))
561
562(defbinding window-iconify () nil
563 (window window))
564
565(defbinding window-deiconify () nil
566 (window window))
567
568(defbinding window-stick () nil
569 (window window))
570
571(defbinding window-unstick () nil
572 (window window))
573
574(defbinding window-maximize () nil
575 (window window))
576
577(defbinding window-unmaximize () nil
578 (window window))
579
580(defbinding window-begin-resize-drag () nil
581 (window window)
582 (edge gdk:window-edge)
583 (button int)
584 (root-x int) (root-y int)
585 (timestamp (unsigned-int 32)))
586
587(defbinding window-begin-move-drag () nil
588 (window window)
589 (edge gdk:window-edge)
590 (button int)
591 (root-x int) (root-y int)
592 (timestamp (unsigned-int 32)))
593
594(defbinding window-set-frame-dimensions () nil
595 (window window)
596 (left int) (top int) (rigth int) (bottom int))
597
598(defbinding (window-default-icons "gtk_window_get_default_icon_list")
599 () (glist gdk:pixbuf))
600
601(defbinding %window-get-default-size () nil
602 (window window)
603 (width int :out)
604 (height int :out))
605
606(defun window-get-default-size (window)
607 (multiple-value-bind (width height) (%window-get-default-size window)
608 (values (unless (= width -1) width) (unless (= height -1) height))))
609
610(defbinding window-get-frame-dimensions () nil
611 (window window)
612 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
613
614(defbinding %window-get-icon-list () (glist gdk:pixbuf)
615 (window window))
616
617(defmethod window-icon ((window window))
618 (let ((icon-list (%window-get-icon-list window)))
619 (if (endp (rest icon-list))
620 (first icon-list)
621 icon-list)))
622
623(defbinding window-get-position () nil
624 (window window)
625 (root-x int :out)
626 (root-y int :out))
627
628(defbinding window-get-size () nil
629 (window window)
630 (width int :out)
631 (height int :out))
632
633(defbinding window-move () nil
634 (window window)
635 (x int)
636 (y int))
637
638(defbinding window-parse-geometry () boolean
639 (window window)
640 (geometry string))
641
642(defbinding window-reshow-with-initial-size () nil
643 (window window))
644
645(defbinding window-resize () nil
646 (window window)
647 (width int)
648 (heigth int))
649
650(defbinding %window-set-icon-list () nil
651 (window window)
652 (icon-list (glist gdk:pixbuf)))
653
654(defmethod (setf window-icon) (icon (window window))
655 (%window-set-icon-list window (mklist icon)))
656
657
560af5c5 658
659
660;;; File selection
661
bbaeff4b 662(defbinding file-selection-complete () nil
d520140e 663 (file-selection file-selection)
664 (pattern string))
560af5c5 665
560af5c5 666
667
f36ca6af 668;;; Scrolled window
560af5c5 669
560af5c5 670(defun (setf scrolled-window-scrollbar-policy) (policy window)
671 (setf (scrolled-window-hscrollbar-policy window) policy)
672 (setf (scrolled-window-vscrollbar-policy window) policy))
673
bbaeff4b 674(defbinding scrolled-window-add-with-viewport () nil
560af5c5 675 (scrolled-window scrolled-window)
676 (child widget))
677
678
679
d520140e 680
681
682
560af5c5 683
560af5c5 684
560af5c5 685
560af5c5 686
560af5c5 687
560af5c5 688
560af5c5 689
560af5c5 690
f36ca6af 691;;; Statusbar
560af5c5 692
bbaeff4b 693(defbinding (statusbar-context-id "gtk_statusbar_get_context_id")
694 () unsigned-int
f36ca6af 695 (statusbar statusbar)
696 (context-description string))
560af5c5 697
bbaeff4b 698(defbinding statusbar-push () unsigned-int
f36ca6af 699 (statusbar statusbar)
700 (context-id unsigned-int)
701 (text string))
560af5c5 702
bbaeff4b 703(defbinding statusbar-pop () nil
f36ca6af 704 (statusbar statusbar)
705 (context-id unsigned-int))
560af5c5 706
bbaeff4b 707(defbinding statusbar-remove () nil
f36ca6af 708 (statusbar statusbar)
709 (context-id unsigned-int)
710 (message-id unsigned-int))
560af5c5 711
560af5c5 712
713
714;;; Fixed
715
bbaeff4b 716(defbinding fixed-put () nil
f36ca6af 717 (fixed fixed)
718 (widget widget)
719 (x (signed 16))
720 (y (signed 16)))
560af5c5 721
bbaeff4b 722(defbinding fixed-move () nil
f36ca6af 723 (fixed fixed)
724 (widget widget)
725 (x (signed 16))
726 (y (signed 16)))
560af5c5 727
728
729
d520140e 730;;; Notebook
560af5c5 731
bbaeff4b 732(defbinding (notebook-insert-page "gtk_notebook_insert_page_menu")
f36ca6af 733 (notebook position child tab-label &optional menu-label) nil
734 (notebook notebook)
735 (child widget)
736 ((if (stringp tab-label)
737 (label-new tab-label)
738 tab-label) widget)
739 ((if (stringp menu-label)
740 (label-new menu-label)
741 menu-label) (or null widget))
742 (position int))
560af5c5 743
f36ca6af 744(defun notebook-append-page (notebook child tab-label &optional menu-label)
745 (notebook-insert-page notebook -1 child tab-label menu-label))
560af5c5 746
f36ca6af 747(defun notebook-prepend-page (notebook child tab-label &optional menu-label)
748 (notebook-insert-page notebook 0 child tab-label menu-label))
560af5c5 749
bbaeff4b 750(defbinding notebook-remove-page () nil
f36ca6af 751 (notebook notebook)
752 (page-num int))
560af5c5 753
754; (defun notebook-current-page-num (notebook)
755; (let ((page-num (notebook-current-page notebook)))
756; (if (= page-num -1)
757; nil
758; page-num)))
759
bbaeff4b 760(defbinding (notebook-nth-page-child "gtk_notebook_get_nth_page") () widget
f36ca6af 761 (notebook notebook)
762 (page-num int))
560af5c5 763
f36ca6af 764(defun notebook-page-child (notebook)
765 (notebook-nth-page-child notebook (notebook-page notebook)))
560af5c5 766
bbaeff4b 767(defbinding %notebook-page-num () int
f36ca6af 768 (notebook notebook)
769 (child widget))
770
771(defun notebook-child-num (notebook child)
772 (let ((page-num (%notebook-page-num notebook child)))
773 (if (= page-num -1)
774 nil
775 page-num)))
776
bbaeff4b 777(defbinding notebook-next-page () nil
f36ca6af 778 (notebook notebook))
560af5c5 779
bbaeff4b 780(defbinding notebook-prev-page () nil
f36ca6af 781 (notebook notebook))
782
bbaeff4b 783(defbinding notebook-popup-enable () nil
f36ca6af 784 (notebook notebook))
785
bbaeff4b 786(defbinding notebook-popup-disable () nil
f36ca6af 787 (notebook notebook))
788
e5b416f0 789; (defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
790; (notebook ref) widget
791; (notebook notebook)
792; ((if (typep ref 'widget)
793; ref
794; (notebook-nth-page-child notebook ref))
795; widget))
796
797; (defbinding %notebook-set-tab-label () nil
798; (notebook notebook)
799; (reference widget)
800; (tab-label widget))
801
802; (defun (setf notebook-tab-label) (tab-label notebook reference)
803; (let ((tab-label-widget (if (stringp tab-label)
804; (label-new tab-label)
805; tab-label)))
806; (%notebook-set-tab-label
807; notebook
808; (if (typep reference 'widget)
809; reference
810; (notebook-nth-page-child notebook reference))
811; tab-label-widget)
812; tab-label-widget))
560af5c5 813
e5b416f0 814; (defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
815; (notebook ref) widget
816; (notebook notebook)
817; ((if (typep ref 'widget)
818; ref
819; (notebook-nth-page-child notebook ref))
820; widget))
821
822; (defbinding %notebook-set-menu-label () nil
823; (notebook notebook)
824; (reference widget)
825; (menu-label widget))
826
827; (defun (setf notebook-menu-label) (menu-label notebook reference)
828; (let ((menu-label-widget (if (stringp menu-label)
829; (label-new menu-label)
830; menu-label)))
831; (%notebook-set-menu-label
832; notebook
833; (if (typep reference 'widget)
834; reference
835; (notebook-nth-page-child notebook reference))
836; menu-label-widget)
837; menu-label-widget))
f36ca6af 838
bbaeff4b 839(defbinding notebook-query-tab-label-packing (notebook ref) nil
f36ca6af 840 (notebook notebook)
841 ((if (typep ref 'widget)
842 ref
843 (notebook-nth-page-child notebook ref))
844 widget)
845 (expand boolean :out)
846 (fill boolean :out)
847 (pack-type pack-type :out))
848
bbaeff4b 849(defbinding
f36ca6af 850 notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil
851 (notebook notebook)
852 ((if (typep ref 'widget)
853 ref
854 (notebook-nth-page-child notebook ref))
855 widget)
856 (expand boolean)
857 (fill boolean)
858 (pack-type pack-type))
859
bbaeff4b 860(defbinding notebook-reorder-child () nil
f36ca6af 861 (notebook notebook)
862 (child widget)
863 (position int))
560af5c5 864
865
866
d520140e 867;;; Paned
560af5c5 868
bbaeff4b 869(defbinding paned-pack1 () nil
d520140e 870 (paned paned)
871 (child widget)
872 (resize boolean)
873 (shrink boolean))
560af5c5 874
bbaeff4b 875(defbinding paned-pack2 () nil
d520140e 876 (paned paned)
877 (child widget)
878 (resize boolean)
879 (shrink boolean))
560af5c5 880
d520140e 881;; gtkglue.c
bbaeff4b 882(defbinding paned-child1 () widget
d520140e 883 (paned paned)
884 (resize boolean :out)
885 (shrink boolean :out))
560af5c5 886
d520140e 887;; gtkglue.c
bbaeff4b 888(defbinding paned-child2 () widget
d520140e 889 (paned paned)
890 (resize boolean :out)
891 (shrink boolean :out))
560af5c5 892
d520140e 893(defun (setf paned-child1) (child paned)
894 (paned-pack1 paned child nil t))
560af5c5 895
d520140e 896(defun (setf paned-child2) (child paned)
897 (paned-pack2 paned child t t))
560af5c5 898
560af5c5 899
560af5c5 900
d520140e 901;;; Layout
560af5c5 902
bbaeff4b 903(defbinding layout-put () nil
d520140e 904 (layout layout)
905 (widget widget)
906 (x int)
907 (y int))
560af5c5 908
bbaeff4b 909(defbinding layout-move () nil
d520140e 910 (layout layout)
911 (widget widget)
912 (x int)
913 (y int))
560af5c5 914
bbaeff4b 915(defbinding layout-set-size () nil
d520140e 916 (layout layout)
917 (width int)
918 (height int))
560af5c5 919
bbaeff4b 920(defbinding layout-get-size () nil
d520140e 921 (layout layout)
922 (width int :out)
923 (height int :out))
560af5c5 924
560af5c5 925
926
560af5c5 927;;; Menu shell
928
bbaeff4b 929(defbinding menu-shell-insert () nil
f36ca6af 930 (menu-shell menu-shell)
931 (menu-item menu-item)
932 (position int))
560af5c5 933
f36ca6af 934(defun menu-shell-append (menu-shell menu-item)
935 (menu-shell-insert menu-shell menu-item -1))
560af5c5 936
f36ca6af 937(defun menu-shell-prepend (menu-shell menu-item)
938 (menu-shell-insert menu-shell menu-item 0))
560af5c5 939
bbaeff4b 940(defbinding menu-shell-deactivate () nil
f36ca6af 941 (menu-shell menu-shell))
560af5c5 942
bbaeff4b 943(defbinding menu-shell-select-item () nil
f36ca6af 944 (menu-shell menu-shell)
945 (menu-item menu-item))
560af5c5 946
bbaeff4b 947(defbinding menu-shell-deselect () nil
f36ca6af 948 (menu-shell menu-shell))
560af5c5 949
bbaeff4b 950(defbinding menu-shell-activate-item () nil
f36ca6af 951 (menu-shell menu-shell)
952 (menu-item menu-item)
953 (fore-deactivate boolean))
560af5c5 954
955
956
957; ;;; Menu bar
958
bbaeff4b 959; (defbinding menu-bar-insert () nil
560af5c5 960; (menu-bar menu-bar)
961; (menu menu)
962; (position int))
963
964; (defun menu-bar-append (menu-bar menu)
965; (menu-bar-insert menu-bar menu -1))
966
967; (defun menu-bar-prepend (menu-bar menu)
968; (menu-bar-insert menu-bar menu 0))
969
970
971
972; ;;; Menu
973
f36ca6af 974;(defun menu-popup ...)
560af5c5 975
bbaeff4b 976(defbinding menu-reposition () nil
f36ca6af 977 (menu menu))
560af5c5 978
bbaeff4b 979(defbinding menu-popdown () nil
f36ca6af 980 (menu menu))
560af5c5 981
bbaeff4b 982(defbinding %menu-set-active () nil
f36ca6af 983 (menu menu)
984 (index unsigned-int))
560af5c5 985
d520140e 986(defun (setf menu-active) (menu index)
987 (%menu-set-active menu index))
988
bbaeff4b 989(defbinding menu-reorder-child () nil
f36ca6af 990 (menu menu)
991 (menu-item menu-item)
992 (position int))
560af5c5 993
994
f36ca6af 995;;; Table
560af5c5 996
bbaeff4b 997(defbinding table-resize () nil
f36ca6af 998 (table table)
999 (rows unsigned-int)
1000 (columns unsigned-int))
560af5c5 1001
bbaeff4b 1002(defbinding table-attach (table child left right top bottom
f36ca6af 1003 &key (x-options '(:expand :fill))
1004 (y-options '(:expand :fill))
1005 (x-padding 0) (y-padding 0)) nil
1006 (table table)
1007 (child widget)
1008 (left unsigned-int)
1009 (right unsigned-int)
1010 (top unsigned-int)
1011 (bottom unsigned-int)
1012 (x-options attach-options)
1013 (y-options attach-options)
1014 (x-padding unsigned-int)
1015 (y-padding unsigned-int))
1016
e5b416f0 1017
bbaeff4b 1018(defbinding %table-set-row-spacing () nil
f36ca6af 1019 (table table)
1020 (row unsigned-int)
1021 (spacing unsigned-int))
1022
e5b416f0 1023(defbinding %table-set-row-spacings () nil
1024 (table table)
1025 (spacing unsigned-int))
1026
1027(defun (setf table-row-spacing) (spacing table &optional row)
1028 (if row
1029 (%table-set-row-spacing table row spacing)
1030 (%table-set-row-spacings table spacing))
f36ca6af 1031 spacing)
1032
e5b416f0 1033(defbinding %table-get-row-spacing () unsigned-int
f36ca6af 1034 (table table)
e5b416f0 1035 (row unsigned-int))
1036
1037(defbinding %table-get-default-row-spacing () unsigned-int
1038 (table table))
1039
1040(defun table-row-spacing (table &optional row)
1041 (if row
1042 (%table-get-row-spacing table row)
1043 (%table-get-default-row-spacing table)))
1044
f36ca6af 1045
bbaeff4b 1046(defbinding %table-set-col-spacing () nil
f36ca6af 1047 (table table)
1048 (col unsigned-int)
1049 (spacing unsigned-int))
1050
e5b416f0 1051(defbinding %table-set-col-spacings () nil
1052 (table table)
1053 (spacing unsigned-int))
1054
1055(defun (setf table-col-spacing) (spacing table &optional col)
1056 (if col
1057 (%table-set-col-spacing table col spacing)
1058 (%table-set-col-spacings table spacing))
f36ca6af 1059 spacing)
1060
e5b416f0 1061(defbinding %table-get-col-spacing () unsigned-int
f36ca6af 1062 (table table)
e5b416f0 1063 (col unsigned-int))
1064
1065(defbinding %table-get-default-col-spacing () unsigned-int
1066 (table table))
1067
1068(defun table-col-spacing (table &optional col)
1069 (if col
1070 (%table-get-col-spacing table col)
1071 (%table-get-default-col-spacing table)))
1072
1073
f36ca6af 1074
1075;;; Toolbar
1076
f36ca6af 1077;; gtkglue.c
bbaeff4b 1078(defbinding toolbar-num-children () int
f36ca6af 1079 (toolbar toolbar))
1080
1081(defun %toolbar-position-num (toolbar position)
1082 (case position
1083 (:prepend 0)
1084 (:append (toolbar-num-children toolbar))
1085 (t
1086 (assert (and (>= position 0) (< position (toolbar-num-children toolbar))))
1087 position)))
1088
bbaeff4b 1089(defbinding %toolbar-insert-element () widget
f36ca6af 1090 (toolbar toolbar)
1091 (type toolbar-child-type)
1092 (widget (or null widget))
1093 (text string)
1094 (tooltip-text string)
1095 (tooltip-private-text string)
1096 (icon (or null widget))
1097 (nil null)
1098 (nil null)
1099 (position int))
560af5c5 1100
f36ca6af 1101(defun toolbar-insert-element (toolbar position
1102 &key tooltip-text tooltip-private-text
1103 type widget icon text callback)
1104 (let* ((icon-widget (typecase icon
1105 ((or null widget) icon)
1106 (t (pixmap-new icon))))
1107 (toolbar-child
1108 (%toolbar-insert-element
1109 toolbar (or type (and widget :widget) :button)
1110 widget text tooltip-text tooltip-private-text icon-widget
1111 (%toolbar-position-num toolbar position))))
1112 (when callback
1113 (signal-connect toolbar-child 'clicked callback))
1114 toolbar-child))
1115
1116(defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text
1117 type widget icon text callback)
1118 (toolbar-insert-element
1119 toolbar :append :type type :widget widget :icon icon :text text
1120 :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1121 :callback callback))
1122
1123(defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text
1124 type widget icon text callback)
1125 (toolbar-insert-element
1126 toolbar :prepend :type type :widget widget :icon icon :text text
1127 :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
1128 :callback callback))
1129
1130(defun toolbar-insert-space (toolbar position)
1131 (toolbar-insert-element toolbar position :type :space))
1132
1133(defun toolbar-append-space (toolbar)
1134 (toolbar-insert-space toolbar :append))
1135
1136(defun toolbar-prepend-space (toolbar)
1137 (toolbar-insert-space toolbar :prepend))
1138
1139(defun toolbar-insert-widget (toolbar widget position &key tooltip-text
1140 tooltip-private-text callback)
1141 (toolbar-insert-element
1142 toolbar position :widget widget :tooltip-text tooltip-text
1143 :tooltip-private-text tooltip-private-text :callback callback))
560af5c5 1144
f36ca6af 1145(defun toolbar-append-widget (toolbar widget &key tooltip-text
1146 tooltip-private-text callback)
1147 (toolbar-insert-widget
1148 toolbar widget :append :tooltip-text tooltip-text
1149 :tooltip-private-text tooltip-private-text :callback callback))
1150
1151(defun toolbar-prepend-widget (toolbar widget &key tooltip-text
1152 tooltip-private-text callback)
1153 (toolbar-insert-widget
1154 toolbar widget :prepend :tooltip-text tooltip-text
1155 :tooltip-private-text tooltip-private-text :callback callback))
1156
1157(defun toolbar-insert-item (toolbar text icon position &key tooltip-text
1158 tooltip-private-text callback)
1159 (toolbar-insert-element
1160 toolbar position :text text :icon icon :callback callback
1161 :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
1162
1163(defun toolbar-append-item (toolbar text icon &key tooltip-text
1164 tooltip-private-text callback)
1165 (toolbar-insert-item
1166 toolbar text icon :append :callback callback
1167 :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
560af5c5 1168
1169
f36ca6af 1170(defun toolbar-prepend-item (toolbar text icon &key tooltip-text
1171 tooltip-private-text callback)
1172 (toolbar-insert-item
1173 toolbar text icon :prepend :callback callback
1174 :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
560af5c5 1175
f36ca6af 1176(defun toolbar-enable-tooltips (toolbar)
1177 (setf (toolbar-tooltips-p toolbar) t))
560af5c5 1178
f36ca6af 1179(defun toolbar-disable-tooltips (toolbar)
1180 (setf (toolbar-tooltips-p toolbar) nil))
560af5c5 1181
1182
1183
560af5c5 1184
560af5c5 1185
560af5c5 1186
1187
1188
bbaeff4b 1189;;; Editable
1190#|
1191(defbinding editable-select-region (editable &optional (start 0) end) nil
f36ca6af 1192 (editable editable)
1193 (start int)
1194 ((or end -1) int))
560af5c5 1195
bbaeff4b 1196(defbinding editable-insert-text
f36ca6af 1197 (editable text &optional (position 0)) nil
1198 (editable editable)
1199 (text string)
1200 ((length text) int)
1201 ((or position -1) int :in-out))
560af5c5 1202
f36ca6af 1203(defun editable-append-text (editable text)
1204 (editable-insert-text editable text nil))
560af5c5 1205
f36ca6af 1206(defun editable-prepend-text (editable text)
1207 (editable-insert-text editable text 0))
560af5c5 1208
bbaeff4b 1209(defbinding editable-delete-text (editable &optional (start 0) end) nil
f36ca6af 1210 (editable editable)
1211 (start int)
1212 ((or end -1) int))
560af5c5 1213
bbaeff4b 1214(defbinding (editable-text "gtk_editable_get_chars")
f36ca6af 1215 (editable &optional (start 0) end) string
1216 (editable editable)
1217 (start int)
1218 ((or end -1) int))
560af5c5 1219
f36ca6af 1220(defun (setf editable-text) (text editable)
1221 (if text
1222 (editable-delete-text
1223 editable
1224 (editable-insert-text editable text))
1225 (editable-delete-text editable))
1226 text)
560af5c5 1227
bbaeff4b 1228(defbinding editable-cut-clipboard () nil
f36ca6af 1229 (editable editable))
560af5c5 1230
bbaeff4b 1231(defbinding editable-copy-clipboard () nil
f36ca6af 1232 (editable editable))
560af5c5 1233
bbaeff4b 1234(defbinding editable-paste-clipboard () nil
f36ca6af 1235 (editable editable))
560af5c5 1236
bbaeff4b 1237; (defbinding editable-claim-selection () nil
b9752933 1238; (editable editable)
1239; (claim boolean)
1240; (time unsigned-int))
560af5c5 1241
bbaeff4b 1242(defbinding editable-delete-selection () nil
f36ca6af 1243 (editable editable))
560af5c5 1244
bbaeff4b 1245; (defbinding editable-changed () nil
b9752933 1246; (editable editable))
bbaeff4b 1247|#
560af5c5 1248
560af5c5 1249
f36ca6af 1250;;; Spin button
560af5c5 1251
f36ca6af 1252(defun spin-button-value-as-int (spin-button)
1253 (round (spin-button-value spin-button)))
560af5c5 1254
bbaeff4b 1255(defbinding spin-button-spin () nil
f36ca6af 1256 (spin-button spin-button)
1257 (direction spin-type)
1258 (increment single-float))
560af5c5 1259
bbaeff4b 1260(defbinding spin-button-update () nil
f36ca6af 1261 (spin-button spin-button))
560af5c5 1262
1263
1264
1265; ;;; Ruler
1266
bbaeff4b 1267(defbinding ruler-set-range () nil
f36ca6af 1268 (ruler ruler)
1269 (lower single-float)
1270 (upper single-float)
1271 (position single-float)
1272 (max-size single-float))
560af5c5 1273
bbaeff4b 1274(defbinding ruler-draw-ticks () nil
f36ca6af 1275 (ruler ruler))
560af5c5 1276
bbaeff4b 1277(defbinding ruler-draw-pos () nil
f36ca6af 1278 (ruler ruler))
560af5c5 1279
560af5c5 1280
560af5c5 1281
d520140e 1282;;; Range
bbaeff4b 1283#|
1284(defbinding range-draw-background () nil
d520140e 1285 (range range))
560af5c5 1286
bbaeff4b 1287(defbinding range-clear-background () nil
d520140e 1288 (range range))
560af5c5 1289
bbaeff4b 1290(defbinding range-draw-trough () nil
d520140e 1291 (range range))
560af5c5 1292
bbaeff4b 1293(defbinding range-draw-slider () nil
d520140e 1294 (range range))
560af5c5 1295
bbaeff4b 1296(defbinding range-draw-step-forw () nil
d520140e 1297 (range range))
560af5c5 1298
bbaeff4b 1299(defbinding range-slider-update () nil
d520140e 1300 (range range))
560af5c5 1301
bbaeff4b 1302(defbinding range-trough-click () int
d520140e 1303 (range range)
1304 (x int)
1305 (y int)
1306 (jump-perc single-float :out))
560af5c5 1307
bbaeff4b 1308(defbinding range-default-hslider-update () nil
d520140e 1309 (range range))
560af5c5 1310
bbaeff4b 1311(defbinding range-default-vslider-update () nil
d520140e 1312 (range range))
560af5c5 1313
bbaeff4b 1314(defbinding range-default-htrough-click () int
d520140e 1315 (range range)
1316 (x int)
1317 (y int)
1318 (jump-perc single-float :out))
560af5c5 1319
bbaeff4b 1320(defbinding range-default-vtrough-click () int
d520140e 1321 (range range)
1322 (x int)
1323 (y int)
1324 (jump-perc single-float :out))
560af5c5 1325
bbaeff4b 1326(defbinding range-default-hmotion () int
d520140e 1327 (range range)
1328 (x-delta int)
1329 (y-delta int))
560af5c5 1330
bbaeff4b 1331(defbinding range-default-vmotion () int
d520140e 1332 (range range)
1333 (x-delta int)
1334 (y-delta int))
bbaeff4b 1335|#
560af5c5 1336
560af5c5 1337
d520140e 1338;;; Scale
560af5c5 1339
e5b416f0 1340; (defbinding scale-draw-value () nil
1341; (scale scale))
560af5c5 1342
560af5c5 1343
560af5c5 1344
d520140e 1345;;; Progress bar
560af5c5 1346
bbaeff4b 1347(defbinding progress-bar-pulse () nil
d520140e 1348 (progress-bar progress-bar))
560af5c5 1349
1350
1351
560af5c5 1352
1353
1354;;; Tooltips
1355
bbaeff4b 1356(defbinding tooltips-enable () nil
d520140e 1357 (tooltips tooltips))
560af5c5 1358
bbaeff4b 1359(defbinding tooltips-disable () nil
d520140e 1360 (tooltips tooltips))
560af5c5 1361
e5b416f0 1362(defun (setf tooltips-enabled-p) (enable tooltips)
1363 (if enable
1364 (tooltips-enable tooltips)
1365 (tooltips-disable tooltips)))
1366
bbaeff4b 1367(defbinding tooltips-set-tip () nil
d520140e 1368 (tooltips tooltips)
1369 (widget widget)
1370 (tip-text string)
1371 (tip-private string))
560af5c5 1372
bbaeff4b 1373(defbinding tooltips-force-window () nil
d520140e 1374 (tooltips tooltips))
560af5c5 1375
1376
1377
d520140e 1378;;; Rc
560af5c5 1379
bbaeff4b 1380(defbinding rc-add-default-file (filename) nil
d520140e 1381 ((namestring (truename filename)) string))
560af5c5 1382
bbaeff4b 1383(defbinding rc-parse (filename) nil
d520140e 1384 ((namestring (truename filename)) string))
560af5c5 1385
bbaeff4b 1386(defbinding rc-parse-string () nil
d520140e 1387 (rc-string string))
560af5c5 1388
bbaeff4b 1389(defbinding rc-reparse-all () nil)
560af5c5 1390
bbaeff4b 1391(defbinding rc-get-style () style
d520140e 1392 (widget widget))
560af5c5 1393
1394
1395
1396;;; Accelerator Groups
bbaeff4b 1397#|
1398(defbinding accel-group-get-default () accel-group)
560af5c5 1399
f36ca6af 1400(deftype-method alien-ref accel-group (type-spec)
1401 (declare (ignore type-spec))
1402 '%accel-group-ref)
560af5c5 1403
f36ca6af 1404(deftype-method alien-unref accel-group (type-spec)
1405 (declare (ignore type-spec))
1406 '%accel-group-unref)
1407
bbaeff4b 1408(defbinding %accel-group-ref () accel-group
f36ca6af 1409 (accel-group (or accel-group pointer)))
1410
bbaeff4b 1411(defbinding %accel-group-unref () nil
f36ca6af 1412 (accel-group (or accel-group pointer)))
560af5c5 1413
bbaeff4b 1414(defbinding accel-group-activate (accel-group key modifiers) boolean
560af5c5 1415 (accel-group accel-group)
1416 ((gdk:keyval-from-name key) unsigned-int)
1417 (modifiers gdk:modifier-type))
1418
bbaeff4b 1419(defbinding accel-groups-activate (object key modifiers) boolean
560af5c5 1420 (object object)
1421 ((gdk:keyval-from-name key) unsigned-int)
1422 (modifiers gdk:modifier-type))
1423
bbaeff4b 1424(defbinding accel-group-attach () nil
560af5c5 1425 (accel-group accel-group)
1426 (object object))
1427
bbaeff4b 1428(defbinding accel-group-detach () nil
560af5c5 1429 (accel-group accel-group)
1430 (object object))
1431
bbaeff4b 1432(defbinding accel-group-lock () nil
560af5c5 1433 (accel-group accel-group))
1434
bbaeff4b 1435(defbinding accel-group-unlock () nil
560af5c5 1436 (accel-group accel-group))
1437
1438
1439;;; Accelerator Groups Entries
1440
bbaeff4b 1441(defbinding accel-group-get-entry (accel-group key modifiers) accel-entry
560af5c5 1442 (accel-group accel-group)
1443 ((gdk:keyval-from-name key) unsigned-int)
1444 (modifiers gdk:modifier-type))
1445
bbaeff4b 1446(defbinding accel-group-lock-entry (accel-group key modifiers) nil
560af5c5 1447 (accel-group accel-group)
1448 ((gdk:keyval-from-name key) unsigned-int)
1449 (modifiers gdk:modifier-type))
1450
bbaeff4b 1451(defbinding accel-group-unlock-entry (accel-group key modifiers) nil
560af5c5 1452 (accel-group accel-group)
1453 ((gdk:keyval-from-name key) unsigned-int)
1454 (modifiers gdk:modifier-type))
1455
bbaeff4b 1456(defbinding accel-group-add
560af5c5 1457 (accel-group key modifiers flags object signal) nil
1458 (accel-group accel-group)
1459 ((gdk:keyval-from-name key) unsigned-int)
1460 (modifiers gdk:modifier-type)
1461 (flags accel-flags)
1462 (object object)
1463 ((name-to-string signal) string))
1464
bbaeff4b 1465(defbinding accel-group-add (accel-group key modifiers object) nil
560af5c5 1466 (accel-group accel-group)
1467 ((gdk:keyval-from-name key) unsigned-int)
1468 (modifiers gdk:modifier-type)
1469 (object object))
1470
1471
1472;;; Accelerator Signals
1473
bbaeff4b 1474(defbinding accel-group-handle-add
560af5c5 1475 (object signal-id accel-group key modifiers flags) nil
1476 (object object)
1477 (signal-id unsigned-int)
1478 (accel-group accel-group)
1479 ((gdk:keyval-from-name key) unsigned-int)
1480 (modifiers gdk:modifier-type)
1481 (flags accel-flags))
1482
bbaeff4b 1483(defbinding accel-group-handle-remove
560af5c5 1484 (object accel-group key modifiers) nil
1485 (object object)
1486 (accel-group accel-group)
1487 ((gdk:keyval-from-name key) unsigned-int)
1488 (modifiers gdk:modifier-type))
bbaeff4b 1489|#