1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
4 ;; This library is free software; you can redistribute it and/or
5 ;; modify it under the terms of the GNU Lesser General Public
6 ;; License as published by the Free Software Foundation; either
7 ;; version 2 of the License, or (at your option) any later version.
9 ;; This library is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;; Lesser General Public License for more details.
14 ;; You should have received a copy of the GNU Lesser General Public
15 ;; License along with this library; if not, write to the Free Software
16 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ;; $Id: gtkutils.lisp,v 1.2 2004-10-31 12:05:52 espen Exp $
24 (defun v-box-new (&optional homogeneous (spacing 0))
25 (make-instance 'v-box :homogeneous homogeneous :spacing spacing))
27 (defun create-button (specs &optional callback &rest args)
28 (destructuring-bind (label &rest initargs) (mklist specs)
30 (apply #'make-instance 'button :label label :visible t initargs)))
35 (apply (funcallable callback) args)))
36 (setf (widget-sensitive-p button) nil))
39 (defun button-new (label &optional callback)
40 (let ((button (make-instance 'button :label label)))
42 (signal-connect button 'clicked callback))
45 (defun label-new (label)
46 (make-instance 'label :label label))
50 (defun %create-toggleable-button (class label callback initstate initargs)
52 (apply #'make-instance class :label label :active initstate :visible t
57 (funcall (funcallable callback) (toggle-button-active-p button))))
58 (funcall (funcallable callback) initstate)
61 (defun create-toggle-button (label callback &optional initstate &rest initargs)
62 (%create-toggleable-button 'toggle-button label callback initstate initargs))
64 (defun create-check-button (label callback &optional initstate &rest initargs)
65 (%create-toggleable-button 'check-button label callback initstate initargs))
67 (defun create-radio-button-group (specs active &optional callback &rest args)
73 (label &optional object &rest initargs) (mklist spec)
76 #'make-instance 'radio-button
77 :label label :visible t initargs)))
78 (when group (%radio-button-set-group button group))
79 (setq group (%radio-button-get-group button))
85 (when (toggle-button-active-p button)
86 (apply (funcallable callback) object args)))))
93 (toggle-button-active-p button) args)))))
95 (setf (toggle-button-active-p button) t))
100 (defun create-option-menu (specs active &optional callback &rest initargs)
101 (let ((menu (make-instance 'menu))
105 (destructuring-bind (label &optional item-callback) (mklist spec)
108 #'make-instance 'radio-menu-item
109 :label label :active (= i active) initargs)))
110 (when group (%radio-menu-item-set-group menu-item group))
111 (setq group (%radio-menu-item-get-group menu-item))
114 (signal-connect menu-item 'activated callback :object t))
116 (signal-connect menu-item 'toggled item-callback :object t)))
118 (menu-shell-append menu menu-item))))
120 (make-instance 'option-menu :history active :menu menu)))
123 ;; (coerce n 'single-float))
125 (defun adjustment-new (value lower upper step-increment page-increment page-size)
126 (make-instance 'adjustment
127 :value value :lower lower :upper upper :step-increment step-increment
128 :page-increment page-increment :page-size page-size))