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