Added ALLOCATE-FOREIGN method
[clg] / gtk / gtk.lisp
CommitLineData
55212af1 1;; Common Lisp bindings for GTK+ v2.x
2;; Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net>
0d07716f 3;;
55212af1 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:
0d07716f 11;;
55212af1 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
0d07716f 14;;
55212af1 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.
0d07716f 22
39db92d4 23;; $Id: gtk.lisp,v 1.52 2006/02/09 22:32:47 espen Exp $
0d07716f 24
25
26(in-package "GTK")
27
28;;; Gtk version
29
84967144 30(defbinding check-version () (copy-of string)
0d07716f 31 (required-major unsigned-int)
32 (required-minor unsigned-int)
33 (required-micro unsigned-int))
34
a60bd055 35(defbinding query-version () nil
0d07716f 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
e69138cc 47(defun clg-version ()
2cd56180 48 "clg 0.91 version")
0d07716f 49
50
6baf860c 51;;;; Initalization
52
30628c63 53(defbinding (gtk-init "gtk_parse_args") () boolean
6baf860c 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)
30628c63 62 (unless (gtk-init)
63 (error "Initialization of GTK+ failed."))
6baf860c 64 (prog1
65 (gdk:display-open display)
3d36c5d6 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))))
6baf860c 70
71
17707159 72;;; Misc
73
74(defbinding grab-add () nil
75 (widget widget))
76
3a476d4e 77(defbinding grab-get-current () widget)
17707159 78
79(defbinding grab-remove () nil
80 (widget widget))
81
e69138cc 82(defbinding get-default-language () (copy-of pango:language))
83
17707159 84
1448a84f 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
d404b3af 103;;; Acccel group
0d07716f 104
213cf4d0 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)
7b6c693b 113 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 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
7b6c693b 136 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 137 (%accel-group-disconnect-key group key modifiers)))))
138
7b6c693b 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
213cf4d0 159(defbinding accel-group-lock () nil
160 (accel-group accel-group))
161
162(defbinding accel-group-unlock () nil
163 (accel-group accel-group))
164
7b6c693b 165(defbinding accel-group-from-accel-closure () accel-group
166 (closure gclosure))
167
213cf4d0 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)
7b6c693b 174 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 175 (%accel-groups-activate object key modifiers)))
176
177(defbinding accel-groups-from-object () (gslist accel-groups)
178 (object gobject))
179
3d36c5d6 180(defbinding accelerator-valid-p (key &optional modifiers) boolean
213cf4d0 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
7b6c693b 189(defgeneric parse-accelerator (accelerator))
190
191(defmethod parse-accelerator ((accelerator string))
213cf4d0 192 (multiple-value-bind (key modifiers) (%accelerator-parse accelerator)
193 (if (zerop key)
194 (error "Invalid accelerator: ~A" accelerator)
195 (values key modifiers))))
196
7b6c693b 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
213cf4d0 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)
0d07716f 234
eb4f580c 235
0d07716f 236;;; Acccel label
237
7b6c693b 238(defbinding accel-label-get-accel-width () unsigned-int
239 (accel-label accel-label))
240
a60bd055 241(defbinding accel-label-refetch () boolean
0d07716f 242 (accel-label accel-label))
243
244
213cf4d0 245
246;;; Accel map
247
7b6c693b 248(defbinding (accel-map-init "_gtk_accel_map_init") () nil)
30628c63 249
213cf4d0 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)
7b6c693b 256 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 257 (%accel-map-add-entry path key modifiers)))
258
7b6c693b 259(defbinding %accel-map-lookup-entry () boolean
213cf4d0 260 (path string)
7b6c693b 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)))))
213cf4d0 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)
7b6c693b 278 (multiple-value-bind (key modifiers) (parse-accelerator accelerator)
213cf4d0 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
7b6c693b 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
213cf4d0 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
7b6c693b 320;;; Accessibility
14eaa563 321
322(defbinding accessible-connect-widget-destroyed () nil
323 (accessible accessible))
324
325
d404b3af 326;;; Adjustment
0d07716f 327
14eaa563 328(defmethod initialize-instance ((adjustment adjustment) &key value)
eb4f580c 329 (prog1
330 (call-next-method)
331 ;; we need to make sure that the value is set last, otherwise it
14eaa563 332 ;; may be outside current limits and ignored
eb4f580c 333 (when value
334 (setf (slot-value adjustment 'value) value))))
335
336
d404b3af 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))
0d07716f 347
d404b3af 348
49043b9a 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
d404b3af 373;;; Aspect frame
374
375
376;;; Bin
0d07716f 377
378(defun (setf bin-child) (child bin)
d404b3af 379 (when-bind (current-child (bin-child bin))
380 (container-remove bin current-child))
0d07716f 381 (container-add bin child)
382 child)
383
d79b3413 384(defmethod compute-signal-function ((bin bin) signal function object)
385 (declare (ignore signal))
386 (if (eq object :child)
9617dc95 387 #'(lambda (&rest args)
388 (apply function (bin-child bin) (rest args)))
389 (call-next-method)))
d404b3af 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
14eaa563 408(defun box-pack (box child &key end (expand t) (fill t) (padding 0))
4886872c 409 (if end
378b3c5f 410 (box-pack-end box child expand fill padding)
411 (box-pack-start box child expand fill padding)))
d404b3af 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
0d07716f 436;;; Button
437
14eaa563 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
a60bd055 444(defbinding button-pressed () nil
0d07716f 445 (button button))
446
d404b3af 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
14eaa563 483(defbinding calendar-get-date () nil
d404b3af 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
d404b3af 496;;; Check menu item
497
498(defbinding check-menu-item-toggled () nil
499 (check-menu-item check-menu-item))
500
501
d404b3af 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
4886872c 514;;;; Combo Box
d404b3af 515
14eaa563 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
4886872c 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))
d404b3af 557
4886872c 558(defbinding combo-box-popup () nil
559 (combo-box combo-box))
d404b3af 560
4886872c 561(defbinding combo-box-popdown () nil
562 (combo-box combo-box))
563
564
565
566;;;; Combo Box Entry
567
14eaa563 568(defmethod initialize-instance ((combo-box-entry combo-box-entry) &key model)
4886872c 569 (call-next-method)
570 (unless model
571 (setf (combo-box-entry-text-column combo-box-entry) 0)))
d404b3af 572
573
0ebef6c1 574;;;; Dialog
d404b3af 575
362f1795 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)))
0ebef6c1 582
d404b3af 583
d79b3413 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
eb4f580c 592 (cond
d79b3413 593 (responses
594 (vector-push-extend response responses)
595 (1- (length responses)))
eb4f580c 596 (t
597 (setf
d79b3413 598 (object-data dialog 'responses)
599 (make-array 1 :adjustable t :fill-pointer t
600 :initial-element response))
eb4f580c 601 0)))
602 (error-p
d79b3413 603 (error "Invalid response: ~A" response))))))
d404b3af 604
d79b3413 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)))
d404b3af 626
0ebef6c1 627(defbinding dialog-run () nil
628 (dialog dialog))
d404b3af 629
d79b3413 630(defbinding dialog-response (dialog response) nil
d404b3af 631 (dialog dialog)
d79b3413 632 ((dialog-response-id dialog response nil t) int))
d404b3af 633
634
635(defbinding %dialog-add-button () button
636 (dialog dialog)
637 (text string)
d79b3413 638 (response-id int))
d404b3af 639
eb4f580c 640(defun dialog-add-button (dialog label &optional (response label)
641 &key default object after)
fe67c0ec 642 "Adds a button to the dialog."
d79b3413 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)))
eb4f580c 648 (when (functionp response)
d79b3413 649 (signal-connect dialog signal response :object object :after after))
eb4f580c 650 (when default
d79b3413 651 (%dialog-set-default-response dialog id))
d404b3af 652 button))
653
654
d79b3413 655(defbinding %dialog-add-action-widget () nil
d404b3af 656 (dialog dialog)
657 (action-widget widget)
d79b3413 658 (response-id int))
d404b3af 659
eb4f580c 660(defun dialog-add-action-widget (dialog widget &optional (response widget)
661 &key default object after)
d79b3413 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)
eb4f580c 669 (when (functionp response)
d79b3413 670 (signal-connect dialog signal response :object object :after after))
eb4f580c 671 (when default
d79b3413 672 (%dialog-set-default-response dialog id))
d404b3af 673 widget))
d404b3af 674
d404b3af 675
0ebef6c1 676(defbinding %dialog-set-default-response () nil
677 (dialog dialog)
d79b3413 678 (response-id int))
d404b3af 679
d79b3413 680(defun dialog-set-default-response (dialog response)
0ebef6c1 681 (%dialog-set-default-response
d79b3413 682 dialog (dialog-response-id dialog response nil t)))
d404b3af 683
d79b3413 684(defbinding dialog-set-response-sensitive (dialog response sensitive) nil
0ebef6c1 685 (dialog dialog)
d79b3413 686 ((dialog-response-id dialog response nil t) int)
0ebef6c1 687 (sensitive boolean))
d404b3af 688
fe67c0ec 689#+gtk2.6
1448a84f 690(defbinding alternative-dialog-button-order-p (&optional screen) boolean
691 (screen (or null gdk:screen)))
fe67c0ec 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)
d79b3413 699 ((map 'vector #'(lambda (response)
700 (dialog-response-id dialog response nil t))
fe67c0ec 701 new-order) (vector int)))
d404b3af 702
0ebef6c1 703
92ba85d4 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
0ebef6c1 714(defmethod container-add ((dialog dialog) (child widget) &rest args)
eb4f580c 715 (apply #'container-add (dialog-vbox dialog) child args))
0ebef6c1 716
d79b3413 717
0ebef6c1 718(defmethod container-remove ((dialog dialog) (child widget))
eb4f580c 719 (container-remove (dialog-vbox dialog) child))
d404b3af 720
0ebef6c1 721(defmethod container-children ((dialog dialog))
eb4f580c 722 (container-children (dialog-vbox dialog)))
0ebef6c1 723
724(defmethod (setf container-children) (children (dialog dialog))
eb4f580c 725 (setf (container-children (dialog-vbox dialog)) children))
0d07716f 726
0d07716f 727
c2c4a7e9 728;;; Entry
0d07716f 729
c2c4a7e9 730(defbinding entry-get-layout-offsets () nil
731 (entry entry)
732 (x int :out)
733 (y int :out))
0d07716f 734
14eaa563 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
0d07716f 743
a03a718a 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)
3d36c5d6 753 ((callback user-data-destroy-func) pointer))
a03a718a 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
49043b9a 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
1448a84f 888 (filter file-filter))
49043b9a 889
890(def-callback-marshal %file-filter-func (boolean file-filter-info))
891
3d36c5d6 892(defbinding file-filter-add-custom (filter needed function) nil
49043b9a 893 (filter file-filter)
894 (needed file-filter-flags)
895 ((callback %file-filter-func) pointer)
896 ((register-callback-function function) unsigned-int)
3d36c5d6 897 ((callback user-data-destroy-func) pointer))
49043b9a 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
eb4f580c 908;;; Image
909
910(defbinding image-set-from-file () nil
911 (image image)
912 (filename pathname))
913
14eaa563 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))))
eb4f580c 929
9617dc95 930(defun create-image-widget (source &optional mask)
14eaa563 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))))
eb4f580c 937
92ba85d4 938#+gtk2.8
939(defbinding image-clear () nil
940 (image image))
941
942
eb4f580c 943
14eaa563 944;;; Image menu item
eb4f580c 945
14eaa563 946(defmethod initialize-instance ((item image-menu-item) &rest initargs &key image)
947 (if (and image (not (typep image 'widget)))
9617dc95 948 (apply #'call-next-method item :image (create-image-widget image) initargs)
14eaa563 949 (call-next-method)))
eb4f580c 950
14eaa563 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))
9617dc95 956 (setf (image-menu-item-image item) (create-image-widget image)))
eb4f580c 957
0d07716f 958
d404b3af 959;;; Label
0d07716f 960
29aa1cc3 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
c2c4a7e9 967(defbinding label-get-layout-offsets () nil
eb4f580c 968 (label label)
c2c4a7e9 969 (x int :out)
970 (y int :out))
971
d404b3af 972(defbinding label-select-region () nil
973 (label label)
974 (start int)
975 (end int))
0d07716f 976
eb4f580c 977(defbinding label-get-selection-bounds () boolean
c2c4a7e9 978 (label label)
979 (start int :out)
980 (end int :out))
30481825 981
0d07716f 982
983
984;;; Radio button
985
dd392521 986(defbinding %radio-button-get-group () pointer
2afcd8bd 987 (radio-button radio-button))
988
a60bd055 989(defbinding %radio-button-set-group () nil
2afcd8bd 990 (radio-button radio-button)
991 (group pointer))
0d07716f 992
9617dc95 993(defmethod add-to-radio-group ((button1 radio-button) (button2 radio-button))
2afcd8bd 994 "Add BUTTON1 to the group which BUTTON2 belongs to."
995 (%radio-button-set-group button1 (%radio-button-get-group button2)))
996
30628c63 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
14eaa563 1016(defmethod initialize-instance ((button radio-button) &key group)
1017 (prog1
1018 (call-next-method)
1019 (when group
9617dc95 1020 (add-to-radio-group button group))))
0d07716f 1021
1022
0d07716f 1023;;; Item
1024
a60bd055 1025(defbinding item-select () nil
0d07716f 1026 (item item))
1027
a60bd055 1028(defbinding item-deselect () nil
0d07716f 1029 (item item))
1030
a60bd055 1031(defbinding item-toggle () nil
0d07716f 1032 (item item))
1033
1034
1035
1036;;; Menu item
1037
14eaa563 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
30481825 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
14eaa563 1048 :use-underline (menu-item-use-underline-p menu-item)
1049 :visible t :parent menu-item)
30481825 1050 label)
0d07716f 1051
378b3c5f 1052(defun menu-item-label (menu-item)
14eaa563 1053 (when (and (slot-boundp menu-item 'child)
1054 (typep (bin-child menu-item) 'label))
1055 (label-label (bin-child menu-item))))
378b3c5f 1056
14eaa563 1057(defbinding menu-item-remove-submenu () nil
30481825 1058 (menu-item menu-item))
0d07716f 1059
378b3c5f 1060(defbinding menu-item-set-accel-path () nil
1061 (menu-item menu-item)
1062 (accel-path string))
1063
a60bd055 1064(defbinding menu-item-select () nil
30481825 1065 (menu-item menu-item))
0d07716f 1066
a60bd055 1067(defbinding menu-item-deselect () nil
30481825 1068 (menu-item menu-item))
0d07716f 1069
a60bd055 1070(defbinding menu-item-activate () nil
30481825 1071 (menu-item menu-item))
0d07716f 1072
378b3c5f 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
0d07716f 1081
14eaa563 1082;;; Menu tool button
1083
1084#+gtk2.6
1448a84f 1085(defbinding menu-tool-button-set-arrow-tooltip () nil
14eaa563 1086 (menu-tool-button menu-tool-button)
1087 (tooltips tooltips)
1088 (tip-text string)
1089 (tip-private string))
1090
1091
30e8a60a 1092;;; Message dialog
1093
39db92d4 1094(defmethod allocate-foreign ((dialog message-dialog) &key (message-type :info)
1095 (buttons :close) flags transient-parent)
1096 (%message-dialog-new transient-parent flags message-type buttons))
1097
1098
1099(defmethod shared-initialize ((dialog message-dialog) names
1100 &key text #+gtk 2.6 secondary-text)
1101 (declare (ignore names))
4c308d58 1102 (when text
1103 (message-dialog-set-markup dialog text))
1104 #+gtk2.6
1105 (when secondary-text
1106 (message-dialog-format-secondary-markup dialog secondary-text))
1107 (call-next-method))
30e8a60a 1108
1109
1110(defbinding %message-dialog-new () pointer
1111 (parent (or null window))
1112 (flags dialog-flags)
1113 (type message-type)
1114 (buttons buttons-type)
4c308d58 1115 (nil null))
30e8a60a 1116
1117(defbinding message-dialog-set-markup () nil
1118 (message-dialog message-dialog)
1119 (markup string))
1120
1121#+gtk2.6
1122(defbinding message-dialog-format-secondary-text () nil
1123 (message-dialog message-dialog)
1124 (text string))
1125
1126#+gtk2.6
1127(defbinding message-dialog-format-secondary-markup () nil
1128 (message-dialog message-dialog)
1129 (markup string))
1130
1131
0d07716f 1132
30481825 1133;;; Radio menu item
0d07716f 1134
dd392521 1135(defbinding %radio-menu-item-get-group () pointer
2afcd8bd 1136 (radio-menu-item radio-menu-item))
1137
a60bd055 1138(defbinding %radio-menu-item-set-group () nil
2afcd8bd 1139 (radio-menu-item radio-menu-item)
1140 (group pointer))
1141
30628c63 1142(defmethod activate-radio-widget ((item radio-menu-item))
1143 (menu-item-activate item))
1144
9617dc95 1145(defmethod add-to-radio-group ((item1 radio-menu-item) (item2 radio-menu-item))
2afcd8bd 1146 "Add ITEM1 to the group which ITEM2 belongs to."
1147 (%radio-menu-item-set-group item1 (%radio-menu-item-get-group item2)))
1148
30628c63 1149(defmethod add-activate-callback ((item radio-menu-item) function &key object after)
1150 (%add-activate-callback item 'activate function object after))
1151
14eaa563 1152(defmethod initialize-instance ((item radio-menu-item) &key group)
378b3c5f 1153 (prog1
1154 (call-next-method)
14eaa563 1155 (when group
9617dc95 1156 (add-to-radio-group item group))))
1157
2afcd8bd 1158
0d07716f 1159
14eaa563 1160;;; Radio tool button
1161
1162(defbinding %radio-tool-button-get-group () pointer
1163 (radio-tool-button radio-tool-button))
1164
1165(defbinding %radio-tool-button-set-group () nil
1166 (radio-tool-button radio-tool-button)
1167 (group pointer))
1168
30628c63 1169(defmethod activate-radio-widget ((button radio-tool-button))
1170 (signal-emit button 'clicked))
1171
9617dc95 1172(defmethod add-to-radio-group ((button1 radio-tool-button) (button2 radio-tool-button))
14eaa563 1173 "Add BUTTON1 to the group which BUTTON2 belongs to."
1174 (%radio-tool-button-set-group button1 (%radio-tool-button-get-group button2)))
30628c63 1175(defmethod add-activate-callback ((button radio-tool-button) function &key object after)
1176 (%add-activate-callback button 'clicked function object after))
14eaa563 1177
1178(defmethod initialize-instance ((button radio-tool-button) &key group)
1179 (prog1
1180 (call-next-method)
1181 (when group
9617dc95 1182 (add-to-radio-group button group))))
1183
14eaa563 1184
0d07716f 1185
c2c4a7e9 1186;;; Toggle button
1187
1188(defbinding toggle-button-toggled () nil
1189 (toggle-button toggle-button))
1190
1191
0d07716f 1192;;; Window
1193
362f1795 1194(defmethod initialize-instance ((window window) &rest initargs
1195 &key accel-group accel-groups)
1196 (declare (ignore accel-group accel-groups))
1197 (prog1
1198 (call-next-method)
1199 (initial-add window #'window-add-accel-group
1200 initargs :accel-group :accel-groups)))
99821988 1201
1202
304cfb76 1203(defbinding window-set-wmclass () nil
0d07716f 1204 (window window)
1205 (wmclass-name string)
1206 (wmclass-class string))
1207
a60bd055 1208(defbinding window-add-accel-group () nil
0d07716f 1209 (window window)
1210 (accel-group accel-group))
1211
a60bd055 1212(defbinding window-remove-accel-group () nil
0d07716f 1213 (window window)
1214 (accel-group accel-group))
1215
a60bd055 1216(defbinding window-activate-focus () int
0d07716f 1217 (window window))
1218
a60bd055 1219(defbinding window-activate-default () int
0d07716f 1220 (window window))
1221
304cfb76 1222(defbinding window-set-default-size (window width height) int
0d07716f 1223 (window window)
304cfb76 1224 ((or width -1) int)
1225 ((or height -1) int))
0d07716f 1226
4eed43f1 1227(defbinding %window-set-geometry-hints () nil
1228 (window window)
1229 (geometry gdk:geometry)
1230 (geometry-mask gdk:window-hints))
1231
1232(defun window-set-geometry-hints (window &key min-width min-height
1233 max-width max-height base-width base-height
1234 width-inc height-inc min-aspect max-aspect
1235 (gravity nil gravity-p) min-size max-size)
1236 (let ((geometry (make-instance 'gdk:geometry
1237 :min-width (or min-width -1)
1238 :min-height (or min-height -1)
1239 :max-width (or max-width -1)
1240 :max-height (or max-height -1)
1241 :base-width (or base-width 0)
1242 :base-height (or base-height 0)
1243 :width-inc (or width-inc 0)
1244 :height-inc (or height-inc 0)
1245 :min-aspect (or min-aspect 0)
1246 :max-aspect (or max-aspect 0)
1247 :gravity gravity))
1248 (mask ()))
1249 (when (or min-size min-width min-height)
1250 (push :min-size mask))
1251 (when (or max-size max-width max-height)
1252 (push :max-size mask))
1253 (when (or base-width base-height)
1254 (push :base-size mask))
1255 (when (or width-inc height-inc)
1256 (push :resize-inc mask))
1257 (when (or min-aspect max-aspect)
1258 (push :aspect mask))
1259 (when gravity-p
1260 (push :win-gravity mask))
1261 (%window-set-geometry-hints window geometry mask)))
0d07716f 1262
99821988 1263(defbinding window-list-toplevels () (glist (copy-of window))
1264 "Returns a list of all existing toplevel windows.")
304cfb76 1265
1266(defbinding window-add-mnemonic (window key target) nil
1267 (window window)
1268 ((gdk:keyval-from-name key) unsigned-int)
1269 (target widget))
1270
1271(defbinding window-remove-mnemonic (window key target) nil
1272 (window window)
1273 ((gdk:keyval-from-name key) unsigned-int)
1274 (target widget))
1275
1276(defbinding window-mnemonic-activate (window key modifier) nil
1277 (window window)
1278 ((gdk:keyval-from-name key) unsigned-int)
1279 (modifier gdk:modifier-type))
1280
4eed43f1 1281(defbinding window-activate-key () boolean
1282 (window window)
1283 (event gdk:key-event))
1284
1285(defbinding window-propagate-key-event () boolean
1286 (window window)
1287 (event gdk:key-event))
1288
92ba85d4 1289#-gtk2.8
304cfb76 1290(defbinding window-present () nil
1291 (window window))
1292
92ba85d4 1293#+gtk2.8
1294(progn
1295 (defbinding %window-present () nil
1296 (window window))
1297
12cae344 1298 (defbinding %window-present-with-time () nil
92ba85d4 1299 (window window)
1300 (timespamp unsigned-int))
1301
1302 (defun window-present (window &optional timestamp)
1303 (if timestamp
12cae344 1304 (%window-present-with-time window timestamp)
92ba85d4 1305 (%window-present window))))
1306
304cfb76 1307(defbinding window-iconify () nil
1308 (window window))
1309
1310(defbinding window-deiconify () nil
1311 (window window))
1312
1313(defbinding window-stick () nil
1314 (window window))
1315
1316(defbinding window-unstick () nil
1317 (window window))
1318
1319(defbinding window-maximize () nil
1320 (window window))
1321
1322(defbinding window-unmaximize () nil
1323 (window window))
1324
4eed43f1 1325(defbinding window-fullscreen () nil
1326 (window window))
1327
1328(defbinding window-unfullscreen () nil
1329 (window window))
1330
1331(defbinding window-set-keep-above () nil
1332 (window window)
1333 (setting boolean))
1334
1335(defbinding window-set-keep-below () nil
1336 (window window)
1337 (setting boolean))
1338
304cfb76 1339(defbinding window-begin-resize-drag () nil
1340 (window window)
1341 (edge gdk:window-edge)
1342 (button int)
1343 (root-x int) (root-y int)
6baf860c 1344 (timestamp unsigned-int))
304cfb76 1345
1346(defbinding window-begin-move-drag () nil
1347 (window window)
1348 (edge gdk:window-edge)
1349 (button int)
1350 (root-x int) (root-y int)
6baf860c 1351 (timestamp unsigned-int))
304cfb76 1352
1353(defbinding window-set-frame-dimensions () nil
1354 (window window)
1355 (left int) (top int) (rigth int) (bottom int))
1356
304cfb76 1357(defbinding %window-get-default-size () nil
1358 (window window)
1359 (width int :out)
1360 (height int :out))
1361
1362(defun window-get-default-size (window)
1363 (multiple-value-bind (width height) (%window-get-default-size window)
1364 (values (unless (= width -1) width) (unless (= height -1) height))))
1365
1366(defbinding window-get-frame-dimensions () nil
1367 (window window)
1368 (left int :out) (top int :out) (rigth int :out) (bottom int :out))
1369
ad98b596 1370(defbinding %window-get-icon-list () (glist (copy-of gdk:pixbuf))
304cfb76 1371 (window window))
1372
304cfb76 1373(defbinding window-get-position () nil
1374 (window window)
1375 (root-x int :out)
1376 (root-y int :out))
1377
1378(defbinding window-get-size () nil
1379 (window window)
1380 (width int :out)
1381 (height int :out))
1382
1383(defbinding window-move () nil
1384 (window window)
1385 (x int)
1386 (y int))
1387
1388(defbinding window-parse-geometry () boolean
1389 (window window)
1390 (geometry string))
1391
1392(defbinding window-reshow-with-initial-size () nil
1393 (window window))
1394
1395(defbinding window-resize () nil
1396 (window window)
1397 (width int)
1398 (heigth int))
1399
4eed43f1 1400(defbinding (window-default-icon-list "gtk_window_get_default_icon_list")
1401 () (glist gdk:pixbuf))
1402
1403(defun window-default-icon ()
1404 (first (window-default-icon-list)))
1405
1406(defbinding %window-set-default-icon-list () nil
1407 (icons (glist gdk:pixbuf)))
1408
1409(defun (setf window-default-icon-list) (icons)
1410 (%window-set-default-icon-list icons)
1411 icons)
1412
1413(defbinding %window-set-default-icon () nil
1414 (icons (glist gdk:pixbuf)))
1415
1416(defmethod (setf window-default-icon) ((icon gdk:pixbuf))
1417 (%window-set-default-icon icon)
1418 icon)
1419
1420(defmethod (setf window-group) ((group window-group) (window window))
1421 (window-group-add-window group window)
1422 group)
1423
1424(defbinding %window-set-default-icon-from-file () boolean
1425 (filename pathname)
1426 (nil null))
1427
1428(defmethod (setf window-default-icon) ((icon-file pathname))
1429 (%window-set-default-icon-from-file icon-file)
1430 icon-file)
1431
1432(defbinding %window-set-icon-from-file () boolean
1433 (window window)
1434 (filename pathname)
1435 (nil null))
1436
1437(defmethod (setf window-icon) ((icon-file pathname) (window window))
1438 (%window-set-icon-from-file window icon-file)
1439 icon-file)
1440
1441(defbinding window-set-auto-startup-notification () nil
1442 (setting boolean))
1443
1444(defbinding decorated-window-init () nil
1445 (window window))
1446
1447(defbinding decorated-window-calculate-frame-size () nil
1448 (window window))
1449
1450(defbinding decorated-window-set-title () nil
304cfb76 1451 (window window)
4eed43f1 1452 (title string))
304cfb76 1453
4eed43f1 1454(defbinding decorated-window-move-resize-window () nil
1455 (window window)
1456 (x int)
1457 (y int)
1458 (width int)
1459 (heigth int))
304cfb76 1460
1461
4eed43f1 1462;;; Window group
0d07716f 1463
4eed43f1 1464(defmethod initialize-instance ((window-group window-group) &rest initargs
1465 &key window windows)
1466 (declare (ignore window windows))
1467 (prog1
1468 (call-next-method)
1469 (initial-add window-group #'window-group-add-window
1470 initargs :window :windows)))
0d07716f 1471
0d07716f 1472
4eed43f1 1473(defbinding window-group-add-window () nil
1474 (window-group window-group)
1475 (window window))
0d07716f 1476
4eed43f1 1477(defbinding window-group-remove-window () nil
1478 (window-group window-group)
1479 (window window))
0d07716f 1480
1481
30481825 1482;;; Scrolled window
0d07716f 1483
0d07716f 1484(defun (setf scrolled-window-scrollbar-policy) (policy window)
1485 (setf (scrolled-window-hscrollbar-policy window) policy)
1486 (setf (scrolled-window-vscrollbar-policy window) policy))
1487
a60bd055 1488(defbinding scrolled-window-add-with-viewport () nil
0d07716f 1489 (scrolled-window scrolled-window)
1490 (child widget))
1491
4c308d58 1492(defmethod shared-initialize ((window scrolled-window) names &key policy)
1493 (declare (ignore names))
1494 (when policy
1495 (setf (slot-value window 'hscrollbar-policy) policy)
1496 (setf (slot-value window 'vscrollbar-policy) policy))
1497 (call-next-method))
2afcd8bd 1498
0d07716f 1499
30481825 1500;;; Statusbar
0d07716f 1501
14eaa563 1502(defbinding statusbar-get-context-id () unsigned-int
30481825 1503 (statusbar statusbar)
1504 (context-description string))
0d07716f 1505
a60bd055 1506(defbinding statusbar-push () unsigned-int
30481825 1507 (statusbar statusbar)
1508 (context-id unsigned-int)
1509 (text string))
0d07716f 1510
a60bd055 1511(defbinding statusbar-pop () nil
30481825 1512 (statusbar statusbar)
1513 (context-id unsigned-int))
0d07716f 1514
a60bd055 1515(defbinding statusbar-remove () nil
30481825 1516 (statusbar statusbar)
1517 (context-id unsigned-int)
1518 (message-id unsigned-int))
0d07716f 1519
0d07716f 1520
1521
1522;;; Fixed
1523
a60bd055 1524(defbinding fixed-put () nil
30481825 1525 (fixed fixed)
1526 (widget widget)
378b3c5f 1527 (x int) (y int))
0d07716f 1528
a60bd055 1529(defbinding fixed-move () nil
30481825 1530 (fixed fixed)
1531 (widget widget)
378b3c5f 1532 (x int) (y int))
0d07716f 1533
1534
1535
2afcd8bd 1536;;; Notebook
0d07716f 1537
49043b9a 1538(defun %ensure-notebook-position (notebook page)
378b3c5f 1539 (etypecase page
49043b9a 1540 (position page)
378b3c5f 1541 (widget (notebook-page-num notebook page t))))
1542
49043b9a 1543(defun %ensure-notebook-child (notebook position)
378b3c5f 1544 (typecase position
1545 (widget position)
49043b9a 1546 (t (notebook-get-nth-page notebook position))))
378b3c5f 1547
1548(defbinding (notebook-insert "gtk_notebook_insert_page_menu")
30481825 1549 (notebook position child tab-label &optional menu-label) nil
1550 (notebook notebook)
1551 (child widget)
1552 ((if (stringp tab-label)
378b3c5f 1553 (make-instance 'label :label tab-label)
30481825 1554 tab-label) widget)
1555 ((if (stringp menu-label)
378b3c5f 1556 (make-instance 'label :label menu-label)
30481825 1557 menu-label) (or null widget))
49043b9a 1558 ((%ensure-notebook-position notebook position) position))
0d07716f 1559
378b3c5f 1560(defun notebook-append (notebook child tab-label &optional menu-label)
1561 (notebook-insert notebook :last child tab-label menu-label))
0d07716f 1562
378b3c5f 1563(defun notebook-prepend (notebook child tab-label &optional menu-label)
1564 (notebook-insert notebook :first child tab-label menu-label))
0d07716f 1565
378b3c5f 1566(defbinding notebook-remove-page (notebook page) nil
30481825 1567 (notebook notebook)
49043b9a 1568 ((%ensure-notebook-position notebook page) position))
0d07716f 1569
a60bd055 1570(defbinding %notebook-page-num () int
30481825 1571 (notebook notebook)
1572 (child widget))
1573
378b3c5f 1574(defun notebook-page-num (notebook child &optional error-p)
30481825 1575 (let ((page-num (%notebook-page-num notebook child)))
1576 (if (= page-num -1)
378b3c5f 1577 (when error-p
49043b9a 1578 (error "~A is not a page in ~A" child notebook))
30481825 1579 page-num)))
1580
a60bd055 1581(defbinding notebook-next-page () nil
30481825 1582 (notebook notebook))
0d07716f 1583
a60bd055 1584(defbinding notebook-prev-page () nil
30481825 1585 (notebook notebook))
1586
378b3c5f 1587(defbinding notebook-reorder-child (notebook child position) nil
1588 (notebook notebook)
1589 (child widget)
92ba85d4 1590 ((%ensure-notebook-position notebook position) int))
378b3c5f 1591
a60bd055 1592(defbinding notebook-popup-enable () nil
30481825 1593 (notebook notebook))
1594
a60bd055 1595(defbinding notebook-popup-disable () nil
30481825 1596 (notebook notebook))
1597
49043b9a 1598(defbinding notebook-get-nth-page () widget
378b3c5f 1599 (notebook notebook)
49043b9a 1600 (page position))
378b3c5f 1601
49043b9a 1602(defun %notebook-current-page (notebook)
1603 (when (slot-boundp notebook 'current-page-num)
1604 (notebook-get-nth-page notebook (notebook-current-page-num notebook))))
378b3c5f 1605
1606(defun (setf notebook-current-page) (page notebook)
49043b9a 1607 (setf (notebook-current-page notebook) (notebook-page-num notebook page)))
378b3c5f 1608
eb4f580c 1609(defbinding (notebook-tab-label "gtk_notebook_get_tab_label")
1610 (notebook page) widget
1611 (notebook notebook)
49043b9a 1612 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1613
eb4f580c 1614(defbinding (notebook-tab-label-text "gtk_notebook_get_tab_label_text")
84967144 1615 (notebook page) (copy-of string)
eb4f580c 1616 (notebook notebook)
49043b9a 1617 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1618
eb4f580c 1619(defbinding %notebook-set-tab-label () nil
1620 (notebook notebook)
1621 (page widget)
1622 (tab-label widget))
1623
1624(defun (setf notebook-tab-label) (tab-label notebook page)
1625 (let ((widget (if (stringp tab-label)
1626 (make-instance 'label :label tab-label)
1627 tab-label)))
49043b9a 1628 (%notebook-set-tab-label notebook (%ensure-notebook-child notebook page) widget)
eb4f580c 1629 widget))
378b3c5f 1630
378b3c5f 1631
eb4f580c 1632(defbinding (notebook-menu-label "gtk_notebook_get_menu_label")
1633 (notebook page) widget
1634 (notebook notebook)
49043b9a 1635 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1636
eb4f580c 1637(defbinding (notebook-menu-label-text "gtk_notebook_get_menu_label_text")
84967144 1638 (notebook page) (copy-of string)
eb4f580c 1639 (notebook notebook)
49043b9a 1640 ((%ensure-notebook-child notebook page) widget))
378b3c5f 1641
eb4f580c 1642(defbinding %notebook-set-menu-label () nil
1643 (notebook notebook)
1644 (page widget)
1645 (menu-label widget))
1646
1647(defun (setf notebook-menu-label) (menu-label notebook page)
1648 (let ((widget (if (stringp menu-label)
1649 (make-instance 'label :label menu-label)
1650 menu-label)))
49043b9a 1651 (%notebook-set-menu-label notebook (%ensure-notebook-child notebook page) widget)
eb4f580c 1652 widget))
378b3c5f 1653
1654
1655(defbinding notebook-query-tab-label-packing (notebook page) nil
30481825 1656 (notebook notebook)
92ba85d4 1657 ((%ensure-notebook-child notebook page) widget)
30481825 1658 (expand boolean :out)
1659 (fill boolean :out)
1660 (pack-type pack-type :out))
1661
378b3c5f 1662(defbinding notebook-set-tab-label-packing
1663 (notebook page expand fill pack-type) nil
30481825 1664 (notebook notebook)
92ba85d4 1665 ((%ensure-notebook-child notebook page) widget)
30481825 1666 (expand boolean)
1667 (fill boolean)
1668 (pack-type pack-type))
1669
0d07716f 1670
1671
2afcd8bd 1672;;; Paned
0d07716f 1673
a60bd055 1674(defbinding paned-pack1 () nil
2afcd8bd 1675 (paned paned)
1676 (child widget)
1677 (resize boolean)
1678 (shrink boolean))
0d07716f 1679
a60bd055 1680(defbinding paned-pack2 () nil
2afcd8bd 1681 (paned paned)
1682 (child widget)
1683 (resize boolean)
1684 (shrink boolean))
0d07716f 1685
0d07716f 1686
2afcd8bd 1687;;; Layout
0d07716f 1688
a60bd055 1689(defbinding layout-put () nil
2afcd8bd 1690 (layout layout)
49043b9a 1691 (child widget)
2afcd8bd 1692 (x int)
1693 (y int))
0d07716f 1694
a60bd055 1695(defbinding layout-move () nil
2afcd8bd 1696 (layout layout)
49043b9a 1697 (child widget)
2afcd8bd 1698 (x int)
1699 (y int))
0d07716f 1700
49043b9a 1701(defbinding layout-set-size () nil
1702 (layout layout)
1703 (width unsigned-int)
1704 (height unsigned-int))
1705
1706(defbinding layout-get-size () nil
1707 (layout layout)
1708 (width unsigned-int :out)
1709 (height unsigned-int :out))
0d07716f 1710
1711
0d07716f 1712;;; Menu shell
1713
378b3c5f 1714(defbinding menu-shell-insert (menu-shell menu-item position) nil
30481825 1715 (menu-shell menu-shell)
1716 (menu-item menu-item)
378b3c5f 1717 ((case position
1718 (:first 0)
1719 (:last -1)
1720 (t position)) int))
0d07716f 1721
30481825 1722(defun menu-shell-append (menu-shell menu-item)
378b3c5f 1723 (menu-shell-insert menu-shell menu-item :last))
0d07716f 1724
30481825 1725(defun menu-shell-prepend (menu-shell menu-item)
378b3c5f 1726 (menu-shell-insert menu-shell menu-item :fisrt))
0d07716f 1727
a60bd055 1728(defbinding menu-shell-deactivate () nil
30481825 1729 (menu-shell menu-shell))
0d07716f 1730
a60bd055 1731(defbinding menu-shell-select-item () nil
30481825 1732 (menu-shell menu-shell)
1733 (menu-item menu-item))
0d07716f 1734
14eaa563 1735(defbinding menu-shell-select-first () nil
1736 (menu-shell menu-shell)
1737 (search-sensitive boolean))
1738
a60bd055 1739(defbinding menu-shell-deselect () nil
30481825 1740 (menu-shell menu-shell))
0d07716f 1741
a60bd055 1742(defbinding menu-shell-activate-item () nil
30481825 1743 (menu-shell menu-shell)
1744 (menu-item menu-item)
1745 (fore-deactivate boolean))
0d07716f 1746
14eaa563 1747(defbinding menu-shell-cancel () nil
1748 (menu-shell menu-shell))
0d07716f 1749
1750
378b3c5f 1751;;; Menu
0d07716f 1752
378b3c5f 1753(defun %menu-position (menu child)
1754 (etypecase child
1755 (int child)
1756 (keyword (case child
1757 (:first 0)
1758 (:last -1)
eb4f580c 1759 (t (error "Invalid position keyword: ~A" child))))
378b3c5f 1760 (widget (menu-child-position menu child))))
0d07716f 1761
1762
378b3c5f 1763(defbinding menu-reorder-child (menu menu-item position) nil
1764 (menu menu)
1765 (menu-item menu-item)
1766 ((%menu-position menu position) int))
0d07716f 1767
14eaa563 1768(defbinding menu-attach () nil
1769 (menu menu)
1770 (menu-item menu-item)
1771 (left-attach unsigned-int)
1772 (right-attach unsigned-int)
1773 (top-attach unsigned-int)
1774 (bottom-attach unsigned-int))
1775
1776(def-callback-marshal %menu-position-func (nil (menu menu) (x int) (y int) (push-in boolean)))
0d07716f 1777
378b3c5f 1778(defbinding %menu-popup () nil
1779 (menu menu)
1780 (parent-menu-shell (or null menu-shell))
1781 (parent-menu-item (or null menu-item))
1782 (callback-func (or null pointer))
1783 (callback-id unsigned-int)
1784 (button unsigned-int)
1785 (activate-time (unsigned 32)))
1786
1787(defun menu-popup (menu button activate-time &key callback parent-menu-shell
1788 parent-menu-item)
1789 (if callback
4886872c 1790 (with-callback-function (id callback)
1791 (%menu-popup
1792 menu parent-menu-shell parent-menu-item
14eaa563 1793 (callback %menu-position-func) id button activate-time))
378b3c5f 1794 (%menu-popup
1795 menu parent-menu-shell parent-menu-item nil 0 button activate-time)))
1796
1797(defbinding menu-set-accel-path () nil
1798 (menu menu)
1799 (accel-path string))
0d07716f 1800
a60bd055 1801(defbinding menu-reposition () nil
30481825 1802 (menu menu))
0d07716f 1803
a60bd055 1804(defbinding menu-popdown () nil
30481825 1805 (menu menu))
0d07716f 1806
378b3c5f 1807(defun menu-child-position (menu child)
1808 (position child (container-children menu)))
1809
1810(defun menu-active-num (menu)
1811 (menu-child-position menu (menu-active menu)))
1812
a60bd055 1813(defbinding %menu-set-active () nil
30481825 1814 (menu menu)
1815 (index unsigned-int))
0d07716f 1816
378b3c5f 1817(defun (setf menu-active) (menu child)
1818 (%menu-set-active menu (%menu-position menu child))
1819 child)
2afcd8bd 1820
14eaa563 1821(defcallback %menu-detach-func (nil (widget widget) (menu menu))
1822 (funcall (object-data menu 'detach-func) widget menu))
1823
1824(defbinding %menu-attach-to-widget () nil
1825 (menu menu)
1826 (widget widget)
1827 ((callback %menu-detach-func) pointer))
1828
1829(defun menu-attach-to-widget (menu widget function)
1830 (setf (object-data menu 'detach-func) function)
1831 (%menu-attach-to-widget menu widget))
1832
1833(defbinding menu-detach () nil
1834 (menu menu))
1835
1836#+gtk2.6
1837(defbinding menu-get-for-attach-widget () (copy-of (glist widget))
1838 (widget widget))
1839
1840(defbinding menu-set-monitor () nil
1841 (menu menu)
1842 (monitor-num int))
0d07716f 1843
1844
30481825 1845;;; Table
0d07716f 1846
a60bd055 1847(defbinding table-resize () nil
30481825 1848 (table table)
1849 (rows unsigned-int)
1850 (columns unsigned-int))
0d07716f 1851
a60bd055 1852(defbinding table-attach (table child left right top bottom
362f1795 1853 &key options x-options y-options
1854 (x-padding 0) (y-padding 0)) nil
30481825 1855 (table table)
1856 (child widget)
1857 (left unsigned-int)
1858 (right unsigned-int)
1859 (top unsigned-int)
1860 (bottom unsigned-int)
362f1795 1861 ((append (mklist options) (mklist x-options)) attach-options)
1862 ((append (mklist options) (mklist y-options)) attach-options)
30481825 1863 (x-padding unsigned-int)
1864 (y-padding unsigned-int))
1865
dd392521 1866
a60bd055 1867(defbinding %table-set-row-spacing () nil
30481825 1868 (table table)
1869 (row unsigned-int)
1870 (spacing unsigned-int))
1871
dd392521 1872(defbinding %table-set-row-spacings () nil
1873 (table table)
1874 (spacing unsigned-int))
1875
1876(defun (setf table-row-spacing) (spacing table &optional row)
1877 (if row
1878 (%table-set-row-spacing table row spacing)
1879 (%table-set-row-spacings table spacing))
30481825 1880 spacing)
1881
dd392521 1882(defbinding %table-get-row-spacing () unsigned-int
30481825 1883 (table table)
dd392521 1884 (row unsigned-int))
1885
1886(defbinding %table-get-default-row-spacing () unsigned-int
1887 (table table))
1888
1889(defun table-row-spacing (table &optional row)
1890 (if row
1891 (%table-get-row-spacing table row)
1892 (%table-get-default-row-spacing table)))
1893
30481825 1894
a60bd055 1895(defbinding %table-set-col-spacing () nil
30481825 1896 (table table)
1897 (col unsigned-int)
1898 (spacing unsigned-int))
1899
dd392521 1900(defbinding %table-set-col-spacings () nil
1901 (table table)
1902 (spacing unsigned-int))
1903
1904(defun (setf table-col-spacing) (spacing table &optional col)
1905 (if col
1906 (%table-set-col-spacing table col spacing)
1907 (%table-set-col-spacings table spacing))
30481825 1908 spacing)
1909
dd392521 1910(defbinding %table-get-col-spacing () unsigned-int
30481825 1911 (table table)
dd392521 1912 (col unsigned-int))
1913
1914(defbinding %table-get-default-col-spacing () unsigned-int
1915 (table table))
1916
1917(defun table-col-spacing (table &optional col)
1918 (if col
1919 (%table-get-col-spacing table col)
1920 (%table-get-default-col-spacing table)))
1921
1922
30481825 1923
1924;;; Toolbar
1925
9617dc95 1926(defmethod initialize-instance ((toolbar toolbar) &rest initargs &key tooltips)
1927 (if (eq tooltips t)
1928 (apply #'call-next-method toolbar
1929 :tooltips (make-instance 'tooltips) initargs)
1930 (call-next-method)))
0d07716f 1931
9617dc95 1932(defbinding %toolbar-insert () nil
378b3c5f 1933 (toolbar toolbar)
9617dc95 1934 (tool-item tool-item)
1935 (position position))
30481825 1936
9617dc95 1937(defun toolbar-insert (toolbar tool-item &optional (position :end))
1938 (%toolbar-insert toolbar tool-item position)
1939 (%tool-item-update-tooltips tool-item))
378b3c5f 1940
9617dc95 1941(defbinding toolbar-get-item-index () int
1942 (toolbar toolbar)
1943 (item tool-item))
30481825 1944
9617dc95 1945(defbinding toolbar-get-nth-item () tool-item
1946 (toolbar toolbar)
1947 (n int))
30481825 1948
9617dc95 1949(defbinding toolbar-get-drop-index () int
1950 (toolbar toolbar)
1951 (x int) (y int))
30481825 1952
9617dc95 1953(defbinding toolbar-set-drop-highlight-item () nil
1954 (toolbar toolbar)
1955 (tool-item tool-item)
1956 (index int))
30481825 1957
0d07716f 1958
9617dc95 1959;;; Tool button
0d07716f 1960
9617dc95 1961(defmethod initialize-instance ((button tool-button) &rest initargs &key icon)
1962 (if (and icon (not (typep icon 'widget)))
1963 (apply #'call-next-method button :icon (create-image-widget icon) initargs)
1964 (call-next-method)))
0d07716f 1965
1966
9617dc95 1967;;; Tool item
0d07716f 1968
9617dc95 1969(defbinding tool-item-set-tooltip () nil
1970 (tool-item tool-item)
1971 (tooltips tooltips)
1972 (tip-text string)
1973 (tip-private string))
0d07716f 1974
0d07716f 1975
9617dc95 1976(defun %tool-item-update-tooltips (tool-item)
1977 (when (and
1978 (slot-boundp tool-item 'parent)
1979 (or
1980 (user-data-p tool-item 'tip-text)
1981 (user-data-p tool-item 'tip-private)))
1982 (tool-item-set-tooltip
1983 tool-item (toolbar-tooltips (widget-parent tool-item))
1984 (or (user-data tool-item 'tip-text) "")
1985 (or (user-data tool-item 'tip-private) ""))))
1986
1987(defmethod (setf tool-item-tip-text) ((tip-text string) (tool-item tool-item))
1988 (setf (user-data tool-item 'tip-text) tip-text)
1989 (%tool-item-update-tooltips tool-item)
1990 tip-text)
1991
1992(defmethod (setf tool-item-tip-private) ((tip-private string) (tool-item tool-item))
1993 (setf (user-data tool-item 'tip-private) tip-private)
1994 (%tool-item-update-tooltips tool-item)
1995 tip-private)
1996
1997(defmethod container-add ((toolbar toolbar) (tool-item tool-item) &rest args)
1998 (declare (ignore args))
1999 (prog1
2000 (call-next-method)
2001 (%tool-item-update-tooltips tool-item)))
0d07716f 2002
14eaa563 2003
2004(defbinding tool-item-retrieve-proxy-menu-item () widget
2005 (tool-item tool-item))
2006
2007(defbinding (tool-item-proxy-menu-item
2008 "gtk_tool_item_get_proxy_menu_item") () menu-item
2009 (tool-item tool-item)
2010 (menu-item-id string))
2011
2012(defbinding %tool-item-set-proxy-menu-item () nil
2013 (tool-item tool-item)
2014 (menu-item-id string)
2015 (menu-item menu-item))
2016
2017(defun (setf tool-item-proxy-menu-item) (menu-item menu-item-id tool-item)
2018 (%tool-item-set-proxy-menu-item menu-item-id tool-item menu-item)
2019 menu-item)
2020
2021#+gtk2.6
2022(defbinding tool-item-rebuild-menu () nil
2023 (tool-item tool-item))
2024
2025
a60bd055 2026;;; Editable
eb4f580c 2027
a60bd055 2028(defbinding editable-select-region (editable &optional (start 0) end) nil
30481825 2029 (editable editable)
2030 (start int)
2031 ((or end -1) int))
0d07716f 2032
eb4f580c 2033(defbinding editable-get-selection-bounds (editable) nil
2034 (editable editable)
2035 (start int :out)
2036 (end int :out))
2037
14eaa563 2038(defbinding editable-insert-text (editable text &optional (position 0)) nil
30481825 2039 (editable editable)
2040 (text string)
2041 ((length text) int)
5a3bf471 2042 (position position :in-out))
0d07716f 2043
30481825 2044(defun editable-append-text (editable text)
2045 (editable-insert-text editable text nil))
0d07716f 2046
30481825 2047(defun editable-prepend-text (editable text)
2048 (editable-insert-text editable text 0))
0d07716f 2049
a60bd055 2050(defbinding editable-delete-text (editable &optional (start 0) end) nil
30481825 2051 (editable editable)
2052 (start int)
2053 ((or end -1) int))
0d07716f 2054
a60bd055 2055(defbinding (editable-text "gtk_editable_get_chars")
30481825 2056 (editable &optional (start 0) end) string
2057 (editable editable)
2058 (start int)
2059 ((or end -1) int))
0d07716f 2060
30481825 2061(defun (setf editable-text) (text editable)
2062 (if text
2063 (editable-delete-text
2064 editable
2065 (editable-insert-text editable text))
2066 (editable-delete-text editable))
2067 text)
0d07716f 2068
a60bd055 2069(defbinding editable-cut-clipboard () nil
30481825 2070 (editable editable))
0d07716f 2071
a60bd055 2072(defbinding editable-copy-clipboard () nil
30481825 2073 (editable editable))
0d07716f 2074
a60bd055 2075(defbinding editable-paste-clipboard () nil
30481825 2076 (editable editable))
0d07716f 2077
a60bd055 2078(defbinding editable-delete-selection () nil
30481825 2079 (editable editable))
0d07716f 2080
0d07716f 2081
0d07716f 2082
30481825 2083;;; Spin button
0d07716f 2084
14eaa563 2085(defbinding spin-button-configure () nil
2086 (spin-button spin-button)
2087 (adjustment adjustment)
2088 (climb-rate double-float)
2089 (digits unsigned-int))
2090
2091(defbinding spin-button-set-range () nil
2092 (spin-button spin-button)
2093 (min double-float)
2094 (max double-float))
2095
2096(defbinding spin-button-get-range () nil
2097 (spin-button spin-button)
2098 (min double-float :out)
2099 (max double-float :out))
2100
30481825 2101(defun spin-button-value-as-int (spin-button)
2102 (round (spin-button-value spin-button)))
0d07716f 2103
45314d76 2104(defbinding %spin-button-spin () nil
30481825 2105 (spin-button spin-button)
2106 (direction spin-type)
45314d76 2107 (increment double-float))
2108
2109(defun spin-button-spin (spin-button value)
2110 (etypecase value
2111 (real (%spin-button-spin spin-button :spin-user-defined value))
2112 (spin-type (%spin-button-spin spin-button value 0))))
2113
0d07716f 2114
a60bd055 2115(defbinding spin-button-update () nil
30481825 2116 (spin-button spin-button))
0d07716f 2117
2118
2119
2120; ;;; Ruler
2121
a60bd055 2122(defbinding ruler-set-range () nil
30481825 2123 (ruler ruler)
2124 (lower single-float)
2125 (upper single-float)
2126 (position single-float)
2127 (max-size single-float))
0d07716f 2128
49043b9a 2129(defbinding ruler-get-range () nil
2130 (ruler ruler)
2131 (lower single-float :out)
2132 (upper single-float :out)
2133 (position single-float :out)
2134 (max-size single-float :out))
0d07716f 2135
0d07716f 2136
0d07716f 2137
2afcd8bd 2138;;; Range
0d07716f 2139
eb4f580c 2140(defun range-lower (range)
2141 (adjustment-lower (range-adjustment range)))
0d07716f 2142
eb4f580c 2143(defun range-upper (range)
2144 (adjustment-upper (range-adjustment range)))
0d07716f 2145
eb4f580c 2146(defun (setf range-lower) (value range)
2147 (setf (adjustment-lower (range-adjustment range)) value))
0d07716f 2148
eb4f580c 2149(defun (setf range-upper) (value range)
2150 (setf (adjustment-upper (range-adjustment range)) value))
0d07716f 2151
eb4f580c 2152(defun range-page-increment (range)
2153 (adjustment-page-increment (range-adjustment range)))
0d07716f 2154
eb4f580c 2155(defun range-step-increment (range)
2156 (adjustment-step-increment (range-adjustment range)))
0d07716f 2157
eb4f580c 2158(defun (setf range-page-increment) (value range)
2159 (setf (adjustment-page-increment (range-adjustment range)) value))
0d07716f 2160
eb4f580c 2161(defun (setf range-step-increment) (value range)
2162 (setf (adjustment-step-increment (range-adjustment range)) value))
0d07716f 2163
eb4f580c 2164(defbinding range-set-range () nil
2afcd8bd 2165 (range range)
eb4f580c 2166 (lower double-float)
2167 (upper double-float))
0d07716f 2168
eb4f580c 2169(defbinding range-set-increments () nil
2afcd8bd 2170 (range range)
eb4f580c 2171 (step double-float)
2172 (page double-float))
0d07716f 2173
0d07716f 2174
2afcd8bd 2175;;; Scale
0d07716f 2176
49043b9a 2177(defbinding scale-get-layout-offsets () nil
2178 (scale scale)
2179 (x int :out)
2180 (y int :out))
0d07716f 2181
0d07716f 2182
2afcd8bd 2183;;; Progress bar
0d07716f 2184
a60bd055 2185(defbinding progress-bar-pulse () nil
2afcd8bd 2186 (progress-bar progress-bar))
0d07716f 2187
2188
362f1795 2189;;; Size group
2190
2191(defmethod initialize-instance ((size-group size-group) &rest initargs
2192 &key widget widgets)
2193 (declare (ignore widget widgets))
2194 (prog1
2195 (call-next-method)
2196 (initial-add size-group #'size-group-add-widget
2197 initargs :widget :widgets)))
2198
2199
2200(defbinding size-group-add-widget () nil
2201 (size-group size-group)
2202 (widget widget))
2203
2204(defbinding size-group-remove-widget () nil
2205 (size-group size-group)
2206 (widget widget))
2207
0d07716f 2208
378b3c5f 2209;;; Stock items
2210
99821988 2211(defbinding %stock-item-copy () pointer
2212 (location pointer))
2213
2214(defbinding %stock-item-free () nil
2215 (location pointer))
378b3c5f 2216
99821988 2217(defmethod reference-foreign ((class (eql (find-class 'stock-item))) location)
2218 (%stock-item-copy location))
2219
2220(defmethod unreference-foreign ((class (eql (find-class 'stock-item))) location)
2221 (%stock-item-free location))
2222
2223(defbinding stock-add (stock-item) nil
2224 (stock-item stock-item)
2225 (1 unsigned-int))
2226
2227(defbinding stock-list-ids () (gslist string))
2228
2229(defbinding %stock-lookup () boolean
2230 (stock-id string)
2231 (location pointer))
2232
2233(defun stock-lookup (stock-id)
2234 (let ((location
8dcd91d7 2235 (allocate-memory (foreign-size (find-class 'stock-item)))))
99821988 2236 (unwind-protect
2237 (when (%stock-lookup stock-id location)
2238 (ensure-proxy-instance 'stock-item (%stock-item-copy location)))
2239 (deallocate-memory location))))
0d07716f 2240
2241
2242;;; Tooltips
2243
a60bd055 2244(defbinding tooltips-enable () nil
2afcd8bd 2245 (tooltips tooltips))
0d07716f 2246
a60bd055 2247(defbinding tooltips-disable () nil
2afcd8bd 2248 (tooltips tooltips))
0d07716f 2249
dd392521 2250(defun (setf tooltips-enabled-p) (enable tooltips)
2251 (if enable
2252 (tooltips-enable tooltips)
2253 (tooltips-disable tooltips)))
2254
a60bd055 2255(defbinding tooltips-set-tip () nil
2afcd8bd 2256 (tooltips tooltips)
2257 (widget widget)
2258 (tip-text string)
2259 (tip-private string))
0d07716f 2260
14eaa563 2261(defbinding tooltips-data-get () tooltips-data
2262 (widget widget))
2263
a60bd055 2264(defbinding tooltips-force-window () nil
2afcd8bd 2265 (tooltips tooltips))
0d07716f 2266
14eaa563 2267(defbinding tooltips-get-info-from-tip-window () boolean
2268 (tip-window window)
2269 (tooltips tooltips :out)
2270 (current-widget widget :out))
0d07716f 2271
2272
e69138cc 2273;;; Resource Files
0d07716f 2274
a60bd055 2275(defbinding rc-add-default-file (filename) nil
2afcd8bd 2276 ((namestring (truename filename)) string))
0d07716f 2277
a60bd055 2278(defbinding rc-parse (filename) nil
2afcd8bd 2279 ((namestring (truename filename)) string))
0d07716f 2280
a60bd055 2281(defbinding rc-parse-string () nil
2afcd8bd 2282 (rc-string string))
0d07716f 2283
a60bd055 2284(defbinding rc-reparse-all () nil)
0d07716f 2285
a60bd055 2286(defbinding rc-get-style () style
2afcd8bd 2287 (widget widget))