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