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