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