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.1 2000-10-05 17:21:46 espen Exp $
23 (defun create-button (specs &optional callback &rest args)
24 (destructuring-bind (label &rest initargs) (mklist specs)
26 (apply #'make-instance 'button :label label :visible t initargs)))
31 (apply (funcallable callback) args)))
32 (setf (widget-sensitive-p button) nil))
35 (defun %create-toggleable-button (class label callback state args)
36 (let ((button (make-instance class :label label :active state :visible t)))
40 (apply (funcallable callback) (toggle-button-active-p button) args)))
41 (apply (funcallable callback) state args)
44 (defun create-toggle-button (label callback &optional state &rest args)
45 (%create-toggleable-button 'toggle-button label callback state args))
47 (defun create-check-button (label callback &optional state &rest args)
48 (%create-toggleable-button 'check-button label callback state args))
50 (defun create-radio-button-group (specs active &optional callback &rest args)
56 (label &optional object &rest initargs) (mklist spec)
59 #'make-instance 'radio-button
60 :label label :visible t initargs)))
61 (when group (%radio-button-set-group button group))
62 (setq group (%radio-button-get-group button))
68 (when (toggle-button-active-p button)
69 (apply (funcallable callback) object args)))))
76 (toggle-button-active-p button) args)))))
78 (setf (toggle-button-active-p button) t))
83 (defun create-option-menu (specs active &optional callback &rest args)
84 (let ((menu (make-instance 'menu))
88 (destructuring-bind (label &optional object &rest initargs) (mklist spec)
91 #'make-instance 'radio-menu-item
92 :label label :active (= i active) initargs)))
93 (when group (%radio-menu-item-set-group menu-item group))
94 (setq group (%radio-menu-item-get-group menu-item))
100 (apply (funcallable callback) object args))))
107 (check-menu-item-active-p menu-item) args)))))
109 (menu-shell-append menu menu-item))))
111 (make-instance 'option-menu :history active :menu menu)))