chiark / gitweb /
Code clean up and propper computation of foreign object sizes
[clg] / gtk / gtk.lisp
CommitLineData
112ac1d3 1;; Common Lisp bindings for GTK+ v2.x
2;; Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net>
560af5c5 3;;
112ac1d3 4;; Permission is hereby granted, free of charge, to any person obtaining
5;; a copy of this software and associated documentation files (the
6;; "Software"), to deal in the Software without restriction, including
7;; without limitation the rights to use, copy, modify, merge, publish,
8;; distribute, sublicense, and/or sell copies of the Software, and to
9;; permit persons to whom the Software is furnished to do so, subject to
10;; the following conditions:
560af5c5 11;;
112ac1d3 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
560af5c5 14;;
112ac1d3 15;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
560af5c5 22
6e8bf4cf 23;; $Id: gtk.lisp,v 1.47 2005-11-15 10:08:13 espen Exp $
560af5c5 24
25
26(in-package "GTK")
27
28;;; Gtk version
29
6bb23851 30(defbinding check-version () (copy-of string)
560af5c5 31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
34
bbaeff4b 35(defbinding query-version () nil
560af5c5 36 (major unsigned-int :out)
37 (minor unsigned-int :out)
38 (micro unsigned-int :out))
39
40(defun gtk-version ()
41 (multiple-value-bind (major minor micro)
42 (query-version)
43 (if (zerop micro)
44 (format nil "Gtk+ v~A.~A" major minor)
45 (format nil "Gtk+ v~A.~A.~A" major minor micro))))
46
c1c0746b 47(defun clg-version ()
5c9cc66a 48 "clg 0.91 version")
560af5c5 49
50
9adccb27 51;;;; Initalization
52
a5522de5 53(defbinding (gtk-init "gtk_parse_args") () boolean
9adccb27 54 "Initializes the library without opening the display."
55 (nil null)
56 (nil null))
57
58(defun clg-init (&optional display)
59 "Initializes the system and starts the event handling"
60 (unless (gdk:display-get-default)
61 (gdk:gdk-init)
a5522de5 62 (unless (gtk-init)
63 (error "Initialization of GTK+ failed."))
9adccb27 64 (prog1
65 (gdk:display-open display)
73572c12 66 (add-fd-handler (gdk:display-connection-number) :input #'main-iterate-all)
67 (setq *periodic-polling-function* #'main-iterate-all)
68 (setq *max-event-to-sec* 0)
69 (setq *max-event-to-usec* 1000))))
9adccb27 70
71
667a112b 72;;; Misc
73
74(defbinding grab-add () nil
75 (widget widget))
76
7abdba43 77(defbinding grab-get-current () widget)
667a112b 78
79(defbinding grab-remove () nil
80 (widget widget))
81
c1c0746b 82(defbinding get-default-language () (copy-of pango:language))
83
667a112b 84
647c99e5 85;;; About dialog
86
87#+gtk2.6
88(progn
89 (def-callback-marshal %about-dialog-activate-link-func
90 (nil (dialog about-dialog) (link (copy-of string))))
91
92 (defbinding about-dialog-set-email-hook (function) nil
93 ((callback %about-dialog-activate-link-func) pointer)
94 ((register-callback-function function) unsigned-int)
95 ((callback user-data-destroy-func) pointer))
96
97 (defbinding about-dialog-set-url-hook (function) nil
98 ((callback %about-dialog-activate-link-func) pointer)
99 ((register-callback-function function) unsigned-int)
100 ((callback user-data-destroy-func) pointer)))
101
102
0f476ab5 103;;; Acccel group
560af5c5 104
31700e82 105(defbinding %accel-group-connect () nil
106 (accel-group accel-group)
107 (key unsigned-int)
108 (modifiers gdk:modifier-type)
109 (flags accel-flags)
110 (gclosure gclosure))
111
112(defun accel-group-connect (group accelerator function &optional flags)
eacab64f 113 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 114 (let ((gclosure (make-callback-closure function)))
115 (%accel-group-connect group key modifiers flags gclosure)
116 gclosure)))
117
118(defbinding accel-group-connect-by-path (group path function) nil
119 (group accel-group)
120 (path string)
121 ((make-callback-closure function) gclosure :return))
122
123(defbinding %accel-group-disconnect (group gclosure) boolean
124 (group accel-group)
125 (gclosure gclosure))
126
127(defbinding %accel-group-disconnect-key () boolean
128 (group accel-group)
129 (key unsigned-int)
130 (modifiers gdk:modifier-type))
131
132(defun accel-group-disconnect (group accelerator)
133 (etypecase accelerator
134 (gclosure (%accel-group-disconnect group accelerator))
135 (string
eacab64f 136 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 137 (%accel-group-disconnect-key group key modifiers)))))
138
eacab64f 139(defbinding %accel-group-query () (copy-of (vector (inlined accel-group-entry) n))
140 (accel-group accel-group)
141 (key unsigned-int)
142 (modifiers gdk:modifier-type)
143 (n int :out))
144
145(defun accel-group-query (accel-group accelerator)
146 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
147 (%accel-group-query accel-group key modifiers)))
148
149(defbinding %accel-group-activate () boolean
150 (accel-group accel-group)
151 (acceleratable gobject)
152 (key unsigned-int)
153 (modifiers gdk:modifier-type))
154
155(defun accel-group-activate (accel-group acceleratable accelerator)
156 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
157 (%accel-group-activate accel-group acceleratable key modifiers)))
158
31700e82 159(defbinding accel-group-lock () nil
160 (accel-group accel-group))
161
162(defbinding accel-group-unlock () nil
163 (accel-group accel-group))
164
eacab64f 165(defbinding accel-group-from-accel-closure () accel-group
166 (closure gclosure))
167
31700e82 168(defbinding %accel-groups-activate () boolean
169 (object gobject)
170 (key unsigned-int)
171 (modifiers gdk:modifier-type))
172
173(defun accel-groups-activate (object accelerator)
eacab64f 174 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 175 (%accel-groups-activate object key modifiers)))
176
177(defbinding accel-groups-from-object () (gslist accel-groups)
178 (object gobject))
179
73572c12 180(defbinding accelerator-valid-p (key &optional modifiers) boolean
31700e82 181 (key unsigned-int)
182 (modifiers gdk:modifier-type))
183
184(defbinding %accelerator-parse () nil
185 (accelerator string)
186 (key unsigned-int :out)
187 (modifiers gdk:modifier-type :out))
188
eacab64f 189(defgeneric parse-accelerator (accelerator))
190
191(defmethod parse-accelerator ((accelerator string))
31700e82 192 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
193 (if (zerop key)
194 (error "Invalid accelerator: ~A" accelerator)
195 (values key modifiers))))
196
eacab64f 197(defmethod parse-accelerator ((accelerator cons))
198 (destructuring-bind (key modifiers) accelerator
199 (values
200 (etypecase key
201 (integer key)
202 (string
203 (or
204 (gdk:keyval-from-name key)
205 (error "Invalid key name: ~A" key)))
206 (character (parse-accelerator key)))
207 modifiers)))
208
209(defmethod parse-accelerator ((key integer))
210 key)
211
212(defmethod parse-accelerator ((key character))
213 (or
214 (gdk:keyval-from-name (string key))
215 (error "Invalid key name: ~A" key)))
216
217
31700e82 218(defbinding accelerator-name () string
219 (key unsigned-int)
220 (modifiers gdk:modifier-type))
221
222#+gtk2.6
223(defbinding accelerator-get-label () string
224 (key unsigned-int)
225 (modifiers gdk:modifier-type))
226
227(defbinding %accelerator-set-default-mod-mask () nil
228 (default-modifiers gdk:modifier-type))
229
230(defun (setf accelerator-default-modifier-mask) (default-modifiers)
231 (%accelerator-set-default-mod-mask default-modifiers))
232
233(defbinding (accelerator-default-modifier-mask "gtk_accelerator_get_default_mod_mask") () gdk:modifier-type)
560af5c5 234
1047e159 235
560af5c5 236;;; Acccel label
237
eacab64f 238(defbinding accel-label-get-accel-width () unsigned-int
239 (accel-label accel-label))
240
bbaeff4b 241(defbinding accel-label-refetch () boolean
560af5c5 242 (accel-label accel-label))
243
244
31700e82 245
246;;; Accel map
247
eacab64f 248(defbinding (accel-map-init "_gtk_accel_map_init") () nil)
a5522de5 249
31700e82 250(defbinding %accel-map-add-entry () nil
251 (path string)
252 (key unsigned-int)
253 (modifiers gdk:modifier-type))
254
255(defun accel-map-add-entry (path accelerator)
eacab64f 256 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 257 (%accel-map-add-entry path key modifiers)))
258
eacab64f 259(defbinding %accel-map-lookup-entry () boolean
31700e82 260 (path string)
eacab64f 261 ((make-instance 'accel-key) accel-key :return))
262
263(defun accel-map-lookup-entry (path)
264 (multiple-value-bind (found-p accel-key) (%accel-map-lookup-entry path)
265 (when found-p
266 (values
267 (slot-value accel-key 'key)
268 (slot-value accel-key 'modifiers)
269 (slot-value accel-key 'flags)))))
31700e82 270
271(defbinding %accel-map-change-entry () boolean
272 (path string)
273 (key unsigned-int)
274 (modifiers gdk:modifier-type)
275 (replace boolean))
276
277(defun accel-map-change-entry (path accelerator &optional replace)
eacab64f 278 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
31700e82 279 (%accel-map-change-entry path key modifiers replace)))
280
281(defbinding accel-map-load () nil
282 (filename pathname))
283
284(defbinding accel-map-save () nil
285 (filename pathname))
286
eacab64f 287(defcallback %accel-map-foreach-func
288 (nil
289 (callback-id unsigned-int) (accel-path (copy-of string))
290 (key unsigned-int) (modifiers gdk:modifier-type) (changed boolean))
291 (invoke-callback callback-id nil accel-path key modifiers changed))
292
293(defbinding %accel-map-foreach (callback-id) nil
294 (callback-id unsigned-int)
295 (%accel-map-foreach-func callback))
296
297(defbinding %accel-map-foreach-unfiltered (callback-id) nil
298 (callback-id unsigned-int)
299 (%accel-map-foreach-func callback))
300
301(defun accel-map-foreach (function &optional (filter-p t))
302 (with-callback-function (id function)
303 (if filter-p
304 (%accel-map-foreach id)
305 (%accel-map-foreach-unfiltered id))))
306
307(defbinding accel-map-add-filter () nil
308 (filter string))
309
31700e82 310(defbinding accel-map-get () accel-map)
311
312(defbinding accel-map-lock-path () nil
313 (path string))
314
315(defbinding accel-map-unlock-path () nil
316 (path string))
317
318
319
eacab64f 320;;; Accessibility
d76e9fca 321
322(defbinding accessible-connect-widget-destroyed () nil
323 (accessible accessible))
324
325
0f476ab5 326;;; Adjustment
560af5c5 327
d76e9fca 328(defmethod initialize-instance ((adjustment adjustment) &key value)
1047e159 329 (prog1
330 (call-next-method)
331 ;; we need to make sure that the value is set last, otherwise it
d76e9fca 332 ;; may be outside current limits and ignored
1047e159 333 (when value
334 (setf (slot-value adjustment 'value) value))))
335
336
0f476ab5 337(defbinding adjustment-changed () nil
338 (adjustment adjustment))
339
340(defbinding adjustment-value-changed () nil
341 (adjustment adjustment))
342
343(defbinding adjustment-clamp-page () nil
344 (adjustment adjustment)
345 (lower single-float)
346 (upper single-float))
560af5c5 347
0f476ab5 348
68f519e0 349;;; Alignment
350
351(defbinding alignment-set () nil
352 (alognment alignment)
353 (x-align single-float)
354 (y-align single-float)
355 (x-scale single-float)
356 (y-scale single-float))
357
358(defbinding alignment-get-padding () nil
359 (alognment alignment)
360 (top unsigned-int :out)
361 (bottom unsigned-int :out)
362 (left unsigned-int :out)
363 (right unsigned-int :out))
364
365(defbinding alignment-set-padding () nil
366 (alognment alignment)
367 (top unsigned-int)
368 (bottom unsigned-int)
369 (left unsigned-int)
370 (right unsigned-int))
371
372
0f476ab5 373;;; Aspect frame
374
375
376;;; Bin
560af5c5 377
378(defun (setf bin-child) (child bin)
0f476ab5 379 (when-bind (current-child (bin-child bin))
380 (container-remove bin current-child))
560af5c5 381 (container-add bin child)
382 child)
383
14c94516 384(defmethod compute-signal-function ((bin bin) signal function object)
385 (declare (ignore signal))
386 (if (eq object :child)
cb4bf772 387 #'(lambda (&rest args)
388 (apply function (bin-child bin) (rest args)))
389 (call-next-method)))
0f476ab5 390
391
392;;; Box
393
394(defbinding box-pack-start () nil
395 (box box)
396 (child widget)
397 (expand boolean)
398 (fill boolean)
399 (padding unsigned-int))
400
401(defbinding box-pack-end () nil
402 (box box)
403 (child widget)
404 (expand boolean)
405 (fill boolean)
406 (padding unsigned-int))
407
d76e9fca 408(defun box-pack (box child &key end (expand t) (fill t) (padding 0))
1a1949c7 409 (if end
f5b67f2b 410 (box-pack-end box child expand fill padding)
411 (box-pack-start box child expand fill padding)))
0f476ab5 412
413(defbinding box-reorder-child () nil
414 (box box)
415 (child widget)
416 (position int))
417
418(defbinding box-query-child-packing () nil
419 (box box)
420 (child widget)
421 (expand boolean :out)
422 (fill boolean :out)
423 (padding unsigned-int :out)
424 (pack-type pack-type :out))
425
426(defbinding box-set-child-packing () nil
427 (box box)
428 (child widget)
429 (expand boolean)
430 (fill boolean)
431 (padding unsigned-int)
432 (pack-type pack-type))
433
434
435
560af5c5 436;;; Button
437
d76e9fca 438(defmethod initialize-instance ((button button) &rest initargs &key stock)
439 (if stock
440 (apply #'call-next-method button :label stock :use-stock t initargs)
441 (call-next-method)))
442
443
bbaeff4b 444(defbinding button-pressed () nil
560af5c5 445 (button button))
446
0f476ab5 447(defbinding button-released () nil
448 (button button))
449
450(defbinding button-clicked () nil
451 (button button))
452
453(defbinding button-enter () nil
454 (button button))
455
456(defbinding button-leave () nil
457 (button button))
458
459
460
461;;; Calendar
462
463(defbinding calendar-select-month () int
464 (calendar calendar)
465 (month unsigned-int)
466 (year unsigned-int))
467
468(defbinding calendar-select-day () nil
469 (calendar calendar)
470 (day unsigned-int))
471
472(defbinding calendar-mark-day () int
473 (calendar calendar)
474 (day unsigned-int))
475
476(defbinding calendar-unmark-day () int
477 (calendar calendar)
478 (day unsigned-int))
479
480(defbinding calendar-clear-marks () nil
481 (calendar calendar))
482
d76e9fca 483(defbinding calendar-get-date () nil
0f476ab5 484 (calendar calendar)
485 (year unsigned-int :out)
486 (month unsigned-int :out)
487 (day unsigned-int :out))
488
489(defbinding calendar-freeze () nil
490 (calendar calendar))
491
492(defbinding calendar-thaw () nil
493 (calendar calendar))
494
495
0f476ab5 496;;; Check menu item
497
498(defbinding check-menu-item-toggled () nil
499 (check-menu-item check-menu-item))
500
501
0f476ab5 502;;; Color selection
503
504(defbinding (color-selection-is-adjusting-p
505 "gtk_color_selection_is_adjusting") () boolean
506 (colorsel color-selection))
507
508
509
510;;; Color selection dialog -- no functions
511
512
513
1a1949c7 514;;;; Combo Box
0f476ab5 515
d76e9fca 516(defmethod initialize-instance ((combo-box combo-box) &rest initargs
517 &key model content active)
518 (remf initargs :active)
519 (if model
520 (apply #'call-next-method combo-box initargs)
521 (progn
522 (apply #'call-next-method combo-box
523 :model (make-instance 'list-store :column-types '(string))
524 initargs)
525 (unless (typep combo-box 'combo-box-entry)
526 (let ((cell (make-instance 'cell-renderer-text)))
527 (cell-layout-pack combo-box cell :expand t)
528 (cell-layout-add-attribute combo-box cell :text 0)))))
529 (when content
530 (mapc #'(lambda (text)
531 (combo-box-append-text combo-box text))
532 content))
533 (when active
534 (setf (combo-box-active combo-box) active)))
535
1a1949c7 536
537;; (defmethod shared-initialize :after ((combo-box combo-box) names &key active)
538;; (when active
539;; (signal-emit combo-box 'changed)))
540
541(defbinding combo-box-append-text () nil
542 (combo-box combo-box)
543 (text string))
544
545(defbinding combo-box-insert-text () nil
546 (combo-box combo-box)
547 (position int)
548 (text string))
549
550(defbinding combo-box-prepend-text () nil
551 (combo-box combo-box)
552 (text string))
553
554#+gtk2.6
555(defbinding combo-box-get-active-text () string
556 (combo-box combo-box))
0f476ab5 557
1a1949c7 558(defbinding combo-box-popup () nil
559 (combo-box combo-box))
0f476ab5 560
1a1949c7 561(defbinding combo-box-popdown () nil
562 (combo-box combo-box))
563
564
565
566;;;; Combo Box Entry
567
d76e9fca 568(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
1a1949c7 569 (call-next-method)
570 (unless model
571 (setf (combo-box-entry-text-column combo-box-entry) 0)))
0f476ab5 572
573
48da76bf 574;;;; Dialog
0f476ab5 575
c49be931 576(defmethod shared-initialize ((dialog dialog) names &rest initargs
577 &key button buttons)
578 (declare (ignore button buttons))
579 (prog1
580 (call-next-method)
581 (initial-apply-add dialog #'dialog-add-button initargs :button :buttons)))
48da76bf 582
0f476ab5 583
14c94516 584(defun dialog-response-id (dialog response &optional create-p error-p)
585 "Returns a numeric response id"
586 (if (typep response 'response-type)
587 (response-type-to-int response)
588 (let ((responses (object-data dialog 'responses)))
589 (cond
590 ((and responses (position response responses :test #'equal)))
591 (create-p
1047e159 592 (cond
14c94516 593 (responses
594 (vector-push-extend response responses)
595 (1- (length responses)))
1047e159 596 (t
597 (setf
14c94516 598 (object-data dialog 'responses)
599 (make-array 1 :adjustable t :fill-pointer t
600 :initial-element response))
1047e159 601 0)))
602 (error-p
14c94516 603 (error "Invalid response: ~A" response))))))
0f476ab5 604
14c94516 605(defun dialog-find-response (dialog id)
606 "Finds a symbolic response given a numeric id"
607 (if (< id 0)
608 (int-to-response-type id)
609 (aref (object-data dialog 'responses) id)))
610
611
612(defmethod compute-signal-id ((dialog dialog) signal)
613 (if (dialog-response-id dialog signal)
614 (ensure-signal-id 'response dialog)
615 (call-next-method)))
616
617(defmethod compute-signal-function ((dialog dialog) signal function object)
618 (declare (ignore function object))
619 (let ((callback (call-next-method))
620 (id (dialog-response-id dialog signal)))
621 (if id
622 #'(lambda (dialog response)
623 (when (= response id)
624 (funcall callback dialog)))
625 callback)))
0f476ab5 626
48da76bf 627(defbinding dialog-run () nil
628 (dialog dialog))
0f476ab5 629
14c94516 630(defbinding dialog-response (dialog response) nil
0f476ab5 631 (dialog dialog)
14c94516 632 ((dialog-response-id dialog response nil t) int))
0f476ab5 633
634
635(defbinding %dialog-add-button () button
636 (dialog dialog)
637 (text string)
14c94516 638 (response-id int))
0f476ab5 639
1047e159 640(defun dialog-add-button (dialog label &optional (response label)
641 &key default object after)
40b2615c 642 "Adds a button to the dialog."
14c94516 643 (let* ((signal (if (functionp response)
644 label
645 response))
646 (id (dialog-response-id dialog signal t))
647 (button (%dialog-add-button dialog label id)))
1047e159 648 (when (functionp response)
14c94516 649 (signal-connect dialog signal response :object object :after after))
1047e159 650 (when default
14c94516 651 (%dialog-set-default-response dialog id))
0f476ab5 652 button))
653
654
14c94516 655(defbinding %dialog-add-action-widget () nil
0f476ab5 656 (dialog dialog)
657 (action-widget widget)
14c94516 658 (response-id int))
0f476ab5 659
1047e159 660(defun dialog-add-action-widget (dialog widget &optional (response widget)
661 &key default object after)
14c94516 662 (let* ((signal (if (functionp response)
663 widget
664 response))
665 (id (dialog-response-id dialog signal t)))
666 (unless (widget-hidden-p widget)
667 (widget-show widget))
668 (%dialog-add-action-widget dialog widget id)
1047e159 669 (when (functionp response)
14c94516 670 (signal-connect dialog signal response :object object :after after))
1047e159 671 (when default
14c94516 672 (%dialog-set-default-response dialog id))
0f476ab5 673 widget))
0f476ab5 674
0f476ab5 675
48da76bf 676(defbinding %dialog-set-default-response () nil
677 (dialog dialog)
14c94516 678 (response-id int))
0f476ab5 679
14c94516 680(defun dialog-set-default-response (dialog response)
48da76bf 681 (%dialog-set-default-response
14c94516 682 dialog (dialog-response-id dialog response nil t)))
0f476ab5 683
14c94516 684(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
48da76bf 685 (dialog dialog)
14c94516 686 ((dialog-response-id dialog response nil t) int)
48da76bf 687 (sensitive boolean))
0f476ab5 688
40b2615c 689#+gtk2.6
647c99e5 690(defbinding alternative-dialog-button-order-p (&optional screen) boolean
691 (screen (or null gdk:screen)))
40b2615c 692
693#+gtk2.6
694(defbinding (dialog-set-alternative-button-order
695 "gtk_dialog_set_alternative_button_order_from_array")
696 (dialog new-order)
697 (dialog dialog)
698 ((length new-order) int)
14c94516 699 ((map 'vector #'(lambda (response)
700 (dialog-response-id dialog response nil t))
40b2615c 701 new-order) (vector int)))
0f476ab5 702
48da76bf 703
bdc0e300 704#+gtk2.8
705(progn
706 (defbinding %dialog-get-response-for-widget () int
707 (dialog dialog)
708 (widget widget))
709
710 (defun dialog-get-response-for-widget (dialog widget)
711 (dialog-find-response dialog (dialog-get-response-for-widget dialog widget))))
712
713
48da76bf 714(defmethod container-add ((dialog dialog) (child widget) &rest args)
1047e159 715 (apply #'container-add (dialog-vbox dialog) child args))
48da76bf 716
14c94516 717
48da76bf 718(defmethod container-remove ((dialog dialog) (child widget))
1047e159 719 (container-remove (dialog-vbox dialog) child))
0f476ab5 720
48da76bf 721(defmethod container-children ((dialog dialog))
1047e159 722 (container-children (dialog-vbox dialog)))
48da76bf 723
724(defmethod (setf container-children) (children (dialog dialog))
1047e159 725 (setf (container-children (dialog-vbox dialog)) children))
560af5c5 726
560af5c5 727
aaa6e6cb 728;;; Entry
560af5c5 729
aaa6e6cb 730(defbinding entry-get-layout-offsets () nil
731 (entry entry)
732 (x int :out)
733 (y int :out))
560af5c5 734
d76e9fca 735(defbinding entry-layout-index-to-text-index () int
736 (entry entry)
737 (layout-index int))
738
739(defbinding entry-text-index-to-layout-index () int
740 (entry entry)
741 (text-index int))
742
560af5c5 743
f45fd227 744;;; Entry Completion
745
746(def-callback-marshal %entry-completion-match-func
747 (boolean entry-completion string (copy-of tree-iter)))
748
749(defbinding entry-completion-set-match-func (completion function) nil
750 (completion entry-completion)
751 ((callback %entry-completion-match-func) pointer)
752 ((register-callback-function function) unsigned-int)
73572c12 753 ((callback user-data-destroy-func) pointer))
f45fd227 754
755(defbinding entry-completion-complete () nil
756 (completion entry-completion))
757
758#+gtk2.6
759(defbinding entry-completion-insert-prefix () nil
760 (completion entry-completion))
761
762(defbinding entry-completion-insert-action-text () nil
763 (completion entry-completion)
764 (index int)
765 (text string))
766
767(defbinding entry-completion-insert-action-markup () nil
768 (completion entry-completion)
769 (index int)
770 (markup string))
771
772(defbinding entry-completion-delete-action () nil
773 (completion entry-completion)
774 (index int))
775
776
68f519e0 777;;; File Chooser
778
779(defmethod initialize-instance ((file-chooser file-chooser) &rest initargs
780 &key filter filters shortcut-folder
781 shortcut-folders shortcut-folder-uti
782 shortcut-folder-uris)
783 (declare (ignore filter filters shortcut-folder shortcut-folders
784 shortcut-folder-uti shortcut-folder-uris))
785 (prog1
786 (call-next-method)
787 (initial-add file-chooser #'file-chooser-add-filter
788 initargs :filer :filters)
789 (initial-add file-chooser #'file-chooser-add-shortcut-folder
790 initargs :shortcut-folder :shortcut-folders)
791 (initial-add file-chooser #'file-chooser-add-shortcut-folder-uri
792 initargs :shortcut-folder-uri :shortcut-folders-uris)))
793
794
795(defbinding file-chooser-select-filename () boolean
796 (file-chooser file-chooser)
797 (filename string))
798
799(defbinding file-chooser-unselect-filename () nil
800 (file-chooser file-chooser)
801 (filename string))
802
803(defbinding file-chooser-select-all () boolean
804 (file-chooser file-chooser))
805
806(defbinding file-chooser-unselect-all () boolean
807 (file-chooser file-chooser))
808
809(defbinding file-chooser-get-filenames () (gslist string)
810 (file-chooser file-chooser))
811
812(defbinding file-chooser-select-uri () boolean
813 (file-chooser file-chooser)
814 (uri string))
815
816(defbinding file-chooser-unselect-uri () nil
817 (file-chooser file-chooser)
818 (uri string))
819
820(defbinding file-chooser-get-uris () (gslist string)
821 (file-chooser file-chooser))
822
823(defbinding file-chooser-add-filter () nil
824 (file-chooser file-chooser)
825 (filter file-filter))
826
827(defbinding file-chooser-remove-filter () nil
828 (file-chooser file-chooser)
829 (filter file-filter))
830
831(defbinding file-chooser-list-filters () (gslist file-filter)
832 (file-chooser file-chooser))
833
834(defbinding file-chooser-add-shortcut-folder () boolean
835 (file-chooser file-chooser)
836 (folder string)
837 (nil null))
838
839(defbinding file-chooser-remove-shortcut-folder () nil
840 (file-chooser file-chooser)
841 (folder string)
842 (nil null))
843
844(defbinding file-chooser-list-shortcut-folders () (gslist string)
845 (file-chooser file-chooser))
846
847(defbinding file-chooser-add-shortcut-folder-uri () boolean
848 (file-chooser file-chooser)
849 (uri string)
850 (nil null))
851
852(defbinding file-chooser-remove-shortcut-folder-uri () nil
853 (file-chooser file-chooser)
854 (uri string)
855 (nil null))
856
857(defbinding file-chooser-list-shortcut-folder-uris () (gslist string)
858 (file-chooser file-chooser))
859
860
861;;; File Filter
862
863(defmethod initialize-instance ((file-filter file-filter) &rest initargs
864 &key mime-type mime-types pattern patterns
865 pixbuf-formats)
866 (declare (ignore mime-type mime-types pattern patterns))
867 (prog1
868 (call-next-method)
869 (when pixbuf-formats
870 #-gtk2.6(warn "Initarg :PIXBUF-FORMATS not supportet in this version of Gtk")
871 #+gtk2.6(file-filter-add-pixbuf-formats file-filter))
872 (initial-add file-filter #'file-filter-add-mime-type
873 initargs :mime-type :mime-types)
874 (initial-add file-filter #'file-filter-add-pattern
875 initargs :pattern :patterns)))
876
877
878(defbinding file-filter-add-mime-type () nil
879 (filter file-filter)
880 (mime-type string))
881
882(defbinding file-filter-add-pattern () nil
883 (filter file-filter)
884 (pattern string))
885
886#+gtk2.6
887(defbinding file-filter-add-pixbuf-formats () nil
647c99e5 888 (filter file-filter))
68f519e0 889
890(def-callback-marshal %file-filter-func (boolean file-filter-info))
891
73572c12 892(defbinding file-filter-add-custom (filter needed function) nil
68f519e0 893 (filter file-filter)
894 (needed file-filter-flags)
895 ((callback %file-filter-func) pointer)
896 ((register-callback-function function) unsigned-int)
73572c12 897 ((callback user-data-destroy-func) pointer))
68f519e0 898
899(defbinding file-filter-get-needed () file-filter-flags
900 (filter file-filter))
901
902(defbinding file-filter-filter () boolean
903 (filter file-filter)
904 (filter-info file-filter-info))
905
906
907
1047e159 908;;; Image
909
910(defbinding image-set-from-file () nil
911 (image image)
912 (filename pathname))
913
d76e9fca 914(defmethod (setf image-pixmap) ((data vector) (image image))
915 (multiple-value-bind (pixmap mask) (gdk:pixmap-create data)
916 (setf (image-pixmap image) pixmap)
917 (setf (image-mask image) mask)))
918
919(defmethod initialize-instance ((image image) &rest initargs &key pixmap file)
920 (cond
921 ((typep pixmap 'vector)
922 (multiple-value-bind (pixmap mask) (gdk:pixmap-create pixmap)
923 (apply #'call-next-method image :pixmap pixmap :mask mask initargs)))
924 (file
925 (prog1
926 (call-next-method)
927 (image-set-from-file image file)))
928 ((call-next-method))))
1047e159 929
cb4bf772 930(defun create-image-widget (source &optional mask)
d76e9fca 931 (etypecase source
932 (gdk:pixbuf (make-instance 'image :pixbuf source))
933 (string (make-instance 'image :stock source))
934 (pathname (make-instance 'image :file source))
935 ((or list vector) (make-instance 'image :pixmap source))
936 (gdk:pixmap (make-instance 'image :pixmap source :mask mask))))
1047e159 937
bdc0e300 938#+gtk2.8
939(defbinding image-clear () nil
940 (image image))
941
942
1047e159 943
d76e9fca 944;;; Image menu item
1047e159 945
d76e9fca 946(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
947 (if (and image (not (typep image 'widget)))
cb4bf772 948 (apply #'call-next-method item :image (create-image-widget image) initargs)
d76e9fca 949 (call-next-method)))
1047e159 950
d76e9fca 951
952(defmethod (setf image-menu-item-image) ((widget widget) (item image-menu-item))
953 (setf (slot-value item 'image) widget))
954
955(defmethod (setf image-menu-item-image) (image (item image-menu-item))
cb4bf772 956 (setf (image-menu-item-image item) (create-image-widget image)))
1047e159 957
560af5c5 958
0f476ab5 959;;; Label
560af5c5 960
881fe3c3 961(defmethod shared-initialize ((label label) names &key pattern)
962 (declare (ignore names))
963 (call-next-method)
964 (when pattern
965 (setf (label-pattern label) pattern)))
966
aaa6e6cb 967(defbinding label-get-layout-offsets () nil
1047e159 968 (label label)
aaa6e6cb 969 (x int :out)
970 (y int :out))
971
0f476ab5 972(defbinding label-select-region () nil
973 (label label)
974 (start int)
975 (end int))
560af5c5 976
1047e159 977(defbinding label-get-selection-bounds () boolean
aaa6e6cb 978 (label label)
979 (start int :out)
980 (end int :out))
f36ca6af 981
560af5c5 982
983
984;;; Radio button
985
e5b416f0 986(defbinding %radio-button-get-group () pointer
d520140e 987 (radio-button radio-button))
988
bbaeff4b 989(defbinding %radio-button-set-group () nil
d520140e 990 (radio-button radio-button)
991 (group pointer))
560af5c5 992
cb4bf772 993(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
d520140e 994 "Add BUTTON1 to the group which BUTTON2 belongs to."
995 (%radio-button-set-group button1 (%radio-button-get-group button2)))
996
a5522de5 997(defun %add-activate-callback (widget signal function object after)
998 (if object
999 (signal-connect widget signal
1000 #'(lambda (object)
1001 (when (slot-value widget 'active)
1002 (funcall function object (slot-value widget 'value))))
1003 :object object :after after)
1004 (signal-connect widget signal
1005 #'(lambda ()
1006 (when (slot-value widget 'active)
1007 (funcall function (slot-value widget 'value))))
1008 :after after)))
1009
1010(defmethod activate-radio-widget ((button radio-button))
1011 (signal-emit button 'clicked))
1012
1013(defmethod add-activate-callback ((button radio-button) function &key object after)
1014 (%add-activate-callback button 'clicked function object after))
1015
d76e9fca 1016(defmethod initialize-instance ((button radio-button) &key group)
1017 (prog1
1018 (call-next-method)
1019 (when group
cb4bf772 1020 (add-to-radio-group button group))))
560af5c5 1021
1022
560af5c5 1023;;; Item
1024
bbaeff4b 1025(defbinding item-select () nil
560af5c5 1026 (item item))
1027
bbaeff4b 1028(defbinding item-deselect () nil
560af5c5 1029 (item item))
1030
bbaeff4b 1031(defbinding item-toggle () nil
560af5c5 1032 (item item))
1033
1034
1035
1036;;; Menu item
1037
d76e9fca 1038(defmethod initialize-instance ((item menu-item) &key label)
1039 (prog1
1040 (call-next-method)
1041 (when label
1042 (setf (menu-item-label item) label))))
1043
1044
f36ca6af 1045(defun (setf menu-item-label) (label menu-item)
1046 (make-instance 'accel-label
1047 :label label :xalign 0.0 :yalign 0.5 :accel-widget menu-item
d76e9fca 1048 :use-underline (menu-item-use-underline-p menu-item)
1049 :visible t :parent menu-item)
f36ca6af 1050 label)
560af5c5 1051
f5b67f2b 1052(defun menu-item-label (menu-item)
d76e9fca 1053 (when (and (slot-boundp menu-item 'child)
1054 (typep (bin-child menu-item) 'label))
1055 (label-label (bin-child menu-item))))
f5b67f2b 1056
d76e9fca 1057(defbinding menu-item-remove-submenu () nil
f36ca6af 1058 (menu-item menu-item))
560af5c5 1059
f5b67f2b 1060(defbinding menu-item-set-accel-path () nil
1061 (menu-item menu-item)
1062 (accel-path string))
1063
bbaeff4b 1064(defbinding menu-item-select () nil
f36ca6af 1065 (menu-item menu-item))
560af5c5 1066
bbaeff4b 1067(defbinding menu-item-deselect () nil
f36ca6af 1068 (menu-item menu-item))
560af5c5 1069
bbaeff4b 1070(defbinding menu-item-activate () nil
f36ca6af 1071 (menu-item menu-item))
560af5c5 1072
f5b67f2b 1073(defbinding menu-item-toggle-size-request () nil
1074 (menu-item menu-item)
1075 (requisition int :out))
1076
1077(defbinding menu-item-toggle-size-allocate () nil
1078 (menu-item menu-item)
1079 (allocation int))
1080
560af5c5 1081
d76e9fca 1082;;; Menu tool button
1083
1084#+gtk2.6
647c99e5 1085(defbinding menu-tool-button-set-arrow-tooltip () nil
d76e9fca 1086 (menu-tool-button menu-tool-button)
1087 (tooltips tooltips)
1088 (tip-text string)
1089 (tip-private string))
1090
1091
f4267180 1092;;; Message dialog
1093
7a2e0799 1094(defmethod initialize-instance ((dialog message-dialog)
1095 &key (message-type :info) (buttons :close)
1096 flags text #+gtk 2.6 secondary-text
1097 transient-parent)
f4267180 1098 (setf
1099 (slot-value dialog 'location)
7a2e0799 1100 (%message-dialog-new transient-parent flags message-type buttons))
1101 (when text
1102 (message-dialog-set-markup dialog text))
1103 #+gtk2.6
1104 (when secondary-text
1105 (message-dialog-format-secondary-markup dialog secondary-text))
1106 (call-next-method))
f4267180 1107
1108
1109(defbinding %message-dialog-new () pointer
1110 (parent (or null window))
1111 (flags dialog-flags)
1112 (type message-type)
1113 (buttons buttons-type)
7a2e0799 1114 (nil null))
f4267180 1115
1116(defbinding message-dialog-set-markup () nil
1117 (message-dialog message-dialog)
1118 (markup string))
1119
1120#+gtk2.6
1121(defbinding message-dialog-format-secondary-text () nil
1122 (message-dialog message-dialog)
1123 (text string))
1124
1125#+gtk2.6
1126(defbinding message-dialog-format-secondary-markup () nil
1127 (message-dialog message-dialog)
1128 (markup string))
1129
1130
560af5c5 1131
f36ca6af 1132;;; Radio menu item
560af5c5 1133
e5b416f0 1134(defbinding %radio-menu-item-get-group () pointer
d520140e 1135 (radio-menu-item radio-menu-item))
1136
bbaeff4b 1137(defbinding %radio-menu-item-set-group () nil
d520140e 1138 (radio-menu-item radio-menu-item)
1139 (group pointer))
1140
a5522de5 1141(defmethod activate-radio-widget ((item radio-menu-item))
1142 (menu-item-activate item))
1143
cb4bf772 1144(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
d520140e 1145 "Add ITEM1 to the group which ITEM2 belongs to."
1146 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1147
a5522de5 1148(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1149 (%add-activate-callback item 'activate function object after))
1150
d76e9fca 1151(defmethod initialize-instance ((item radio-menu-item) &key group)
f5b67f2b 1152 (prog1
1153 (call-next-method)
d76e9fca 1154 (when group
cb4bf772 1155 (add-to-radio-group item group))))
1156
d520140e 1157
560af5c5 1158
d76e9fca 1159;;; Radio tool button
1160
1161(defbinding %radio-tool-button-get-group () pointer
1162 (radio-tool-button radio-tool-button))
1163
1164(defbinding %radio-tool-button-set-group () nil
1165 (radio-tool-button radio-tool-button)
1166 (group pointer))
1167
a5522de5 1168(defmethod activate-radio-widget ((button radio-tool-button))
1169 (signal-emit button 'clicked))
1170
cb4bf772 1171(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
d76e9fca 1172 "Add BUTTON1 to the group which BUTTON2 belongs to."
1173 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
a5522de5 1174(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1175 (%add-activate-callback button 'clicked function object after))
d76e9fca 1176
1177(defmethod initialize-instance ((button radio-tool-button) &key group)
1178 (prog1
1179 (call-next-method)
1180 (when group
cb4bf772 1181 (add-to-radio-group button group))))
1182
d76e9fca 1183
560af5c5 1184
aaa6e6cb 1185;;; Toggle button
1186
1187(defbinding toggle-button-toggled () nil
1188 (toggle-button toggle-button))
1189
1190
560af5c5 1191;;; Window
1192
c49be931 1193(defmethod initialize-instance ((window window) &rest initargs
1194 &key accel-group accel-groups)
1195 (declare (ignore accel-group accel-groups))
1196 (prog1
1197 (call-next-method)
1198 (initial-add window #'window-add-accel-group
1199 initargs :accel-group :accel-groups)))
73d58e01 1200
1201
7625ebd8 1202(defbinding window-set-wmclass () nil
560af5c5 1203 (window window)
1204 (wmclass-name string)
1205 (wmclass-class string))
1206
bbaeff4b 1207(defbinding window-add-accel-group () nil
560af5c5 1208 (window window)
1209 (accel-group accel-group))
1210
bbaeff4b 1211(defbinding window-remove-accel-group () nil
560af5c5 1212 (window window)
1213 (accel-group accel-group))
1214
bbaeff4b 1215(defbinding window-activate-focus () int
560af5c5 1216 (window window))
1217
bbaeff4b 1218(defbinding window-activate-default () int
560af5c5 1219 (window window))
1220
7625ebd8 1221(defbinding window-set-default-size (window width height) int
560af5c5 1222 (window window)
7625ebd8 1223 ((or width -1) int)
1224 ((or height -1) int))
560af5c5 1225
4d16221f 1226(defbinding %window-set-geometry-hints () nil
1227 (window window)
1228 (geometry gdk:geometry)
1229 (geometry-mask gdk:window-hints))
1230
1231(defun window-set-geometry-hints (window &key min-width min-height
1232 max-width max-height base-width base-height
1233 width-inc height-inc min-aspect max-aspect
1234 (gravity nil gravity-p) min-size max-size)
1235 (let ((geometry (make-instance 'gdk:geometry
1236 :min-width (or min-width -1)
1237 :min-height (or min-height -1)
1238 :max-width (or max-width -1)
1239 :max-height (or max-height -1)
1240 :base-width (or base-width 0)
1241 :base-height (or base-height 0)
1242 :width-inc (or width-inc 0)
1243 :height-inc (or height-inc 0)
1244 :min-aspect (or min-aspect 0)
1245 :max-aspect (or max-aspect 0)
1246 :gravity gravity))
1247 (mask ()))
1248 (when (or min-size min-width min-height)
1249 (push :min-size mask))
1250 (when (or max-size max-width max-height)
1251 (push :max-size mask))
1252 (when (or base-width base-height)
1253 (push :base-size mask))
1254 (when (or width-inc height-inc)
1255 (push :resize-inc mask))
1256 (when (or min-aspect max-aspect)
1257 (push :aspect mask))
1258 (when gravity-p
1259 (push :win-gravity mask))
1260 (%window-set-geometry-hints window geometry mask)))
560af5c5 1261
73d58e01 1262(defbinding window-list-toplevels () (glist (copy-of window))
1263 "Returns a list of all existing toplevel windows.")
7625ebd8 1264
1265(defbinding window-add-mnemonic (window key target) nil
1266 (window window)
1267 ((gdk:keyval-from-name key) unsigned-int)
1268 (target widget))
1269
1270(defbinding window-remove-mnemonic (window key target) nil
1271 (window window)
1272 ((gdk:keyval-from-name key) unsigned-int)
1273 (target widget))
1274
1275(defbinding window-mnemonic-activate (window key modifier) nil
1276 (window window)
1277 ((gdk:keyval-from-name key) unsigned-int)
1278 (modifier gdk:modifier-type))
1279
4d16221f 1280(defbinding window-activate-key () boolean
1281 (window window)
1282 (event gdk:key-event))
1283
1284(defbinding window-propagate-key-event () boolean
1285 (window window)
1286 (event gdk:key-event))
1287
bdc0e300 1288#-gtk2.8
7625ebd8 1289(defbinding window-present () nil
1290 (window window))
1291
bdc0e300 1292#+gtk2.8
1293(progn
1294 (defbinding %window-present () nil
1295 (window window))
1296
6e8bf4cf 1297 (defbinding %window-present-with-time () nil
bdc0e300 1298 (window window)
1299 (timespamp unsigned-int))
1300
1301 (defun window-present (window &optional timestamp)
1302 (if timestamp
6e8bf4cf 1303 (%window-present-with-time window timestamp)
bdc0e300 1304 (%window-present window))))
1305
7625ebd8 1306(defbinding window-iconify () nil
1307 (window window))
1308
1309(defbinding window-deiconify () nil
1310 (window window))
1311
1312(defbinding window-stick () nil
1313 (window window))
1314
1315(defbinding window-unstick () nil
1316 (window window))
1317
1318(defbinding window-maximize () nil
1319 (window window))
1320
1321(defbinding window-unmaximize () nil
1322 (window window))
1323
4d16221f 1324(defbinding window-fullscreen () nil
1325 (window window))
1326
1327(defbinding window-unfullscreen () nil
1328 (window window))
1329
1330(defbinding window-set-keep-above () nil
1331 (window window)
1332 (setting boolean))
1333
1334(defbinding window-set-keep-below () nil
1335 (window window)
1336 (setting boolean))
1337
7625ebd8 1338(defbinding window-begin-resize-drag () nil
1339 (window window)
1340 (edge gdk:window-edge)
1341 (button int)
1342 (root-x int) (root-y int)
9adccb27 1343 (timestamp unsigned-int))
7625ebd8 1344
1345(defbinding window-begin-move-drag () nil
1346 (window window)
1347 (edge gdk:window-edge)
1348 (button int)
1349 (root-x int) (root-y int)
9adccb27 1350 (timestamp unsigned-int))
7625ebd8 1351
1352(defbinding window-set-frame-dimensions () nil
1353 (window window)
1354 (left int) (top int) (rigth int) (bottom int))
1355
7625ebd8 1356(defbinding %window-get-default-size () nil
1357 (window window)
1358 (width int :out)
1359 (height int :out))
1360
1361(defun window-get-default-size (window)
1362 (multiple-value-bind (width height) (%window-get-default-size window)
1363 (values (unless (= width -1) width) (unless (= height -1) height))))
1364
1365(defbinding window-get-frame-dimensions () nil
1366 (window window)
1367 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1368
1369(defbinding %window-get-icon-list () (glist gdk:pixbuf)
1370 (window window))
1371
7625ebd8 1372(defbinding window-get-position () nil
1373 (window window)
1374 (root-x int :out)
1375 (root-y int :out))
1376
1377(defbinding window-get-size () nil
1378 (window window)
1379 (width int :out)
1380 (height int :out))
1381
1382(defbinding window-move () nil
1383 (window window)
1384 (x int)
1385 (y int))
1386
1387(defbinding window-parse-geometry () boolean
1388 (window window)
1389 (geometry string))
1390
1391(defbinding window-reshow-with-initial-size () nil
1392 (window window))
1393
1394(defbinding window-resize () nil
1395 (window window)
1396 (width int)
1397 (heigth int))
1398
4d16221f 1399(defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1400 () (glist gdk:pixbuf))
1401
1402(defun window-default-icon ()
1403 (first (window-default-icon-list)))
1404
1405(defbinding %window-set-default-icon-list () nil
1406 (icons (glist gdk:pixbuf)))
1407
1408(defun (setf window-default-icon-list) (icons)
1409 (%window-set-default-icon-list icons)
1410 icons)
1411
1412(defbinding %window-set-default-icon () nil
1413 (icons (glist gdk:pixbuf)))
1414
1415(defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1416 (%window-set-default-icon icon)
1417 icon)
1418
1419(defmethod (setf window-group) ((group window-group) (window window))
1420 (window-group-add-window group window)
1421 group)
1422
1423(defbinding %window-set-default-icon-from-file () boolean
1424 (filename pathname)
1425 (nil null))
1426
1427(defmethod (setf window-default-icon) ((icon-file pathname))
1428 (%window-set-default-icon-from-file icon-file)
1429 icon-file)
1430
1431(defbinding %window-set-icon-from-file () boolean
1432 (window window)
1433 (filename pathname)
1434 (nil null))
1435
1436(defmethod (setf window-icon) ((icon-file pathname) (window window))
1437 (%window-set-icon-from-file window icon-file)
1438 icon-file)
1439
1440(defbinding window-set-auto-startup-notification () nil
1441 (setting boolean))
1442
1443(defbinding decorated-window-init () nil
1444 (window window))
1445
1446(defbinding decorated-window-calculate-frame-size () nil
1447 (window window))
1448
1449(defbinding decorated-window-set-title () nil
7625ebd8 1450 (window window)
4d16221f 1451 (title string))
7625ebd8 1452
4d16221f 1453(defbinding decorated-window-move-resize-window () nil
1454 (window window)
1455 (x int)
1456 (y int)
1457 (width int)
1458 (heigth int))
7625ebd8 1459
1460
4d16221f 1461;;; Window group
560af5c5 1462
4d16221f 1463(defmethod initialize-instance ((window-group window-group) &rest initargs
1464 &key window windows)
1465 (declare (ignore window windows))
1466 (prog1
1467 (call-next-method)
1468 (initial-add window-group #'window-group-add-window
1469 initargs :window :windows)))
560af5c5 1470
560af5c5 1471
4d16221f 1472(defbinding window-group-add-window () nil
1473 (window-group window-group)
1474 (window window))
560af5c5 1475
4d16221f 1476(defbinding window-group-remove-window () nil
1477 (window-group window-group)
1478 (window window))
560af5c5 1479
1480
f36ca6af 1481;;; Scrolled window
560af5c5 1482
560af5c5 1483(defun (setf scrolled-window-scrollbar-policy) (policy window)
1484 (setf (scrolled-window-hscrollbar-policy window) policy)
1485 (setf (scrolled-window-vscrollbar-policy window) policy))
1486
bbaeff4b 1487(defbinding scrolled-window-add-with-viewport () nil
560af5c5 1488 (scrolled-window scrolled-window)
1489 (child widget))
1490
7a2e0799 1491(defmethod shared-initialize ((window scrolled-window) names &key policy)
1492 (declare (ignore names))
1493 (when policy
1494 (setf (slot-value window 'hscrollbar-policy) policy)
1495 (setf (slot-value window 'vscrollbar-policy) policy))
1496 (call-next-method))
d520140e 1497
560af5c5 1498
f36ca6af 1499;;; Statusbar
560af5c5 1500
d76e9fca 1501(defbinding statusbar-get-context-id () unsigned-int
f36ca6af 1502 (statusbar statusbar)
1503 (context-description string))
560af5c5 1504
bbaeff4b 1505(defbinding statusbar-push () unsigned-int
f36ca6af 1506 (statusbar statusbar)
1507 (context-id unsigned-int)
1508 (text string))
560af5c5 1509
bbaeff4b 1510(defbinding statusbar-pop () nil
f36ca6af 1511 (statusbar statusbar)
1512 (context-id unsigned-int))
560af5c5 1513
bbaeff4b 1514(defbinding statusbar-remove () nil
f36ca6af 1515 (statusbar statusbar)
1516 (context-id unsigned-int)
1517 (message-id unsigned-int))
560af5c5 1518
560af5c5 1519
1520
1521;;; Fixed
1522
bbaeff4b 1523(defbinding fixed-put () nil
f36ca6af 1524 (fixed fixed)
1525 (widget widget)
f5b67f2b 1526 (x int) (y int))
560af5c5 1527
bbaeff4b 1528(defbinding fixed-move () nil
f36ca6af 1529 (fixed fixed)
1530 (widget widget)
f5b67f2b 1531 (x int) (y int))
560af5c5 1532
1533
1534
d520140e 1535;;; Notebook
560af5c5 1536
68f519e0 1537(defun %ensure-notebook-position (notebook page)
f5b67f2b 1538 (etypecase page
68f519e0 1539 (position page)
f5b67f2b 1540 (widget (notebook-page-num notebook page t))))
1541
68f519e0 1542(defun %ensure-notebook-child (notebook position)
f5b67f2b 1543 (typecase position
1544 (widget position)
68f519e0 1545 (t (notebook-get-nth-page notebook position))))
f5b67f2b 1546
1547(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
f36ca6af 1548 (notebook position child tab-label &optional menu-label) nil
1549 (notebook notebook)
1550 (child widget)
1551 ((if (stringp tab-label)
f5b67f2b 1552 (make-instance 'label :label tab-label)
f36ca6af 1553 tab-label) widget)
1554 ((if (stringp menu-label)
f5b67f2b 1555 (make-instance 'label :label menu-label)
f36ca6af 1556 menu-label) (or null widget))
68f519e0 1557 ((%ensure-notebook-position notebook position) position))
560af5c5 1558
f5b67f2b 1559(defun notebook-append (notebook child tab-label &optional menu-label)
1560 (notebook-insert notebook :last child tab-label menu-label))
560af5c5 1561
f5b67f2b 1562(defun notebook-prepend (notebook child tab-label &optional menu-label)
1563 (notebook-insert notebook :first child tab-label menu-label))
560af5c5 1564
f5b67f2b 1565(defbinding notebook-remove-page (notebook page) nil
f36ca6af 1566 (notebook notebook)
68f519e0 1567 ((%ensure-notebook-position notebook page) position))
560af5c5 1568
bbaeff4b 1569(defbinding %notebook-page-num () int
f36ca6af 1570 (notebook notebook)
1571 (child widget))
1572
f5b67f2b 1573(defun notebook-page-num (notebook child &optional error-p)
f36ca6af 1574 (let ((page-num (%notebook-page-num notebook child)))
1575 (if (= page-num -1)
f5b67f2b 1576 (when error-p
68f519e0 1577 (error "~A is not a page in ~A" child notebook))
f36ca6af 1578 page-num)))
1579
bbaeff4b 1580(defbinding notebook-next-page () nil
f36ca6af 1581 (notebook notebook))
560af5c5 1582
bbaeff4b 1583(defbinding notebook-prev-page () nil
f36ca6af 1584 (notebook notebook))
1585
f5b67f2b 1586(defbinding notebook-reorder-child (notebook child position) nil
1587 (notebook notebook)
1588 (child widget)
bdc0e300 1589 ((%ensure-notebook-position notebook position) int))
f5b67f2b 1590
bbaeff4b 1591(defbinding notebook-popup-enable () nil
f36ca6af 1592 (notebook notebook))
1593
bbaeff4b 1594(defbinding notebook-popup-disable () nil
f36ca6af 1595 (notebook notebook))
1596
68f519e0 1597(defbinding notebook-get-nth-page () widget
f5b67f2b 1598 (notebook notebook)
68f519e0 1599 (page position))
f5b67f2b 1600
68f519e0 1601(defun %notebook-current-page (notebook)
1602 (when (slot-boundp notebook 'current-page-num)
1603 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
f5b67f2b 1604
1605(defun (setf notebook-current-page) (page notebook)
68f519e0 1606 (setf (notebook-current-page notebook) (notebook-page-num notebook page)))
f5b67f2b 1607
1047e159 1608(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1609 (notebook page) widget
1610 (notebook notebook)
68f519e0 1611 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1612
1047e159 1613(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
6bb23851 1614 (notebook page) (copy-of string)
1047e159 1615 (notebook notebook)
68f519e0 1616 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1617
1047e159 1618(defbinding %notebook-set-tab-label () nil
1619 (notebook notebook)
1620 (page widget)
1621 (tab-label widget))
1622
1623(defun (setf notebook-tab-label) (tab-label notebook page)
1624 (let ((widget (if (stringp tab-label)
1625 (make-instance 'label :label tab-label)
1626 tab-label)))
68f519e0 1627 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1628 widget))
f5b67f2b 1629
f5b67f2b 1630
1047e159 1631(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1632 (notebook page) widget
1633 (notebook notebook)
68f519e0 1634 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1635
1047e159 1636(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
6bb23851 1637 (notebook page) (copy-of string)
1047e159 1638 (notebook notebook)
68f519e0 1639 ((%ensure-notebook-child notebook page) widget))
f5b67f2b 1640
1047e159 1641(defbinding %notebook-set-menu-label () nil
1642 (notebook notebook)
1643 (page widget)
1644 (menu-label widget))
1645
1646(defun (setf notebook-menu-label) (menu-label notebook page)
1647 (let ((widget (if (stringp menu-label)
1648 (make-instance 'label :label menu-label)
1649 menu-label)))
68f519e0 1650 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
1047e159 1651 widget))
f5b67f2b 1652
1653
1654(defbinding notebook-query-tab-label-packing (notebook page) nil
f36ca6af 1655 (notebook notebook)
bdc0e300 1656 ((%ensure-notebook-child notebook page) widget)
f36ca6af 1657 (expand boolean :out)
1658 (fill boolean :out)
1659 (pack-type pack-type :out))
1660
f5b67f2b 1661(defbinding notebook-set-tab-label-packing
1662 (notebook page expand fill pack-type) nil
f36ca6af 1663 (notebook notebook)
bdc0e300 1664 ((%ensure-notebook-child notebook page) widget)
f36ca6af 1665 (expand boolean)
1666 (fill boolean)
1667 (pack-type pack-type))
1668
560af5c5 1669
1670
d520140e 1671;;; Paned
560af5c5 1672
bbaeff4b 1673(defbinding paned-pack1 () nil
d520140e 1674 (paned paned)
1675 (child widget)
1676 (resize boolean)
1677 (shrink boolean))
560af5c5 1678
bbaeff4b 1679(defbinding paned-pack2 () nil
d520140e 1680 (paned paned)
1681 (child widget)
1682 (resize boolean)
1683 (shrink boolean))
560af5c5 1684
560af5c5 1685
d520140e 1686;;; Layout
560af5c5 1687
bbaeff4b 1688(defbinding layout-put () nil
d520140e 1689 (layout layout)
68f519e0 1690 (child widget)
d520140e 1691 (x int)
1692 (y int))
560af5c5 1693
bbaeff4b 1694(defbinding layout-move () nil
d520140e 1695 (layout layout)
68f519e0 1696 (child widget)
d520140e 1697 (x int)
1698 (y int))
560af5c5 1699
68f519e0 1700(defbinding layout-set-size () nil
1701 (layout layout)
1702 (width unsigned-int)
1703 (height unsigned-int))
1704
1705(defbinding layout-get-size () nil
1706 (layout layout)
1707 (width unsigned-int :out)
1708 (height unsigned-int :out))
560af5c5 1709
1710
560af5c5 1711;;; Menu shell
1712
f5b67f2b 1713(defbinding menu-shell-insert (menu-shell menu-item position) nil
f36ca6af 1714 (menu-shell menu-shell)
1715 (menu-item menu-item)
f5b67f2b 1716 ((case position
1717 (:first 0)
1718 (:last -1)
1719 (t position)) int))
560af5c5 1720
f36ca6af 1721(defun menu-shell-append (menu-shell menu-item)
f5b67f2b 1722 (menu-shell-insert menu-shell menu-item :last))
560af5c5 1723
f36ca6af 1724(defun menu-shell-prepend (menu-shell menu-item)
f5b67f2b 1725 (menu-shell-insert menu-shell menu-item :fisrt))
560af5c5 1726
bbaeff4b 1727(defbinding menu-shell-deactivate () nil
f36ca6af 1728 (menu-shell menu-shell))
560af5c5 1729
bbaeff4b 1730(defbinding menu-shell-select-item () nil
f36ca6af 1731 (menu-shell menu-shell)
1732 (menu-item menu-item))
560af5c5 1733
d76e9fca 1734(defbinding menu-shell-select-first () nil
1735 (menu-shell menu-shell)
1736 (search-sensitive boolean))
1737
bbaeff4b 1738(defbinding menu-shell-deselect () nil
f36ca6af 1739 (menu-shell menu-shell))
560af5c5 1740
bbaeff4b 1741(defbinding menu-shell-activate-item () nil
f36ca6af 1742 (menu-shell menu-shell)
1743 (menu-item menu-item)
1744 (fore-deactivate boolean))
560af5c5 1745
d76e9fca 1746(defbinding menu-shell-cancel () nil
1747 (menu-shell menu-shell))
560af5c5 1748
1749
f5b67f2b 1750;;; Menu
560af5c5 1751
f5b67f2b 1752(defun %menu-position (menu child)
1753 (etypecase child
1754 (int child)
1755 (keyword (case child
1756 (:first 0)
1757 (:last -1)
1047e159 1758 (t (error "Invalid position keyword: ~A" child))))
f5b67f2b 1759 (widget (menu-child-position menu child))))
560af5c5 1760
1761
f5b67f2b 1762(defbinding menu-reorder-child (menu menu-item position) nil
1763 (menu menu)
1764 (menu-item menu-item)
1765 ((%menu-position menu position) int))
560af5c5 1766
d76e9fca 1767(defbinding menu-attach () nil
1768 (menu menu)
1769 (menu-item menu-item)
1770 (left-attach unsigned-int)
1771 (right-attach unsigned-int)
1772 (top-attach unsigned-int)
1773 (bottom-attach unsigned-int))
1774
1775(def-callback-marshal %menu-position-func (nil (menu menu) (x int) (y int) (push-in boolean)))
560af5c5 1776
f5b67f2b 1777(defbinding %menu-popup () nil
1778 (menu menu)
1779 (parent-menu-shell (or null menu-shell))
1780 (parent-menu-item (or null menu-item))
1781 (callback-func (or null pointer))
1782 (callback-id unsigned-int)
1783 (button unsigned-int)
1784 (activate-time (unsigned 32)))
1785
1786(defun menu-popup (menu button activate-time &key callback parent-menu-shell
1787 parent-menu-item)
1788 (if callback
1a1949c7 1789 (with-callback-function (id callback)
1790 (%menu-popup
1791 menu parent-menu-shell parent-menu-item
d76e9fca 1792 (callback %menu-position-func) id button activate-time))
f5b67f2b 1793 (%menu-popup
1794 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
1795
1796(defbinding menu-set-accel-path () nil
1797 (menu menu)
1798 (accel-path string))
560af5c5 1799
bbaeff4b 1800(defbinding menu-reposition () nil
f36ca6af 1801 (menu menu))
560af5c5 1802
bbaeff4b 1803(defbinding menu-popdown () nil
f36ca6af 1804 (menu menu))
560af5c5 1805
f5b67f2b 1806(defun menu-child-position (menu child)
1807 (position child (container-children menu)))
1808
1809(defun menu-active-num (menu)
1810 (menu-child-position menu (menu-active menu)))
1811
bbaeff4b 1812(defbinding %menu-set-active () nil
f36ca6af 1813 (menu menu)
1814 (index unsigned-int))
560af5c5 1815
f5b67f2b 1816(defun (setf menu-active) (menu child)
1817 (%menu-set-active menu (%menu-position menu child))
1818 child)
d520140e 1819
d76e9fca 1820(defcallback %menu-detach-func (nil (widget widget) (menu menu))
1821 (funcall (object-data menu 'detach-func) widget menu))
1822
1823(defbinding %menu-attach-to-widget () nil
1824 (menu menu)
1825 (widget widget)
1826 ((callback %menu-detach-func) pointer))
1827
1828(defun menu-attach-to-widget (menu widget function)
1829 (setf (object-data menu 'detach-func) function)
1830 (%menu-attach-to-widget menu widget))
1831
1832(defbinding menu-detach () nil
1833 (menu menu))
1834
1835#+gtk2.6
1836(defbinding menu-get-for-attach-widget () (copy-of (glist widget))
1837 (widget widget))
1838
1839(defbinding menu-set-monitor () nil
1840 (menu menu)
1841 (monitor-num int))
560af5c5 1842
1843
f36ca6af 1844;;; Table
560af5c5 1845
bbaeff4b 1846(defbinding table-resize () nil
f36ca6af 1847 (table table)
1848 (rows unsigned-int)
1849 (columns unsigned-int))
560af5c5 1850
bbaeff4b 1851(defbinding table-attach (table child left right top bottom
c49be931 1852 &key options x-options y-options
1853 (x-padding 0) (y-padding 0)) nil
f36ca6af 1854 (table table)
1855 (child widget)
1856 (left unsigned-int)
1857 (right unsigned-int)
1858 (top unsigned-int)
1859 (bottom unsigned-int)
c49be931 1860 ((append (mklist options) (mklist x-options)) attach-options)
1861 ((append (mklist options) (mklist y-options)) attach-options)
f36ca6af 1862 (x-padding unsigned-int)
1863 (y-padding unsigned-int))
1864
e5b416f0 1865
bbaeff4b 1866(defbinding %table-set-row-spacing () nil
f36ca6af 1867 (table table)
1868 (row unsigned-int)
1869 (spacing unsigned-int))
1870
e5b416f0 1871(defbinding %table-set-row-spacings () nil
1872 (table table)
1873 (spacing unsigned-int))
1874
1875(defun (setf table-row-spacing) (spacing table &optional row)
1876 (if row
1877 (%table-set-row-spacing table row spacing)
1878 (%table-set-row-spacings table spacing))
f36ca6af 1879 spacing)
1880
e5b416f0 1881(defbinding %table-get-row-spacing () unsigned-int
f36ca6af 1882 (table table)
e5b416f0 1883 (row unsigned-int))
1884
1885(defbinding %table-get-default-row-spacing () unsigned-int
1886 (table table))
1887
1888(defun table-row-spacing (table &optional row)
1889 (if row
1890 (%table-get-row-spacing table row)
1891 (%table-get-default-row-spacing table)))
1892
f36ca6af 1893
bbaeff4b 1894(defbinding %table-set-col-spacing () nil
f36ca6af 1895 (table table)
1896 (col unsigned-int)
1897 (spacing unsigned-int))
1898
e5b416f0 1899(defbinding %table-set-col-spacings () nil
1900 (table table)
1901 (spacing unsigned-int))
1902
1903(defun (setf table-col-spacing) (spacing table &optional col)
1904 (if col
1905 (%table-set-col-spacing table col spacing)
1906 (%table-set-col-spacings table spacing))
f36ca6af 1907 spacing)
1908
e5b416f0 1909(defbinding %table-get-col-spacing () unsigned-int
f36ca6af 1910 (table table)
e5b416f0 1911 (col unsigned-int))
1912
1913(defbinding %table-get-default-col-spacing () unsigned-int
1914 (table table))
1915
1916(defun table-col-spacing (table &optional col)
1917 (if col
1918 (%table-get-col-spacing table col)
1919 (%table-get-default-col-spacing table)))
1920
1921
f36ca6af 1922
1923;;; Toolbar
1924
cb4bf772 1925(defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
1926 (if (eq tooltips t)
1927 (apply #'call-next-method toolbar
1928 :tooltips (make-instance 'tooltips) initargs)
1929 (call-next-method)))
560af5c5 1930
cb4bf772 1931(defbinding %toolbar-insert () nil
f5b67f2b 1932 (toolbar toolbar)
cb4bf772 1933 (tool-item tool-item)
1934 (position position))
f36ca6af 1935
cb4bf772 1936(defun toolbar-insert (toolbar tool-item &optional (position :end))
1937 (%toolbar-insert toolbar tool-item position)
1938 (%tool-item-update-tooltips tool-item))
f5b67f2b 1939
cb4bf772 1940(defbinding toolbar-get-item-index () int
1941 (toolbar toolbar)
1942 (item tool-item))
f36ca6af 1943
cb4bf772 1944(defbinding toolbar-get-nth-item () tool-item
1945 (toolbar toolbar)
1946 (n int))
f36ca6af 1947
cb4bf772 1948(defbinding toolbar-get-drop-index () int
1949 (toolbar toolbar)
1950 (x int) (y int))
f36ca6af 1951
cb4bf772 1952(defbinding toolbar-set-drop-highlight-item () nil
1953 (toolbar toolbar)
1954 (tool-item tool-item)
1955 (index int))
f36ca6af 1956
560af5c5 1957
cb4bf772 1958;;; Tool button
560af5c5 1959
cb4bf772 1960(defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
1961 (if (and icon (not (typep icon 'widget)))
1962 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
1963 (call-next-method)))
560af5c5 1964
1965
cb4bf772 1966;;; Tool item
560af5c5 1967
cb4bf772 1968(defbinding tool-item-set-tooltip () nil
1969 (tool-item tool-item)
1970 (tooltips tooltips)
1971 (tip-text string)
1972 (tip-private string))
560af5c5 1973
560af5c5 1974
cb4bf772 1975(defun %tool-item-update-tooltips (tool-item)
1976 (when (and
1977 (slot-boundp tool-item 'parent)
1978 (or
1979 (user-data-p tool-item 'tip-text)
1980 (user-data-p tool-item 'tip-private)))
1981 (tool-item-set-tooltip
1982 tool-item (toolbar-tooltips (widget-parent tool-item))
1983 (or (user-data tool-item 'tip-text) "")
1984 (or (user-data tool-item 'tip-private) ""))))
1985
1986(defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
1987 (setf (user-data tool-item 'tip-text) tip-text)
1988 (%tool-item-update-tooltips tool-item)
1989 tip-text)
1990
1991(defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
1992 (setf (user-data tool-item 'tip-private) tip-private)
1993 (%tool-item-update-tooltips tool-item)
1994 tip-private)
1995
1996(defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
1997 (declare (ignore args))
1998 (prog1
1999 (call-next-method)
2000 (%tool-item-update-tooltips tool-item)))
560af5c5 2001
d76e9fca 2002
2003(defbinding tool-item-retrieve-proxy-menu-item () widget
2004 (tool-item tool-item))
2005
2006(defbinding (tool-item-proxy-menu-item
2007 "gtk_tool_item_get_proxy_menu_item") () menu-item
2008 (tool-item tool-item)
2009 (menu-item-id string))
2010
2011(defbinding %tool-item-set-proxy-menu-item () nil
2012 (tool-item tool-item)
2013 (menu-item-id string)
2014 (menu-item menu-item))
2015
2016(defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2017 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2018 menu-item)
2019
2020#+gtk2.6
2021(defbinding tool-item-rebuild-menu () nil
2022 (tool-item tool-item))
2023
2024
bbaeff4b 2025;;; Editable
1047e159 2026
bbaeff4b 2027(defbinding editable-select-region (editable &optional (start 0) end) nil
f36ca6af 2028 (editable editable)
2029 (start int)
2030 ((or end -1) int))
560af5c5 2031
1047e159 2032(defbinding editable-get-selection-bounds (editable) nil
2033 (editable editable)
2034 (start int :out)
2035 (end int :out))
2036
d76e9fca 2037(defbinding editable-insert-text (editable text &optional (position 0)) nil
f36ca6af 2038 (editable editable)
2039 (text string)
2040 ((length text) int)
34fe0ead 2041 (position position :in-out))
560af5c5 2042
f36ca6af 2043(defun editable-append-text (editable text)
2044 (editable-insert-text editable text nil))
560af5c5 2045
f36ca6af 2046(defun editable-prepend-text (editable text)
2047 (editable-insert-text editable text 0))
560af5c5 2048
bbaeff4b 2049(defbinding editable-delete-text (editable &optional (start 0) end) nil
f36ca6af 2050 (editable editable)
2051 (start int)
2052 ((or end -1) int))
560af5c5 2053
bbaeff4b 2054(defbinding (editable-text "gtk_editable_get_chars")
f36ca6af 2055 (editable &optional (start 0) end) string
2056 (editable editable)
2057 (start int)
2058 ((or end -1) int))
560af5c5 2059
f36ca6af 2060(defun (setf editable-text) (text editable)
2061 (if text
2062 (editable-delete-text
2063 editable
2064 (editable-insert-text editable text))
2065 (editable-delete-text editable))
2066 text)
560af5c5 2067
bbaeff4b 2068(defbinding editable-cut-clipboard () nil
f36ca6af 2069 (editable editable))
560af5c5 2070
bbaeff4b 2071(defbinding editable-copy-clipboard () nil
f36ca6af 2072 (editable editable))
560af5c5 2073
bbaeff4b 2074(defbinding editable-paste-clipboard () nil
f36ca6af 2075 (editable editable))
560af5c5 2076
bbaeff4b 2077(defbinding editable-delete-selection () nil
f36ca6af 2078 (editable editable))
560af5c5 2079
560af5c5 2080
560af5c5 2081
f36ca6af 2082;;; Spin button
560af5c5 2083
d76e9fca 2084(defbinding spin-button-configure () nil
2085 (spin-button spin-button)
2086 (adjustment adjustment)
2087 (climb-rate double-float)
2088 (digits unsigned-int))
2089
2090(defbinding spin-button-set-range () nil
2091 (spin-button spin-button)
2092 (min double-float)
2093 (max double-float))
2094
2095(defbinding spin-button-get-range () nil
2096 (spin-button spin-button)
2097 (min double-float :out)
2098 (max double-float :out))
2099
f36ca6af 2100(defun spin-button-value-as-int (spin-button)
2101 (round (spin-button-value spin-button)))
560af5c5 2102
510fbcc1 2103(defbinding %spin-button-spin () nil
f36ca6af 2104 (spin-button spin-button)
2105 (direction spin-type)
510fbcc1 2106 (increment double-float))
2107
2108(defun spin-button-spin (spin-button value)
2109 (etypecase value
2110 (real (%spin-button-spin spin-button :spin-user-defined value))
2111 (spin-type (%spin-button-spin spin-button value 0))))
2112
560af5c5 2113
bbaeff4b 2114(defbinding spin-button-update () nil
f36ca6af 2115 (spin-button spin-button))
560af5c5 2116
2117
2118
2119; ;;; Ruler
2120
bbaeff4b 2121(defbinding ruler-set-range () nil
f36ca6af 2122 (ruler ruler)
2123 (lower single-float)
2124 (upper single-float)
2125 (position single-float)
2126 (max-size single-float))
560af5c5 2127
68f519e0 2128(defbinding ruler-get-range () nil
2129 (ruler ruler)
2130 (lower single-float :out)
2131 (upper single-float :out)
2132 (position single-float :out)
2133 (max-size single-float :out))
560af5c5 2134
560af5c5 2135
560af5c5 2136
d520140e 2137;;; Range
560af5c5 2138
1047e159 2139(defun range-lower (range)
2140 (adjustment-lower (range-adjustment range)))
560af5c5 2141
1047e159 2142(defun range-upper (range)
2143 (adjustment-upper (range-adjustment range)))
560af5c5 2144
1047e159 2145(defun (setf range-lower) (value range)
2146 (setf (adjustment-lower (range-adjustment range)) value))
560af5c5 2147
1047e159 2148(defun (setf range-upper) (value range)
2149 (setf (adjustment-upper (range-adjustment range)) value))
560af5c5 2150
1047e159 2151(defun range-page-increment (range)
2152 (adjustment-page-increment (range-adjustment range)))
560af5c5 2153
1047e159 2154(defun range-step-increment (range)
2155 (adjustment-step-increment (range-adjustment range)))
560af5c5 2156
1047e159 2157(defun (setf range-page-increment) (value range)
2158 (setf (adjustment-page-increment (range-adjustment range)) value))
560af5c5 2159
1047e159 2160(defun (setf range-step-increment) (value range)
2161 (setf (adjustment-step-increment (range-adjustment range)) value))
560af5c5 2162
1047e159 2163(defbinding range-set-range () nil
d520140e 2164 (range range)
1047e159 2165 (lower double-float)
2166 (upper double-float))
560af5c5 2167
1047e159 2168(defbinding range-set-increments () nil
d520140e 2169 (range range)
1047e159 2170 (step double-float)
2171 (page double-float))
560af5c5 2172
560af5c5 2173
d520140e 2174;;; Scale
560af5c5 2175
68f519e0 2176(defbinding scale-get-layout-offsets () nil
2177 (scale scale)
2178 (x int :out)
2179 (y int :out))
560af5c5 2180
560af5c5 2181
d520140e 2182;;; Progress bar
560af5c5 2183
bbaeff4b 2184(defbinding progress-bar-pulse () nil
d520140e 2185 (progress-bar progress-bar))
560af5c5 2186
2187
c49be931 2188;;; Size group
2189
2190(defmethod initialize-instance ((size-group size-group) &rest initargs
2191 &key widget widgets)
2192 (declare (ignore widget widgets))
2193 (prog1
2194 (call-next-method)
2195 (initial-add size-group #'size-group-add-widget
2196 initargs :widget :widgets)))
2197
2198
2199(defbinding size-group-add-widget () nil
2200 (size-group size-group)
2201 (widget widget))
2202
2203(defbinding size-group-remove-widget () nil
2204 (size-group size-group)
2205 (widget widget))
2206
560af5c5 2207
f5b67f2b 2208;;; Stock items
2209
73d58e01 2210(defbinding %stock-item-copy () pointer
2211 (location pointer))
2212
2213(defbinding %stock-item-free () nil
2214 (location pointer))
f5b67f2b 2215
73d58e01 2216(defmethod reference-foreign ((class (eql (find-class 'stock-item))) location)
2217 (%stock-item-copy location))
2218
2219(defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location)
2220 (%stock-item-free location))
2221
2222(defbinding stock-add (stock-item) nil
2223 (stock-item stock-item)
2224 (1 unsigned-int))
2225
2226(defbinding stock-list-ids () (gslist string))
2227
2228(defbinding %stock-lookup () boolean
2229 (stock-id string)
2230 (location pointer))
2231
2232(defun stock-lookup (stock-id)
2233 (let ((location
2234 (allocate-memory (proxy-instance-size (find-class 'stock-item)))))
2235 (unwind-protect
2236 (when (%stock-lookup stock-id location)
2237 (ensure-proxy-instance 'stock-item (%stock-item-copy location)))
2238 (deallocate-memory location))))
560af5c5 2239
2240
2241;;; Tooltips
2242
bbaeff4b 2243(defbinding tooltips-enable () nil
d520140e 2244 (tooltips tooltips))
560af5c5 2245
bbaeff4b 2246(defbinding tooltips-disable () nil
d520140e 2247 (tooltips tooltips))
560af5c5 2248
e5b416f0 2249(defun (setf tooltips-enabled-p) (enable tooltips)
2250 (if enable
2251 (tooltips-enable tooltips)
2252 (tooltips-disable tooltips)))
2253
bbaeff4b 2254(defbinding tooltips-set-tip () nil
d520140e 2255 (tooltips tooltips)
2256 (widget widget)
2257 (tip-text string)
2258 (tip-private string))
560af5c5 2259
d76e9fca 2260(defbinding tooltips-data-get () tooltips-data
2261 (widget widget))
2262
bbaeff4b 2263(defbinding tooltips-force-window () nil
d520140e 2264 (tooltips tooltips))
560af5c5 2265
d76e9fca 2266(defbinding tooltips-get-info-from-tip-window () boolean
2267 (tip-window window)
2268 (tooltips tooltips :out)
2269 (current-widget widget :out))
560af5c5 2270
2271
c1c0746b 2272;;; Resource Files
560af5c5 2273
bbaeff4b 2274(defbinding rc-add-default-file (filename) nil
d520140e 2275 ((namestring (truename filename)) string))
560af5c5 2276
bbaeff4b 2277(defbinding rc-parse (filename) nil
d520140e 2278 ((namestring (truename filename)) string))
560af5c5 2279
bbaeff4b 2280(defbinding rc-parse-string () nil
d520140e 2281 (rc-string string))
560af5c5 2282
bbaeff4b 2283(defbinding rc-reparse-all () nil)
560af5c5 2284
bbaeff4b 2285(defbinding rc-get-style () style
d520140e 2286 (widget widget))