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