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