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