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