chiark / gitweb /
Removed some redundant and dead code
[clg] / gtk / gtkutils.lisp
CommitLineData
55212af1 1;; Common Lisp bindings for GTK+ v2.x
2;; Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net>
ac9d7adb 3;;
55212af1 4;; Permission is hereby granted, free of charge, to any person obtaining
5;; a copy of this software and associated documentation files (the
6;; "Software"), to deal in the Software without restriction, including
7;; without limitation the rights to use, copy, modify, merge, publish,
8;; distribute, sublicense, and/or sell copies of the Software, and to
9;; permit persons to whom the Software is furnished to do so, subject to
10;; the following conditions:
ac9d7adb 11;;
55212af1 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
ac9d7adb 14;;
55212af1 15;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23;; $Id: gtkutils.lisp,v 1.8 2005/04/23 16:48:52 espen Exp $
ac9d7adb 24
25
26(in-package "GTK")
27
4886872c 28(defun create-button (specs &optional callback &key object)
ac9d7adb 29 (destructuring-bind (label &rest initargs) (mklist specs)
30 (let ((button
31 (apply #'make-instance 'button :label label :visible t initargs)))
32 (if callback
4886872c 33 (signal-connect button 'clicked callback :object object)
ac9d7adb 34 (setf (widget-sensitive-p button) nil))
35 button)))
36
eb4f580c 37
4886872c 38(defun create-label (label &rest args)
39 (apply #'make-instance 'label :label label args))
eb4f580c 40
41
4886872c 42;; TODO: same syntax as create-button
eb4f580c 43(defun %create-toggleable-button (class label callback initstate initargs)
44 (let ((button
45 (apply #'make-instance class :label label :active initstate :visible t
46 initargs)))
ac9d7adb 47 (signal-connect
48 button 'toggled
49 #'(lambda ()
eb4f580c 50 (funcall (funcallable callback) (toggle-button-active-p button))))
51 (funcall (funcallable callback) initstate)
ac9d7adb 52 button))
53
eb4f580c 54(defun create-toggle-button (label callback &optional initstate &rest initargs)
55 (%create-toggleable-button 'toggle-button label callback initstate initargs))
ac9d7adb 56
eb4f580c 57(defun create-check-button (label callback &optional initstate &rest initargs)
58 (%create-toggleable-button 'check-button label callback initstate initargs))
ac9d7adb 59
eb4f580c 60(defun adjustment-new (value lower upper step-increment page-increment page-size)
61 (make-instance 'adjustment
62 :value value :lower lower :upper upper :step-increment step-increment
63 :page-increment page-increment :page-size page-size))
0ee31070 64
68882ccd 65(defun make-radio-group (type specs callback &rest initargs)
66 (let* ((active ())
67 (widgets
68 (loop
69 for spec in specs
70 as widget = (apply #'make-instance type (append spec initargs))
71 do (when callback
72 (apply #'add-activate-callback widget (mklist callback)))
73 (when (and (not active) (getf spec :active))
74 (setq active widget))
75 collect widget)))
76
77 (let ((active (or active (first widgets))))
78 (loop
79 for widget in widgets
80 unless (eq widget active)
81 do (add-to-radio-group widget active))
c3041ab3 82 (activate-radio-widget active))
68882ccd 83
84 widgets))