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