chiark / gitweb /
Initial revision
authorespen <espen>
Mon, 14 Aug 2000 16:44:10 +0000 (16:44 +0000)
committerespen <espen>
Mon, 14 Aug 2000 16:44:10 +0000 (16:44 +0000)
37 files changed:
COPYING [new file with mode: 0644]
README [new file with mode: 0644]
clg.system [new file with mode: 0644]
examples/3drings.xpm [new file with mode: 0644]
examples/filesqueue.xpm [new file with mode: 0644]
examples/modeller.xpm [new file with mode: 0644]
examples/test.xpm [new file with mode: 0644]
examples/testgtk.lisp [new file with mode: 0644]
examples/testgtkrc [new file with mode: 0644]
examples/testgtkrc2 [new file with mode: 0644]
gdk/gdk-export.lisp [new file with mode: 0644]
gdk/gdk-package.lisp [new file with mode: 0644]
gdk/gdk.lisp [new file with mode: 0644]
gdk/gdkenums.lisp [new file with mode: 0644]
gdk/gdkglue.c [new file with mode: 0644]
gdk/gdktypes.lisp [new file with mode: 0644]
glib/gforeign.lisp [new file with mode: 0644]
glib/glib-export.lisp [new file with mode: 0644]
glib/glib-package.lisp [new file with mode: 0644]
glib/glib.lisp [new file with mode: 0644]
glib/gobject.lisp [new file with mode: 0644]
glib/gtype.lisp [new file with mode: 0644]
glib/gutils.lisp [new file with mode: 0644]
gtk/gtk-export.lisp [new file with mode: 0644]
gtk/gtk-package.lisp [new file with mode: 0644]
gtk/gtk.lisp [new file with mode: 0644]
gtk/gtkcontainer.lisp [new file with mode: 0644]
gtk/gtkenums.lisp [new file with mode: 0644]
gtk/gtkglue.c [new file with mode: 0644]
gtk/gtkobject.lisp [new file with mode: 0644]
gtk/gtktypes.lisp [new file with mode: 0644]
gtk/gtkwidget.lisp [new file with mode: 0644]
hello-world.lisp [new file with mode: 0644]
tools/autoexport.lisp [new file with mode: 0644]
tools/config.lisp [new file with mode: 0644]
tools/makeenums.pl [new file with mode: 0644]
tools/sharedlib.lisp [new file with mode: 0644]

diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..223ede7
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,504 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..64e0564
--- /dev/null
+++ b/README
@@ -0,0 +1,25 @@
+This package contains Common Lisp bindings to GTK+ v2.0. It currently
+works with only CMUCL, but ports to other CL implementations may be
+added later.
+
+
+New versions
+------------
+
+The most recent version of this package can be found at:
+
+
+
+Build instructions
+------------------
+
+1. When building for CMUCL, first obtain a matching binary and source
+   tree (the only source file you will actually need is lisp.h, which
+   have to be copied or linked to your CMUCL_LIB directory).  On ELF
+   systems you may also have to rebuild lisp with -rdynamic added to
+   OS_LINK_FLAGS.
+
+2. 
+
+
+
diff --git a/clg.system b/clg.system
new file mode 100644 (file)
index 0000000..53d5df3
--- /dev/null
@@ -0,0 +1,81 @@
+;;; -*- Mode: lisp -*-
+
+(setf
+ (logical-pathname-translations "clg")
+ '(("**;*.*.*" "/home/espen/src/clg/**/*.*.*")))
+(setq mk::*cmu-errors-to-file* nil)
+
+(load "clg:tools;config")
+(load "clg:tools;sharedlib")
+
+(import 'alien:load-shared-library)
+
+(eval
+ `(mk:defsystem clg
+    :source-pathname "clg:"
+    :binary-pathname "clg:"
+    :components
+    ((:module tools
+      :components ("autoexport"))
+     (:module glib
+      :initially-do
+      (progn
+       (load-shared-library "libglib-1.3.so.1")
+       (load-shared-library "libgobject-1.3.so.1" :init "g_type_init"))
+      :components
+      ((:file "glib-package")
+       (:file "gutils" :depends-on ("glib-package"))
+       (:file "gforeign" :depends-on ("gutils"))
+       (:file "glib" :depends-on ("gforeign"))
+       (:file "gtype" :depends-on ("glib"))
+       (:file "gobject" :depends-on ("gtype"))
+       (:file "glib-export" :depends-on ("gutils" "glib" "gtype" "gobject")))
+      :depends-on (tools))
+     (:file "gdkglue"
+      :source-pathname "gdk;"
+      :binary-pathname "gdk;"
+      :initially-do
+      (progn
+       (load-shared-library "libgdk_pixbuf-1.3.so.1")
+       (load-shared-library "libgdk-x11-1.3.so.1")
+       ;; Initializing of gdk types is done by gtk, so we
+       ;; have to load an initialize it at this point
+       (load-shared-library
+        "libgtk-x11-1.3.so.1"
+        :init "gtk_init"
+        :prototype '(function
+                     c-call:void
+                     alien:system-area-pointer
+                     alien:system-area-pointer)
+        :initargs (list (system:int-sap 0) (system:int-sap 0))))
+      :language :c
+      :compiler-options (:cflags ,(configure-cflags "gtk-config-2.0")
+                        :optimize 2))
+     (:module gdk
+      :components
+      ((:file "gdk-package")
+       (:file "gdk-export" :depends-on ("gdkenums" "gdktypes" "gdk"))
+       (:file "gdkenums" :depends-on ("gdk-package"))
+       (:file "gdktypes" :depends-on ("gdkenums"))
+       (:file "gdk" :depends-on ("gdktypes")))
+      :depends-on (glib "gdkglue"))
+     (:file "gtkglue"
+      :source-pathname "gtk;"
+      :binary-pathname "gtk;"
+      :language :c
+      :compiler-options (:cflags ,(configure-cflags "gtk-config-2.0")
+                        :optimize 2
+                        :definitions (#+cmu CMUCL)
+                        :include-paths ("/usr/lib/cmucl")))
+     (:module gtk
+      :components
+      ((:file "gtk-package")
+       (:file "gtk-export" :depends-on ("gtkenums" "gtktypes" "gtk"))
+       (:file "gtkobject" :depends-on ("gtk-package"))
+       (:file "gtkenums" :depends-on ("gtk-package"))
+       (:file "gtktypes" :depends-on ("gtkenums" "gtkobject"))
+       (:file "gtkwidget" :depends-on ("gtktypes"))
+       (:file "gtkcontainer" :depends-on ("gtktypes"))
+       (:file "gtk" :depends-on ("gtkcontainer")))
+      :depends-on (glib gdk "gtkglue")))))
+
diff --git a/examples/3drings.xpm b/examples/3drings.xpm
new file mode 100644 (file)
index 0000000..1ca75da
--- /dev/null
@@ -0,0 +1,116 @@
+/* XPM */
+static char * DRings_xpm[] = {
+"48 48 65 1",
+"      c None",
+".     c #104010404103",
+"X     c #1040208130C2",
+"o     c #104014515144",
+"O     c #000010402081",
+"+     c #1040104030C2",
+"@     c #208120815144",
+"#     c #28A241035965",
+"$     c #30C230C26185",
+"%     c #208130C24103",
+"&     c #104010402081",
+"*     c #104000002081",
+"=     c #000010401040",
+"-     c #492441036185",
+";     c #596559659E79",
+":     c #30C220815144",
+">     c #0820186128A2",
+",     c #000000001040",
+"<     c #2081104030C2",
+"1     c #514459659658",
+"2     c #514455556185",
+"3     c #104000001040",
+"4     c #000008200000",
+"5     c #618569A6AEBA",
+"6     c #618569A69658",
+"7     c #410345148E38",
+"8     c #104020814103",
+"9     c #79E782079658",
+"0     c #208120814103",
+"q     c #596571C69E79",
+"w     c #4103514471C6",
+"e     c #2081208130C2",
+"r     c #6185618571C6",
+"t     c #28A228A25965",
+"y     c #596561858617",
+"u     c #96589E79BEFB",
+"i     c #28A230C271C6",
+"p     c #38E345145144",
+"a     c #79E78207A699",
+"s     c #30C2492469A6",
+"d     c #410330C25965",
+"f     c #410351446185",
+"g     c #AEBAAAAAD75C",
+"h     c #38E338E34103",
+"j     c #EFBEEBADEFBE",
+"k     c #208130C25144",
+"l     c #9658A289DF7D",
+"z     c #208110404103",
+"x     c #28A228A26185",
+"c     c #8E388A28BEFB",
+"v     c #208118612081",
+"b     c #38E3451479E7",
+"n     c #4924618579E7",
+"m     c #86178617B6DA",
+"M     c #30C220814103",
+"N     c #104030C25144",
+"B     c #4103410371C6",
+"V     c #86178A28D75C",
+"C     c #DF7DDB6CE79D",
+"Z     c #BEFBC30BD75C",
+"A     c #410330C271C6",
+"S     c #30C228A230C2",
+"D     c #082008201861",
+"F     c #186130C238E3",
+"G     c #0000208130C2",
+"                                .Xo             ",
+"                              O+O@#$%           ",
+"                             &*=+X-;:           ",
+"                            >&=,=<11#2          ",
+"                            +O34,X567&          ",
+"                           8X+=,90q9w.          ",
+"                          +e<>3r tyu-&          ",
+"                          Xi%.=  paus+          ",
+"                         Od-@=   fga$h          ",
+"                         @y7X,  Xrjak           ",
+"                       2:eaw+   $ag;@           ",
+"                   .X@8@k@o@X+ +pl9tO           ",
+"                 +zX@x$$isikt8o02crv            ",
+"                8@%ip7757ywbs$Ohn6#.            ",
+"               &0%$p7r215ybw1pzp2-0=            ",
+"              8tk$#yw21665n;1+%-p$O             ",
+"             O<e7pbryq5am9ay6XMpM>3&            ",
+"            9.NtpBw16amclVcm1t%kX*88            ",
+"            +&etd7r6y9ulgglm6>e>3s@83           ",
+"            +0k$y-y69cgCCCZVam%+#ik8X           ",
+"           O&oi$d725amgCjCZu962ybtx8+p          ",
+"           &X0x$sBym9VZCCCZca;yBbi%08&          ",
+"           =++@sApMy5muZZgum6y2wds:>+&          ",
+"          #tp;1;yB#i25cVucma5;w-pti@8&          ",
+"        .#2alumnBp:@1r59y9y6ywBS$%0X+=          ",
+"      %$wmZVu;#tX8X07r1656y2wbp$k@%@OD          ",
+"     0Byc9a;h%0>&D&hBrr2r1bwB-AF:0<&*=          ",
+"    kBf;yr#@X+&<%MkhsBwBwpsB#Bktkt8+Oh          ",
+"   xt7B-t8*,3O.X00:$i#dBd#bptFek0X.+*           ",
+"  Xt#b#@=,  =&O+X0Ft%ibsp$p$ki%l5sX&=           ",
+" &<kvX&4    +O*&<X0e:%$pAti%:edugn0=            ",
+" +X@&+,     V,O&>+Xt>tktktv0%@k;Cls+            ",
+" =+O*4*X:p;9cy3&&8ve0FMtt$ee0>z7cZ6k            ",
+" D=D4,=.k$sBs$ee=+X0Fk%-#t%0X&O0nu9bG           ",
+" ,,434*&ze@F<eeeeee><tdhdSMe<&&XAaawx           ",
+"  4,4,=+><peeeeee&=<%M%$hSF0X&O&kw5r%Z          ",
+"                   D&vSFMF<>&D =0S-2i&          ",
+"                       +>puB>   >0h7s.          ",
+"                       SM5VqM   &0t#$8          ",
+"                        XpVV70  &0kMk.          ",
+"                         XdyB%z *X<%@+          ",
+"                         &k$b0X+=8X08o          ",
+"                          &e:e+=*X.X+&          ",
+"                           +X.O+X0O.=,          ",
+"                            +>&+0>3&*           ",
+"                             &X0k+O,            ",
+"                               >v,3             ",
+"                                                "};
diff --git a/examples/filesqueue.xpm b/examples/filesqueue.xpm
new file mode 100644 (file)
index 0000000..586d27e
--- /dev/null
@@ -0,0 +1,98 @@
+/* XPM */
+static char * FilesQueue_xpm[] = {
+"44 31 64 1",
+"      c None",
+".     c #E79DE38DDF7D",
+"X     c #CF3CC71BCF3C",
+"o     c #71C675D671C6",
+"O     c #B6DAB2CAB6DA",
+"+     c #CF3CD34CCF3C",
+"@     c #DF7DE38DE79D",
+"#     c #FFFFFBEEFFFF",
+"$     c #EFBEEFBEEFBE",
+"%     c #DF7DDB6CDF7D",
+"&     c #BEFBBAEAC71B",
+"*     c #BEFBBAEABEFB",
+"=     c #BEFBC30BC71B",
+"-     c #71C66DB671C6",
+";     c #D75CD34CD75C",
+":     c #9E799A699E79",
+">     c #E79DE38DE79D",
+",     c #CF3CCB2BC71B",
+"<     c #B6DAB2CABEFB",
+"1     c #BEFBBAEAB6DA",
+"2     c #B6DAB6DAB6DA",
+"3     c #618561856185",
+"4     c #C71BBAEABEFB",
+"5     c #AEBAAAAAAEBA",
+"6     c #965892488E38",
+"7     c #A699A699A699",
+"8     c #38E338E338E3",
+"9     c #F7DEF7DEF7DE",
+"0     c #E79DEFBEEFBE",
+"q     c #DF7DE38DDF7D",
+"w     c #C71BC71BC71B",
+"e     c #C71BC30BBEFB",
+"r     c #BEFBC30BBEFB",
+"t     c #B6DAAAAAAEBA",
+"y     c #410345144103",
+"u     c #D75CDB6CD75C",
+"i     c #C71BCB2BC71B",
+"p     c #BEFBCB2BBEFB",
+"a     c #9E79A289A699",
+"s     c #86178E388E38",
+"d     c #CF3CCF3CD75C",
+"f     c #CF3CD75CCF3C",
+"g     c #C71BC30BCF3C",
+"h     c #28A22CB228A2",
+"j     c #000000000000",
+"k     c #D75CD34CDF7D",
+"l     c #10400C300820",
+"z     c #E79DEBADEFBE",
+"x     c #DF7DDB6CD75C",
+"c     c #514459655965",
+"v     c #8617861779E7",
+"b     c #DF7DD34CD75C",
+"n     c #CF3CCB2BCF3C",
+"m     c #618555555965",
+"M     c #861786178617",
+"N     c #30C234D330C2",
+"B     c #EFBEEBADE79D",
+"V     c #DF7DDB6CE79D",
+"C     c #D75CE38DD75C",
+"Z     c #514449245144",
+"A     c #186120812081",
+"S     c #79E77DF779E7",
+"D     c #6185659569A6",
+"F     c #9E7992489E79",
+"                      .XoOX+                ",
+"                   @#$%&*=-o;:              ",
+"                  @>,=O<12*&:-<3X           ",
+"                 >%&1*4*2*OO**56758790      ",
+"               9qX+we=r*&e<<<251t5555yu9    ",
+"             $qu++;ipi=p*=p**2tOOO27a5s<-   ",
+"           #9udfXi;,gi&**4**4r*Ot5t55tehj   ",
+"          0qku+u;+d,gg=*=r*&**&<255t<*yl1   ",
+"       $$zq@%xk%uf;,w,i=i=e**r=12tO1=8cvj   ",
+"     $@%>.%.%%%xbkx,w+ni,wwrwe*4*1=;8mMNj   ",
+"    zz@Bz>>>V%%%C+u;;dfnnfwggi&=&X+yZsNll   ",
+"  af#9@B0>q>qqq>xk.;;;kfX+XnXw=g,fycMhhN5   ",
+"  al5#9$$>qzBV.%x%%b;x+fnf+,X,iiqym6NAo-j   ",
+"  #roS%#$zz>>V%%xkk%f;;+df,XnwnVZD:8AS-j*   ",
+"  D-9Oy*9$Bz>q%qx%%u;x;;dknX+d>Zm:hhSDjr    ",
+"  a3o+>S3z#90@@z.%>qCC%uu;ff%@Zm:NhMoj=     ",
+"  wlvvo#:3599$>B>q>%%%%+f;fk$ymaalMvjr      ",
+"  0.a--S49mct9$z@.qkkqC;xu%@Zm5AlvSj*       ",
+"  ohu%3:Z:9@y609q@@>..>Cx>$Zm5NhMvjr        ",
+"   -j797Zv5705y=#$0>>V.%>#Z378AMMj*         ",
+"     Zj9Xo-McBXDv%90.%%#9cc78AsMj*          ",
+"      8hM#M-DSF96cvz0>z#c35Nhs6j1           ",
+"        jl9#o63vx#-D###mmt8N66j*            ",
+"         5jc@fZF3o%+ZFDm<8A6FjO             ",
+"           :j50sSay<$ss2Nh:FjO              ",
+"            6880&SDMF.rNNFFj1               ",
+"              8jr#:SFScA6ajO                ",
+"                Alr$DSysajO                 ",
+"                 >jy#51:jO                  ",
+"                  %Dy*gjO                   ",
+"                    alla                    "};
diff --git a/examples/modeller.xpm b/examples/modeller.xpm
new file mode 100644 (file)
index 0000000..62e27f9
--- /dev/null
@@ -0,0 +1,117 @@
+/* XPM */
+static char * InterfaceModeller_app_2_Tile_xpm[] = {
+"48 48 66 1",
+"      c None",
+".     c #86174D344103",
+"X     c #69A651445144",
+"o     c #8617410330C2",
+"O     c #69A6410338E3",
+"+     c #30C218611861",
+"@     c #AEBA6DB66185",
+"#     c #71C638E328A2",
+"$     c #69A634D328A2",
+"%     c #30C228A228A2",
+"&     c #79E73CF330C2",
+"*     c #BEFB9E799E79",
+"=     c #8E3869A66185",
+"-     c #514424921861",
+";     c #A699A289B6DA",
+":     c #A6999E79A699",
+">     c #71C65D756185",
+",     c #9E799A69A699",
+"<     c #8E3882078E38",
+"1     c #861779E78617",
+"2     c #A6999A69AEBA",
+"3     c #8E388A289658",
+"4     c #71C675D679E7",
+"5     c #96588A289E79",
+"6     c #30C230C238E3",
+"7     c #C71BC71BC71B",
+"8     c #9E79A289AEBA",
+"9     c #AEBAAAAABEFB",
+"0     c #96589248A699",
+"q     c #A699AAAAB6DA",
+"w     c #AEBAAAAAB6DA",
+"e     c #D75CD34CD75C",
+"r     c #EFBEE79DEFBE",
+"t     c #BEFBB6DABEFB",
+"y     c #B6DABAEAC71B",
+"u     c #AEBAAEBAB6DA",
+"i     c #E79DDB6CDF7D",
+"p     c #96588E389658",
+"a     c #596559656185",
+"s     c #AEBA8E388E38",
+"d     c #CF3CCB2BCF3C",
+"f     c #9E799A699E79",
+"g     c #86177DF78E38",
+"h     c #69A6659571C6",
+"j     c #AEBAAEBABEFB",
+"k     c #96589E799E79",
+"l     c #B6DAA699A699",
+"z     c #E79DC71BC71B",
+"x     c #B6DAB6DAB6DA",
+"c     c #861786179658",
+"v     c #B6DAB2CABEFB",
+"b     c #BEFBAAAAAEBA",
+"n     c #C71BBEFBC71B",
+"m     c #514441034103",
+"M     c #41033CF34103",
+"N     c #492428A228A2",
+"B     c #AEBAA289B6DA",
+"V     c #618530C22081",
+"C     c #69A630C228A2",
+"Z     c #69A630C22081",
+"A     c #596528A22081",
+"S     c #492428A22081",
+"D     c #618528A22081",
+"F     c #596520811861",
+"G     c #69A628A22081",
+"H     c #FFFF14514103",
+"                                            .X  ",
+"                                           .oO+ ",
+"                                         @.o#++ ",
+"                                        @.o$%+  ",
+"                                       @.&#++   ",
+"                                      @.o#++    ",
+"                                     @.o$++     ",
+"                                    @.&#++      ",
+"                                    .O#++       ",
+"                                  *=-$++        ",
+"                                 ;:>+++         ",
+"                                ;,<1%           ",
+"                               2,34             ",
+"                             2;,51              ",
+"                            2,,,,6              ",
+"           7777            28888,6              ",
+"         77777777        2829,,,06              ",
+"    9qwwe7rrrrr77rr     828,9tyt,6              ",
+" uuwriirrieiiieii77pa< 82,8,,,8,06              ",
+" s=1ttiieeeeded77eufgh>j,8,8,k,0,6              ",
+" =@lzieeeeee77eeex:fpcg4>9,,,,qjv6              ",
+" =O=blt7eeee7deenw:ffp<gha:t979;06              ",
+" =OO@=@zieeee7ex:::fffff0,v72444h6              ",
+" =OOo&Osst7iee7wkf:f:ff;t721444ham              ",
+" =#&&&&OO@di7eu:ff:fferiv114444hmMX             ",
+" =O&&&..o.sdp33fff:errrii7cc1hhh6mmNX=          ",
+" =O&&&@.o.@sberrrrrriiuxuxnB;44aMmVCO#OX        ",
+" =O&&o@..o.zrrrie777nnxtuxx:x;n:>mV##&&O$mX     ",
+" =O&&o....zrrieieuxunx7txx:nnfwpMmVZ#$ZZZVVN    ",
+" =O&oooo.*rrde77ewxnxxtnw:f4M%M%+NA#$Z$ZZVmN>   ",
+" =Oo&ooo@iree7inxn7nnuuff4h%M>m%S-AZ$CCZDZmSX   ",
+" =O&o.o.@rrn7eulun7xxuwp4mm6ahM%--AZCCZDDDANX   ",
+" =Ooooo.*rixenuwwn7nxupph%M>>h6mAADVVZVVDDANX   ",
+" =O&o.o.zrexwwnwuxxnughX%mahhmMN-AZCCVVDDAAN>   ",
+" *XOoo.*iin7n777xxxtphaM+ama>MSNFVCZZVVDAAAS>   ",
+"   1O..izewxux7nuuux4%++%hha>%N-DDCZZVDAAAASX   ",
+"    1.=ituu:uButnxxuX%>hh>M%++NADZZZVDADAA--X   ",
+"     :e7f::lnn7*ppnx6ahm6++mNN-ADCZVDDAAAA-SX   ",
+"     7nupp:wxxg%MMau6%++NmmmADADVVVVVDAA---NX   ",
+"    7uBgh1wwxg6h>m%:MmmVNAVDZVZCVZZDAAAAF-S+X   ",
+"    nfgaM%pnwhX6%mXb6$DVVZC$C#C$ZZDVAAA---+NX   ",
+"   27a%MaM47:mN.OoolmODGZ####$$ZZVDDA-----SSX   ",
+"   2gmg<m6p7wmmOo...O$GZ####$$CZVVDAAA----++X   ",
+"  qBcaM  <gxgmXmo.@.o&$$##$$$CZZZDADA-A-++-NX   ",
+"   M6>    paMa HX.@@@oZ$###$$CZVDDAAAA---SS+X   ",
+"  43            p=&@@&&$##$CCCVVVAAA--+S+S+%X   ",
+"        k         =o@.##$VVmmmNNNSSSSSS%XXXX    ",
+"                   s>OSSNmN>>aaa177777          "};
diff --git a/examples/test.xpm b/examples/test.xpm
new file mode 100644 (file)
index 0000000..9b0d2ef
--- /dev/null
@@ -0,0 +1,92 @@
+/* XPM */
+static char *openfile[] = {
+/* width height num_colors chars_per_pixel */
+"    20    19       66            2",
+/* colors */
+".. c None",
+".# c #000000",
+".a c #dfdfdf",
+".b c #7f7f7f",
+".c c #006f6f",
+".d c #00efef",
+".e c #009f9f",
+".f c #004040",
+".g c #00bfbf",
+".h c #ff0000",
+".i c #ffffff",
+".j c #7f0000",
+".k c #007070",
+".l c #00ffff",
+".m c #00a0a0",
+".n c #004f4f",
+".o c #00cfcf",
+".p c #8f8f8f",
+".q c #6f6f6f",
+".r c #a0a0a0",
+".s c #7f7f00",
+".t c #007f7f",
+".u c #5f5f5f",
+".v c #707070",
+".w c #00f0f0",
+".x c #009090",
+".y c #ffff00",
+".z c #0000ff",
+".A c #00afaf",
+".B c #00d0d0",
+".C c #00dfdf",
+".D c #005f5f",
+".E c #00b0b0",
+".F c #001010",
+".G c #00c0c0",
+".H c #000f0f",
+".I c #00007f",
+".J c #005050",
+".K c #002f2f",
+".L c #dfcfcf",
+".M c #dfd0d0",
+".N c #006060",
+".O c #00e0e0",
+".P c #00ff00",
+".Q c #002020",
+".R c #dfc0c0",
+".S c #008080",
+".T c #001f1f",
+".U c #003f3f",
+".V c #007f00",
+".W c #00000f",
+".X c #000010",
+".Y c #00001f",
+".Z c #000020",
+".0 c #00002f",
+".1 c #000030",
+".2 c #00003f",
+".3 c #000040",
+".4 c #00004f",
+".5 c #000050",
+".6 c #00005f",
+".7 c #000060",
+".8 c #00006f",
+".9 c #000070",
+"#. c #7f7f80",
+"## c #9f9f9f",
+/* pixels */
+"........................................",
+"........................................",
+"........................................",
+".......................#.#.#............",
+".....................#.......#...#......",
+"...............................#.#......",
+".......#.#.#.................#.#.#......",
+".....#.y.i.y.#.#.#.#.#.#.#..............",
+".....#.i.y.i.y.i.y.i.y.i.#..............",
+".....#.y.i.y.i.y.i.y.i.y.#..............",
+".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....",
+".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......",
+".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........",
+".....#.y.#.s.s.s.s.s.s.s.s.s.#..........",
+".....#.#.s.s.s.s.s.s.s.s.s.#............",
+".....#.#.#.#.#.#.#.#.#.#.#..............",
+"........................................",
+"........................................",
+"........................................"
+};
diff --git a/examples/testgtk.lisp b/examples/testgtk.lisp
new file mode 100644 (file)
index 0000000..5193872
--- /dev/null
@@ -0,0 +1,3615 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: testgtk.lisp,v 1.1 2000/08/14 16:44:26 espen Exp $
+
+
+(use-package "GTK")
+
+(defmacro define-test-window (name title &body body)
+  `(let ((window nil))
+     (defun ,name ()
+       (unless window
+        (setq window (window-new :toplevel))
+        (signal-connect
+         window 'destroy #'(lambda () (widget-destroyed window)))
+        (setf (window-title window) ,title)
+        (setf (container-border-width window) 0)
+        ,@body)
+       
+       (if (not (widget-visible-p window))
+          (widget-show-all window)
+          (widget-destroy window)))))
+      
+
+(defmacro define-test-dialog (name title &body body)
+  `(let ((window nil))
+     (defun ,name ()
+       (unless window
+        (setq window (dialog-new))
+        (signal-connect
+         window 'destroy #'(lambda () (widget-destroyed window)))
+        (setf (window-title window) ,title)
+        (setf (container-border-width window) 0)
+        (let ((main-box (vbox-new nil 0))
+              (action-area (dialog-action-area window)))
+          (box-pack-start (dialog-vbox window) main-box t t 0)
+          ,@body))
+       
+       (if (not (widget-visible-p window))
+          (widget-show-all window)
+        (widget-destroy window)))))
+
+
+(defmacro define-standard-dialog (name title &body body)
+  `(define-test-dialog ,name ,title
+     (let ((close-button (button-new "close")))
+       (signal-connect close-button 'clicked #'widget-destroy :object window)
+       (setf (widget-can-default-p close-button) t)
+       (box-pack-start action-area close-button t t 0)
+       (widget-grab-default close-button)
+       ,@body)))
+
+
+(defun build-option-menu (items history)
+  (let ((option-menu (option-menu-new))
+       (menu (menu-new)))
+    (labels ((create-menu (items i group)
+              (when items
+                (let* ((item (first items))
+                       (menu-item (radio-menu-item-new group (first item))))
+                  (signal-connect
+                   menu-item 'activate
+                   #'(lambda ()
+                       (when (widget-mapped-p menu-item)
+                         (funcall (second item)))))
+                  
+                  (menu-append menu menu-item)
+                  (when (= i history)
+                    (setf (check-menu-item-active-p menu-item) t))
+                  (widget-show menu-item)
+                  (create-menu
+                   (rest items) (1+ i) (radio-menu-item-group menu-item))))))
+      (create-menu items 0 nil))
+    (setf (option-menu-menu option-menu) menu)
+    (setf (option-menu-history option-menu) history)
+    option-menu))
+
+
+
+;;; Pixmaps used in some of the tests
+
+(defvar gtk-mini-xpm
+  '("15 20 17 1"
+    "       c None"
+    ".      c #14121F"
+    "+      c #278828"
+    "@      c #9B3334"
+    "#      c #284C72"
+    "$      c #24692A"
+    "%      c #69282E"
+    "&      c #37C539"
+    "*      c #1D2F4D"
+    "=      c #6D7076"
+    "-      c #7D8482"
+    ";      c #E24A49"
+    ">      c #515357"
+    ",      c #9B9C9B"
+    "'      c #2FA232"
+    ")      c #3CE23D"
+    "!      c #3B6CCB"
+    "               "
+    "      ***>     "
+    "    >.*!!!*    "
+    "   ***....#*=  "
+    "  *!*.!!!**!!# "
+    " .!!#*!#*!!!!# "
+    " @%#!.##.*!!$& "
+    " @;%*!*.#!#')) "
+    " @;;@%!!*$&)'' "
+    " @%.%@%$'&)$+' "
+    " @;...@$'*'*)+ "
+    " @;%..@$+*.')$ "
+    " @;%%;;$+..$)# "
+    " @;%%;@$$$'.$# "
+    " %;@@;;$$+))&* "
+    "  %;;;@+$&)&*  "
+    "   %;;@'))+>   "
+    "    %;@'&#     "
+    "     >%$$      "
+    "      >=       "))
+
+(defvar book-closed-xpm
+  '("16 16 6 1"
+    "       c None s None"
+    ".      c black"
+    "X      c red"
+    "o      c yellow"
+    "O      c #808080"
+    "#      c white"
+    "                "
+    "       ..       "
+    "     ..XX.      "
+    "   ..XXXXX.     "
+    " ..XXXXXXXX.    "
+    ".ooXXXXXXXXX.   "
+    "..ooXXXXXXXXX.  "
+    ".X.ooXXXXXXXXX. "
+    ".XX.ooXXXXXX..  "
+    " .XX.ooXXX..#O  "
+    "  .XX.oo..##OO. "
+    "   .XX..##OO..  "
+    "    .X.#OO..    "
+    "     ..O..      "
+    "      ..        "
+    "                "))
+
+(defvar mini-page-xpm
+  '("16 16 4 1"
+    "       c None s None"
+    ".      c black"
+    "X      c white"
+    "o      c #808080"
+    "                "
+    "   .......      "
+    "   .XXXXX..     "
+    "   .XoooX.X.    "
+    "   .XXXXX....   "
+    "   .XooooXoo.o  "
+    "   .XXXXXXXX.o  "
+    "   .XooooooX.o  "
+    "   .XXXXXXXX.o  "
+    "   .XooooooX.o  "
+    "   .XXXXXXXX.o  "
+    "   .XooooooX.o  "
+    "   .XXXXXXXX.o  "
+    "   ..........o  "
+    "    oooooooooo  "
+    "                "))
+
+(defvar book-open-xpm
+  '("16 16 4 1"
+    "       c None s None"
+    ".      c black"
+    "X      c #808080"
+    "o      c white"
+    "                "
+    "  ..            "
+    " .Xo.    ...    "
+    " .Xoo. ..oo.    "
+    " .Xooo.Xooo...  "
+    " .Xooo.oooo.X.  "
+    " .Xooo.Xooo.X.  "
+    " .Xooo.oooo.X.  "
+    " .Xooo.Xooo.X.  "
+    " .Xooo.oooo.X.  "
+    "  .Xoo.Xoo..X.  "
+    "   .Xo.o..ooX.  "
+    "    .X..XXXXX.  "
+    "    ..X.......  "
+    "     ..         "
+    "                "))
+
+
+
+;;; Button box
+
+(defun create-bbox (class title spacing child-w child-h layout)
+  (let* ((frame (make-instance 'frame :title title))
+        (bbox (make-instance 'class
+               :border-width 5
+               :layout layout
+               :spacing spacing
+               :childrent
+               (list
+                (make-instance 'button :label "OK")
+                (make-instance 'button :label "Cancel")
+                (make-instance 'button :label "Help"))
+               :parent frame)))
+    (setf (button-box-child-size bbox) (vector child-w child-h))
+    frame))
+
+
+(define-test-window create-button-box "Button Boxes"
+  (setf (container-border-width window) 10)
+  (let ((main-box (vbox-new nil 0)))
+    (let ((frame (frame-new "Horizontal Button Boxes"))
+         (box (vbox-new nil 0)))
+      (container-add window main-box)
+      (box-pack-start main-box frame t t 10)
+      (setf (container-border-width box) 10)
+      (container-add frame box)
+      (box-pack-start
+       box (create-bbox #'hbutton-box-new "Spread" 40 85 20 :spread) t t 0)
+      (box-pack-start
+       box (create-bbox #'hbutton-box-new "Edge" 40 85 20 :edge) t t 0)
+      (box-pack-start
+       box (create-bbox #'hbutton-box-new "Start" 40 85 20 :start) t t 0)
+      (box-pack-start
+       box (create-bbox #'hbutton-box-new "End" 40 85 20 :end) t t 0))
+
+    (let ((frame (frame-new "Vertical Button Boxes"))
+         (box (hbox-new nil 0)))
+      (box-pack-start main-box frame t t 10)
+      (setf (container-border-width box) 10)
+      (container-add frame box)
+      (box-pack-start
+       box (create-bbox #'vbutton-box-new "Spread" 30 85 20 :spread) t t 5)
+      (box-pack-start
+       box (create-bbox #'vbutton-box-new "Edge" 30 85 20 :edge) t t 5)
+      (box-pack-start
+       box (create-bbox #'vbutton-box-new "Start" 30 85 20 :start) t t 5)
+      (box-pack-start
+       box (create-bbox #'vbutton-box-new "End" 30 85 20 :end) t t 5))))
+
+
+
+(define-standard-dialog create-buttons "Buttons"
+  (let ((table (table-new 3 3 nil))
+       (buttons `((,(button-new "button1") 0 1 0 1)
+                  (,(button-new "button2") 1 2 1 2)
+                  (,(button-new "button3") 2 3 2 3)
+                  (,(button-new "button4") 0 1 2 3)
+                  (,(button-new "button5") 2 3 0 1)
+                  (,(button-new "button6") 1 2 2 3)
+                  (,(button-new "button7") 1 2 0 1)
+                  (,(button-new "button8") 2 3 1 2)
+                  (,(button-new "button9") 0 1 1 2))))
+    (setf (table-row-spacings table) 5)
+    (setf (table-column-spacings table) 5)
+    (setf (container-border-width table) 10)
+    (box-pack-start main-box table t t 0)
+    (do ((tmp buttons (rest tmp)))
+       ((endp tmp))
+      (let ((button (first tmp))
+           (widget (or (first (second tmp))
+                       (first (first buttons)))))
+       (signal-connect (first button) 'clicked
+        #'(lambda ()
+            (if (widget-visible-p widget)
+                (widget-hide widget)
+              (widget-show widget))))
+       (apply #'table-attach table button)))))
+
+
+;; Calenadar
+
+(define-standard-dialog create-calendar "Calendar"
+  (setf (container-border-width main-box) 10)
+  (box-pack-start main-box (calendar-new) t t 0))
+
+
+
+;;; Check buttons
+
+(define-standard-dialog create-check-buttons "GtkCheckButton"
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 10)
+  (box-pack-start main-box (check-button-new "button1") t t 0)
+  (box-pack-start main-box (check-button-new "button2") t t 0)
+  (box-pack-start main-box (check-button-new "button3") t t 0))
+
+
+
+;;; CList
+
+(let ((style1 nil)
+      (style2 nil)
+      (style3 nil))
+  (defun insert-row-clist (clist)
+    (let* ((text '("This" "is" "an" "inserted" "row"
+                  "This" "is" "an" "inserted" "row"
+                  "This" "is" "an" "inserted" "row"
+                  "This" "is" "an" "inserted" "row"))
+          (row 
+           (if (clist-focus-row clist)
+               (clist-insert clist (clist-focus-row clist) text)
+             (clist-prepend clist text))))
+      
+      (unless style1
+       (let ((color1 '#(0 56000 0))
+             (color2 '#(32000 0 56000)))
+         (setq style1 (style-copy (widget-style clist)))
+         (setf
+          (style-base style1 :normal) color1
+          (style-base style1 :selected) color2)
+
+         (setq style2 (style-copy (widget-style clist)))
+         (setf
+          (style-fg style2 :normal) color1
+          (style-fg style2 :selected) color2)
+
+         (setq style3 (style-copy (widget-style clist)))
+         (setf
+          (style-fg style3 :normal) color1
+          (style-base style3 :normal) color2
+          (style-font style3) "-*-courier-medium-*-*-*-*-120-*-*-*-*-*-*")))
+
+      (setf (clist-cell-style clist row 3) style1)
+      (setf (clist-cell-style clist row 4) style2)
+      (setf (clist-cell-style clist row 0) style3))))
+
+
+(define-standard-dialog create-clist "clist"
+  (let* ((titles '("auto resize" "not resizeable" "max width 100"
+                  "min width 50" "hide column" "Title 5" "Title 6"
+                  "Title 7" "Title 8"  "Title 9"  "Title 10"
+                  "Title 11" "Title 12" "Title 13" "Title 14"
+                  "Title 15" "Title 16" "Title 17" "Title 18"
+                  "Title 19"))
+        (clist (clist-new titles))
+        (scrolled-window (scrolled-window-new nil nil)))
+
+    (setf (container-border-width scrolled-window) 5)
+    (setf (scrolled-window-scrollbar-policy scrolled-window) :automatic)
+    (container-add scrolled-window clist)
+
+    (signal-connect
+     clist 'click-column
+     #'(lambda (column)
+        (cond
+         ((= column 4)
+          (setf (clist-column-visible-p clist column) nil))
+         ((= column (clist-sort-column clist))
+          (if (eq (clist-sort-type clist) :ascending)
+              (setf (clist-sort-type clist) :descending)
+            (setf (clist-sort-type clist) :ascending)))
+         (t
+          (setf (clist-sort-column clist) column)))
+        (clist-sort clist)))
+
+    (let ((box2 (hbox-new nil 5)))
+      (setf (container-border-width box2) 5)
+      (box-pack-start main-box box2 nil nil 0)
+      
+      (let ((button (button-new "Insert Row")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked #'insert-row-clist :object clist))
+
+      (let ((button (button-new "Add 1,000 Rows With Pixmaps")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (multiple-value-bind (pixmap mask)
+                (gdk:pixmap-create gtk-mini-xpm)
+              (let ((texts (do ((i 4 (1+ i))
+                                (texts '(nil "Center" "Right")))
+                               ((= i (length titles)) (reverse texts))
+                             (push (format nil "Column ~D" i) texts))))
+                (clist-freeze clist)
+                (dotimes (i 1000)
+                  (let ((row
+                         (clist-append
+                          clist
+                          (cons (format nil "CListRow ~D" (random 1000))
+                                texts))))
+                    (clist-set-cell-pixtext
+                     clist row 3 "gtk+" 5 (list pixmap mask))))
+                (clist-thaw clist))))))
+
+      (let ((button (button-new "Add 10,000 Rows")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (let ((texts (do ((i 3 (1+ i))
+                              (texts '("Center" "Right")))
+                             ((= i (length titles)) (reverse texts))
+                           (push (format nil "Column ~D" i) texts))))
+              (clist-freeze clist)
+              (dotimes (i 10000)
+                (clist-append
+                 clist (cons (format nil "CListRow ~D" (random 1000)) texts)))
+              (clist-thaw clist))))))
+    
+
+    (let ((box2 (hbox-new nil 5)))
+      (setf (container-border-width box2) 5)
+      (box-pack-start main-box box2 nil nil 0)
+           
+      (let ((button (button-new "Clear List")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (clist-clear clist))))
+    
+      (let ((button (button-new "Remove Selection")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (clist-freeze clist)
+            (let ((selection-mode (clist-selection-mode clist)))
+              (labels ((remove-selection ()
+                         (let ((selection (clist-selection clist)))
+                           (when selection
+                             (clist-remove clist (first selection))
+                             (unless (eq selection-mode :browse)
+                               (remove-selection))))))
+                (remove-selection))
+            
+              (when (and
+                     (eq selection-mode :extended)
+                     (not (clist-selection clist))
+                     (clist-focus-row clist))
+                (clist-select-row clist (clist-focus-row clist))))
+            (clist-thaw clist))))
+
+      (let ((button (button-new "Undo Selection")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked #'clist-undo-selection :object clist))
+
+      (let ((button (button-new "Warning Test")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect button 'clicked #'(lambda ()))))
+    
+
+    (let ((box2 (hbox-new nil 5)))
+      (setf (container-border-width box2) 5)
+      (box-pack-start main-box box2 nil nil 0)
+      
+      (let ((button (check-button-new "Show Title Buttons")))
+       (box-pack-start box2 button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (if (toggle-button-active-p button)
+                (clist-column-titles-show clist)
+              (clist-column-titles-hide clist))))
+       (setf (toggle-button-active-p button) t))
+
+      (let ((button (check-button-new "Reorderable")))
+       (box-pack-start box2 button nil t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (setf
+             (clist-reorderable-p clist) (toggle-button-active-p button))))
+       (setf (toggle-button-active-p button) t))
+
+      (box-pack-start box2 (label-new "Selection Mode : ") nil t 0)      
+      (let ((option-menu
+            (build-option-menu
+             `(("Single"
+                ,#'(lambda () (setf (clist-selection-mode clist) :single)))
+               ("Browse"
+                ,#'(lambda () (setf (clist-selection-mode clist) :browse)))
+               ("Multiple"
+                ,#'(lambda () (setf (clist-selection-mode clist) :multiple)))
+               ("Extended"
+                ,#'(lambda () (setf (clist-selection-mode clist) :extended))))
+             3)))
+       (box-pack-start box2 option-menu nil t 0)))
+
+    (box-pack-start main-box scrolled-window t t 0)
+    (setf (clist-row-height clist) 18)
+    (setf (widget-height clist) 300)
+
+    (dotimes (i (length titles))
+      (setf (clist-column-width clist i) 80))
+
+    (setf (clist-column-auto-resize-p clist 0) t)
+    (setf (clist-column-resizeable-p clist 1) nil)
+    (setf (clist-column-max-width clist 2) 100)
+    (setf (clist-column-min-width clist 3) 50)
+    (setf (clist-selection-mode clist) :extended)
+    (setf (clist-column-justification clist 1) :right)
+    (setf (clist-column-justification clist 2) :center)
+
+    (let ((style (style-new))
+         (texts (do ((i 3 (1+ i))
+                     (texts '("Center" "Right")))
+                    ((= i (length titles)) (reverse texts))
+                    (push (format nil "Column ~D" i) texts))))
+       (setf
+        (style-font style) "-adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*"
+       (style-fg style :normal) '#(56000 0 0)
+       (style-base style :normal) '#(0 56000 32000))
+      
+      (dotimes (i 10)
+        (clist-append clist (cons (format nil "CListRow ~D" i) texts))
+       (if (= (mod i 4) 2)
+           (setf (clist-row-style clist i) style)
+         (setf (clist-cell-style clist i (mod i 4)) style))))))
+
+
+
+;;; Color selection
+
+(let ((color-dialog nil))
+  (defun create-color-selection ()
+    (unless color-dialog
+      (setq color-dialog
+           (color-selection-dialog-new "color selection dialog"))
+
+      (setf (window-position color-dialog) :mouse)
+      (signal-connect
+       color-dialog 'destroy #'(lambda () (widget-destroyed color-dialog)))
+      
+      (let ((colorsel (color-selection-dialog-colorsel color-dialog)))
+       (setf (color-selection-use-opacity-p colorsel) t)
+       (setf (color-selection-policy colorsel) :continuous)
+       
+;      (signal-connect colorsel 'color-changed #'(lambda () nil))
+
+       (let ((button (color-selection-dialog-ok-button color-dialog)))
+         (signal-connect
+          button 'clicked
+          #'(lambda ()
+              (let ((color (color-selection-color colorsel)))
+                (format t "Selected color: ~A~%" color)
+                (setf (color-selection-color colorsel) color))))))
+
+      (let ((button (color-selection-dialog-cancel-button color-dialog)))
+       (signal-connect
+        button 'clicked #'widget-destroy :object color-dialog)))
+       
+    (if (not (widget-visible-p color-dialog))
+       (widget-show-all color-dialog)
+      (widget-destroy color-dialog))))
+
+
+
+;;; CTree
+
+(let ((total-pages 0)
+      (total-books 0)
+      (status-labels)
+      (style1)
+      (style2)
+      (pixmap1)
+      (pixmap2)
+      (pixmap3))
+
+  (defun after-press (ctree &rest data)
+    (declare (ignore data))
+    (setf
+     (label-text (svref status-labels 0))
+     (format nil "~D" total-books))
+    (setf
+     (label-text (svref status-labels 1))
+     (format nil "~D" total-pages))
+    (setf
+     (label-text (svref status-labels 2))
+     (format nil "~D" (length (clist-selection ctree))))
+    (setf
+     (label-text (svref status-labels 3))
+     (format nil "~D" (clist-n-rows ctree)))
+    nil)
+    
+  (defun build-recursive (ctree parent current-depth depth books pages)
+    (let ((sibling nil))
+      (do ((i (+ pages books) (1- i)))
+         ((= i books))
+       (declare (fixnum i))
+       (incf total-pages)
+       (setq
+        sibling
+        (ctree-insert-node
+         ctree parent sibling
+         (list
+          (format nil "Page ~D" (random 100))
+          (format nil "Item ~D-~D" current-depth i))
+         5 :pixmap pixmap3 :leaf t))
+       (when (and parent (eq (ctree-line-style ctree) :tabbed))
+         (setf
+          (ctree-row-style ctree sibling)
+          (ctree-row-style ctree parent))))
+      
+      (unless (= current-depth depth)
+       (do ((i books (1- i)))
+           ((zerop i))
+         (incf total-books)
+         (setq
+          sibling
+          (ctree-insert-node
+           ctree parent sibling
+           (list
+            (format nil "Book ~D" (random 100))
+            (format nil "Item ~D-~D" current-depth i))
+           5 :closed pixmap1 :opened pixmap2))
+
+         (let ((style (style-new))
+               (color (case (mod current-depth 3)
+                        (0 (vector
+                            (* 10000 (mod current-depth 6))
+                            0
+                            (- 65535 (mod (* i 10000) 65535))))
+                        (1 (vector
+                            (* 10000 (mod current-depth 6))
+                            (- 65535 (mod (* i 10000) 65535))
+                            0))
+                        (t (vector
+                            (- 65535 (mod (* i 10000) 65535))
+                            0
+                            (* 10000 (mod current-depth 6)))))))
+           (setf (style-base style :normal) color)
+           (ctree-set-node-data ctree sibling style #'style-unref)
+           
+           (when (eq (ctree-line-style ctree) :tabbed)
+             (setf (ctree-row-style ctree sibling) style)))
+
+         (build-recursive
+          ctree sibling (1+ current-depth)  depth books pages)))))
+
+  (defun rebuild-tree (ctree depth books pages)
+    (let ((n (* (/ (1- (expt books depth)) (1- books)) (1+ pages))))
+      (if (> n 10000)
+         (format t "~D total items? Try less~%" n)
+       (progn
+         (clist-freeze ctree)
+         (clist-clear ctree)
+         (setq total-books 1)
+         (setq total-pages 0)
+         (let ((parent
+                (ctree-insert-node
+                 ctree nil nil '("Root") 5
+                 :closed pixmap1 :opened pixmap2 :expanded t))
+               (style (style-new)))
+           (setf (style-base style :normal) '#(0 45000 55000))
+           (ctree-set-node-data ctree parent style #'style-unref)
+           
+           (when (eq (ctree-line-style ctree) :tabbed)
+             (setf (ctree-row-style ctree parent) style))
+
+           (build-recursive ctree parent 1 depth books pages)
+           (clist-thaw ctree)
+           (after-press ctree))))))
+
+  (let ((export-window)
+       (export-ctree))
+    (defun export-tree (ctree)
+      (unless export-window
+       (setq export-window (window-new :toplevel))
+       (signal-connect
+        export-window 'destroy
+        #'(lambda ()
+            (widget-destroyed export-window)))
+       
+       (setf (window-title export-window) "Exported ctree")
+       (setf (container-border-width export-window) 5)
+
+       (let ((vbox (vbox-new nil 0)))
+         (container-add export-window vbox)
+
+         (let ((button (button-new "Close")))
+           (box-pack-end vbox button nil t 0)
+           (signal-connect
+            button 'clicked #'widget-destroy :object export-window))
+
+         (box-pack-end vbox (hseparator-new) nil t 10)
+
+         (setq export-ctree (ctree-new '("Tree" "Info")))
+         (setf (ctree-line-style export-ctree) :dotted)
+
+         (let ((scrolled-window (scrolled-window-new)))
+           (container-add scrolled-window export-ctree)
+           (setf
+            (scrolled-window-scrollbar-policy scrolled-window) :automatic)
+           (box-pack vbox scrolled-window)
+           (setf (clist-selection-mode export-ctree) :extended)
+           (setf (clist-column-width export-ctree 0) 200)
+           (setf (clist-column-width export-ctree 1) 200)
+           (setf (widget-width export-ctree) 300)
+           (setf (widget-height export-ctree) 200))))
+
+      (unless (widget-visible-p export-window)
+       (widget-show-all export-window))
+
+      (clist-clear export-ctree)
+      (let ((node (ctree-nth-node ctree (clist-focus-row ctree))))
+       (when node
+         (let ((tree-list
+                (list (ctree-map-to-list ctree node #'(lambda (node) node)))))
+           (ctree-insert-from-list
+            export-ctree nil tree-list
+            #'(lambda (export-ctree-node ctree-node)
+                (multiple-value-bind
+                    (text spacing pixmap-closed bitmap-closed pixmap-opened
+                     bitmap-opened leaf expanded)
+                    (ctree-node-info ctree ctree-node)
+                  (ctree-set-node-info
+                   export-ctree export-ctree-node text spacing
+                   :closed (list pixmap-closed bitmap-closed)
+                   :opened (list pixmap-opened bitmap-opened)
+                   :leaf leaf :expanded expanded))
+                (unless (eq (ctree-cell-type ctree ctree-node 1) :empty)
+                  (setf
+                   (ctree-cell-text export-ctree export-ctree-node 1)
+                   (ctree-cell-text ctree ctree-node 1))))))))))
+  
+
+  (define-test-window create-ctree "CTree"
+    (let ((vbox (vbox-new nil 0))
+         (ctree (ctree-new '("Tree" "Info"))))
+
+      (container-add window vbox)
+
+      (let ((hbox (hbox-new nil 5)))
+       (setf (container-border-width hbox) 5)
+       (box-pack-start vbox hbox nil t 0)
+
+       (let ((spin1 (spin-button-new (adjustment-new 4 1 10 1 5 0) 0 0))
+             (spin2 (spin-button-new (adjustment-new 3 1 20 1 5 0) 0 0))
+             (spin3 (spin-button-new (adjustment-new 5 1 20 1 5 0) 0 0)))
+
+         (box-pack-start hbox (label-new "Depth :") nil t 0)
+         (box-pack-start hbox spin1 nil t 5)
+         (box-pack-start hbox (label-new "Books :") nil t 0)
+         (box-pack-start hbox spin2 nil t 5)
+         (box-pack-start hbox (label-new "Pages :") nil t 0)
+         (box-pack-start hbox spin3 nil t 5)
+         
+         (let ((button (button-new "Rebuild Tree")))
+           (box-pack-start hbox button t t 0)
+           (signal-connect
+            button 'clicked
+            #'(lambda ()
+                (let ((depth (spin-button-value-as-int spin1))
+                      (books (spin-button-value-as-int spin2))
+                      (pages (spin-button-value-as-int spin3)))
+                  (rebuild-tree ctree depth books pages))))))
+       
+       (let ((button (button-new "Close")))
+         (box-pack-end hbox button t t 0)
+         (signal-connect button 'clicked #'widget-destroy :object window)))
+    
+      (let ((scrolled-window (scrolled-window-new)))
+       (setf (container-border-width scrolled-window) 5)
+       (setf (scrolled-window-hscrollbar-policy scrolled-window) :automatic)
+       (setf (scrolled-window-vscrollbar-policy scrolled-window) :always)
+       (box-pack-start vbox scrolled-window t t 0)
+       
+       (container-add scrolled-window ctree)
+       (setf (clist-column-auto-resize-p ctree 0) t)
+       (setf (clist-column-width ctree 1) 200)
+       (setf (clist-selection-mode ctree) :extended)
+       (setf (ctree-line-style ctree) :dotted))
+
+      (signal-connect
+       ctree 'click-column
+       #'(lambda (column)
+          (cond
+           ((/= column (clist-sort-column ctree))
+            (setf (clist-sort-column ctree) column))
+           ((eq (clist-sort-type ctree) :ascending)
+            (setf (clist-sort-type ctree) :descending))
+           (t (setf (clist-sort-type ctree) :ascending)))
+          (ctree-sort-recursive ctree)))
+
+      (signal-connect
+       ctree 'button-press-event #'after-press :object t :after t)
+      (signal-connect
+       ctree 'button-release-event #'after-press :object t :after t)
+      (signal-connect
+       ctree 'tree-move #'after-press :object t :after t)
+      (signal-connect
+       ctree 'end-selection #'after-press :object t :after t)
+      (signal-connect
+       ctree 'toggle-focus-row #'after-press :object t :after t)
+      (signal-connect
+       ctree 'select-all #'after-press :object t :after t)
+      (signal-connect
+       ctree 'unselect-all #'after-press :object t :after t)
+      (signal-connect
+       ctree 'scroll-vertical #'after-press :object t :after t)
+
+      (let ((bbox (hbox-new nil 5)))
+       (setf (container-border-width bbox) 5)
+       (box-pack-start vbox bbox nil t 0)
+
+       (let ((mbox (vbox-new t 5)))
+         (box-pack bbox mbox :expand nil)
+         (box-pack mbox (label-new "Row Height :") :expand nil :fill nil)
+         (box-pack mbox (label-new "Indent :") :expand nil :fill nil)
+         (box-pack mbox (label-new "Spacing :") :expand nil :fill nil))
+
+       (let ((mbox (vbox-new t 5)))
+         (box-pack bbox mbox :expand nil)
+         
+         (let* ((adjustment (adjustment-new 20 12 100 1 10 0))
+                (spinner (spin-button-new adjustment 0 0)))
+           (box-pack mbox spinner :expand nil :fill nil :padding 5)
+           (flet ((set-row-height ()
+                    (setf
+                     (clist-row-height ctree)
+                     (spin-button-value-as-int spinner))))
+             (signal-connect adjustment 'value-changed #'set-row-height)
+             (set-row-height)))
+         
+         (let* ((adjustment (adjustment-new 20 0 60 1 10 0))
+                (spinner (spin-button-new adjustment 0 0)))
+           (box-pack mbox spinner :expand nil :fill nil :padding 5)
+           (flet ((set-indent ()
+                    (setf
+                     (ctree-indent ctree)
+                     (spin-button-value-as-int spinner))))
+             (signal-connect adjustment 'value-changed #'set-indent)
+             (set-indent)))
+
+         (let* ((adjustment (adjustment-new 5 0 60 1 10 0))
+                (spinner (spin-button-new adjustment 0 0)))
+           (box-pack mbox spinner :expand nil :fill nil :padding 5)
+           (flet ((set-spacing ()
+                    (setf
+                     (ctree-spacing ctree)
+                     (spin-button-value-as-int spinner))))
+             (signal-connect adjustment 'value-changed #'set-spacing)
+             (set-spacing))))
+
+       
+       (let ((mbox (vbox-new t 5)))
+         (box-pack bbox mbox :expand nil)
+         
+         (let ((hbox (hbox-new nil 5)))
+           (box-pack mbox hbox :expand nil :fill nil)
+
+           (let ((button (button-new "Expand All")))
+             (box-pack hbox button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (ctree-expand-recursive ctree nil)
+                  (after-press ctree))))
+
+           (let ((button (button-new "Collapse All")))
+             (box-pack hbox button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (ctree-collapse-recursive ctree nil)
+                  (after-press ctree))))
+
+           (let ((button (button-new "Change Style")))
+             (box-pack hbox button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (let ((node (ctree-nth-node
+                               ctree (or (clist-focus-row ctree) 0))))
+                    (when node
+                      (unless style1
+                        (let ((color1 '#(0 56000 0))
+                              (color2 '#(32000 0 56000)))
+                          (setq style1 (style-new))
+                          (setf (style-base style1 :normal) color1)
+                          (setf (style-fg style1 :selected) color2)
+
+                          (setq style2 (style-new))
+                          (setf (style-base style2 :selected) color2)
+                          (setf (style-base style2 :normal) color2)
+                          (setf (style-fg style2 :normal) color1)
+                          (setf
+                           (style-font style2)
+                           "-*-courier-medium-*-*-*-*-300-*-*-*-*-*-*")))
+                      (setf (ctree-cell-style ctree node 1) style1)
+                      (setf (ctree-cell-style ctree node 0) style2)
+
+                      (when (ctree-node-child node)
+                        (setf
+                         (ctree-row-style ctree (ctree-node-child node))
+                         style2)))))))
+
+           (let ((button (button-new "Export Tree")))
+             (box-pack hbox button)
+             (signal-connect button 'clicked #'export-tree :object ctree)))
+
+         (let ((hbox (hbox-new nil 5)))
+           (box-pack mbox hbox :expand nil :fill nil)
+
+           (let ((button (button-new "Select All")))
+             (box-pack hbox button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (ctree-select-recursive ctree nil)
+                  (after-press ctree))))
+
+           (let ((button (button-new "Unselect All")))
+             (box-pack hbox button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (ctree-unselect-recursive ctree nil)
+                  (after-press ctree))))
+
+           (let ((button (button-new "Remove Selection")))
+             (box-pack hbox button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (clist-freeze ctree)
+                  (let ((selection-mode (clist-selection-mode ctree)))
+                    (labels
+                        ((remove-selection ()
+                           (let ((node (first (ctree-selection ctree))))
+                             (when node
+                               
+                               (ctree-apply-post-recursive
+                                ctree node
+                                #'(lambda (node)
+                                    (if (ctree-node-leaf-p node)
+                                        (decf total-pages)
+                                      (decf total-books))))
+                                  
+                               (ctree-remove-node ctree node)
+                               (unless (eq selection-mode :browse)
+                                 (remove-selection))))))
+                      (remove-selection))
+            
+                    (when (and
+                           (eq selection-mode :extended)
+                           (not (clist-selection ctree))
+                           (clist-focus-row ctree))
+                      (ctree-select
+                       ctree
+                       (ctree-nth-node ctree (clist-focus-row ctree)))))
+                  (clist-thaw ctree)
+                  (after-press ctree))))
+           
+           (let ((button (check-button-new "Reorderable")))
+             (box-pack hbox button :expand nil)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (setf
+                   (clist-reorderable-p ctree)
+                   (toggle-button-active-p button))))
+             (setf (toggle-button-active-p button) t)))
+
+         (let ((hbox (hbox-new nil 5)))
+           (box-pack mbox hbox :expand nil :fill nil)
+
+           (flet
+               ((set-line-style (line-style)
+                  (let ((current-line-style (ctree-line-style ctree)))
+                    (when (or
+                           (and
+                            (eq current-line-style :tabbed)
+                            (not (eq line-style :tabbed)))
+                           (and
+                            (not (eq current-line-style :tabbed))
+                            (eq line-style :tabbed)))
+                      (ctree-apply-pre-recursive
+                       ctree nil
+                       #'(lambda (node)
+                           (let
+                               ((style
+                                 (cond
+                                  ((eq (ctree-line-style ctree) :tabbed) nil)
+                                  ((not (ctree-node-leaf-p node))
+                                   (ctree-node-data ctree node))
+                                  ((ctree-node-parent node)
+                                   (ctree-node-data
+                                    ctree (ctree-node-parent node))))))
+                             (setf (ctree-row-style ctree node) style))))
+                      (setf (ctree-line-style ctree) line-style)))))
+             
+             (let ((option-menu
+                    (build-option-menu
+                     `(("No lines" ,#'(lambda () (set-line-style :none)))
+                       ("Solid" ,#'(lambda () (set-line-style :solid)))
+                       ("Dotted" ,#'(lambda () (set-line-style :dotted)))
+                       ("Tabbed" ,#'(lambda () (set-line-style :tabbed))))
+                     2)))
+               (box-pack hbox option-menu :expand nil)))
+
+           (let ((option-menu
+                  (build-option-menu
+                   `(("None"
+                      ,#'(lambda ()
+                           (setf (ctree-expander-style ctree) :none)))
+                     ("Square"
+                      ,#'(lambda ()
+                           (setf (ctree-expander-style ctree) :square)))
+                     ("Triangle"
+                      ,#'(lambda ()
+                           (setf (ctree-expander-style ctree) :triangle)))
+                     ("Circular"
+                      ,#'(lambda ()
+                           (setf (ctree-expander-style ctree) :circular))))
+                   1)))
+             (box-pack hbox option-menu :expand nil))
+
+           (let ((option-menu
+                  (build-option-menu
+                   `(("Left"
+                      ,#'(lambda ()
+                           (setf
+                            (clist-column-justification ctree 0) :left)))
+                     ("Right"
+                      ,#'(lambda ()
+                           (setf
+                            (clist-column-justification ctree 0) :right))))
+                   0)))
+             (box-pack hbox option-menu :expand nil))
+
+           (flet ((set-sel-mode (mode)
+                    (setf (clist-selection-mode ctree) mode)
+                    (after-press ctree)))
+             (let ((option-menu
+                    (build-option-menu
+                     `(("Single" ,#'(lambda () (set-sel-mode :single)))
+                       ("Browse" ,#'(lambda () (set-sel-mode :browse)))
+                       ("Multiple" ,#'(lambda () (set-sel-mode :multiple)))
+                       ("Extended" ,#'(lambda () (set-sel-mode :extended))))
+                     3)))
+               (box-pack hbox option-menu :expand nil))))))
+
+      (let ((frame (frame-new)))
+       (setf (container-border-width frame) 0)
+       (setf (frame-shadow-type frame) :out)
+       (box-pack vbox frame :expand nil)
+
+       (let ((hbox (hbox-new t 2)))
+         (setf (container-border-width hbox) 2)
+         (container-add frame hbox)
+
+         (setq
+          status-labels
+          (map 'vector
+           #'(lambda (text)
+               (let ((frame (frame-new))
+                     (hbox2 (hbox-new nil 0)))
+                 (setf (frame-shadow-type frame) :in)
+                 (box-pack hbox frame :expand nil)
+                 (setf (container-border-width hbox2) 2)
+                 (container-add frame hbox2)
+                 (box-pack hbox2 (label-new text) :expand nil)
+                 (let ((label (label-new "")))
+                   (box-pack-end hbox2 label nil t 5)
+                   label)))
+           '("Books :" "Pages :" "Selected :" "Visible :")))))
+      
+      (widget-realize window)
+      (let ((gdk:window (widget-window window)))
+       (setq pixmap1 (multiple-value-list
+                      (gdk:pixmap-create book-closed-xpm :window gdk:window)))
+       (setq pixmap2 (multiple-value-list
+                      (gdk:pixmap-create book-open-xpm :window gdk:window)))
+       (setq pixmap3 (multiple-value-list
+                      (gdk:pixmap-create mini-page-xpm :window gdk:window))))
+      (setf (widget-height ctree) 300)
+      
+      (rebuild-tree ctree 4 3 5))))
+
+
+
+;;; Cursors
+
+(defun clamp (n min-val max-val)
+  (declare (number n min-val max-val))
+  (max (min n max-val) min-val))
+
+(defun set-cursor (spinner drawing-area label)
+  (let ((cursor
+        (gforeign:int-enum
+         (logand (clamp (spin-button-value-as-int spinner) 0 152) #xFE)
+         'gdk:cursor-type)))   
+    (setf (label-text label) (string-downcase (symbol-name cursor)))
+    (setf (widget-cursor drawing-area) cursor)))
+    
+
+(define-standard-dialog create-cursors "Cursors"
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 5)
+  (let* ((hbox (hbox-new nil 0))
+        (label (label-new "Cursor Value : "))
+        (adj (adjustment-new 0 0 152 2 10 0))
+        (spinner (spin-button-new adj 0 0)))
+    (setf (container-border-width hbox) 5)
+    (box-pack-start main-box hbox nil t 0)
+    (setf (misc-xalign label) 0)
+    (setf (misc-yalign label) 0.5)
+    (box-pack-start hbox label nil t 0)
+    (box-pack-start hbox spinner t t 0)
+
+    (let ((frame (make-frame
+                 :shadow-type :etched-in
+                 :label-xalign 0.5
+                 :label "Cursor Area"
+                 :border-width 10
+                 :parent main-box
+                 :visible t))
+         (drawing-area (drawing-area-new)))
+      (setf (widget-width drawing-area) 80)
+      (setf (widget-height drawing-area) 80)
+      (container-add frame drawing-area)
+      (signal-connect
+       drawing-area 'expose-event
+       #'(lambda (event)
+          (declare (ignore event))
+          (multiple-value-bind (width height)
+              (drawing-area-size drawing-area)
+            (let* ((drawable (widget-window drawing-area))
+                   (style (widget-style drawing-area))
+                   (white-gc (style-get-gc style :white))
+                   (gray-gc (style-get-gc style :background :normal))
+                   (black-gc (style-get-gc style :black)))
+              (gdk:draw-rectangle
+               drawable white-gc t 0 0 width (floor height 2))
+              (gdk:draw-rectangle
+               drawable black-gc t 0 (floor height 2) width (floor height 2))
+              (gdk:draw-rectangle
+               drawable gray-gc t (floor width 3) (floor height 3)
+               (floor width 3) (floor height 3))))
+            t))
+      (setf (widget-events drawing-area) '(:exposure :button-press))
+      (signal-connect
+       drawing-area 'button-press-event
+       #'(lambda (event)
+          (when (and
+                 (eq (gdk:event-type event) :button-press)
+                 (or
+                  (= (gdk:event-button event) 1)
+                  (= (gdk:event-button event) 3)))
+            (spin-button-spin
+             spinner
+             (if (= (gdk:event-button event) 1)
+                 :step-forward
+               :step-backward)
+             0)
+            t)))
+      (widget-show drawing-area)
+
+    (let ((label (make-label
+                 :visible t
+                 :label "XXX"
+                 :parent main-box)))
+      (setf (box-child-expand-p #|main-box|# label) nil)
+      (signal-connect
+       spinner 'changed
+       #'(lambda ()
+          (set-cursor spinner drawing-area label)))
+
+      (widget-realize drawing-area)
+      (set-cursor spinner drawing-area label)))))
+
+
+
+;;; Dialog
+
+(define-test-dialog create-dialog "Dialog"
+  (setf (widget-width window) 200)
+  (setf (widget-height window) 110)
+      
+  (let ((button (button-new "OK")))
+    (signal-connect button 'clicked #'(lambda () (widget-destroy window)))
+    (setf (widget-can-default-p button) t)
+    (box-pack-start action-area button t t 0)
+    (widget-grab-default button)
+    (widget-show button))
+  
+  (let ((button (button-new "Toggle"))
+       (label nil))
+    (signal-connect
+     button 'clicked
+     #'(lambda ()
+        (if (not label)
+            (progn
+              (setq label (label-new "Dialog Test"))
+              (signal-connect label 'destroy #'widget-destroy :object label)
+              (setf (misc-xpad label) 10)
+              (setf (misc-ypad label) 10)
+              (box-pack-start main-box label t t 0)
+              (widget-show label))
+          (progn
+            (widget-destroy label)
+            (setq label nil)))))
+    (setf (widget-can-default-p button) t)
+    (box-pack-start action-area button t t 0)
+    (widget-grab-default button)
+    (widget-show button)))
+
+
+
+;; Entry
+
+(define-standard-dialog create-entry "Entry"
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 10)
+  (let ((entry (make-instance 'entry
+               :test "hello world"
+               :visible t
+               :parent (list main-box :fill t :expand t))))
+    (entry-select-region entry 0 5)
+
+    (let ((combo (make-instance 'combo
+                 :visible t
+                 :parent (list main-box :expand t :fill t))))
+      (setf
+       (combo-popdown-strings combo)
+       '("item0"
+        "item1 item1"
+        "item2 item2 item2"
+        "item3 item3 item3 item3"
+        "item4 item4 item4 item4 item4"
+        "item5 item5 item5 item5 item5 item5"
+        "item6 item6 item6 item6 item6"
+        "item7 item7 item7 item7"
+        "item8 item8 item8"
+        "item9 item9"))
+      (editable-select-region entry 0 5))
+    
+    (let ((check-button (check-button-new "Editable")))
+      (box-pack-start main-box check-button nil t 0)
+      (signal-connect
+       check-button 'toggled
+       #'(lambda ()
+          (setf
+           (editable-editable-p entry)
+           (toggle-button-active-p check-button))))
+      (setf (toggle-button-active-p check-button) t)
+      (widget-show check-button))
+                   
+    (let ((check-button (check-button-new "Visible")))
+      (box-pack-start main-box check-button nil t 0)
+      (signal-connect
+       check-button 'toggled
+       #'(lambda ()
+          (setf
+           (entry-visible-p entry)
+           (toggle-button-active-p check-button))))
+      (setf (toggle-button-active-p check-button) t)
+      (widget-show check-button))
+                   
+    (let ((check-button (check-button-new "Sensitive")))
+      (box-pack-start main-box check-button nil t 0)
+      (signal-connect
+       check-button 'toggled
+       #'(lambda ()
+          (setf
+           (widget-sensitive-p entry)
+           (toggle-button-active-p check-button))))
+      (setf (toggle-button-active-p check-button) t)
+      (widget-show check-button))))
+
+
+
+;; File selecetion dialog
+
+(let ((filesel nil))
+  (defun create-file-selection ()
+    (unless filesel
+      (setq filesel (file-selection-new "file selection dialog"))
+      (file-selection-hide-fileop-buttons filesel)
+      (setf (window-position filesel) :mouse)
+      (signal-connect
+       filesel 'destroy #'(lambda () (widget-destroyed filesel)))
+      (signal-connect
+       (file-selection-ok-button filesel) 'clicked
+       #'(lambda ()
+          (format
+           t "Selected file: ~A~%" (file-selection-filename filesel))
+          (widget-destroy filesel)))
+      (signal-connect
+       (file-selection-cancel-button filesel) 'clicked
+       #'widget-destroy :object filesel)
+
+      (let ((button (button-new "Hide Fileops")))
+       (signal-connect
+        button 'clicked
+        #'file-selection-hide-fileop-buttons :object filesel)
+       (box-pack-start (file-selection-action-area filesel) button nil nil 0)
+       (widget-show button))
+
+      (let ((button (button-new "Show Fileops")))
+       (signal-connect
+        button 'clicked
+        #'file-selection-show-fileop-buttons :object filesel)
+       (box-pack-start (file-selection-action-area filesel) button nil nil 0)
+       (widget-show button)))
+
+    (if (not (widget-visible-p filesel))
+       (widget-show-all filesel)
+      (widget-destroy filesel))))
+
+
+
+;;; Handle box
+
+(defun create-handle-box-toolbar ()
+  (let ((toolbar (toolbar-new :horizontal :both)))
+    (toolbar-append-item
+     toolbar "Horizontal" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Horizontal toolbar layout"
+     :callback #'(lambda () (setf (toolbar-orientation toolbar) :horizontal)))
+
+    (toolbar-append-item
+     toolbar "Vertical" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Vertical toolbar layout"
+     :callback #'(lambda () (setf (toolbar-orientation toolbar) :vertical)))
+
+    (toolbar-append-space toolbar)
+    
+    (toolbar-append-item
+     toolbar "Icons" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Only show toolbar icons"
+     :callback #'(lambda () (setf (toolbar-style toolbar) :icons)))
+    
+    (toolbar-append-item
+     toolbar "Text" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Only show toolbar text"
+     :callback #'(lambda () (setf (toolbar-style toolbar) :text)))
+  
+    (toolbar-append-item
+     toolbar "Both" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Show toolbar icons and text"
+     :callback #'(lambda () (setf (toolbar-style toolbar) :both)))
+
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-item
+     toolbar "Small" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Use small spaces"
+     :callback #'(lambda () (setf (toolbar-space-size toolbar) 5)))
+    
+    (toolbar-append-item
+     toolbar "Big" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Use big spaces"
+     :callback #'(lambda () (setf (toolbar-space-size toolbar) 10)))
+    
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-item
+     toolbar "Enable" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Enable tooltips"
+     :callback #'(lambda () (toolbar-enable-tooltips toolbar)))
+
+    (toolbar-append-item
+     toolbar "Disable" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Disable tooltips"
+     :callback #'(lambda () (toolbar-disable-tooltips toolbar)))
+
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-item
+     toolbar "Borders" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Show borders"
+     :callback #'(lambda () (setf (toolbar-relief toolbar) :normal)))
+    
+    (toolbar-append-item
+     toolbar "Borderless" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Hide borders"
+     :callback #'(lambda () (setf (toolbar-relief toolbar) :none)))
+
+    toolbar))
+
+
+(defun handle-box-child-signal (handle-box child action)
+  (format t "~S: child ~S ~A~%" handle-box child action))
+
+
+(define-test-window create-handle-box "Handle Box Test"
+  (setf (window-allow-grow-p window) t)
+  (setf (window-allow-shrink-p window) t)
+  (setf (window-auto-shrink-p window) nil)
+  (setf (container-border-width window) 20)
+  (let ((vbox (vbox-new nil 0)))
+    (container-add window vbox)
+
+    (container-add vbox (label-new "Above"))
+    (container-add vbox (hseparator-new))
+
+    (let ((hbox (hbox-new nil 10)))
+      (container-add vbox hbox)
+      
+      (let ((handle-box (handle-box-new)))
+       (box-pack-start hbox handle-box nil nil 0)
+       (signal-connect
+        handle-box 'child-attached
+        #'(lambda (child)
+            (handle-box-child-signal handle-box child "attached")))
+       (signal-connect
+        handle-box 'child-detached
+        #'(lambda (child)
+            (handle-box-child-signal handle-box child "detached")))
+       (container-add handle-box (create-handle-box-toolbar)))
+
+      (let ((handle-box (handle-box-new)))
+       (box-pack-start hbox handle-box nil nil 0)
+       (signal-connect
+        handle-box 'child-attached
+        #'(lambda (child)
+            (handle-box-child-signal handle-box child "attached")))
+       (signal-connect
+        handle-box 'child-detached
+        #'(lambda (child)
+            (handle-box-child-signal handle-box child "detached")))
+
+       (let ((handle-box2 (handle-box-new)))
+         (container-add handle-box handle-box2)
+         (signal-connect
+          handle-box2 'child-attached
+          #'(lambda (child)
+              (handle-box-child-signal handle-box child "attached")))
+         (signal-connect
+          handle-box2 'child-detached
+          #'(lambda (child)
+              (handle-box-child-signal handle-box child "detached")))
+         (container-add handle-box2 (label-new "Foo!")))))
+    
+    (container-add vbox (hseparator-new))
+    (container-add vbox (label-new "Below"))))
+
+
+
+;;; Labels
+      
+(define-test-window create-labels "Labels"
+  (setf (container-border-width window) 5)
+  (let ((hbox (hbox-new nil 5)))
+    (container-add window hbox)
+    (let ((vbox (vbox-new nil 5)))
+      (box-pack-start hbox vbox nil nil 0)
+
+      (let ((frame (frame-new  "Normal Label")))
+       (container-add frame (label-new "This is a Normal label"))
+       (box-pack-start vbox frame nil nil 0))
+
+      (let ((frame (frame-new  "Multi-line Label")))
+       (container-add frame (label-new
+"This is a Multi-line label.
+Second line
+Third line"))
+       (box-pack-start vbox frame nil nil 0))
+
+      (let ((frame (frame-new  "Left Justified Label"))
+           (label (label-new
+"This is a Left-Justified
+Multi-line.
+Third line")))
+       (setf (label-justify label) :left)
+       (container-add frame label)
+       (box-pack-start vbox frame nil nil 0))
+
+      (let ((frame (frame-new  "Right Justified Label"))
+           (label (label-new
+"This is a Right-Justified
+Multi-line.
+Third line")))
+       (setf (label-justify label) :right)
+       (container-add frame label)
+       (box-pack-start vbox frame nil nil 0)))
+
+    (let ((vbox (vbox-new nil 5)))
+      (box-pack-start hbox vbox nil nil 0)
+    
+      (let ((frame (frame-new  "Line wrapped label"))
+           (label (label-new
+"This is an example of a line-wrapped label.  It should not be taking up the entire             width allocated to it, but automatically wraps the words to fit.  The time has come, for all good men, to come to the aid of their party.  The sixth sheik's six sheep's sick.
+     It supports multiple paragraphs correctly, and  correctly   adds many          extra  spaces. ")))
+       (setf (label-wrap-p label) t)
+       (container-add frame label)
+       (box-pack-start vbox frame nil nil 0))
+      
+      (let ((frame (frame-new  "Filled, wrapped label"))
+           (label (label-new
+"This is an example of a line-wrapped, filled label.  It should be taking up the entire              width allocated to it.  Here is a seneance to prove my point.  Here is another sentence. Here comes the sun, do de do de do.
+    This is a new paragraph.
+    This is another newer, longer, better paragraph.  It is coming to an end, unfortunately.")))
+       (setf (label-justify label) :fill)
+       (setf (label-wrap-p label) t)
+       (container-add frame label)
+       (box-pack-start vbox frame nil nil 0))
+       
+      (let ((frame (frame-new  "Underlined label"))
+           (label (label-new
+"This label is underlined!
+This one is underlined in ÆüËܸì¤ÎÆþÍÑquite a funky fashion")))
+       (setf (label-justify label) :left)
+       (setf (label-pattern label) "_________________________ _ _________ _ _____ _ __ __  ___ ____ _____")
+       (container-add frame label)
+       (box-pack-start vbox frame nil nil 0)))))
+
+
+
+;;; Layout
+
+(defun layout-expose-handler (layout event)
+  (multiple-value-bind (x-offset y-offset)
+      (layout-offset layout)
+    (declare (fixnum x-offset y-offset))
+    (multiple-value-bind (area-x area-y area-width area-height)
+       (gdk:event-area event)
+      (declare (fixnum area-x area-y area-width area-height))
+      (let ((imin (truncate (+ x-offset area-x) 10))
+           (imax (truncate (+ x-offset area-x area-width 9) 10))
+           (jmin (truncate (+ y-offset area-y) 10))
+           (jmax (truncate (+ y-offset area-y area-height 9) 10)))
+       (declare (fixnum imin imax jmin jmax))
+       (gdk:window-clear-area
+        (widget-window layout) area-x area-y area-width area-height)
+
+       (let ((window (layout-bin-window layout))
+             (gc (style-get-gc (widget-style layout) :black)))
+         (do ((i imin (1+ i)))
+             ((= i imax))
+           (declare (fixnum i))
+           (do ((j jmin (1+ j)))
+               ((= j jmax))
+             (declare (fixnum j))
+             (unless (zerop (mod (+ i j) 2))
+               (gdk:draw-rectangle
+                window gc t
+                (- (* 10 i) x-offset) (- (* 10 j) y-offset)
+                (1+ (mod i 10)) (1+ (mod j 10))))))))))
+  t)
+
+
+(define-test-window create-layout "Layout"
+  (setf (widget-width window) 200)
+  (setf (widget-height window) 200)
+  (let ((scrolled (scrolled-window-new))
+       (layout (layout-new)))
+    (container-add window scrolled)
+    (container-add scrolled layout)
+    (setf (adjustment-step-increment (layout-hadjustment layout)) 10.0)
+    (setf (adjustment-step-increment (layout-vadjustment layout)) 10.0)
+    (setf (widget-events layout) '(:exposure))
+    (signal-connect layout 'expose-event #'layout-expose-handler :object t)
+    (setf (layout-size layout) '#(1600 128000))
+
+    (dotimes (i 16)
+      (dotimes (j 16)
+       (let* ((text (format nil "Button ~D, ~D" i j))
+              (button (if (not (zerop (mod (+ i j) 2)))
+                          (button-new text)
+                        (label-new text))))
+         (layout-put layout button (* j 100) (* i 100)))))
+
+    (do ((i 16 (1+ i)))
+       ((= i 1280))
+      (declare (fixnum i))
+      (let* ((text (format nil "Button ~D, ~D" i 0))
+            (button (if (not (zerop (mod i 2)))
+                        (button-new text)
+                      (label-new text))))
+       (layout-put layout button 0 (* i 100))))))
+      
+
+
+;;; List    
+    
+(define-standard-dialog create-list "List"
+  (let ((scrolled-window (scrolled-window-new))
+        (list (list-new)))
+    (setf (container-border-width scrolled-window) 5)
+    (setf (scrolled-window-scrollbar-policy scrolled-window) :automatic)
+    (box-pack-start main-box scrolled-window t t 0)
+    (setf (widget-height scrolled-window) 300)
+
+    (setf (list-selection-mode list) :extended)
+    (scrolled-window-add-with-viewport scrolled-window list)
+    (setf
+     (container-focus-vadjustment list)
+     (scrolled-window-vadjustment scrolled-window))
+    (setf
+     (container-focus-hadjustment list)
+     (scrolled-window-hadjustment scrolled-window))
+    
+    (with-open-file (file "cl-gtk:src;gtktypes.lisp")
+      (labels ((read-file ()
+                (let ((line (read-line file nil nil)))
+                  (when line
+                    (container-add list (list-item-new line))
+                    (read-file)))))
+       (read-file)))
+
+    (let ((hbox (hbox-new t 5)))
+      (setf (container-border-width hbox) 5)
+      (box-pack-start main-box hbox nil t 0)
+
+      (let ((button (button-new "Insert Row"))
+           (i 0))
+       (box-pack-start hbox button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (let ((item
+                   (list-item-new (format nil "added item ~A" (incf i)))))
+              (widget-show item)
+              (container-add list item)))))
+       
+      (let ((button (button-new "Clear List")))
+       (box-pack-start hbox button t t 0)
+       (signal-connect
+        button 'clicked #'(lambda () (list-clear-items list 0 -1))))
+
+      (let ((button (button-new "Remove Selection")))
+       (box-pack-start hbox button t t 0)
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (let ((selection (list-selection list)))
+              (if (eq (list-selection-mode list) :extended)
+                  (let ((item (or
+                               (container-focus-child list)
+                               (first selection))))
+                    (when item
+                      (let* ((children (container-children list))
+                             (sel-row
+                              (or
+                               (find-if
+                                #'(lambda (item)
+                                    (eq (widget-state item) :selected))
+                                (member item children))
+                               (find-if
+                                #'(lambda (item)
+                                    (eq (widget-state item) :selected))
+                                (member item (reverse children))))))
+                        (list-remove-items list selection)
+                        (when sel-row
+                          (list-select-child list sel-row)))))
+                (list-remove-items list selection)))))
+       (box-pack-start hbox button t t 0)))
+
+    (let ((cbox (hbox-new nil 0)))
+      (box-pack-start main-box cbox nil t 0)
+
+      (let ((hbox (hbox-new nil 5))
+           (option-menu
+            (build-option-menu
+             `(("Single"
+                ,#'(lambda () (setf (list-selection-mode list) :single)))
+               ("Browse"
+                ,#'(lambda () (setf (list-selection-mode list) :browse)))
+               ("Multiple"
+                ,#'(lambda () (setf (list-selection-mode list) :multiple)))
+               ("Extended"
+                ,#'(lambda () (setf (list-selection-mode list) :extended))))
+             3)))
+
+       (setf (container-border-width hbox) 5)
+       (box-pack-start cbox hbox t nil 0)
+       (box-pack-start hbox (label-new "Selection Mode :") nil t 0)
+       (box-pack-start hbox option-menu nil t 0)))))
+
+
+
+;; Menus
+
+(defun create-menu (depth tearoff)
+  (unless (zerop depth)
+    (let ((menu (menu-new)))
+      (when tearoff
+       (let ((menuitem (tearoff-menu-item-new)))
+         (menu-append menu menuitem)
+         (widget-show menuitem)
+         ))
+      (let ((group nil))
+       (dotimes (i 5)
+         (let ((menuitem
+                (radio-menu-item-new
+                 group (format nil "item ~2D - ~D" depth (1+ i)))))
+           (setq group (radio-menu-item-group menuitem)) ; ough!
+           (unless (zerop (mod depth 2))
+           (setf (check-menu-item-toggle-indicator-p menuitem) t))
+           (menu-append menu menuitem)
+           (widget-show menuitem)
+           (when (= i 3)
+             (setf (widget-sensitive-p menuitem) nil))
+           (setf (menu-item-submenu menuitem) (create-menu (1- depth) t)))))
+      menu)))  
+
+
+(define-standard-dialog create-menus "Menus"
+  (setf (box-spacing main-box) 0)
+  (setf (container-border-width main-box) 0)
+  (widget-show main-box)
+  (let ((accel-group (accel-group-new))
+       (menubar (menu-bar-new)))
+    (accel-group-attach accel-group window)
+    (box-pack-start main-box menubar nil t 0)
+    (widget-show menubar)
+
+    (let ((menuitem (menu-item-new (format nil "test~%line2"))))
+      (setf (menu-item-submenu menuitem) (create-menu 2 t))
+      (menu-bar-append menubar menuitem)
+      (widget-show menuitem))
+
+    (let ((menuitem (menu-item-new "foo")))
+      (setf (menu-item-submenu menuitem) (create-menu 3 t))
+      (menu-bar-append menubar menuitem)
+      (widget-show menuitem))
+
+    (let ((menuitem (menu-item-new "bar")))
+      (setf (menu-item-submenu menuitem) (create-menu 4 t))
+      (menu-item-right-justify menuitem)
+      (menu-bar-append menubar menuitem)
+      (widget-show menuitem))
+
+    (let ((box2 (vbox-new nil 10))
+         (menu (create-menu 1 nil)))
+      (setf (container-border-width box2) 10)
+      (box-pack-start main-box box2 t t 0)
+      (widget-show box2)
+      
+      (setf (menu-accel-group menu) accel-group)
+
+      (let ((menuitem (check-menu-item-new "Accelerate Me")))
+       (menu-append menu menuitem)
+       (widget-show menuitem)
+        (widget-add-accelerator
+         menuitem 'activate accel-group "F1" 0 '(:visible :signal-visible)))
+    
+      (let ((menuitem (check-menu-item-new "Accelerator Locked")))
+       (menu-append menu menuitem)
+       (widget-show menuitem)
+        (widget-add-accelerator
+         menuitem 'activate accel-group "F2" 0 '(:visible :locked)))
+    
+      (let ((menuitem (check-menu-item-new "Accelerator Frozen")))
+       (menu-append menu menuitem)
+       (widget-show menuitem)
+        (widget-add-accelerator
+         menuitem 'activate accel-group "F2" 0 '(:visible))
+        (widget-add-accelerator
+         menuitem 'activate accel-group "F3" 0 '(:visible))
+        (widget-lock-accelerators menuitem))
+      
+      (let ((optionmenu (option-menu-new)))
+       (setf (option-menu-menu optionmenu) menu)
+       (setf (option-menu-history optionmenu) 3)
+       (box-pack-start box2 optionmenu t t 0)
+       (widget-show optionmenu)))))
+
+
+;;; Notebook
+
+(define-standard-dialog create-notebook "Notebook"
+  (multiple-value-bind (book-open book-open-mask)
+      (gdk:pixmap-create book-open-xpm)
+    (multiple-value-bind (book-closed book-closed-mask)
+       (gdk:pixmap-create book-closed-xpm)
+
+      (labels
+         ((create-pages (notebook i end)
+            (when (<= i end)
+              (let* ((title (format nil "Page ~D" i))
+                     (child (frame-new title))
+                     (vbox (vbox-new t 0))
+                     (hbox (hbox-new t 0)))
+                (setf (container-border-width child) 10)
+                (setf (container-border-width vbox) 10)
+                (container-add child vbox)
+                (box-pack-start vbox hbox nil t 5)
+                
+                (let ((button (check-button-new "Fill Tab")))
+                  (box-pack-start hbox button t t 5)
+                  (setf (toggle-button-active-p button) t)
+                  (signal-connect
+                   button 'toggled
+                   #'(lambda ()
+                       (multiple-value-bind (expand fill pack-type)
+                           (notebook-query-tab-label-packing notebook child)
+                         (declare (ignore fill))
+                         (notebook-set-tab-label-packing
+                          notebook child expand
+                          (toggle-button-active-p button) pack-type)))))
+                
+                (let ((button (check-button-new "Expand Tab")))
+                  (box-pack-start hbox button t t 5)
+                  (signal-connect
+                   button 'toggled
+                   #'(lambda ()
+                       (multiple-value-bind (expand fill pack-type)
+                           (notebook-query-tab-label-packing notebook child)
+                         (declare (ignore expand))
+                         (notebook-set-tab-label-packing
+                          notebook child (toggle-button-active-p button)
+                          fill pack-type)))))
+                
+                (let ((button (check-button-new "Pack end")))
+                  (box-pack-start hbox button t t 5)
+                  (signal-connect
+                   button 'toggled
+                   #'(lambda ()
+                       (multiple-value-bind (expand fill pack-type)
+                           (notebook-query-tab-label-packing notebook child)
+                         (declare (ignore pack-type))
+                         (notebook-set-tab-label-packing
+                          notebook child expand fill
+                          (if (toggle-button-active-p button)
+                              :end
+                            :start))))))
+
+                (let ((button (button-new "Hide Page")))
+                  (box-pack-start vbox button nil nil 5)
+                  (signal-connect
+                   button 'clicked #'(lambda () (widget-hide child))))
+
+                (widget-show-all child)
+                
+                (let ((label-box (hbox-new nil 0))
+                      (menu-box (hbox-new nil 0)))
+                  (box-pack-start
+                   label-box (pixmap-new (list book-closed book-closed-mask))
+                   nil t 0)
+                  (box-pack-start label-box (label-new title) nil t 0)
+                  (widget-show-all label-box)
+                  (box-pack-start
+                   menu-box (pixmap-new (list book-closed book-closed-mask))
+                   nil t 0)
+                  (box-pack-start menu-box (label-new title) nil t 0)
+                  (widget-show-all menu-box)
+                  (notebook-append-page notebook child label-box menu-box)))
+              
+              (create-pages notebook (1+ i) end))))
+
+       
+       (setf (container-border-width main-box) 0)
+       (setf (box-spacing main-box) 0)
+       
+       (let ((notebook (notebook-new)))
+         (signal-connect
+          notebook 'switch-page
+          #'(lambda (pointer page)
+              (declare (ignore pointer))
+              (let ((old-page (notebook-current-page-num notebook)))
+                (unless (eq page old-page)
+                  (setf
+                   (pixmap-pixmap
+                    (first
+                     (container-children
+                      (notebook-tab-label notebook page))))
+                   (list book-open book-open-mask))
+                  (setf
+                   (pixmap-pixmap
+                    (first
+                     (container-children
+                      (notebook-menu-label notebook page))))
+                   (list book-open book-open-mask))
+
+                  (when old-page
+                    (setf
+                     (pixmap-pixmap
+                      (first
+                       (container-children
+                        (notebook-tab-label notebook old-page))))
+                     (list book-closed book-closed-mask))
+                    (setf
+                     (pixmap-pixmap
+                      (first
+                       (container-children
+                        (notebook-menu-label notebook old-page))))
+                     (list book-closed book-closed-mask)))))))
+         
+         (setf (notebook-tab-pos notebook) :top)
+         (box-pack-start main-box notebook t t 0)
+         (setf (container-border-width notebook) 10)
+         
+         (widget-realize notebook)
+         (create-pages notebook 1 5)
+       
+         (box-pack-start main-box (hseparator-new) nil t 10)
+       
+         (let ((box2 (hbox-new nil 5)))
+           (setf (container-border-width box2) 10)
+           (box-pack-start main-box box2 nil t 0)
+         
+           (let ((button (check-button-new "popup menu")))
+             (box-pack-start box2 button t nil 0)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (if (toggle-button-active-p button)
+                      (notebook-popup-enable notebook)
+                    (notebook-popup-disable notebook)))))
+      
+           (let ((button (check-button-new "homogeneous tabs")))
+             (box-pack-start box2 button t nil 0)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (setf
+                   (notebook-homogeneous-p notebook)
+                   (toggle-button-active-p button))))))
+       
+         (let ((box2 (hbox-new nil 5)))
+           (setf (container-border-width box2) 10)
+           (box-pack-start main-box box2 nil t 0)
+         
+           (box-pack-start box2 (label-new "Notebook Style : ") nil t 0)
+         
+           (let* ((scrollable-p nil)
+                  (option-menu
+                   (build-option-menu
+                    `(("Standard"
+                       ,#'(lambda ()
+                            (setf (notebook-show-tabs-p notebook) t)
+                            (when scrollable-p
+                              (setq scrollable-p nil)
+                              (setf (notebook-scrollable-p notebook) nil)
+                              (dotimes (n 10)
+                                (notebook-remove-page notebook 5)))))
+                      ("No tabs"
+                      ,#'(lambda ()
+                           (setf (notebook-show-tabs-p notebook) nil)
+                           (when scrollable-p
+                             (setq scrollable-p nil)
+                             (setf (notebook-scrollable-p notebook) nil)
+                             (dotimes (n 10)
+                               (notebook-remove-page notebook 5)))))
+                      ("Scrollable"
+                      ,#'(lambda ()
+                           (unless scrollable-p
+                             (setq scrollable-p t)
+                             (setf (notebook-show-tabs-p notebook) t)
+                             (setf (notebook-scrollable-p notebook) t)
+                             (create-pages notebook 6 15)))))
+                    0)))
+             (box-pack-start box2 option-menu nil t 0))
+
+           (let ((button (button-new "Show all Pages")))
+             (box-pack-start box2 button nil t 0)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (container-foreach notebook #'widget-show)))))
+
+         (let ((box2 (hbox-new nil 5)))
+           (setf (container-border-width box2) 10)
+           (box-pack-start main-box box2 nil t 0)
+           
+           (let ((button (button-new "prev")))
+             (box-pack-start box2 button t t 0)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (notebook-prev-page notebook))))
+      
+           (let ((button (button-new "next")))
+             (box-pack-start box2 button t t 0)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (notebook-next-page notebook))))
+
+           (let ((button (button-new "rotate"))
+                 (tab-pos 2))
+             (box-pack-start box2 button t t 0)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (setq tab-pos (mod (1+ tab-pos) 4))
+                  (setf (notebook-tab-pos notebook) tab-pos))))))))))
+
+
+
+;;; Panes
+
+(defun toggle-resize (child)
+  (let* ((paned (widget-parent child))
+        (is-child1-p (eq child (paned-child1 paned))))
+    (multiple-value-bind (child resize shrink)
+       (if is-child1-p
+           (paned-child1 paned)
+         (paned-child2 paned))
+      (widget-ref child)
+      (container-remove paned child)
+      (if is-child1-p
+         (paned-pack1 paned child (not resize) shrink)
+       (paned-pack2 paned child (not resize) shrink))
+      (widget-unref child))))
+
+(defun toggle-shrink (child)
+  (let* ((paned (widget-parent child))
+        (is-child1-p (eq child (paned-child1 paned))))
+    (multiple-value-bind (child resize shrink)
+       (if is-child1-p
+           (paned-child1 paned)
+         (paned-child2 paned))
+      (widget-ref child)
+      (container-remove paned child)
+      (if is-child1-p
+         (paned-pack1 paned child resize (not shrink))
+       (paned-pack2 paned child resize (not shrink)))
+      (widget-unref child))))
+
+(defun create-pane-options (paned frame-label label1 label2)
+  (let ((frame (frame-new frame-label))
+       (table (table-new 3 2 t)))
+    (setf (container-border-width frame) 4)
+    (container-add frame table)
+
+    (table-attach table (label-new label1) 0 1 0 1)
+
+    (let ((check-button (check-button-new "Resize")))
+      (table-attach table check-button 0 1 1 2)
+      (signal-connect
+       check-button 'toggled #'toggle-resize :object (paned-child1 paned)))
+
+    (let ((check-button (check-button-new "Shrink")))
+      (table-attach table check-button 0 1 2 3)
+      (setf (toggle-button-active-p check-button) t)
+      (signal-connect
+       check-button 'toggled #'toggle-shrink :object (paned-child1 paned)))
+
+    (table-attach table (label-new label2) 1 2 0 1)
+
+    (let ((check-button (check-button-new "Resize")))
+      (table-attach table check-button 1 2 1 2)
+      (setf (toggle-button-active-p check-button) t)
+      (signal-connect
+       check-button 'toggled #'toggle-resize :object (paned-child2 paned)))
+
+    (let ((check-button (check-button-new "Shrink")))
+      (table-attach table check-button 1 2 2 3)
+      (setf (toggle-button-active-p check-button) t)
+      (signal-connect
+       check-button 'toggled #'toggle-shrink :object (paned-child2 paned)))
+
+    frame))
+
+(define-test-window create-panes "Panes"
+  (let ((vbox (vbox-new nil 0))
+       (vpaned (vpaned-new))
+       (hpaned (hpaned-new)))
+    (container-add window vbox)
+    (box-pack-start vbox vpaned t t 0)
+    (setf (container-border-width vpaned) 5)
+
+    (paned-add1 vpaned hpaned)
+
+    (let ((frame (frame-new nil)))
+      (setf (frame-shadow-type frame) :in)
+      (setf (widget-width frame) 60)
+      (setf (widget-height frame) 60)
+      (paned-add1 hpaned frame)
+      (container-add frame (button-new "Hi there")))
+
+    (let ((frame (frame-new nil)))
+      (setf (frame-shadow-type frame) :in)
+      (setf (widget-width frame) 80)
+      (setf (widget-height frame) 60)
+      (paned-add2 hpaned frame))
+
+    (let ((frame (frame-new nil)))
+      (setf (frame-shadow-type frame) :in)
+      (setf (widget-width frame) 80)
+      (setf (widget-height frame) 60)
+      (paned-add2 vpaned frame))
+
+    ;; Now create toggle buttons to control sizing
+
+    (box-pack-start
+     vbox (create-pane-options hpaned "Horizontal" "Left" "Right") nil nil 0)
+
+    (box-pack-start
+     vbox (create-pane-options vpaned "Vertical" "Top" "Bottom") nil nil 0)))
+  
+
+
+;;; Pixmap
+
+(define-standard-dialog create-pixmap "Pixmap"
+  (setf (container-border-width main-box) 10)
+  (let* ((button (button-new))
+        (hbox (hbox-new nil 0)))
+    (box-pack-start main-box button nil nil 0)
+    (container-add button hbox)
+    (setf (container-border-width hbox) 2)
+    (container-add hbox (pixmap-new "cl-gtk:src;test.xpm"))
+    (container-add hbox (label-new "Pixmap test"))))
+
+
+
+;;; Progress bar
+
+(define-standard-dialog create-progress-bar "Progress bar"
+  (setf (window-allow-grow-p window) nil)
+  (setf (window-allow-shrink-p window) nil)
+  (setf (window-auto-shrink-p window) t)
+  
+  (setf (container-border-width main-box) 10)
+
+  (let* ((pbar-adj (adjustment-new 0 1 300 0 0 0))
+        (pbar (progress-bar-new pbar-adj))
+        (user-label (label-new "")))
+  
+    (let ((frame (frame-new "Progress"))
+         (vbox (vbox-new nil 5)))
+      (box-pack-start main-box frame nil t 0)
+      (container-add frame vbox)
+      
+      (let ((timer (timeout-add
+                   100
+                   #'(lambda ()
+                       (let* ((value (adjustment-value pbar-adj))
+                              (new-value
+                               (if (= value (adjustment-upper pbar-adj))
+                                   (adjustment-lower pbar-adj)
+                                 (1+ value))))
+                         (setf (progress-value pbar) new-value))
+                       t))))
+       (signal-connect window 'destroy #'(lambda () (timeout-remove timer))))
+       
+      (signal-connect
+       pbar-adj 'value-changed
+       #'(lambda ()
+          (setf
+           (label-text user-label)
+           (if (progress-activity-mode-p pbar)
+               "???"
+             (format nil "~D" (round (* 100 (progress-percentage pbar))))))))
+
+      (setf (progress-format-string pbar) "%v from [%l,%u] (=%p%%)")
+      
+      (let ((align (alignment-new 0.5 0.5 0.0 0.0)))
+       (box-pack-start vbox align nil nil 0)
+       (container-add align pbar))
+      
+      (let ((hbox (hbox-new nil 5)))
+       (box-pack-start hbox (label-new "Label updated by user :") nil t 0)
+       (box-pack-start hbox user-label nil t 0)
+       
+       (let ((align (alignment-new 0.5 0.5 0.0 0.0)))
+         (box-pack-start vbox align nil nil 5)
+         (container-add align hbox))))
+    
+    (let ((frame (frame-new "Options"))
+         (vbox (vbox-new nil 5)))
+      (box-pack-start main-box frame nil t 0)
+      (container-add frame vbox)
+
+      (let ((table (table-new 7 2 nil)))
+       (box-pack-start vbox table nil t 0)
+
+       (let ((label (label-new "Orientation :")))
+         (setf (misc-xalign label) 0.0)
+         (setf (misc-yalign label) 0.5)
+         (table-attach table label 0 1 0 1 :x-padding 5 :y-padding 5))
+       
+       (let ((hbox (hbox-new nil 0)))
+         (box-pack-start
+          hbox
+          (build-option-menu
+           `(("Left-Right"
+              ,#'(lambda ()
+                   (setf (progress-bar-orientation pbar) :left-to-right)))
+             ("Right-Left"
+              ,#'(lambda ()
+                   (setf (progress-bar-orientation pbar) :right-to-left)))
+             ("Bottom-Top"
+              ,#'(lambda ()
+                   (setf (progress-bar-orientation pbar) :bottom-to-top)))
+             ("Top-Bottom"
+              ,#'(lambda ()
+                   (setf (progress-bar-orientation pbar) :top-to-bottom))))
+           0)
+          t t 0)
+         (table-attach table hbox 1 2 0 1 :x-padding 5 :y-padding 5))
+       
+       (let* ((button (check-button-new "Show text"))
+              (entry (entry-new))
+              (x-align-adj (adjustment-new 0.5 0.0 1.0 0.1 0.1 0.0))
+              (x-align-spin (spin-button-new x-align-adj 0 1))
+              (y-align-adj (adjustment-new 0.5 0.0 1.0 0.1 0.1 0.0))
+              (y-align-spin (spin-button-new y-align-adj 0 1)))
+              
+         (signal-connect
+          button 'clicked
+          #'(lambda ()
+              (let ((state (toggle-button-active-p button)))
+                (setf (progress-show-text-p pbar) state)
+                (setf (widget-sensitive-p entry) state)
+                (setf (widget-sensitive-p x-align-spin) state)
+                (setf (widget-sensitive-p y-align-spin) state))))
+         (table-attach table button 0 1 1 2 :x-padding 5 :y-padding 5)
+
+         (signal-connect
+          entry 'changed
+          #'(lambda ()
+              (setf
+               (progress-format-string pbar)
+               (entry-text entry))))     
+         (setf (entry-text entry) "%v from [%l,%u] (=%p%%)")
+         (setf (widget-width entry) 100)
+         (setf (widget-sensitive-p entry) nil)
+       
+         (let ((hbox (hbox-new nil 0)))
+           (box-pack-start hbox (label-new "Format : ") nil t 0)
+           (box-pack-start hbox entry t t 0)
+           (table-attach table hbox 1 2 1 2 :x-padding 5 :y-padding 5))
+
+         (let ((label (label-new "Text align :")))
+           (setf (misc-xalign label) 0.0)
+           (setf (misc-yalign label) 0.5)
+           (table-attach table label 0 1 2 3 :x-padding 5 :y-padding 5))
+
+         (flet ((adjust-align ()
+                  (setf
+                   (progress-text-xalign pbar)
+                   (spin-button-value x-align-spin))
+                  (setf
+                   (progress-text-yalign pbar)
+                   (spin-button-value y-align-spin))))
+           (signal-connect x-align-adj 'value-changed #'adjust-align)
+           (signal-connect y-align-adj 'value-changed #'adjust-align))
+         (setf (widget-sensitive-p x-align-spin) nil)
+         (setf (widget-sensitive-p y-align-spin) nil)
+         
+         (let ((hbox (hbox-new nil 0)))
+           (box-pack-start hbox (label-new "x :") nil t 5)
+           (box-pack-start hbox x-align-spin nil t 0)
+           (box-pack-start hbox (label-new "y :") nil t 5)
+           (box-pack-start hbox y-align-spin nil t 0)
+           (table-attach table hbox 1 2 2 3 :x-padding 5 :y-padding 5)))
+
+       (let ((label (label-new "Bar Style :")))
+         (setf (misc-xalign label) 0.0)
+         (setf (misc-yalign label) 0.5)
+         (table-attach table label 0 1 3 4 :x-padding 5 :y-padding 5))
+
+       (let* ((block-adj (adjustment-new 10 2 20 1 5 0))
+              (block-spin (spin-button-new block-adj 0 0)))
+         (let ((hbox (hbox-new nil 0)))
+           (box-pack-start
+            hbox
+            (build-option-menu
+             `(("Continuous"
+                ,#'(lambda ()
+                     (setf (progress-bar-style pbar) :continuous)
+                     (setf (widget-sensitive-p block-spin) nil)))
+               ("Discrete"
+                ,#'(lambda ()
+                     (setf (progress-bar-style pbar) :discrete)
+                     (setf (widget-sensitive-p block-spin) t))))
+             0)
+            t t 0)
+           (table-attach table hbox 1 2 3 4 :x-padding 5 :y-padding 5))
+       
+         (let ((label (label-new "Block count :")))
+           (setf (misc-xalign label) 0.0)
+           (setf (misc-yalign label) 0.5)
+           (table-attach table label 0 1 4 5 :x-padding 5 :y-padding 5))
+
+         (signal-connect
+          block-adj 'value-changed
+          #'(lambda ()
+              (setf (progress-percentage pbar) 0)
+              (setf
+               (progress-bar-discrete-blocks pbar)
+               (spin-button-value-as-int block-spin))))
+         (setf (widget-sensitive-p block-spin) nil)
+           
+         (let ((hbox (hbox-new nil 0)))
+           (box-pack-start hbox block-spin nil t 0)
+           (table-attach table hbox 1 2 4 5 :x-padding 5 :y-padding 5)))
+
+       (let* ((step-size-adj (adjustment-new 3 1 20 1 5 0))
+              (step-size-spin (spin-button-new step-size-adj 0 0))
+              (block-adj (adjustment-new 5 2 10 1 5 00))
+              (block-spin (spin-button-new block-adj 0 0)))
+       
+       (let ((button (check-button-new "Activity mode")))
+         (signal-connect
+          button 'clicked
+          #'(lambda ()
+              (let ((state (toggle-button-active-p button)))
+                (setf (progress-activity-mode-p pbar) state)
+                (setf (widget-sensitive-p step-size-spin) state)
+                (setf (widget-sensitive-p block-spin) state))))
+         (table-attach table button 0 1 5 6 :x-padding 5 :y-padding 5))
+
+       (signal-connect
+        step-size-adj 'value-changed
+        #'(lambda ()
+            (setf
+             (progress-bar-activity-step pbar)
+             (spin-button-value-as-int step-size-spin))))
+       (setf (widget-sensitive-p step-size-spin) nil)
+
+       (let ((hbox (hbox-new nil 0)))
+         (box-pack-start hbox (label-new "Step size : ") nil t 0)
+         (box-pack-start hbox step-size-spin nil t 0)
+         (table-attach table hbox 1 2 5 6 :x-padding 5 :y-padding 5))
+
+       (signal-connect
+        block-adj 'value-changed
+        #'(lambda ()
+            (setf
+             (progress-bar-activity-blocks pbar)
+             (spin-button-value-as-int block-spin))))
+       (setf (widget-sensitive-p block-spin) nil)
+
+       (let ((hbox (hbox-new nil 0)))
+         (box-pack-start hbox (label-new "Blocks :     ") nil t 0)
+         (box-pack-start hbox block-spin nil t 0)
+         (table-attach table hbox 1 2 6 7 :x-padding 5 :y-padding 5)))))))
+      
+
+
+;;; Radio buttons
+
+(define-standard-dialog create-radio-buttons "Radio buttons"
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 10)
+  (let* ((button1 (radio-button-new nil :label "button1"))
+        (button2 (radio-button-new
+                  (radio-button-group button1) :label "button2"))
+        (button3 (radio-button-new
+                  (radio-button-group button2) :label "button3")))
+    (box-pack-start main-box button1 t t 0)
+    (box-pack-start main-box button2 t t 0)
+    (setf (toggle-button-active-p button2) t)
+    (box-pack-start main-box button3 t t 0)))
+
+
+
+;;; Rangle controls
+
+(define-standard-dialog create-range-controls "Range controls"
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 10)
+  (let ((adjustment (adjustment-new 0.0 0.0 101.0 0.1 1.0 1.0)))
+
+    (let ((scale (hscale-new adjustment)))
+      (setf (widget-width scale) 150)
+      (setf (widget-height scale) 30)
+      (setf (range-update-policy scale) :delayed)
+      (setf (scale-digits scale) 1)
+      (setf (scale-draw-value-p scale) t)
+      (box-pack-start main-box scale t t 0))
+    
+    (let ((scrollbar (hscrollbar-new adjustment)))
+      (setf (range-update-policy scrollbar) :continuous)
+      (box-pack-start main-box scrollbar t t 0))))
+
+
+
+;;; Reparent test
+
+(define-standard-dialog create-reparent "reparent"
+  (let ((box2 (hbox-new nil 5))
+       (label (label-new "Hellow World")))
+    (setf (container-border-width box2) 10)
+    (box-pack-start main-box box2 t t 0)
+
+    (let ((frame (frame-new "Frame 1"))
+         (box3 (vbox-new nil 5))
+         (button (button-new "switch")))
+      (box-pack-start box2 frame t t 0)
+      
+      (setf (container-border-width box3) 5)
+      (container-add frame box3)
+      
+      (signal-connect
+       button 'clicked
+       #'(lambda ()
+          (widget-reparent label box3)))
+      (box-pack-start box3 button nil t 0)
+      
+      (box-pack-start box3 label nil t 0)
+      (signal-connect
+       label 'parent-set
+       #'(lambda (old-parent)
+          (declare (ignore old-parent)))))
+    
+    (let ((frame (frame-new "Frame 2"))
+         (box3 (vbox-new nil 5))
+         (button (button-new "switch")))
+      (box-pack-start box2 frame t t 0)
+       
+      (setf (container-border-width box3) 5)
+      (container-add frame box3)
+      
+      (signal-connect
+       button 'clicked
+       #'(lambda ()
+          (widget-reparent label box3)))
+      (box-pack-start box3 button nil t 0))))
+
+
+
+;;; Rulers
+
+(define-test-window create-rulers "rulers"
+  (setf (widget-width window) 300)
+  (setf (widget-height window) 300)
+  (setf (widget-events window) '(:pointer-motion :pointer-motion-hint))
+
+  (let ((table (table-new 2 2 nil)))
+    (container-add window table)
+    (widget-show table)
+
+    (let ((ruler (hruler-new)))
+      (setf (ruler-metric ruler) :centimeters)
+      (ruler-set-range ruler 100 0 0 20)
+      (signal-connect
+       window 'motion-notify-event
+       #'(lambda (event) (widget-event ruler event)))
+      (table-attach table ruler 1 2 0 1 :y-options '(:fill))
+      (widget-show ruler))
+
+    (let ((ruler (vruler-new)))
+      (ruler-set-range ruler 5 15 0 20)
+      (signal-connect
+       window 'motion-notify-event
+       #'(lambda (event) (widget-event ruler event)))
+      (table-attach table ruler 0 1 1 2 :x-options '(:fill))
+      (widget-show ruler))))
+
+
+
+;;; Scrolled window
+
+(define-standard-dialog create-scrolled-windows "Scrolled windows"
+  (let ((scrolled-window (scrolled-window-new nil nil)))
+    (setf (container-border-width scrolled-window) 10)
+    (setf (scrolled-window-scrollbar-policy scrolled-window) :automatic)
+    (box-pack-start main-box scrolled-window t t 0)
+
+    (let ((table (table-new 20 20 nil)))
+      (setf (table-row-spacings table) 10)
+      (setf (table-column-spacings table) 10)
+      (scrolled-window-add-with-viewport scrolled-window table)
+      (setf
+       (container-focus-vadjustment table)
+       (scrolled-window-vadjustment scrolled-window))
+      (setf
+       (container-focus-hadjustment table)
+       (scrolled-window-hadjustment scrolled-window))
+      
+      (dotimes (i 20)
+       (dotimes (j 20)
+         (let ((button
+                (toggle-button-new (format nil "button (~D,~D)~%" i j))))
+           (table-attach table button i (1+ i) j (1+ j)))))))
+  
+  (let ((button (button-new "remove")))
+    (signal-connect button 'clicked #'(lambda ()))
+    (setf (widget-can-default-p button) t)
+    (box-pack-start action-area button t t 0)
+    (widget-grab-default button))
+
+  (setf (window-default-height window) 300)
+  (setf (window-default-width window) 300))
+
+
+
+;;; Shapes
+
+(defun shape-create-icon (xpm-file x y px py window-type root-window)
+  (let ((window (window-new window-type))
+       (fixed (fixed-new)))
+    (setf (widget-width fixed) 100)
+    (setf (widget-height fixed) 100)
+    (container-add window fixed)
+    (widget-show fixed)
+    
+    (setf
+     (widget-events window)
+     (append
+      (widget-events window)
+      '(:button-motion :pointer-motion-hint :button-press)))
+    (widget-realize window)
+    
+    (multiple-value-bind (gdk-pixmap gdk-pixmap-mask)
+       (gdk:pixmap-create xpm-file)
+      (let ((pixmap (pixmap-new (list gdk-pixmap gdk-pixmap-mask)))
+           (x-offset 0)
+           (y-offset 0))
+       (declare (fixnum x-offset y-offset))
+       (fixed-put fixed pixmap px py)
+       (widget-show pixmap)
+       (widget-shape-combine-mask window gdk-pixmap-mask px py)
+       (signal-connect
+        window 'button-press-event
+        #'(lambda (event)
+            (when (eq (gdk:event-type event) :button-press)
+              (setq x-offset (truncate (gdk:event-x event)))
+              (setq y-offset (truncate (gdk:event-y event)))
+              (grab-add window)
+              (gdk:pointer-grab
+               (widget-window window) t
+               '(:button-release :button-motion :pointer-motion-hint)
+               nil nil 0))
+            t))
+
+       (signal-connect
+        window 'button-release-event
+        #'(lambda (event)
+            (declare (ignore event))
+            (grab-remove window)
+            (gdk:pointer-ungrab 0)
+            t))
+       
+       (signal-connect
+        window 'motion-notify-event
+        #'(lambda (event)
+            (declare (ignore event))
+            (multiple-value-bind (win xp yp mask)
+                (gdk:window-get-pointer root-window)
+              (declare (ignore mask win) (fixnum xp yp))
+              (widget-set-uposition
+               window :x (- xp x-offset) :y (- yp y-offset)))
+            t))))
+    
+    (widget-set-uposition window :x x :y y)
+    (widget-show window)
+    window))
+
+
+(let ((modeller nil)
+      (sheets nil)
+      (rings nil))
+  (defun create-shapes ()
+    (let ((root-window (gdk:get-root-window)))
+      (if (not modeller)
+         (progn
+           (setq
+            modeller
+            (shape-create-icon
+             "cl-gtk:src;Modeller.xpm"
+             440 140 0 0 :popup root-window))
+           (signal-connect
+            modeller 'destroy
+            #'(lambda () (widget-destroyed modeller))))
+       (widget-destroy modeller))
+
+      (if (not sheets)
+         (progn
+           (setq
+            sheets
+            (shape-create-icon
+             "cl-gtk:src;FilesQueue.xpm"
+             580 170 0 0 :popup root-window))
+           (signal-connect
+            sheets 'destroy
+            #'(lambda () (widget-destroyed sheets))))
+       (widget-destroy sheets))
+
+      (if (not rings)
+         (progn
+           (setq
+            rings
+            (shape-create-icon
+             "cl-gtk:src;3DRings.xpm"
+             460 270 25 25 :toplevel root-window))
+           (signal-connect
+            rings 'destroy
+            #'(lambda () (widget-destroyed rings))))
+       (widget-destroy rings)))))
+
+
+
+;;; Spin buttons
+
+(define-test-window create-spins "Spin buttons"
+  (let ((main-vbox (vbox-new nil 5)))
+    (setf (container-border-width main-vbox) 10)
+    (container-add window main-vbox)
+
+    (let ((frame (frame-new "Not accelerated"))
+         (vbox (vbox-new nil 0))
+         (hbox (hbox-new nil 0)))
+      (box-pack-start main-vbox frame t t 0)
+      (setf (container-border-width vbox) 5)
+      (container-add frame vbox)
+      (box-pack-start vbox hbox t t 5)
+
+      (let* ((vbox2 (vbox-new nil 0))
+            (label (label-new "Day :"))
+            (spinner (spin-button-new
+                      (adjustment-new 1 1 31 1 5 0) 0 0)))
+       (box-pack-start hbox vbox2 t t 5)
+       (setf (misc-xalign label) 0)
+       (setf (misc-yalign label) 0.5)
+       (box-pack-start vbox2 label nil t 0)
+       (setf (spin-button-wrap-p spinner) t)
+       (setf (spin-button-shadow-type spinner) :out)
+       (box-pack-start vbox2 spinner nil t 0))
+    
+      (let* ((vbox2 (vbox-new nil 0))
+            (label (label-new "Month :"))
+            (spinner (spin-button-new
+                      (adjustment-new 1 1 12 1 5 0) 0 0)))
+       (box-pack-start hbox vbox2 t t 5)
+       (setf (misc-xalign label) 0)
+       (setf (misc-yalign label) 0.5)
+       (box-pack-start vbox2 label nil t 0)
+       (setf (spin-button-wrap-p spinner) t)
+       (setf (spin-button-shadow-type spinner) :etched-in)
+       (box-pack-start vbox2 spinner nil t 0))
+
+      (let* ((vbox2 (vbox-new nil 0))
+            (label (label-new "Year :"))
+            (spinner (spin-button-new
+                      (adjustment-new 1998 0 2100 1 100 0) 0 0)))
+       (box-pack-start hbox vbox2 t t 5)
+       (setf (misc-xalign label) 0)
+       (setf (misc-yalign label) 0.5)
+       (box-pack-start vbox2 label nil t 0)
+       (setf (spin-button-wrap-p spinner) t)
+       (setf (spin-button-shadow-type spinner) :in)
+       (box-pack-start vbox2 spinner nil t 0)))
+
+    (let* ((frame (frame-new "Accelerated"))
+          (vbox (vbox-new nil 0))
+          (hbox (hbox-new nil 0))
+          (spinner1 (spin-button-new
+                     (adjustment-new 0 -10000 10000 0.5 100 0) 1.0 2))
+          (adj (adjustment-new 2 1 5 1 1 0))
+          (spinner2 (spin-button-new adj 1.0 0)))
+         
+      (box-pack-start main-vbox frame t t 0)
+      (setf (container-border-width vbox) 5)
+      (container-add frame vbox)
+      (box-pack-start vbox hbox nil t 5)
+
+      (let* ((vbox2 (vbox-new nil 0))
+            (label (label-new "Value :")))
+       (box-pack-start hbox vbox2 t t 5)
+       (setf (misc-xalign label) 0)
+       (setf (misc-yalign label) 0.5)
+       (box-pack-start vbox2 label nil t 0)
+       (setf (spin-button-wrap-p spinner1) t)
+       (setf (widget-width spinner1) 100)
+       (setf (widget-height spinner1) 0)
+       (box-pack-start vbox2 spinner1 nil t 0))
+
+      (let* ((vbox2 (vbox-new nil 0))
+            (label (label-new "Digits :")))
+       (box-pack-start hbox vbox2 t t 5)
+       (setf (misc-xalign label) 0)
+       (setf (misc-yalign label) 0.5)
+       (box-pack-start vbox2 label nil t 0)
+       (setf (spin-button-wrap-p spinner2) t)
+       (signal-connect adj 'value-changed
+                       #'(lambda ()
+                           (setf
+                            (spin-button-digits spinner1)
+                            (floor (spin-button-value spinner2)))))
+       (box-pack-start vbox2 spinner2 nil t 0))
+
+      (let ((button (check-button-new "Snap to 0.5-ticks")))
+       (signal-connect button 'clicked
+                       #'(lambda ()
+                           (setf
+                            (spin-button-snap-to-ticks-p spinner1)
+                            (toggle-button-active-p button))))
+       (box-pack-start vbox button t t 0)
+       (setf (toggle-button-active-p button) t))
+
+      (let ((button (check-button-new "Numeric only input mode")))
+       (signal-connect button 'clicked
+                       #'(lambda ()
+                           (setf
+                            (spin-button-numeric-p spinner1)
+                            (toggle-button-active-p button))))
+       (box-pack-start vbox button t t 0)
+       (setf (toggle-button-active-p button) t))
+
+      (let ((val-label (label-new "0"))
+           (hbox (hbox-new nil 0)))
+       (box-pack-start vbox hbox nil t 5)
+       (let ((button (button-new "Value as Int")))
+         (signal-connect
+          button 'clicked
+          #'(lambda ()
+              (setf
+               (label-text val-label)
+               (format nil "~D" (spin-button-value-as-int spinner1)))))
+         (box-pack-start hbox button t t 5))
+       
+       (let ((button (button-new "Value as Float")))
+         (signal-connect
+          button 'clicked
+          #'(lambda ()
+              (setf
+               (label-text val-label)
+               (format nil
+                       (format nil "~~,~DF" (spin-button-digits spinner1))
+                       (spin-button-value spinner1)))))
+         (box-pack-start hbox button t t 5))
+
+       (box-pack-start vbox val-label t t 0)))
+    
+    (let ((hbox (hbox-new nil 0))
+         (button (button-new "Close")))
+      (signal-connect button 'clicked #'(lambda () (widget-destroy window)))
+      (box-pack-start main-vbox hbox nil t 0)
+      (box-pack-start hbox button t t 5))))
+
+
+
+;;; Statusbar
+
+(define-test-window create-statusbar "Statusbar"
+  (let ((box1 (vbox-new nil 0)))
+    (container-add window box1)
+
+    (let ((box2 (vbox-new nil 10))
+         (statusbar (statusbar-new))
+         (statusbar-counter 0))
+      (setf (container-border-width box2) 10)
+      (box-pack-start box1 box2 t t 0)
+      (box-pack-end box1 statusbar t t 0)
+      (signal-connect
+       statusbar 'text-popped
+       #'(lambda (context-id text)
+          (declare (ignore context-id))
+          (format nil "Popped: ~A~%" text)))
+
+      (make-button
+       :label "push something"
+       :visible t
+       :parent box2
+       :signal (list
+                'clicked
+                #'(lambda ()
+                    (statusbar-push
+                     statusbar
+                     1
+                     (format nil "something ~D" (incf statusbar-counter))))))
+      
+      (make-button
+       :label "pop"
+       :visible t
+       :parent box2
+       :signal (list
+               'clicked
+               #'(lambda ()
+                   (statusbar-pop statusbar 1))
+               :after t))
+      
+      (make-button
+       :label "steal #4"
+       :visible t
+       :parent box2
+       :signal (list
+               'clicked
+               #'(lambda ()
+                   (statusbar-remove statusbar 1 4))
+               :after t))
+
+      (make-button :label "test contexts"
+                  :visible t
+                  :parent box2
+                  :signal (list 'clicked #'(lambda ()))))
+
+    (box-pack-start box1 (hseparator-new) nil t 0)
+
+    (let ((box2 (vbox-new nil 10)))
+      (setf (container-border-width box2) 10)
+      (box-pack-start box1 box2 nil t 0)
+
+      (let ((button (button-new "close")))
+       (signal-connect button 'clicked #'(lambda () (widget-destroy window)))
+       (box-pack-start box2 button t t 0)
+       (setf (widget-can-default-p button) t)
+       (widget-grab-default button)))))
+
+
+
+;;; Idle test
+
+(define-standard-dialog create-idle-test "Idle Test"
+  (let ((label (label-new "count: 0"))
+       (idle nil)
+       (count 0))
+    (declare (fixnum count))
+    (signal-connect
+     window 'destroy #'(lambda () (when idle (idle-remove idle))))
+    (setf (misc-xpad label) 10)
+    (setf (misc-ypad label) 10)
+    (box-pack-start main-box label t t 0)
+
+    (let* ((container (make-hbox :parent main-box :child label :visible t))
+          (frame (make-frame
+                  :border-width 5
+                  :label "Label Container"
+                  :visible t
+                  :parent main-box))
+          (box (make-vbox :visible t :parent frame)))
+      (make-check-button
+       :label "Resize-Parent"
+       :visible t
+       :parent box
+       :signal
+       (list
+       'clicked
+       #'(lambda ()
+           (setf (container-resize-mode container) :parent))))
+      
+      (make-check-button
+       :label "Resize-Queue"
+       :visible t
+       :parent box
+       :signal
+       (list
+       'clicked
+       #'(lambda ()
+           (setf (container-resize-mode container) :queue))))
+      
+      (make-check-button
+       :label "Resize-Immediate"
+       :visible t
+       :parent box
+       :signal
+       (list
+       'clicked
+       #'(lambda ()
+           (setf (container-resize-mode container) :immediate)))))
+
+    (let ((button (button-new "start")))
+      (signal-connect
+       button 'clicked
+       #'(lambda ()
+       (unless idle
+        (setq
+         idle
+         (idle-add
+          #'(lambda ()
+              (incf count)
+              (setf (label-text label) (format nil "count: ~D" count))
+              t))))))
+      (setf (widget-can-default-p button) t)
+      (box-pack-start action-area button t t 0)
+      (widget-show button))
+      
+    (let ((button (button-new "stop")))
+      (signal-connect
+       button 'clicked
+       #'(lambda ()
+       (when idle
+        (idle-remove idle)
+        (setq idle nil))))
+      (setf (widget-can-default-p button) t)
+      (box-pack-start action-area button t t 0)
+      (widget-show button))))
+    
+
+
+;;; Timeout test
+
+(define-standard-dialog create-timeout-test "Timeout Test"
+  (let ((label (label-new "count: 0"))
+       (timer nil)
+       (count 0))
+    (declare (fixnum count))
+    (signal-connect
+     window 'destroy #'(lambda () (when timer (timeout-remove timer))))
+      
+    (setf (misc-xpad label) 10)
+    (setf (misc-ypad label) 10)
+    (box-pack-start main-box label t t 0)
+    (widget-show label)
+      
+    (let ((button (button-new "start")))
+      (signal-connect
+       button 'clicked
+       #'(lambda ()
+       (unless timer
+        (setq
+         timer
+         (timeout-add
+          100
+          #'(lambda ()
+              (incf count)
+              (setf (label-text label) (format nil "count: ~D" count))
+              t))))))
+      (setf (widget-can-default-p button) t)
+      (box-pack-start action-area button t t 0)
+      (widget-show button))
+      
+    (let ((button (button-new "stop")))
+      (signal-connect
+       button 'clicked
+       #'(lambda ()
+       (when timer
+        (timeout-remove timer)
+        (setq timer nil))))
+      (setf (widget-can-default-p button) t)
+      (box-pack-start action-area button t t 0)
+      (widget-show button))))
+  
+
+
+;;; Text
+
+(define-test-window create-text "Text"
+  (setf (widget-name window) "text window")
+  (setf (widget-width window) 500)
+  (setf (widget-height window) 500)
+  (setf (window-allow-grow-p window) t)
+  (setf (window-allow-shrink-p window) t)
+  (setf (window-auto-shrink-p window) nil)
+  (let ((box1 (vbox-new nil 0)))
+    (container-add window box1)
+    
+    (let ((box2 (vbox-new nil 10)))
+      (setf (container-border-width box2) 10)
+      (box-pack-start box1 box2 t t 0)
+
+      (let ((scrolled-window (scrolled-window-new))
+           (text (text-new)))
+       (box-pack-start box2 scrolled-window t t 0)
+       (setf (scrolled-window-hscrollbar-policy scrolled-window) :never)
+       (setf (scrolled-window-vscrollbar-policy scrolled-window) :always)
+       (setf (editable-editable-p text) t)
+       (container-add scrolled-window text)
+       (widget-grab-focus text)
+       
+       (text-freeze text)
+       (let ((font
+              (gdk:font-load
+               "-adobe-courier-medium-r-normal--*-120-*-*-*-*-*-*"))
+             (colors
+              (map 'list
+                   #'(lambda (definition)
+                       (cons
+                        (gdk:color-new-from-vector (first definition))
+                        (second definition)))
+                   '((#(#x0000 #x0000 #x0000) "black")
+                     (#(#xFFFF #xFFFF #xFFFF) "white")
+                     (#(#xFFFF #x0000 #x0000) "red")
+                     (#(#x0000 #xFFFF #x0000) "green")
+                     (#(#x0000 #x0000 #xFFFF) "blue")
+                     (#(#x0000 #xFFFF #xFFFF) "cyan")
+                     (#(#xFFFF #x0000 #xFFFF) "magneta")
+                     (#(#xFFFF #xFFFF #x0000) "yellow")))))
+         (dolist (color1 colors)
+           (text-insert text (format nil "~A~,7T" (cdr color1)) :font font)
+           (dolist (color2 colors)
+             (text-insert
+              text "XYZ" :font font
+              :foreground (car color2) :background (car color1)))
+           (text-insert text (format nil "~%")))
+         (dolist (color colors)
+           (gdk:color-destroy (car color)))
+         (gdk:font-unref font))
+                        
+       (with-open-file (file "cl-gtk:src;testgtk.lisp")
+         (labels ((read-file ()
+                    (let ((line (read-line file nil nil)))
+                      (when line
+                        (text-insert text (format nil "~A~%" line))
+                        (read-file)))))
+           (read-file)))
+
+       (text-thaw text)
+
+       (let ((hbox (hbutton-box-new)))
+         (box-pack-start box2 hbox nil nil 0)
+         (let ((check-button (check-button-new "Editable")))
+           (box-pack-start hbox check-button nil nil 0)
+           (signal-connect
+            check-button 'toggled
+            #'(lambda ()
+                (setf
+                 (editable-editable-p text)
+                 (toggle-button-active-p check-button))))
+           (setf (toggle-button-active-p check-button) t))
+
+         (let ((check-button (check-button-new "Wrap Words")))
+           (box-pack-start hbox check-button nil t 0)
+           (signal-connect
+            check-button 'toggled
+            #'(lambda ()
+                (setf
+                 (text-word-wrap-p text)
+                 (toggle-button-active-p check-button))))
+           (setf (toggle-button-active-p check-button) nil)))))
+
+    (box-pack-start box1 (hseparator-new) nil t 0)
+
+    (let ((box2 (vbox-new nil 10)))
+      (setf (container-border-width box2) 10)
+      (box-pack-start box1 box2 nil t 0)
+      
+      (let ((button (button-new "insert random")))
+       (signal-connect button 'clicked #'(lambda () nil))
+       (box-pack-start box2 button t t 0))
+
+      (let ((button (button-new "close")))
+       (signal-connect
+        button 'clicked
+        #'(lambda ()
+            (widget-destroy window)
+            (setq window nil)))
+       (box-pack-start box2 button t t 0)
+       (setf (widget-can-default-p button) t)
+       (widget-grab-default button)))))
+      
+
+
+;;; Toggle buttons
+
+(define-standard-dialog create-toggle-buttons "Toggle Button"
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 10)
+  (box-pack main-box (toggle-button-new "button1"))
+  (box-pack main-box (toggle-button-new "button2"))
+  (box-pack main-box (toggle-button-new "button3")))
+
+
+
+;;; Toolbar test
+
+(define-test-window create-toolbar "Toolbar test"
+  (setf (window-allow-grow-p window) nil)
+  (setf (window-allow-shrink-p window) t)
+  (setf (window-auto-shrink-p window) t)
+  (widget-realize window)
+
+
+  (let ((toolbar (toolbar-new :horizontal :both)))
+    (setf (toolbar-relief toolbar) :none)
+
+    (toolbar-append-item
+     toolbar "Horizontal" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Horizontal toolbar layout"
+     :tooltip-private-text "Toolbar/Horizontal"
+     :callback #'(lambda () (setf (toolbar-orientation toolbar) :horizontal)))
+
+    (toolbar-append-item
+     toolbar "Vertical" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Vertical toolbar layout"
+     :tooltip-private-text "Toolbar/Vertical"
+     :callback #'(lambda () (setf (toolbar-orientation toolbar) :vertical)))
+
+    (toolbar-append-space toolbar)
+    
+    (toolbar-append-item
+     toolbar "Icons" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Only show toolbar icons"
+     :tooltip-private-text "Toolbar/IconsOnly"
+     :callback #'(lambda () (setf (toolbar-style toolbar) :icons)))
+    
+    (toolbar-append-item
+     toolbar "Text" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Only show toolbar text"
+     :tooltip-private-text "Toolbar/TextOnly"
+     :callback #'(lambda () (setf (toolbar-style toolbar) :text)))
+  
+    (toolbar-append-item
+     toolbar "Both" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Show toolbar icons and text"
+     :tooltip-private-text "Toolbar/Both"
+     :callback #'(lambda () (setf (toolbar-style toolbar) :both)))
+
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-widget
+     toolbar (entry-new)
+     :tooltip-text "This is an unusable GtkEntry ;)"
+     :tooltip-private-text "Hey don't click me!")
+
+    (toolbar-append-space toolbar)
+    
+    (toolbar-append-item
+     toolbar "Small" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Use small spaces"
+     :tooltip-private-text "Toolbar/Small"
+     :callback #'(lambda () (setf (toolbar-space-size toolbar) 5)))
+    
+    (toolbar-append-item
+     toolbar "Big" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Use big spaces"
+     :tooltip-private-text "Toolbar/Big"
+     :callback #'(lambda () (setf (toolbar-space-size toolbar) 10)))
+    
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-item
+     toolbar "Enable" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Enable tooltips"
+     :callback #'(lambda () (toolbar-enable-tooltips toolbar)))
+
+    (toolbar-append-item
+     toolbar "Disable" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Disable tooltips"
+     :callback #'(lambda () (toolbar-disable-tooltips toolbar)))
+
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-item
+     toolbar "Borders" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Show borders"
+     :callback #'(lambda () (setf (toolbar-relief toolbar) :normal)))
+    
+    (toolbar-append-item
+     toolbar
+     "Borderless" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Hide borders"
+     :callback #'(lambda () (setf (toolbar-relief toolbar) :none)))
+
+    (toolbar-append-space toolbar)
+
+    (toolbar-append-item
+     toolbar "Empty" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Empty spaces"
+     :callback #'(lambda () (setf (toolbar-space-style toolbar) :empty)))
+
+    (toolbar-append-item
+     toolbar "Lines" (pixmap-new "cl-gtk:src;test.xpm")
+     :tooltip-text "Lines in spaces"
+     :callback #'(lambda () (setf (toolbar-space-style toolbar) :line)))
+
+    (container-add window toolbar)))
+
+
+
+;;; Tooltips test
+
+(define-standard-dialog create-tooltips "Tooltips"
+  (setf (window-allow-grow-p window) t)
+  (setf (window-allow-shrink-p window) nil)
+  (setf (window-auto-shrink-p window) t)
+  (setf (widget-width window) 200)
+  (setf (container-border-width main-box) 10)
+  (setf (box-spacing main-box) 10)
+
+  (let ((tooltips (tooltips-new)))
+
+    (let ((button (toggle-button-new "button1")))
+      (box-pack-start main-box button t t 0)
+      (tooltips-set-tip
+       tooltips button "This is button 1" "ContextHelp/button/1"))
+
+    (let ((button (toggle-button-new "button2")))
+      (box-pack-start main-box button t t 0)
+      (tooltips-set-tip
+       tooltips button "This is button 2. This is also a really long tooltip which probably won't fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly."
+       "ContextHelp/button/2"))
+
+    (let ((toggle (toggle-button-new "Override TipSQuery Label")))
+      (box-pack-start main-box toggle t t 0)
+      (tooltips-set-tip
+       tooltips toggle "Toggle TipsQuery view" "Hi msw! ;)")
+
+      (let* ((box3 (make-vbox
+                   :homogeneous nil
+                   :spacing 5
+                   :border-width 5
+                   :visible t))
+            (tips-query (make-tips-query
+                         :visible t
+                         :parent box3))
+            (button (make-button
+                     :label "[?]"
+                     :visible t
+                     :parent box3
+                     :signal (list
+                              'clicked #'tips-query-start-query
+                              :object tips-query))))
+            
+       (box-set-child-packing box3 button nil nil 0 :start)
+       (tooltips-set-tip
+        tooltips button "Start the Tooltip Inspector" "ContextHelp/buttons/?")
+       (setf (tips-query-caller tips-query) button)
+       
+       (signal-connect
+        tips-query 'widget-entered
+        #'(lambda (widget tip-text tip-private)
+            (declare (ignore widget tip-private))
+            (when (toggle-button-active-p toggle)
+              (setf
+               (label-text tips-query)
+               (if tip-text
+                   "There is a Tip!"
+                 "There is no Tip!"))
+              (signal-emit-stop tips-query 'widget-entered))))
+       
+       (signal-connect
+        tips-query 'widget-selected
+        #'(lambda (widget tip-text tip-private event)
+            (declare (ignore tip-text event))
+            (when widget
+              (format
+               t "Help ~S requested for ~S~%"
+               (or tip-private "None") (type-of widget)))
+            t))
+
+       (let ((frame (make-frame
+                     :label "ToolTips Inspector"
+                     :label-xalign 0.5
+                     :border-width 0
+                     :visible t
+                     :parent main-box
+                     :child box3)))
+         (box-set-child-packing main-box frame t t 0 :start))
+
+       (tooltips-set-tip
+        tooltips close-button "Push this button to close window"
+        "ContextHelp/buttons/Close")))))
+                 
+
+
+;;; Tree
+
+(defconstant +default-number-of-items+ 3)
+(defconstant +default-recursion-level+ 3)
+
+(defun create-subtree (item level nb-item-max recursion-level-max)
+  (unless (and level (= level recursion-level-max))
+    (multiple-value-bind (level item-subtree no-root-item)
+       (if (not level)
+           (values 0 item t)
+         (values level (tree-new) nil))
+      
+      (dotimes (nb-item nb-item-max)
+       (let ((new-item
+              (tree-item-new (format nil "item ~D-~D" level nb-item))))
+         (tree-append item-subtree new-item)
+         (create-subtree
+          new-item (1+ level) nb-item-max recursion-level-max)
+         (widget-show new-item)))
+
+      (unless no-root-item
+       (setf (tree-item-subtree item) item-subtree)))))
+  
+
+(defun create-tree-sample (selection-mode draw-line view-line no-root-item
+                          nb-item-max recursion-level-max)
+  (let ((window (window-new :toplevel)))
+    (setf (window-title window) "Tree Sample")
+    (signal-connect window 'destroy #'(lambda ()))
+                   
+    (let ((box1 (vbox-new nil 0))
+         (root-tree (tree-new))
+         (add-button (button-new "Add Item"))
+         (remove-button (button-new "Remove Item(s)"))
+         (subtree-button (button-new "Remove Subtree")))
+      (container-add window box1)
+      (widget-show box1)
+
+      (let ((box2 (vbox-new nil 0))
+           (scrolled-win (scrolled-window-new nil nil)))
+       (box-pack box1 box2)
+       (setf (container-border-width box2) 5)
+       (widget-show box2)
+       (setf (scrolled-window-scrollbar-policy scrolled-win) :automatic)
+       (box-pack box2 scrolled-win)
+       (setf (widget-width scrolled-win) 200)
+       (setf (widget-height scrolled-win) 200)
+       (widget-show scrolled-win)
+       (signal-connect
+        root-tree 'selection-changed
+        #'(lambda ()
+            (format t "Selection: ~A~%" (tree-selection root-tree))
+            (let ((nb-selected (length (tree-selection root-tree))))
+              (if (zerop nb-selected)
+                  (progn
+                    (if (container-children root-tree)
+                        (setf (widget-sensitive-p add-button) t)
+                      (setf (widget-sensitive-p add-button) nil))
+                    (setf (widget-sensitive-p remove-button) nil)
+                    (setf (widget-sensitive-p subtree-button) nil))
+                (progn
+                  (setf (widget-sensitive-p remove-button) t)
+                  (setf (widget-sensitive-p add-button) (= 1 nb-selected))
+                  (setf
+                   (widget-sensitive-p subtree-button) (= 1 nb-selected)))))))
+       (scrolled-window-add-with-viewport scrolled-win root-tree)
+       (setf (tree-selection-mode root-tree) selection-mode)
+       (setf (tree-view-lines-p root-tree) draw-line)
+       (setf (tree-view-mode root-tree) (if view-line :line :item))
+       (widget-show root-tree)
+
+       (let ((root-item
+              (if no-root-item
+                  root-tree
+                (let ((root-item (tree-item-new "root item")))
+                  (tree-append root-tree root-item)
+                  (widget-show root-item)
+                  root-item))))
+         (create-subtree
+          root-item (if no-root-item nil 0) nb-item-max recursion-level-max)))
+         
+      (let ((box2 (vbox-new nil 0)))
+       (box-pack-start box1 box2 nil nil 0)
+       (setf (container-border-width box2) 5)
+       (widget-show box2)
+
+       (setf (widget-sensitive-p add-button) nil)
+       (let ((nb-item-add 0))
+         (signal-connect
+          add-button 'clicked
+          #'(lambda ()
+              (let* ((selected-list (tree-selection root-tree))
+                     (subtree (if (not selected-list)
+                                  root-tree
+                                (let ((selected-item (first selected-list)))
+                                  (or
+                                   (tree-item-subtree selected-item)
+                                   (let ((subtree (tree-new)))
+                                     (setf
+                                      (tree-item-subtree selected-item)
+                                      subtree)
+                                     subtree)))))
+                     (new-item
+                      (tree-item-new (format nil "item add ~D" nb-item-add))))
+                (tree-append subtree new-item)
+                (widget-show new-item)
+                (incf nb-item-add)))))
+       (box-pack-start box2 add-button t t 0)
+       (widget-show add-button)
+
+       (setf (widget-sensitive-p remove-button) nil)
+       (signal-connect
+        remove-button 'clicked
+        #'(lambda ()
+            (format t "Remove: ~A~%" (tree-selection root-tree))
+            (tree-remove-items root-tree (tree-selection root-tree))))
+       (box-pack-start box2 remove-button t t 0)
+       (widget-show remove-button)
+       
+       (setf (widget-sensitive-p subtree-button) nil)
+       (signal-connect
+        subtree-button 'clicked
+        #'(lambda ()
+            (let ((selected-list (tree-selection root-tree)))
+              (when selected-list
+                (let ((item (first selected-list)))
+                  (when item
+                    (setf (tree-item-subtree item) nil)))))))
+       (box-pack-start box2 subtree-button t t 0)
+       (widget-show subtree-button))
+      
+      (let ((separator (hseparator-new)))
+       (box-pack-start box1 separator nil nil 0)
+       (widget-show separator))
+
+      (let ((box2 (vbox-new nil 0))
+           (button (button-new "Close")))
+       (box-pack-start box1 box2 nil nil 0)
+       (setf (container-border-width box2) 5)
+       (widget-show box2)
+       (box-pack-start box2 button t t 0)
+       (signal-connect button 'clicked
+                       #'(lambda ()
+                           (widget-destroy window)))
+       (widget-show button)))
+
+    (widget-show window)))
+
+
+(define-test-window create-tree "Set Tree Parameters"
+  (let ((box1 (vbox-new nil 0)))
+    (container-add window box1)
+
+    (let ((box2 (vbox-new nil 5)))
+      (box-pack box1 box2)
+      (setf (container-border-width box2) 5)
+      
+      (let ((box3 (hbox-new nil 5)))
+       (box-pack box2 box3)
+
+       (let* ((single-button (radio-button-new nil :label "SIGNLE"))
+              (browse-button
+               (radio-button-new
+                (radio-button-group single-button) :label "BROWSE"))
+              (multiple-button
+               (radio-button-new
+                (radio-button-group single-button) :label "MULTIPLE"))
+              (draw-line-button (check-button-new "Draw line"))
+              (view-line-button (check-button-new "View Line mode"))
+              (no-root-item-button (check-button-new "Without Root item"))
+              (num-of-items-spinner
+               (spin-button-new
+                (adjustment-new
+                 +default-number-of-items+ 1 255 1 5 0)
+                0 0))
+              (depth-spinner
+               (spin-button-new
+                (adjustment-new
+                 +default-recursion-level+ 0 255 1 5 0)
+                5 0)))
+       
+         (let ((frame (frame-new "Selection Mode"))
+               (box4 (vbox-new nil 0)))
+           (box-pack box3 frame)
+           (container-add frame box4)
+           (setf (container-border-width box4) 5)
+           (box-pack box4 single-button)
+           (box-pack box4 browse-button)
+           (box-pack box4 multiple-button))
+         
+         (let ((frame (frame-new "Options"))
+               (box4 (vbox-new nil 0)))
+           (box-pack box3 frame)
+           (container-add frame box4)
+           (setf (container-border-width box4) 5)
+           (box-pack box4 draw-line-button)
+           (box-pack box4 view-line-button)
+           (box-pack box4 no-root-item-button)
+           (setf (toggle-button-active-p draw-line-button) t)
+           (setf (toggle-button-active-p view-line-button) t)
+           (setf (toggle-button-active-p no-root-item-button) nil))
+
+         (let ((frame (frame-new "Size Parameters"))
+               (box4 (vbox-new nil 5)))
+           (box-pack box2 frame)
+           (container-add frame box4)
+           (setf (container-border-width box4) 5)
+      
+           (let ((box5 (hbox-new nil 5)))
+             (box-pack box4 box5 :expand nil :fill nil)
+             (let ((label (label-new "Number of items : ")))
+               (setf (misc-xalign label) 0)
+               (setf (misc-yalign label) 0.5)
+               (box-pack box5 label :expand nil)
+               (box-pack box5 num-of-items-spinner :expand nil))
+             (let ((label (label-new "Depth : ")))
+               (setf (misc-xalign label) 0)
+               (setf (misc-yalign label) 0.5)
+               (box-pack box5 label :expand nil)
+               (box-pack box5 depth-spinner :expand nil))))
+
+         (box-pack box1 (hseparator-new) :expand nil :fill nil)
+
+         (let ((box2 (hbox-new t 10)))
+           (box-pack box1 box2)
+           (setf (container-border-width box2) 5)
+           (let ((button (button-new "Create Tree")))
+             (box-pack box2 button)
+             (signal-connect
+              button 'clicked
+              #'(lambda ()
+                  (let ((selection-mode
+                         (cond
+                          ((toggle-button-active-p single-button) :single)
+                          ((toggle-button-active-p browse-button) :browse)
+                          (t :multiple)))
+                        (draw-line
+                         (toggle-button-active-p draw-line-button))
+                        (view-line
+                         (toggle-button-active-p view-line-button))
+                        (no-root-item
+                         (toggle-button-active-p no-root-item-button))
+                        (num-of-items
+                         (spin-button-value-as-int num-of-items-spinner))
+                        (depth
+                         (spin-button-value-as-int depth-spinner)))
+                    
+                    (if (> (expt num-of-items depth) 10000)
+                        (format t "~D total items? That will take a very long time. Try less~%" (expt num-of-items depth))
+                      (create-tree-sample
+                       selection-mode draw-line view-line no-root-item
+                       num-of-items depth))))))
+           (let ((button (button-new "Close")))
+             (box-pack box2 button)
+             (signal-connect
+              button 'clicked #'widget-destroy :object window))))))))
+
+
+
+;;; Main window
+      
+(defun create-main-window ()
+  (let* ((buttons
+         '(("button box" create-button-box)
+           ("buttons" create-buttons)
+           ("calendar" create-calendar)
+           ("check buttons" create-check-buttons)
+           ("clist" create-clist)
+           ("color selection" create-color-selection)
+           ("ctree" create-ctree)
+           ("cursors" create-cursors)
+           ("dialog" create-dialog)
+;          ("dnd")
+           ("entry" create-entry)
+           ("event watcher")
+           ("file selection" create-file-selection)
+           ("font selection")
+           ("gamma curve")
+           ("handle box" create-handle-box)
+           ("item factory")
+           ("labels" create-labels)
+           ("layout" create-layout)
+           ("list" create-list)
+           ("menus" create-menus)
+           ("modal window")
+           ("notebook" create-notebook)
+           ("panes" create-panes)
+           ("pixmap" create-pixmap)
+           ("preview color")
+           ("preview gray")
+           ("progress bar" create-progress-bar)
+           ("radio buttons" create-radio-buttons)
+           ("range controls" create-range-controls)
+           ("rc file")
+           ("reparent" create-reparent)
+           ("rulers" create-rulers)
+           ("saved position")
+           ("scrolled windows" create-scrolled-windows)
+           ("shapes" create-shapes)
+           ("spinbutton" create-spins)
+           ("statusbar" create-statusbar)
+           ("test idle" create-idle-test)
+           ("test mainloop")
+           ("test scrolling")
+           ("test selection")
+           ("test timeout" create-timeout-test)
+           ("text" create-text)
+           ("toggle buttons" create-toggle-buttons)
+           ("toolbar" create-toolbar)
+           ("tooltips" create-tooltips)
+           ("tree" create-tree)
+           ("WM hints")))
+        (main-window (make-instance 'window
+                       :type :toplevel :title "testgtk.lisp"
+                       :name "main window" :x 20 :y 20 :width 200 :height 400
+                       :allow-grow nil :allow-shrink nil :auto-shrink nil))
+        (scrolled-window (make-instance 'scrolled-window
+                          :hscrollbar-policy :automatic
+                          :vscrollbar-policy :automatic
+                          :border-width 10))
+        (close-button (make-instance 'button
+                       :label "close"
+                       :can-default t ;:has-default t
+                       :signals
+                       (list
+                        (list
+                         'clicked #'widget-destroy :object main-window)))))
+
+    ;; Main box
+    (make-instance 'vbox
+     :parent main-window
+     :children
+     (list 
+      (list
+       (make-instance 'label :label (gtk-version))
+       :expand nil :fill nil)
+      (list
+       (make-instance 'label :label (format nil "clg CVS version"))
+       :expand nil :fill nil)
+      scrolled-window
+      (list (make-instance 'hseparator) :expand nil)
+      (list
+       (make-instance 'vbox
+       :homogeneous nil :spacing 10 :border-width 10
+       :children (list (list close-button :expand t :fill t)))
+       :expand nil)))
+
+    (let ((button-box
+          (make-instance 'vbox
+           :border-width 10
+           :focus-vadjustment (scrolled-window-vadjustment scrolled-window)
+           :children
+           (map
+            'list
+            #'(lambda (button)
+                (let ((widget (make-instance 'button :label (first button))))
+                  (if (second button)
+                      (signal-connect widget 'clicked (second button))
+                    (setf (widget-sensitive-p widget) nil))
+                  widget))
+            buttons))))
+    
+      (scrolled-window-add-with-viewport scrolled-window button-box))
+    
+    (widget-grab-default close-button)
+    (widget-show-all main-window)
+    main-window))
+;(gdk:rgb-init)
+(rc-parse "cl-gtk:src;testgtkrc2")
+(rc-parse "cl-gtk:src;testgtkrc")
+
+
+;(create-main-window)
+
diff --git a/examples/testgtkrc b/examples/testgtkrc
new file mode 100644 (file)
index 0000000..8ff515d
--- /dev/null
@@ -0,0 +1,146 @@
+# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..."
+#
+# include "rc-file"
+#
+# style <name> [= <name>]
+# {
+#   <option>
+# }
+#
+# widget <widget_set> style <style_name>
+# widget_class <widget_class_set> style <style_name>
+
+# testgtkrc2 sets all the buttons in the main window to blue by default
+include "testgtkrc2"
+
+#include "/usr/local/share/themes/Pixmap/gtk/gtkrc"
+#include "/usr/local/share/themes/Redmond95/gtk/gtkrc"
+#include "/usr/local/share/themes/Metal/gtk/gtkrc"
+#include "/usr/local/share/themes/Notif/gtk/gtkrc"
+#include "/usr/local/share/themes/Default/gtk/gtkrc"
+
+pixmap_path "."
+
+style "defaultfont"
+{
+#  fontset = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*,*"
+  font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*"
+}
+
+# common default
+class "GtkWidget" style "defaultfont"
+
+style "window"
+{
+# bg_pixmap[NORMAL] = "marble.xpm"
+}
+
+style "scale"
+{
+  fg[NORMAL] = { 1.0, 0, 0 }
+  bg_pixmap[NORMAL] = "<parent>"
+}
+
+style "button" = "default"
+{
+#  fg[PRELIGHT] = { 1.0, 1.0, 1.0 }
+#  bg[PRELIGHT] = { 0, 0, 0.75 }
+#  bg[PRELIGHT] = { 0.75, 0, 0x00 }
+}
+
+style "toggle_button" = "button"
+{
+  fg[NORMAL] = { 1.0, 0, 0 }
+  fg[ACTIVE] = { 1.0, 0, 0 }
+#  bg_pixmap[ACTIVE] = "check-y.xpm"
+#  bg_pixmap[NORMAL] = "check-n.xpm"
+}
+
+style "text"
+{
+#  bg_pixmap[NORMAL] = "marble.xpm"
+  text[NORMAL] = { 1.0, 1.0, 1.0 }
+  fg[NORMAL] = { 1.0, 1.0, 1.0 }
+  base[NORMAL] = { 0.0, 0.0, 0.0 }
+}
+
+style "slider"
+{
+  fg[NORMAL] = { 1.0, 1.0, 1.0 }
+  bg[NORMAL] = { 0.0, 0.0, 1.0 }
+  bg[ACTIVE] = { 0.0 ,0.0, 0.5 }
+  bg[PRELIGHT] = { 0.75 ,0.75, 1.0 }
+}
+
+style "ruler"
+{
+  font = '-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*'
+}
+
+style "curve"
+{
+  fg[NORMAL] = { 58000, 0, 0 }                  # red
+}
+
+style "red-bar"
+{
+  bg[PRELIGHT] = { 0.95, .55, 0.55 }
+}
+
+# override testgtk2, introduce the green color in the button list
+style 'button_list' = 'button'
+{
+  font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
+  bg[PRELIGHT] = { 0, 0.75, 0x00 }
+}
+widget "main window.*GtkScrolledWindow.*GtkButton*" style "button_list"
+
+
+class "GtkScrollbar" style "red-bar"
+
+widget_class "GtkWindow" style "window"
+widget_class "GtkDialog" style "window"
+widget_class "GtkFileSelection" style "window"
+widget_class "*Gtk*Scale" style "scale"
+widget_class "*GtkCheckButton*" style "toggle_button"
+widget_class "*GtkRadioButton*" style "toggle_button"
+widget_class "*GtkButton*" style "button"
+widget_class "*Ruler" style "ruler"
+widget_class "*GtkText" style "text"
+widget "*GtkCurve" style "curve"
+
+binding "test1"
+{
+  bind "<ctrl>1" {
+    "debug-msg" ("jup!")
+  }
+}
+
+binding "test2"
+{
+  bind "<ctrl>1" {
+    "debug-msg" ("hallo and")
+    "debug-msg" ("huhu")
+  }
+}
+
+# possible priorities are (in ascending order):
+# lowest
+# gtk         (used by gtk for internal class bindings)
+# application (for hard coded bindings on application basis)
+# rc          (used implicitel by rc files)
+# highest
+class "GtkCList" binding  "test1"           # implicit : rc
+#class "GtkWindow" binding : highest "test2" # override "rc" priority
+
+binding "clist-test"
+{
+  bind "j" {
+    "scroll-vertical" (step-backward, 0.0)
+  }
+  bind "k" {
+    "scroll-vertical" (step-forward, 0.0)
+  }
+}
+
+class "GtkCList" binding "clist-test"
diff --git a/examples/testgtkrc2 b/examples/testgtkrc2
new file mode 100644 (file)
index 0000000..71d2891
--- /dev/null
@@ -0,0 +1,21 @@
+# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..."
+#
+# include "rc-file"
+#
+# style <name> [= <name>]
+# {
+#   <option>
+# }
+#
+# widget <widget_set> style <style_name>
+# widget_class <widget_class_set> style <style_name>
+
+# this file gets included from testgtkrc
+
+style 'main_buttons' = 'button'
+{
+  font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
+  bg[PRELIGHT] = { 0, 0, 0.75 }
+}
+
+widget "main window.*GtkButton*" style "main_buttons"
diff --git a/gdk/gdk-export.lisp b/gdk/gdk-export.lisp
new file mode 100644 (file)
index 0000000..a44dd43
--- /dev/null
@@ -0,0 +1,6 @@
+(in-package "GDK")
+
+;;; Autogenerating exported symbols
+(export-from-file #p"clg:gdk;gdkenums.lisp")
+(export-from-file #p"clg:gdk;gdktypes.lisp")
+(export-from-file #p"clg:gdk;gdk.lisp")
diff --git a/gdk/gdk-package.lisp b/gdk/gdk-package.lisp
new file mode 100644 (file)
index 0000000..02a9d07
--- /dev/null
@@ -0,0 +1,7 @@
+(defpackage "GDK"
+  (:use "GLIB" "COMMON-LISP" "AUTOEXPORT")
+  (:shadowing-import-from "PCL"
+   "CLASS-NAME" "CLASS-OF" "FIND-CLASS")
+  (:shadowing-import-from "GLIB" "DEFTYPE"))
+
+
diff --git a/gdk/gdk.lisp b/gdk/gdk.lisp
new file mode 100644 (file)
index 0000000..54afe17
--- /dev/null
@@ -0,0 +1,550 @@
+;; Common Lisp bindings for GTK+ v1.2.x
+;; Copyright (C) 1999 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gdk.lisp,v 1.1 2000/08/14 16:44:39 espen Exp $
+
+
+(in-package "GDK")
+
+
+;;; Events
+
+; (defmethod initialize-instance ((event event) &rest initargs &key)
+;   (declare (ignore initargs))
+;   (call-next-method)
+;   )
+
+(defun find-event-class (event-type)
+  (find-class
+   (ecase event-type
+     (:expose 'expose-event)
+     (:delete 'delete-event))))
+
+(deftype-method alien-copier event (type-spec)
+  (declare (ignore type-spec))
+  '%event-copy)
+
+(deftype-method alien-deallocator event (type-spec)
+  (declare (ignore type-spec))
+  '%event-free)
+
+(deftype-method translate-from-alien
+    event (type-spec location &optional (alloc :dynamic))
+  `(let ((location ,location))
+     (unless (null-pointer-p location)
+       (let ((event-class
+             (find-event-class
+              (funcall (get-reader-function 'event-type) location 0))))
+        ,(ecase alloc
+           (:dynamic '(ensure-alien-instance event-class location))
+           (:static '(ensure-alien-instance event-class location :static t))
+           (:copy '(ensure-alien-instance
+                    event-class (%event-copy location))))))))
+
+
+(define-foreign event-poll-fd () int)
+
+(define-foreign ("gdk_events_pending" events-pending-p) () boolean)
+
+(define-foreign event-get () event)
+
+(define-foreign event-peek () event)
+
+(define-foreign event-get-graphics-expose () event
+  (window window))
+
+(define-foreign event-put () event
+  (event event))
+
+(define-foreign %event-copy (event &optional size) pointer
+  (event (or event pointer)))
+
+(define-foreign %event-free () nil
+  (event (or event pointer)))
+
+(define-foreign event-get-time () (unsigned 32)
+  (event event))
+
+;(define-foreign event-handler-set () ...)
+
+(define-foreign set-show-events () nil
+  (show-events boolean))
+
+;;; Misc
+
+(define-foreign set-use-xshm () nil
+  (use-xshm boolean))
+
+(define-foreign get-show-events () boolean)
+
+(define-foreign get-use-xshm () boolean)
+
+(define-foreign get-display () string)
+
+; (define-foreign time-get () (unsigned 32))
+
+; (define-foreign timer-get () (unsigned 32))
+
+; (define-foreign timer-set () nil
+;   (milliseconds (unsigned 32)))
+
+; (define-foreign timer-enable () nil)
+
+; (define-foreign timer-disable () nil)
+
+; input ...
+
+(define-foreign pointer-grab () int
+  (window window)
+  (owner-events boolean)
+  (event-mask event-mask)
+  (confine-to (or null window))
+  (cursor (or null cursor))
+  (time (unsigned 32)))
+
+(define-foreign pointer-ungrab () nil
+  (time (unsigned 32)))
+
+(define-foreign keyboard-grab () int
+  (window window)
+  (owner-events boolean)
+  (time (unsigned 32)))
+
+(define-foreign keyboard-ungrab () nil
+  (time (unsigned 32)))
+
+(define-foreign ("gdk_pointer_is_grabbed" pointer-is-grabbed-p) () boolean)
+
+(define-foreign screen-width () int)
+(define-foreign screen-height () int)
+
+(define-foreign screen-width-mm () int)
+(define-foreign screen-height-mm () int)
+
+(define-foreign flush () nil)
+(define-foreign beep () nil)
+
+(define-foreign key-repeat-disable () nil)
+(define-foreign key-repeat-restore () nil)
+
+
+
+;;; Visuals
+
+(define-foreign visual-get-best-depth () int)
+
+(define-foreign visual-get-best-type () visual-type)
+
+(define-foreign visual-get-system () visual)
+
+
+(define-foreign
+  ("gdk_visual_get_best" %visual-get-best-with-nothing) () visual)
+
+(define-foreign %visual-get-best-with-depth () visual
+  (depth int))
+
+(define-foreign %visual-get-best-with-type () visual
+  (type visual-type))
+
+(define-foreign %visual-get-best-with-both () visual
+  (depth int)
+  (type visual-type))
+
+(defun visual-get-best (&key depth type)
+  (cond
+   ((and depth type) (%visual-get-best-with-both depth type))
+   (depth (%visual-get-best-with-depth depth))
+   (type (%visual-get-best-with-type type))
+   (t (%visual-get-best-with-nothing))))
+
+;(define-foreign query-depths ..)
+
+;(define-foreign query-visual-types ..)
+
+(define-foreign list-visuals () (double-list visual))
+
+
+;;; Windows
+
+; (define-foreign window-new ... )
+
+(define-foreign window-destroy () nil
+  (window window))
+
+
+; (define-foreign window-at-pointer () window
+;   (window window)
+;   (x int :in-out)
+;   (y int :in-out))
+
+(define-foreign window-show () nil
+  (window window))
+
+(define-foreign window-hide () nil
+  (window window))
+
+(define-foreign window-withdraw () nil
+  (window window))
+
+(define-foreign window-move () nil
+  (window window)
+  (x int)
+  (y int))
+
+(define-foreign window-resize () nil
+  (window window)
+  (width int)
+  (height int))
+
+(define-foreign window-move-resize () nil
+  (window window)
+  (x int)
+  (y int)
+  (width int)
+  (height int))
+
+(define-foreign window-reparent () nil
+  (window window)
+  (new-parent window)
+  (x int)
+  (y int))
+
+(define-foreign window-clear () nil
+  (window window))
+
+(unexport
+ '(window-clear-area-no-e window-clear-area-e))
+
+(define-foreign ("gdk_window_clear_area" window-clear-area-no-e) () nil
+  (window window)
+  (x int) (y int) (width int) (height int))
+
+(define-foreign window-clear-area-e () nil
+  (window window)
+  (x int) (y int) (width int) (height int))
+
+(defun window-clear-area (window x y width height &optional expose)
+  (if expose
+      (window-clear-area-e window x y width height)
+    (window-clear-area-no-e window x y width height)))
+
+; (define-foreign window-copy-area () nil
+;   (window window)
+;   (gc gc)
+;   (x int)
+;   (y int)
+;   (source-window window)
+;   (source-x int)
+;   (source-y int)
+;   (width int)
+;   (height int))
+
+(define-foreign window-raise () nil
+  (window window))
+
+(define-foreign window-lower () nil
+  (window window))
+
+; (define-foreign window-set-user-data () nil
+
+(define-foreign window-set-override-redirect () nil
+  (window window)
+  (override-redirect boolean))
+
+; (define-foreign window-add-filter () nil
+
+; (define-foreign window-remove-filter () nil
+
+(define-foreign window-shape-combine-mask () nil
+  (window window)
+  (shape-mask bitmap)
+  (offset-x int)
+  (offset-y int))
+
+(define-foreign window-set-child-shapes () nil
+  (window window))
+
+(define-foreign window-merge-child-shapes () nil
+  (window window))
+
+(define-foreign ("gdk_window_is_visible" window-is-visible-p) () boolean
+  (window window))
+
+(define-foreign ("gdk_window_is_viewable" window-is-viewable-p) () boolean
+  (window window))
+
+(define-foreign window-set-static-gravities () boolean
+  (window window)
+  (use-static boolean))
+
+; (define-foreign add-client-message-filter ...
+
+
+;;; Drag and Drop
+
+(define-foreign drag-context-new () drag-context)
+
+(define-foreign drag-context-ref () nil
+  (context drag-context))
+
+(define-foreign drag-context-unref () nil
+  (context drag-context))
+
+;; Destination side
+
+(define-foreign drag-status () nil
+  (context drag-context)
+  (action drag-action)
+  (time (unsigned 32)))
+
+
+
+
+(define-foreign window-set-cursor () nil
+  (window window)
+  (cursor cursor))
+
+(define-foreign window-get-pointer () window
+  (window window)
+  (x int :out)
+  (y int :out)
+  (mask modifier-type :out))
+
+(define-foreign get-root-window () window)
+
+
+
+;;
+
+(define-foreign rgb-init () nil)
+
+
+
+
+;;; Cursor
+
+(deftype-method alien-ref cursor (type-spec)
+  (declare (ignore type-spec))
+  '%cursor-ref)
+
+(deftype-method alien-unref cursor (type-spec)
+  (declare (ignore type-spec))
+  '%cursor-unref)
+
+
+(define-foreign cursor-new () cursor
+  (cursor-type cursor-type))
+
+(define-foreign cursor-new-from-pixmap () cursor
+  (source pixmap)
+  (mask bitmap)
+  (foreground color)
+  (background color)
+  (x int) (y int))
+
+(define-foreign %cursor-ref () pointer
+  (cursor (or cursor pointer)))
+
+(define-foreign %cursor-unref () nil
+  (cursor (or cursor pointer)))
+
+
+
+;;; Pixmaps
+
+(define-foreign pixmap-new (width height depth &key window) pixmap
+  (width int)
+  (height int)
+  (depth int)
+  (window (or null window)))
+                                       
+
+(define-foreign %pixmap-colormap-create-from-xpm () pixmap
+  (window (or null window))
+  (colormap (or null colormap))
+  (mask bitmap :out)
+  (color (or null color))
+  (filename string))
+
+(define-foreign pixmap-colormap-create-from-xpm-d () pixmap
+  (window (or null window))
+  (colormap (or null colormap))
+  (mask bitmap :out)
+  (color (or null color))
+  (data pointer))
+
+; (defun pixmap-create (source &key color window colormap)
+;   (let ((window
+;       (if (not (or window colormap))
+;           (get-root-window)
+;         window)))
+;     (multiple-value-bind (pixmap bitmap)
+;         (typecase source
+;        ((or string pathname)
+;         (pixmap-colormap-create-from-xpm
+;          window colormap color (namestring (truename source))))
+;        (t
+;         (with-array (data :initial-contents source :free-contents t)
+;           (pixmap-colormap-create-from-xpm-d window colormap color data))))
+;       (if color
+;        (progn
+;          (bitmap-unref bitmap)
+;          pixmap)
+;      (values pixmap bitmap)))))
+    
+
+
+;;; Color
+
+(defun %scale-value (value)
+  (etypecase value
+    (integer value)
+    (float (truncate (* value 65535)))))
+
+(defmethod initialize-instance ((color color) &rest initargs
+                               &key (colors #(0 0 0)) red green blue)
+  (declare (ignore initargs))
+  (call-next-method)
+  (with-slots ((%red red) (%green green) (%blue blue)) color
+    (setf
+     %red (%scale-value (or red (svref colors 0)))
+     %green (%scale-value (or green (svref colors 1)))
+     %blue (%scale-value (or blue (svref colors 2))))))
+
+
+(defun ensure-color (color)
+  (etypecase color
+    (null nil)
+    (color color)
+    (vector (make-instance 'color :colors color))))
+       
+
+  
+;;; Fonts
+
+(define-foreign font-load () font
+  (font-name string))
+
+(defun ensure-font (font)
+  (etypecase font
+    (null nil)
+    (font font)
+    (string (font-load font))))
+
+(define-foreign fontset-load () font
+  (fontset-name string))
+
+(define-foreign font-ref () font
+  (font font))
+
+(define-foreign font-unref () nil
+  (font font))
+
+(defun font-maybe-unref (font1 font2)
+  (unless (eq font1 font2)
+    (font-unref font1)))
+
+(define-foreign font-id () int
+  (font font))
+
+(define-foreign ("gdk_font_equal" font-equalp) () boolean
+  (font-a font)
+  (font-b font))
+
+(define-foreign string-width () int
+  (font font)
+  (string string))
+
+(define-foreign text-width
+    (font text &aux (length (length text))) int
+  (font font)
+  (text string)
+  (length int))
+
+; (define-foreign ("gdk_text_width_wc" text-width-wc)
+;     (font text &aux (length (length text))) int
+;   (font font)
+;   (text string)
+;   (length int))
+
+(define-foreign char-width () int
+  (font font)
+  (char char))
+
+; (define-foreign ("gdk_char_width_wc" char-width-wc) () int
+;   (font font)
+;   (char char))
+
+
+(define-foreign string-measure () int
+  (font font)
+  (string string))
+
+(define-foreign text-measure
+    (font text &aux (length (length text))) int
+  (font font)
+  (text string)
+  (length int))
+
+(define-foreign char-measure () int
+  (font font)
+  (char char))
+
+(define-foreign string-height () int
+  (font font)
+  (string string))
+
+(define-foreign text-height
+    (font text &aux (length (length text))) int
+  (font font)
+  (text string)
+  (length int))
+
+(define-foreign char-height () int
+  (font font)
+  (char char))
+
+
+;;; Drawing functions
+
+(define-foreign draw-rectangle () nil
+  (drawable (or window pixmap bitmap))
+  (gc gc) (filled boolean)
+  (x int) (y int) (width int) (height int))
+
+
+;;; Key values
+
+(define-foreign keyval-name () string
+  (keyval unsigned-int))
+
+(define-foreign keyval-from-name () unsigned-int
+  (name string))
+
+(define-foreign keyval-to-upper () unsigned-int
+  (keyval unsigned-int))
+
+(define-foreign keyval-to-lower ()unsigned-int
+  (keyval unsigned-int))
+
+(define-foreign ("gdk_keyval_is_upper" keyval-is-upper-p) () boolean
+  (keyval unsigned-int))
+
+(define-foreign ("gdk_keyval_is_lower" keyval-is-lower-p) () boolean
+  (keyval unsigned-int))
+
diff --git a/gdk/gdkenums.lisp b/gdk/gdkenums.lisp
new file mode 100644 (file)
index 0000000..db53cf2
--- /dev/null
@@ -0,0 +1,558 @@
+;; generated by a modified makeenums.pl  ; -*- lisp -*-
+
+(in-package "GDK")
+
+; enumerations from "gdkcursor.h"
+
+(deftype (cursor-type "GdkCursorType") ()
+  '(enum
+    (:num-glyphs  154)
+    (:x-cursor  0)
+    (:arrow  2)
+    (:based-arrow-down  4)
+    (:based-arrow-up  6)
+    (:boat  8)
+    (:bogosity  10)
+    (:bottom-left-corner  12)
+    (:bottom-right-corner  14)
+    (:bottom-side  16)
+    (:bottom-tee  18)
+    (:box-spiral  20)
+    (:center-ptr  22)
+    (:circle  24)
+    (:clock  26)
+    (:coffee-mug  28)
+    (:cross  30)
+    (:cross-reverse  32)
+    (:crosshair  34)
+    (:diamond-cross  36)
+    (:dot  38)
+    (:dotbox  40)
+    (:double-arrow  42)
+    (:draft-large  44)
+    (:draft-small  46)
+    (:draped-box  48)
+    (:exchange  50)
+    (:fleur  52)
+    (:gobbler  54)
+    (:gumby  56)
+    (:hand1  58)
+    (:hand2  60)
+    (:heart  62)
+    (:icon  64)
+    (:iron-cross  66)
+    (:left-ptr  68)
+    (:left-side  70)
+    (:left-tee  72)
+    (:leftbutton  74)
+    (:ll-angle  76)
+    (:lr-angle  78)
+    (:man  80)
+    (:middlebutton  82)
+    (:mouse  84)
+    (:pencil  86)
+    (:pirate  88)
+    (:plus  90)
+    (:question-arrow  92)
+    (:right-ptr  94)
+    (:right-side  96)
+    (:right-tee  98)
+    (:rightbutton  100)
+    (:rtl-logo  102)
+    (:sailboat  104)
+    (:sb-down-arrow  106)
+    (:sb-h-double-arrow  108)
+    (:sb-left-arrow  110)
+    (:sb-right-arrow  112)
+    (:sb-up-arrow  114)
+    (:sb-v-double-arrow  116)
+    (:shuttle  118)
+    (:sizing  120)
+    (:spider  122)
+    (:spraycan  124)
+    (:star  126)
+    (:target  128)
+    (:tcross  130)
+    (:top-left-arrow  132)
+    (:top-left-corner  134)
+    (:top-right-corner  136)
+    (:top-side  138)
+    (:top-tee  140)
+    (:trek  142)
+    (:ul-angle  144)
+    (:umbrella  146)
+    (:ur-angle  148)
+    (:watch  150)
+    (:xterm  152)
+    :last-cursor
+    (:cursor-is-pixmap  -1 )))
+
+; enumerations from "gdkdnd.h"
+
+(deftype (drag-action "GdkDragAction") ()
+  '(flags
+    (:default  0)
+    (:copy  1)
+    (:move  2)
+    (:link  3)
+    (:private  4)
+    (:ask  5 )))
+
+(deftype (drag-protocol "GdkDragProtocol") ()
+  '(enum
+    :motif
+    :xdnd
+    :rootwin
+    :none
+    :win32-dropfiles
+    :ole2
+    :local))
+
+; enumerations from "gdkevents.h"
+
+(deftype (filter-return "GdkFilterReturn") ()
+  '(enum
+    :continue
+    :translate
+    :remove))
+
+(deftype (event-type "GdkEventType") ()
+  '(enum
+    (:nothing  -1)
+    (:delete  0)
+    (:destroy  1)
+    (:expose  2)
+    (:motion-notify  3)
+    (:button-press  4)
+    (:2button-press  5)
+    (:3button-press  6)
+    (:button-release  7)
+    (:key-press  8)
+    (:key-release  9)
+    (:enter-notify  10)
+    (:leave-notify  11)
+    (:focus-change  12)
+    (:configure  13)
+    (:map  14)
+    (:unmap  15)
+    (:property-notify  16)
+    (:selection-clear  17)
+    (:selection-request  18)
+    (:selection-notify  19)
+    (:proximity-in  20)
+    (:proximity-out  21)
+    (:drag-enter  22)
+    (:drag-leave  23)
+    (:drag-motion  24)
+    (:drag-status  25)
+    (:drop-start  26)
+    (:drop-finished  27)
+    (:client-event  28)
+    (:visibility-notify  29)
+    (:no-expose  30)
+    (:scroll  31 )))
+
+(deftype (event-mask "GdkEventMask") ()
+  '(flags
+    (:exposure-mask  1)
+    (:pointer-motion-mask  2)
+    (:pointer-motion-hint-mask  3)
+    (:button-motion-mask  4)
+    (:button1-motion-mask  5)
+    (:button2-motion-mask  6)
+    (:button3-motion-mask  7)
+    (:button-press-mask  8)
+    (:button-release-mask  9)
+    (:key-press-mask  10)
+    (:key-release-mask  11)
+    (:enter-notify-mask  12)
+    (:leave-notify-mask  13)
+    (:focus-change-mask  14)
+    (:structure-mask  15)
+    (:property-change-mask  16)
+    (:visibility-notify-mask  17)
+    (:proximity-in-mask  18)
+    (:proximity-out-mask  19)
+    (:substructure-mask  20)
+    (:scroll-mask  21)
+;    (:all-events-mask  #x3FFFFE )
+   ))
+
+(deftype (visibility-state "GdkVisibilityState") ()
+  '(enum
+    :unobscured
+    :partial
+    :fully-obscured))
+
+(deftype (scroll-direction "GdkScrollDirection") ()
+  '(enum
+    :up
+    :down
+    :left
+    :right))
+
+(deftype (notify-type "GdkNotifyType") ()
+  '(enum
+    (:ancestor  0)
+    (:virtual  1)
+    (:inferior  2)
+    (:nonlinear  3)
+    (:nonlinear-virtual  4)
+    (:unknown  5 )))
+
+(deftype (crossing-mode "GdkCrossingMode") ()
+  '(enum
+    :normal
+    :grab
+    :ungrab))
+
+(deftype (property-state "GdkPropertyState") ()
+  '(enum
+    :new-value
+    :delete))
+
+; enumerations from "gdkfont.h"
+
+(deftype (font-type "GdkFontType") ()
+  '(enum
+    :font
+    :fontset))
+
+; enumerations from "gdkgc.h"
+
+(deftype (cap-style "GdkCapStyle") ()
+  '(enum
+    :not-last
+    :butt
+    :round
+    :projecting))
+
+(deftype (fill "GdkFill") ()
+  '(enum
+    :solid
+    :tiled
+    :stippled
+    :opaque-stippled))
+
+(deftype (gc-function "GdkFunction") ()
+  '(enum
+    :copy
+    :invert
+    :xor
+    :clear
+    :and
+    :and-reverse
+    :and-invert
+    :noop
+    :or
+    :equiv
+    :or-reverse
+    :copy-invert
+    :or-invert
+    :nand
+    :nor
+    :set))
+
+(deftype (join-style "GdkJoinStyle") ()
+  '(enum
+    :miter
+    :round
+    :bevel))
+
+(deftype (line-style "GdkLineStyle") ()
+  '(enum
+    :solid
+    :on-off-dash
+    :double-dash))
+
+(deftype (subwindow-mode "GdkSubwindowMode") ()
+  '(enum
+    (:clip-by-children  0)
+    (:include-inferiors  1 )))
+
+(deftype (g-c-values-mask "GdkGCValuesMask") ()
+  '(flags
+    (:foreground  0)
+    (:background  1)
+    (:font  2)
+    (:function  3)
+    (:fill  4)
+    (:tile  5)
+    (:stipple  6)
+    (:clip-mask  7)
+    (:subwindow  8)
+    (:ts-x-origin  9)
+    (:ts-y-origin  10)
+    (:clip-x-origin  11)
+    (:clip-y-origin  12)
+    (:exposures  13)
+    (:line-width  14)
+    (:line-style  15)
+    (:cap-style  16)
+    (:join-style  17 )))
+
+; enumerations from "gdkimage.h"
+
+(deftype (image-type "GdkImageType") ()
+  '(enum
+    :normal
+    :shared
+    :fastest
+    :shared-pixmap))
+
+; enumerations from "gdkim.h"
+
+(deftype (im-style "GdkIMStyle") ()
+  '(flags
+;    (:preedit-area  #x0001)
+;    (:preedit-callbacks  #x0002)
+;    (:preedit-position  #x0004)
+;    (:preedit-nothing  #x0008)
+;    (:preedit-none  #x0010)
+;    (:preedit-mask  #x001f)
+;    (:status-area  #x0100)
+;    (:status-callbacks  #x0200)
+;    (:status-nothing  #x0400)
+;    (:status-none  #x0800)
+;    (:status-mask  #x0f00  )
+   ))
+
+; (deftype (ic-attributes-type "GdkICAttributesType") ()
+;   '(flags
+;     (:style  0)
+;     (:client-window  1)
+;     (:focus-window  2)
+;     (:filter-events  3)
+;     (:spot-location  4)
+;     (:line-spacing  5)
+;     (:cursor  6)
+;     (:preedit-fontset  10)
+;     (:preedit-area  11)
+;     (:preedit-area-needed  12)
+;     (:preedit-foreground  13)
+;     (:preedit-background  14)
+;     (:preedit-pixmap  15)
+;     (:preedit-colormap  16)
+;     (:status-fontset  21)
+;     (:status-area  22)
+;     (:status-area-needed  23)
+;     (:status-foreground  24)
+;     (:status-background  25)
+;     (:status-pixmap  26)
+;     (:status-colormap  27)
+; ;    (:all-req  GDK_IC_STYLE | )
+;     :client-window
+; ;    (:preedit-area-req  GDK_IC_PREEDIT_AREA |  )
+;     :preedit-fontset
+; ;    (:preedit-position-req  GDK_IC_PREEDIT_AREA | GDK_IC_SPOT_LOCATION | )
+;     :preedit-fontset
+; ;    (:status-area-req  GDK_IC_STATUS_AREA |  )
+;     :status-fontset))
+
+; enumerations from "gdkinput.h"
+
+(deftype (extension-mode "GdkExtensionMode") ()
+  '(enum
+    :none
+    :all
+    :cursor))
+
+(deftype (input-source "GdkInputSource") ()
+  '(enum
+    :mouse
+    :pen
+    :eraser
+    :cursor))
+
+(deftype (input-mode "GdkInputMode") ()
+  '(enum
+    :disabled
+    :screen
+    :window))
+
+(deftype (axis-use "GdkAxisUse") ()
+  '(enum
+    :ignore
+    :x
+    :y
+    :pressure
+    :xtilt
+    :ytilt
+    :wheel
+    :last))
+
+; enumerations from "gdkpixbuf.h"
+
+; (deftype (pixbuf-alpha-mode "GdkPixbufAlphaMode") ()
+;   '(enum
+;     :bilevel
+;     :full))
+
+; enumerations from "gdkproperty.h"
+
+(deftype (prop-mode "GdkPropMode") ()
+  '(enum
+    :replace
+    :prepend
+    :append))
+
+; enumerations from "gdkregion.h"
+
+(deftype (fill-rule "GdkFillRule") ()
+  '(enum
+    :even-odd-rule
+    :winding-rule))
+
+(deftype (overlap-type "GdkOverlapType") ()
+  '(enum
+    :in
+    :out
+    :part))
+
+; enumerations from "gdkrgb.h"
+
+(deftype (rgb-dither "GdkRgbDither") ()
+  '(enum
+    :none
+    :normal
+    :max))
+
+; enumerations from "gdkselection.h"
+
+(deftype (selection "GdkSelection") ()
+  '(enum
+    (:primary  1)
+    (:secondary  2 )))
+
+(deftype (target "GdkTarget") ()
+  '(enum
+    (:bitmap  5)
+    (:colormap  7)
+    (:drawable  17)
+    (:pixmap  20)
+    (:string  31 )))
+
+(deftype (selection-type "GdkSelectionType") ()
+  '(enum
+    (:atom  4)
+    (:bitmap  5)
+    (:colormap  7)
+    (:drawable  17)
+    (:integer  19)
+    (:pixmap  20)
+    (:window  33)
+    (:string  31 )))
+
+; enumerations from "gdktypes.h"
+
+(deftype (byte-order "GdkByteOrder") ()
+  '(enum
+    :lsb-first
+    :msb-first))
+
+(deftype (modifier-type "GdkModifierType") ()
+  '(flags
+    (:shift-mask  0)
+    (:lock-mask  1)
+    (:control-mask  2)
+    (:mod1-mask  3)
+    (:mod2-mask  4)
+    (:mod3-mask  5)
+    (:mod4-mask  6)
+    (:mod5-mask  7)
+    (:button1-mask  8)
+    (:button2-mask  9)
+    (:button3-mask  10)
+    (:button4-mask  11)
+    (:button5-mask  12)
+    (:release-mask  31)
+;    (:modifier-mask  GDK_RELEASE_MASK | #x1fff )
+   ))
+
+(deftype (input-condition "GdkInputCondition") ()
+  '(flags
+    (:read  0)
+    (:write  1)
+    (:exception  2 )))
+
+(deftype (status "GdkStatus") ()
+  '(enum
+    (:ok  0)
+    (:error  -1)
+    (:error-param  -2)
+    (:error-file  -3)
+    (:error-mem  -4 )))
+
+(deftype (grab-status "GdkGrabStatus") ()
+  '(enum
+    (:success  0)
+    (:already-grabbed  1)
+    (:invalid-time  2)
+    (:not-viewable  3)
+    (:frozen  4 )))
+
+; enumerations from "gdkvisual.h"
+
+(deftype (visual-type "GdkVisualType") ()
+  '(enum
+    :static-gray
+    :grayscale
+    :static-color
+    :pseudo-color
+    :true-color
+    :direct-color))
+
+; enumerations from "gdkwindow.h"
+
+(deftype (window-class "GdkWindowClass") ()
+  '(enum
+    :output
+    :only))
+
+(deftype (window-type "GdkWindowType") ()
+  '(enum
+    :root
+    :toplevel
+    :child
+    :dialog
+    :temp
+    :foreign))
+
+(deftype (window-attributes-type "GdkWindowAttributesType") ()
+  '(flags
+    (:title  1)
+    (:x  2)
+    (:y  3)
+    (:cursor  4)
+    (:colormap  5)
+    (:visual  6)
+    (:wmclass  7)
+    (:noredir  8 )))
+
+(deftype (window-hints "GdkWindowHints") ()
+  '(flags
+    (:pos  0)
+    (:min-size  1)
+    (:max-size  2)
+    (:base-size  3)
+    (:aspect  4)
+    (:resize-inc  5 )))
+
+(deftype (wm-decoration "GdkWMDecoration") ()
+  '(flags
+    (:all  0)
+    (:border  1)
+    (:resizeh  2)
+    (:title  3)
+    (:menu  4)
+    (:minimize  5)
+    (:maximize  6 )))
+
+(deftype (wm-function "GdkWMFunction") ()
+  '(flags
+    (:all  0)
+    (:resize  1)
+    (:move  2)
+    (:minimize  3)
+    (:maximize  4)
+    (:close  5 )))
diff --git a/gdk/gdkglue.c b/gdk/gdkglue.c
new file mode 100644 (file)
index 0000000..89e6470
--- /dev/null
@@ -0,0 +1,38 @@
+/* Common Lisp bindings for GTK+ v2.0
+ * Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* $Id: gdkglue.c,v 1.1 2000/08/14 16:44:41 espen Exp $ */
+
+
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+
+extern GPollFD event_poll_fd;
+
+gint gdk_event_poll_fd ()
+{
+  return event_poll_fd.fd;
+}
+
+
+GdkWindow*
+gdk_get_root_window ()
+{
+  return gdk_window_foreign_new (GDK_ROOT_WINDOW ());
+}
diff --git a/gdk/gdktypes.lisp b/gdk/gdktypes.lisp
new file mode 100644 (file)
index 0000000..4b0ff4b
--- /dev/null
@@ -0,0 +1,199 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gdktypes.lisp,v 1.1 2000/08/14 16:44:41 espen Exp $
+
+(in-package "GDK")
+
+
+(defclass color (alien-object)
+  ((pixel
+    :allocation :alien
+    :type unsigned-long)
+   (red
+    :allocation :alien
+    :accessor color-red
+    :type unsigned-short)
+   (green
+    :allocation :alien
+    :accessor color-grenn
+    :type unsigned-short)
+   (blue
+    :allocation :alien
+    :accessor color-blue
+    :type unsigned-short))
+  (:metaclass alien-class)
+  (:alien-name "GdkColor"))
+
+
+(defclass visual (static-structure)
+  ()
+  (:metaclass alien-class)
+  (:alien-name "GdkVisual"))
+
+
+(defclass colormap (gobject)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkColormap"))
+
+
+(defclass drawable (gobject)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkDrawable"))
+
+
+(defclass window (drawable)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkWindow")
+  (:type-init "gdk_window_object_get_type"))
+
+
+(defclass pixmap (drawable)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkPixmap"))
+
+; (defclass bitmap (drawable))
+(deftype bitmap () 'pointer)
+
+; (defclass geometry (alien-structure)
+;   ((min-width
+;     :allocation :alien
+;     :accessor geometry-min-width
+;     :initarg :min-width
+;     :type int)  
+;    (min-height
+;     :allocation :alien
+;     :accessor geometry-min-height
+;     :initarg :min-heigth
+;     :type int)
+;    (max-width
+;     :allocation :alien
+;     :accessor geometry-max-width
+;     :initarg :max-width
+;     :type int)  
+;    (max-height
+;     :allocation :alien
+;     :accessor geometry-max-height
+;     :initarg :max-heigth
+;     :type int)
+;    (base-width
+;     :allocation :alien
+;     :accessor geometry-base-width
+;     :initarg :base-width
+;     :type int)
+;    (base-height
+;     :allocation :alien
+;     :accessor geometry-base-height
+;     :initarg :base-heigth
+;     :type int)
+;    (width-inc
+;     :allocation :alien
+;     :accessor geometry-width-inc
+;     :initarg :width-inc
+;     :type int)   
+;    (height-inc
+;     :allocation :alien
+;     :accessor geometry-height-inc
+;     :initarg :heigth-inc
+;     :type int)
+;    (min-aspect
+;     :allocation :alien
+;     :accessor geometry-min-aspect
+;     :initarg :min-aspect
+;     :type double-float)
+;    (max-aspect
+;     :allocation :alien
+;     :accessor geometry-max-aspect
+;     :initarg :max-aspect
+;     :type double-float))
+;   (:metaclass alien-class))
+  
+
+(defclass image (gobject)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkImage"))
+
+
+(defclass gc (gobject)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkGC"))
+
+
+(defclass font (alien-object)
+  ()
+  (:metaclass alien-class)
+  (:alien-name "GdkFont"))
+
+
+(defclass cursor (alien-object)
+  ((type
+    :allocation :alien
+    :accessor cursor-type
+    :initarg :type
+    :type cursor-type))
+  (:metaclass alien-class))
+
+
+(defclass drag-context (gobject)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GdkDragContext"))
+
+
+(defclass event (alien-structure)
+  ((type
+    :allocation :alien
+;    :accessor event-type
+    :type event-type)
+   (window
+    :allocation :alien
+    :accessor event-window
+    :initarg :window
+    :type window)
+   (send-event
+    :allocation :alien
+    :accessor event-send-event
+    :initarg :send-event
+    :type (signed 8)))
+  (:metaclass alien-class)
+  (:alien-name "GdkEvent"))
+
+
+(defclass expose-event (event)
+  ()
+  (:metaclass alien-class))
+
+
+(defclass delete-event (event)
+  ()
+  (:metaclass alien-class))
+
+
+
+
+;(define-boxed device-key)
+;(define-boxed device-info)
+;(define-boxed time-coord)
+;(define-boxed ic)
+;(define-boxed ic-attr)
+
diff --git a/glib/gforeign.lisp b/glib/gforeign.lisp
new file mode 100644 (file)
index 0000000..e94db37
--- /dev/null
@@ -0,0 +1,694 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gforeign.lisp,v 1.1 2000/08/14 16:44:38 espen Exp $
+
+(in-package "GLIB")
+
+;;;; Type methods
+
+(defvar *type-methods* (make-hash-table))
+
+(defun ensure-type-method-fun (fname)
+  (unless (fboundp fname)
+    (setf
+     (symbol-function fname)
+     #'(lambda (type-spec &rest args)
+        (apply
+         (find-applicable-type-method type-spec fname) type-spec args)))))
+
+(defmacro define-type-method-fun (fname lambda-list)
+  (declare (ignore lambda-list))
+  `(defun ,fname (type-spec &rest args)
+     (apply
+      (find-applicable-type-method type-spec ',fname) type-spec args)))
+
+
+(defun ensure-type-name (type)
+  (etypecase type
+    (symbol type)
+    (pcl::class (class-name type))))
+
+(defun add-type-method (type fname function)
+  (push
+   (cons fname function)
+   (gethash (ensure-type-name type) *type-methods*)))
+
+(defun find-type-method (type fname)
+  (cdr (assoc fname (gethash (ensure-type-name type) *type-methods*))))
+
+(defun find-applicable-type-method (type-spec fname &optional (error t))
+  (flet ((find-superclass-method (class)
+          (when class
+            (dolist (super (cdr (pcl::class-precedence-list class)))
+              (return-if (find-type-method super fname)))))
+        (find-expanded-type-method (type-spec)
+          (multiple-value-bind (expanded-type-spec expanded-p)
+              (type-expand-1 type-spec)
+            (cond
+             (expanded-p 
+              (find-applicable-type-method expanded-type-spec fname nil))
+             ((neq type-spec t)
+              (find-applicable-type-method t fname nil))))))
+
+    (or
+     (typecase type-spec
+       (pcl::class
+       (or
+        (find-type-method type-spec fname)
+        (find-superclass-method type-spec)))
+       (symbol
+       (or
+        (find-type-method type-spec fname)
+        (find-expanded-type-method type-spec)
+        (find-superclass-method (find-class type-spec nil))))
+       (cons
+       (or
+        (find-type-method (first type-spec) fname)
+        (find-expanded-type-method type-spec)))
+       (t
+       (error "Invalid type specifier ~A" type-spec)))
+     (and
+      error
+      (error
+       "No applicable method for ~A when called with type specifier ~A"
+       fname type-spec)))))
+
+(defmacro deftype-method (fname type lambda-list &body body)
+  `(progn
+     (ensure-type-method-fun ',fname)
+     (add-type-method ',type ',fname #'(lambda ,lambda-list ,@body))
+     ',fname))
+  
+(defmacro deftype (name parameters &body body)
+  (destructuring-bind (lisp-name &optional alien-name) (mklist name)
+    `(progn
+       ,(when alien-name
+         `(setf (alien-type-name ',lisp-name) ,alien-name))
+       (lisp:deftype ,lisp-name ,parameters ,@body))))
+
+;; To make the compiler shut up
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (define-type-method-fun translate-type-spec (type-spec))
+  (define-type-method-fun translate-to-alien (type-spec expr &optional copy))
+  (define-type-method-fun translate-from-alien (type-spec expr &optional alloc))
+  (define-type-method-fun cleanup-alien (type-spec expr &optional copied)))
+  
+
+;;;; 
+
+(defvar *type-function-cache* (make-hash-table :test #'equal))
+
+(defun get-cached-function (type-spec fname)
+  (cdr (assoc fname (gethash type-spec *type-function-cache*))))
+
+(defun set-cached-function (type-spec fname function)
+  (push (cons fname function) (gethash type-spec *type-function-cache*))
+  function)
+  
+
+;; Creates a function to translate an object of the specified type
+;; from lisp to alien representation.
+(defun get-to-alien-function (type-spec)
+  (or
+   (get-cached-function type-spec 'to-alien-function)
+   (set-cached-function type-spec 'to-alien-function
+    (compile
+     nil
+     `(lambda (object)
+       (declare (ignorable object))
+       ,(translate-to-alien type-spec 'object))))))
+
+;; and the opposite
+(defun get-from-alien-function (type-spec)
+  (or
+   (get-cached-function type-spec 'from-alien-function)
+   (set-cached-function type-spec 'from-alien-function
+    (compile
+     nil
+     `(lambda (alien)
+       (declare (ignorable alien))
+       ,(translate-from-alien type-spec 'alien))))))
+
+;; and for cleaning up
+(defun get-cleanup-function (type-spec)
+  (or
+   (get-cached-function type-spec 'cleanup-function)
+   (set-cached-function type-spec 'cleanup-function
+    (compile
+     nil
+     `(lambda (alien)
+       (declare (ignorable alien))
+       ,(cleanup-alien type-spec 'alien))))))
+
+
+
+;; Creates a function to write an object of the specified type
+;; to the given memory location
+(defun get-writer-function (type-spec)
+  (or
+   (get-cached-function type-spec 'writer-function)
+   (set-cached-function type-spec 'writer-function
+    (compile
+     nil
+     `(lambda (value sap offset)
+       (declare (ignorable value sap offset))
+       (setf
+        (,(sap-ref-fname type-spec) sap offset)
+        ,(translate-to-alien type-spec 'value :copy)))))))
+
+;; Creates a function to read an object of the specified type
+;; from the given memory location
+(defun get-reader-function (type-spec)
+  (or
+   (get-cached-function type-spec 'reader-function)
+   (set-cached-function type-spec 'reader-function
+    (compile
+     nil
+     `(lambda (sap offset)      
+       (declare (ignorable sap offset))
+       ,(translate-from-alien
+         type-spec `(,(sap-ref-fname type-spec) sap offset) :copy))))))
+
+
+(defun get-destroy-function (type-spec)
+  (or
+   (get-cached-function type-spec 'destroy-function)
+   (set-cached-function type-spec 'destroy-function
+    (compile
+     nil
+     `(lambda (sap offset)      
+       (declare (ignorable sap offset))
+       ,(cleanup-alien
+         type-spec `(,(sap-ref-fname type-spec) sap offset) :copied))))))
+
+
+
+;;;;
+
+(defconstant +size-of-int+ 4)
+(defconstant +size-of-sap+ 4)
+(defconstant +size-of-float+ 4)
+(defconstant +size-of-double+ 8)
+
+(defun sap-ref-unsigned (sap offset)
+  (sap-ref-32 sap offset))
+
+(defun sap-ref-signed (sap offset)
+  (signed-sap-ref-32 sap offset))
+
+(defun sap-ref-fname (type-spec)
+  (let ((alien-type-spec (mklist (translate-type-spec type-spec))))
+    (ecase (first alien-type-spec)
+      (unsigned
+       (ecase (second alien-type-spec)
+        (8 'sap-ref-8)
+        (16 'sap-ref-16)
+        (32 'sap-ref-32)
+        (64 'sap-ref-64)))
+      (signed
+       (ecase (second alien-type-spec)
+        (8 'signed-sap-ref-8)
+        (16 'signed-sap-ref-16)
+        (32 'signed-sap-ref-32)
+        (64 'signed-sap-ref-64)))
+      (system-area-pointer 'sap-ref-sap)
+      (single-float 'sap-ref-single)
+      (double-float 'sap-ref-double))))
+
+
+(defun signed (size)
+  (if (eq size '*)
+      `(signed ,(* 8 +size-of-int+))
+    `(signed ,size)))
+
+(defun unsigned (size)
+  (if (eq size '*)
+      `(unsigned ,(* 8 +size-of-int+))
+    `(unsigned ,size)))
+
+(defun size-of (type-spec)
+  (let ((alien-type-spec (translate-type-spec type-spec)))
+    (ecase (first (mklist alien-type-spec))
+     ((signed unsigned) (/ (second alien-type-spec) 8))
+     ((system-area-pointer single-float) +size-of-sap+)
+     (single-float +size-of-float+)
+     (double-float +size-of-double+))))
+
+
+;;;; Foreign function call interface
+
+(defvar *package-prefix* nil)
+
+(defun set-package-prefix (prefix &optional (package *package*))
+  (let ((package (find-package package)))
+    (delete-if #'(lambda (assoc) (eq (car assoc) package)) *package-prefix*)
+    (push (cons package prefix) *package-prefix*))
+  prefix)
+
+(defun package-prefix (&optional (package *package*))
+  (let ((package (find-package package)))
+    (or
+     (cdr (assoc package *package-prefix*))
+     (substitute #\_ #\- (string-downcase (package-name package))))))
+
+(defmacro use-prefix (prefix &optional (package *package*))
+  `(eval-when (:compile-toplevel :load-toplevel :execute)
+     (set-package-prefix ,prefix ,package)))
+
+
+(defun default-alien-func-name (lisp-name)
+  (let* ((lisp-name-string
+         (if (char= (char (the simple-string (string lisp-name)) 0) #\%)
+             (subseq (the simple-string (string lisp-name)) 1)
+           (string lisp-name)))
+        (prefix (package-prefix *package*))
+        (name (substitute #\_ #\- (string-downcase lisp-name-string))))
+    (if (or (not prefix) (string= prefix ""))
+       name
+      (format nil "~A_~A" prefix name))))
+
+
+(defmacro define-foreign (name lambda-list return-type-spec &rest docs/args)
+  (multiple-value-bind (c-name lisp-name)
+      (if (atom name)
+         (values (default-alien-func-name name) name)
+       (values-list name))
+    (let ((supplied-lambda-list lambda-list)
+         (docs nil)
+         (args nil))
+      (dolist (doc/arg docs/args)
+       (if (stringp doc/arg)
+           (push doc/arg docs)
+         (progn
+           (destructuring-bind (expr type &optional (style :in)) doc/arg
+             (unless (member style '(:in :out))
+               (error "Bogus argument style ~S in ~S." style doc/arg))
+             (when (and (not supplied-lambda-list) (namep expr) (eq style :in))
+               (push expr lambda-list))
+             (push
+              (list (if (namep expr) expr (gensym)) expr type style) args)))))
+      
+      (%define-foreign
+       c-name lisp-name (or supplied-lambda-list (nreverse lambda-list))
+       return-type-spec (reverse docs) (reverse args)))))
+
+
+#+cmu
+(defun %define-foreign (foreign-name lisp-name lambda-list
+                       return-type-spec docs args)
+  (ext:collect ((alien-types) (alien-bindings) (alien-parameters)
+               (alien-values) (alien-deallocatiors))
+    (dolist (arg args)
+      (destructuring-bind (var expr type-spec style) arg
+       (let ((declaration (translate-type-spec type-spec))
+             (deallocation (cleanup-alien type-spec expr)))
+         (cond
+          ((eq style :out)
+           (alien-types `(* ,declaration))
+           (alien-parameters `(addr ,var))
+           (alien-bindings `(,var ,declaration))
+           (alien-values (translate-from-alien type-spec var)))
+         (deallocation
+          (alien-types declaration)
+          (alien-bindings
+           `(,var ,declaration ,(translate-to-alien type-spec expr)))
+          (alien-parameters var)
+          (alien-deallocatiors deallocation))
+         (t
+          (alien-types declaration)
+          (alien-parameters (translate-to-alien type-spec expr)))))))
+
+    (let ((alien-funcall `(alien-funcall ,lisp-name ,@(alien-parameters))))
+      `(defun ,lisp-name ,lambda-list
+        ,@docs
+        (with-alien ((,lisp-name
+                      (function
+                       ,(translate-type-spec return-type-spec)
+                       ,@(alien-types))
+                      :extern ,foreign-name)
+                     ,@(alien-bindings))
+          ,(if return-type-spec
+               `(let ((result
+                       ,(translate-from-alien return-type-spec alien-funcall)))
+                  ,@(alien-deallocatiors)
+                  (values result ,@(alien-values)))
+             `(progn
+                ,alien-funcall
+                ,@(alien-deallocatiors)
+                (values ,@(alien-values)))))))))
+
+  
+
+
+;;;; Translations for fundamental types
+
+(lisp:deftype long (&optional (min '*) (max '*)) `(integer ,min ,max))
+(lisp:deftype unsigned-long (&optional (min '*) (max '*)) `(integer ,min ,max))
+(lisp:deftype int (&optional (min '*) (max '*)) `(long ,min ,max))
+(lisp:deftype unsigned-int (&optional (min '*) (max '*)) `(unsigned-long ,min ,max))
+(lisp:deftype short (&optional (min '*) (max '*)) `(int ,min ,max))
+(lisp:deftype unsigned-short (&optional (min '*) (max '*)) `(unsigned-int ,min ,max))
+(lisp:deftype signed (&optional (size '*)) `(signed-byte ,size))
+(lisp:deftype unsigned (&optional (size '*)) `(signed-byte ,size))
+(lisp:deftype char () 'base-char)
+(lisp:deftype pointer () 'system-area-pointer)
+(lisp:deftype boolean (&optional (size '*))
+  (declare (ignore size))
+  `(member t nil))
+(lisp:deftype static (type) type)
+(lisp:deftype invalid () nil)
+
+
+(deftype-method cleanup-alien t (type-spec alien &optional copied)
+  (declare (ignore type-spec alien copied))
+  nil)
+
+
+(deftype-method translate-to-alien integer (type-spec number &optional copy)
+  (declare (ignore type-spec copy))
+  number)
+
+(deftype-method translate-from-alien integer (type-spec number &optional alloc)
+  (declare (ignore type-spec alloc))
+  number)
+
+
+(deftype-method translate-type-spec fixnum (type-spec)
+  (declare (ignore type-spec))
+  (signed '*))
+
+(deftype-method translate-to-alien fixnum (type-spec number &optional copy)
+  (declare (ignore type-spec copy))
+  number)
+
+(deftype-method translate-from-alien fixnum (type-spec number &optional alloc)
+  (declare (ignore type-spec alloc))
+  number)
+
+
+(deftype-method translate-type-spec long (type-spec)
+  (declare (ignore type-spec))
+  (signed '*))
+
+
+(deftype-method translate-type-spec unsigned-long (type-spec)
+  (declare (ignore type-spec))
+  (unsigned '*))
+
+
+(deftype-method translate-type-spec short (type-spec)
+  (declare (ignore type-spec))
+  '(signed 16))
+
+
+(deftype-method translate-type-spec unsigned-short (type-spec)
+  (declare (ignore type-spec))
+  '(unsigned 16))
+
+
+(deftype-method translate-type-spec signed-byte (type-spec)
+  (destructuring-bind (name &optional (size '*))
+      (type-expand-to 'signed-byte type-spec)
+    (declare (ignore name))
+    (signed size)))
+
+(deftype-method translate-to-alien signed-byte (type-spec number &optional copy)
+  (declare (ignore type-spec copy))
+  number)
+
+(deftype-method
+    translate-from-alien signed-byte (type-spec number &optional alloc)
+  (declare (ignore type-spec alloc))
+  number)
+
+
+(deftype-method translate-type-spec unsigned-byte (type-spec)
+  (destructuring-bind (name &optional (size '*))
+      (type-expand-to 'unsigned-byte type-spec)
+    (declare (ignore name))
+    (unsigned size)))
+
+(deftype-method
+    translate-to-alien unsigned-byte (type-spec number &optional copy)
+  (declare (ignore type-spec copy))
+  number)
+
+(deftype-method
+    translate-from-alien unsigned-byte (type-spec number &optional alloc)
+  (declare (ignore type-spec alloc))
+  number)
+
+
+(deftype-method translate-type-spec single-float (type-spec)
+  (declare (ignore type-spec))
+  'single-float)
+
+(deftype-method
+    translate-to-alien single-float (type-spec number &optional copy)
+  (declare (ignore type-spec copy))
+  number)
+
+(deftype-method
+    translate-from-alien single-float (type-spec number &optional alloc)
+  (declare (ignore type-spec alloc))
+  number)
+
+
+(deftype-method translate-type-spec double-float (type-spec)
+  (declare (ignore type-spec))
+  'double-float)
+
+(deftype-method
+    translate-to-alien double-float (type-spec number &optional copy)
+  (declare (ignore type-spec copy))
+  number)
+
+(deftype-method
+    translate-from-alien double-float (type-spec number &optional alloc)
+  (declare (ignore type-spec alloc))
+  number)
+
+
+(deftype-method translate-type-spec base-char (type-spec)
+  (declare (ignore type-spec))
+  '(unsigned 8))
+
+(deftype-method translate-to-alien base-char (type-spec char &optional copy)
+  (declare (ignore type-spec copy))
+  `(char-code ,char))
+
+(deftype-method translate-from-alien base-char (type-spec code &optional alloc)
+  (declare (ignore type-spec alloc))
+  `(code-char ,code))
+
+
+(deftype-method translate-type-spec string (type-spec)
+  (declare (ignore type-spec))
+  'system-area-pointer)
+
+(deftype-method translate-to-alien string (type-spec string &optional copy)
+  (declare (ignore type-spec))
+  (if copy
+      `(let ((string ,string))
+        (copy-memory
+         (make-pointer (1+ (kernel:get-lisp-obj-address string)))
+         (1+ (length string))))
+    `(make-pointer (1+ (kernel:get-lisp-obj-address ,string)))))
+
+(deftype-method
+    translate-from-alien string (type-spec sap &optional (alloc :dynamic))
+  (declare (ignore type-spec))
+  `(let ((sap ,sap))
+     (unless (null-pointer-p sap)
+       (prog1
+          (c-call::%naturalize-c-string sap)
+        ,(when (eq alloc :dynamic) `(deallocate-memory ,sap))))))
+
+(deftype-method cleanup-alien string (type-spec sap &optional copied)
+  (declare (ignore type-spec))
+  (when copied
+    `(let ((sap ,sap))
+       (unless (null-pointer-p sap)
+        (deallocate-memory sap)))))
+
+
+(deftype-method translate-type-spec boolean (type-spec)
+  (if (atom type-spec)
+      (unsigned '*)
+    (destructuring-bind (name &optional (size '*))
+       (type-expand-to 'boolean type-spec)
+      (declare (ignore name))
+      (unsigned size))))
+
+(deftype-method translate-to-alien boolean (type-spec boolean &optional copy)
+  (declare (ignore type-spec copy))
+  `(if ,boolean 1 0))
+
+(deftype-method translate-from-alien boolean (type-spec int &optional alloc)
+  (declare (ignore type-spec alloc))
+  `(not (zerop ,int)))
+
+
+(deftype-method translate-type-spec or (union-type-spec)
+  (destructuring-bind (name &rest type-specs)
+      (type-expand-to 'or union-type-spec)
+    (declare (ignore name))
+    (let ((type-spec-translations
+          (map 'list #'translate-type-spec type-specs)))
+      (unless (apply #'all-equal type-spec-translations)
+       (error
+        "No common alien type specifier for union type: ~A" union-type-spec))
+      (first type-spec-translations))))
+
+(deftype-method translate-to-alien or (union-type-spec expr &optional copy)
+  (destructuring-bind (name &rest type-specs)
+      (type-expand-to 'or union-type-spec)
+    (declare (ignore name))
+    `(let ((value ,expr))
+       (etypecase value
+        ,@(map
+           'list
+           #'(lambda (type-spec)
+               (list type-spec (translate-to-alien type-spec 'value copy)))
+           type-specs)))))
+
+
+
+(deftype-method translate-type-spec system-area-pointer (type-spec)
+  (declare (ignore type-spec))
+  'system-area-pointer)
+
+(deftype-method
+    translate-to-alien system-area-pointer (type-spec sap &optional copy)
+  (declare (ignore type-spec copy))
+  sap)
+
+(deftype-method
+  translate-from-alien system-area-pointer (type-spec sap &optional alloc)
+  (declare (ignore type-spec alloc))
+  sap)
+
+
+(deftype-method translate-type-spec null (type-spec)
+  (declare (ignore type-spec))
+  'system-area-pointer)
+
+(deftype-method translate-to-alien null (type-spec expr &optional copy)
+  (declare (ignore type-spec copy))
+  `(make-pointer 0))
+
+
+(deftype-method translate-type-spec nil (type-spec)
+  (declare (ignore type-spec))
+  'void)
+
+
+(deftype-method transalte-type-spec static (type-spec)
+  (translate-type-spec (second type-spec)))
+  
+(deftype-method translate-to-alien static (type-spec expr &optional copy)
+  (declare (ignore copy))
+  (translate-to-alien (second type-spec) expr nil))
+
+(deftype-method translate-from-alien static (type-spec alien &optional alloc)
+  (declare (ignore alloc))
+  (translate-from-alien (second type-spec) alien nil))
+
+(deftype-method cleanup-alien static (type-spec alien &optional copied)
+  (declare (ignore copied))
+  (cleanup-alien type-spec alien nil))
+
+
+
+;;;; Enum and flags type
+
+(defun map-mappings (args op)
+  (let ((current-value 0))
+    (map
+     'list 
+     #'(lambda (mapping)
+        (destructuring-bind (symbol &optional (value current-value))
+            (mklist mapping)
+          (setf current-value (1+ value))
+          (case op
+            (:enum-int (list symbol value))
+            (:flags-int (list symbol (ash 1 value)))
+            (:int-enum (list value symbol))
+            (:int-flags (list (ash 1 value) symbol))
+            (:symbols symbol))))
+     (if (integerp (first args))
+        (rest args)
+       args))))
+
+(lisp:deftype enum (&rest args)
+  `(member ,@(map-mappings args :symbols)))
+
+(deftype-method translate-type-spec enum (type-spec)
+  (destructuring-bind (name &rest args) (type-expand-to 'enum type-spec)
+    (declare (ignore name))
+    (if (integerp (first args))
+       `(signed ,(first args))
+      '(signed 32))))
+
+(deftype-method translate-to-alien enum (type-spec expr &optional copy)
+  (declare (ignore copy))
+  (destructuring-bind (name &rest args) (type-expand-to 'enum type-spec)
+    (declare (ignore name))
+    `(ecase ,expr
+       ,@(map-mappings args :enum-int))))
+
+(deftype-method translate-from-alien enum (type-spec expr &optional alloc)
+  (declare (ignore alloc))
+  (destructuring-bind (name &rest args) (type-expand-to 'enum type-spec)
+    (declare (ignore name))
+    `(ecase ,expr
+       ,@(map-mappings args :int-enum))))
+
+
+(lisp:deftype flags (&rest args)
+  `(or
+    null
+    (cons
+     (member ,@(map-mappings args :symbols))
+     list)))
+
+(deftype-method translate-type-spec flags (type-spec)
+  (destructuring-bind (name &rest args) (type-expand-to 'flags type-spec)
+    (declare (ignore name))
+    (if (integerp (first args))
+       `(signed ,(first args))
+      '(signed 32))))
+
+(deftype-method translate-to-alien flags (type-spec expr &optional copy)
+  (declare (ignore copy))
+  (destructuring-bind (name &rest args) (type-expand-to 'flags type-spec)
+    (declare (ignore name))
+    (let ((mappings (map-mappings args :flags-int)))
+      `(let ((value 0))
+        (dolist (flag ,expr value)
+          (setq value (logior value (second (assoc flag ',mappings)))))))))
+
+(deftype-method translate-from-alien flags (type-spec expr &optional alloc)
+  (declare (ignore alloc))
+  (destructuring-bind (name &rest args) (type-expand-to 'flags type-spec)
+    (declare (ignore name))
+    (let ((mappings (map-mappings args :int-flags)))
+      `(let ((result nil))
+        (dolist (mapping ',mappings result)
+          (unless (zerop (logand ,expr (first mapping)))
+            (push (second mapping) result)))))))
diff --git a/glib/glib-export.lisp b/glib/glib-export.lisp
new file mode 100644 (file)
index 0000000..cf68270
--- /dev/null
@@ -0,0 +1,45 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: glib-export.lisp,v 1.1 2000/08/14 16:44:30 espen Exp $
+
+
+;;; Autogenerating exported symbols
+
+(in-package "GLIB")
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defexport define-foreign (name &rest args)
+    (declare (ignore args))
+    (if (symbolp name)
+       name
+      (second name)))
+
+  (defexport deftype (name &rest args)
+    (declare (ignore args))
+    (if (symbolp name)
+       name
+      (first name)))
+
+  (defexport define-type-method-func (name lambda-list)
+    (declare (ignore lambda-list))
+    name))
+
+(export-from-file #p"clg:glib;gutils.lisp")
+(export-from-file #p"clg:glib;glib.lisp")
+(export-from-file #p"clg:glib;gtype.lisp")
+(export-from-file #p"clg:glib;gobject.lisp")
diff --git a/glib/glib-package.lisp b/glib/glib-package.lisp
new file mode 100644 (file)
index 0000000..e95a313
--- /dev/null
@@ -0,0 +1,37 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: glib-package.lisp,v 1.1 2000/08/14 16:44:30 espen Exp $
+
+(export 'kernel::type-expand-1 "KERNEL")
+
+(defpackage "GLIB"
+  (:use "ALIEN" "C-CALL" "SYSTEM" "COMMON-LISP" "PCL" "AUTOEXPORT")
+  (:shadow "DEFTYPE")
+  (:shadowing-import-from "PCL"
+          "CLASS-NAME" "BUILT-IN-CLASS" "CLASS-OF" "FIND-CLASS" "LOCATION"
+          "ALLOCATION" "DIRECT-SLOTS")
+  (:import-from "KERNEL" "TYPE-EXPAND-1")
+  (:export "DEFTYPE-METHOD" "TRANSLATE-TYPE-SPEC" "TRANSLATE-TO-ALIEN"
+          "TRANSLATE-FROM-ALIEN" "CLEANUP-ALIEN")
+  (:export "DEFINE-FOREIGN" "USE-PREFIX" "PACKAGE-PREFIX")
+  (:export "LONG" "UNSIGNED-LONG" "INT" "UNSIGNED-INT" "SHORT" "UNSIGNED-SHORT"
+          "SIGNED" "UNSIGNED" "CHAR" "POINTER" "ENUM" "FLAGS" "TYPE-NUMBER"
+          "STATIC")
+  (:export "GET-TO-ALIEN-FUNCTION" "GET-FROM-ALIEN-FUNCTION"
+          "GET-CLEANUP-FUNCTION" "GET-READER-FUNCTION" "GET-WRITER-FUNCTION"
+          "GET-DESTROY-FUNCTION"))
diff --git a/glib/glib.lisp b/glib/glib.lisp
new file mode 100644 (file)
index 0000000..fb62649
--- /dev/null
@@ -0,0 +1,194 @@
+;; Common Lisp bindings for GTK+ v1.2.x
+;; Copyright (C) 1999 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: glib.lisp,v 1.1 2000/08/14 16:44:31 espen Exp $
+
+
+(in-package "GLIB")
+(use-prefix "g")
+
+
+;;;; Memory management
+
+(define-foreign ("g_malloc0" allocate-memory) () pointer
+  (size unsigned-long))
+
+(define-foreign ("g_realloc" reallocate-memory) () pointer
+  (address pointer)
+  (size unsigned-long))
+
+(define-foreign ("g_free" deallocate-memory) () nil
+  (address pointer))
+
+(defun copy-memory (from length &optional (to (allocate-memory length)))
+  (kernel:system-area-copy from 0 to 0 (* 8 length))
+  to)
+
+
+
+;;;; Linked list
+
+(deftype glist () 'pointer)
+(deftype double-list (type) `(or (null (cons ,type list))))
+
+
+(define-foreign ("g_list_append" %glist-append) () glist
+  (glist glist)
+  (data unsigned))
+
+(defmacro glist-append (glist value type-spec)
+  (ecase (first (mklist (translate-type-spec type-spec)))
+    (unsigned `(%glist-append ,glist ,value))
+;    (signed `(%glist-append ,glist (signed-to-unsigned ,value)))
+    (system-area-pointer `(%glist-append ,glist (system:sap-int ,value)))))
+
+
+(defmacro glist-data (glist type-spec)
+  (ecase (first (mklist (translate-type-spec type-spec)))
+    (unsigned `(sap-ref-unsigned ,glist 0))
+    (signed `(sap-ref-signed ,glist 0))
+    (system-area-pointer `(sap-ref-sap ,glist 0))))
+
+
+(defun glist-next (glist)
+  (unless (null-pointer-p glist)
+    (sap-ref-sap glist +size-of-sap+)))
+  
+(define-foreign ("g_list_free" glist-free) () nil
+  (glist pointer))
+
+
+(deftype-method translate-type-spec double-list (type-spec)
+  (declare (ignore type-spec))
+  'system-area-pointer)
+
+(deftype-method translate-to-alien double-list (type-spec list &optional copy)
+  (declare (ignore copy))
+  (let* ((element-type-spec (second (type-expand-to 'double-list type-spec)))
+        (to-alien (translate-to-alien element-type-spec 'element t)))
+    `(let ((glist (make-pointer 0))) 
+       (dolist (element ,list glist)
+        (setq glist (glist-append glist ,to-alien element-type-spec))))))
+
+(deftype-method
+    translate-from-alien
+    double-list (type-spec glist &optional (alloc :dynamic))
+  (let ((element-type-spec (second (type-expand-to 'double-list type-spec))))
+    `(let ((glist ,glist)
+          (list nil))
+       (do ((tmp glist (glist-next tmp)))
+          ((null-pointer-p tmp))
+        (push
+         ,(translate-from-alien
+           element-type-spec `(glist-data tmp ,element-type-spec) alloc)
+         list))
+       ,(when (eq alloc :dynamic)
+         '(glist-free glist))
+       (nreverse list))))
+
+(deftype-method cleanup-alien double-list (type-spec glist &optional copied)
+  (declare (ignore copied))
+  (let* ((element-type-spec (second (type-expand-to 'double-list type-spec)))
+        (alien-type-spec (translate-type-spec element-type-spec)))
+    `(let ((glist ,glist))
+       (unless (null-pointer-p glist)
+        ,(when (eq alien-type-spec 'system-area-pointer)
+           `(do ((tmp glist (glist-next tmp)))
+                ((null-pointer-p tmp))
+              ,(cleanup-alien element-type-spec '(glist-data tmp) t)))
+        (glist-free glist)))))
+
+
+
+;;; Array
+#|
+(define-foreign ("g_array_new" %array-new) () garray
+  (zero-terminated boolean)
+  (clear boolean)
+  (element-size unsigned-int))
+
+(defun array-new (&key zero-terminated clear (element-size 4) initial-contents)
+  (let ((array (%array-new zero-terminated clear element-size)))
+    (when initial-contents
+      (dolist (element initial-contents)
+       (array-append array element)))
+    array))
+
+(define-foreign ("g_array_free" %array-free) () none
+  (array garray)
+  (free-segment boolean))
+
+(defun array-free (array &optional free-data (free-segment t))
+  (when free-data
+    (dotimes (i (array-get-size array))
+      (free (array-get-pointer array i))))
+  (%array-free array free-segment))
+
+(defmacro with-array (binding &body body)
+  (let ((array (gensym)))
+    (destructuring-bind (var &rest args
+                        &key (free-contents nil) (free-segment t)
+                        &allow-other-keys )
+        binding
+      (remf args :free-contents)
+      (remf args :free-segment)
+      `(let* ((,array (array-new ,@args))
+             (,var (array-get-data ,array)))
+        (unwind-protect
+            ,@body
+          (array-free ,array ,free-contents ,free-segment))))))
+
+;; cl-gtk.c
+(define-foreign ("g_array_insert_int" array-insert-int) () garray
+  (array garray)
+  (index unsigned-int)
+  (value int))
+
+(defun array-insert-value (array index value)
+  (etypecase value
+    (null (array-insert-int array index 0))
+    (integer (array-insert-int array index value))
+    (string (array-insert-int array index (sap-int (gforeign::pointer-to-sap (%strdup value)))))
+    (pointer (array-insert-int array index (sap-int (gforeign::pointer-to-sap value))))))
+
+(defun array-prepend (array value)
+  (array-insert-value array 0 value))
+
+(defun array-append (array value)
+  (array-insert-value array (array-get-size array) value))
+
+;; cl-gtk.c
+(define-foreign ("g_array_get_int" array-get-int) () int
+  (array garray)
+  (index unsigned-int))
+
+(defun array-get-pointer (array index)
+  (gforeign::sap-to-pointer (int-sap (array-get-int array index))))
+
+;; cl-gtk.c
+(define-foreign ("g_array_get_data" array-get-data) () pointer
+  (array garray))
+
+(define-foreign ("g_array_set_size" array-set-size) () garray
+  (array garray)
+  (size unsigned-int))
+
+;; cl-gtk.c
+(define-foreign ("g_array_get_size" array-get-size) () int
+  (array garray))
+|#
\ No newline at end of file
diff --git a/glib/gobject.lisp b/glib/gobject.lisp
new file mode 100644 (file)
index 0000000..574fa1c
--- /dev/null
@@ -0,0 +1,104 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gobject.lisp,v 1.1 2000/08/14 16:44:30 espen Exp $
+
+(in-package "GLIB")
+
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass gobject (gtype)
+    ()
+    (:metaclass gtype-class)
+    (:alien-name "GObject"))
+
+  (defclass gobject-class (gtype-class)))
+
+
+;;;; Methods for gobject
+
+;; Specializing reference-instance and unreference-instance on gobject
+;; is not really necessary but done for efficiency
+
+(defmethod reference-instance ((object gobject))
+  (%object-ref object)
+  object)
+
+(defmethod unreference-instance ((object gobject))
+  (%object-unref object))
+
+(deftype-method alien-ref gobject (type-spec)
+  (declare (ignore type-spec))
+  '%object-ref)
+
+(deftype-method alien-unref gobject (type-spec)
+  (declare (ignore type-spec))
+  '%object-unref)
+
+(define-foreign %object-ref () pointer
+  (object (or gobject pointer)))
+
+(define-foreign %object-unref () nil
+  (object (or gobject pointer)))
+
+
+;; Parameter stuff not yet implemented
+
+; (define-foreign object-set-param () nil
+;   (object gobject)
+;   (name string)
+;   (value gvalue))
+
+; (define-foreign object-get-param () nil
+;   (object gobject)
+;   (name string)
+;   (value gvalue :out))
+
+; (define-foreign object-queue-param-changed () nil
+;   (object gobject)
+;   (name string))
+
+
+
+;;;; Methods for gobject-class
+
+(defmethod shared-initialize ((class gobject-class) names &rest initargs
+                             &key type-init name)
+  (declare (ignore initargs names))
+  (let ((alien
+        (alien::%heap-alien
+         (alien::make-heap-alien-info
+          :type (alien::parse-alien-type '(function (unsigned 32)))
+          :sap-form (system:foreign-symbol-address
+                     (or
+                      (first type-init)
+                      (default-alien-func-name
+                        (format
+                         nil "~A_get_type" (or name (class-name class))))))))))
+    (alien:alien-funcall alien))
+  (call-next-method))
+
+
+; (define-foreign object-class-install-param () nil
+;   (class pointer)
+;   (id unsigned-int)
+;   (parameter parameter))
+
+; (define-foreign object-class-find-param-spec () parameter
+;   (class pointer)
+;   (name string))
+
diff --git a/glib/gtype.lisp b/glib/gtype.lisp
new file mode 100644 (file)
index 0000000..5cb1a7c
--- /dev/null
@@ -0,0 +1,640 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gtype.lisp,v 1.1 2000/08/14 16:44:34 espen Exp $
+
+(in-package "GLIB")
+
+(use-prefix "g")
+
+
+;;;; 
+
+(deftype type-number () '(unsigned 32))
+
+(define-foreign ("g_type_name" alien-type-name) (type) (static string)
+  ((find-type-number type) type-number))
+
+(define-foreign %type-from-name () type-number
+  (name string))
+
+;(define-foreign type-parent () type-number
+;  (type type-number))
+
+(define-foreign type-instance-size (type) int
+  ((find-type-number type) type-number))
+
+(define-foreign type-create-instance (type) pointer
+  ((find-type-number type) type-number))
+
+(define-foreign type-free-instance () nil
+  (instance pointer))
+
+
+(defvar *type-to-number-hash* (make-hash-table))
+(defvar *number-to-type-hash* (make-hash-table))
+
+(defun type-number-from-alien-name (name &optional (error t))
+  (if (string= name "invalid")
+      0
+    (let ((type-number (%type-from-name name)))
+      (cond
+       ((and (zerop type-number) error)
+       (error "Invalid alien type name: ~A" name))
+       ((zerop type-number) nil)
+       (t type-number)))))
+
+(defun (setf alien-type-name) (alien-name type)
+  (let ((type-name (ensure-type-name type))
+       (type-number (type-number-from-alien-name alien-name)))
+    (setf (gethash type-number *number-to-type-hash*) type-name)
+    (setf (gethash type-name *type-to-number-hash*) type-number)))
+
+(defun (setf find-type-number) (type-number type)
+  (setf (gethash (ensure-type-name type) *type-to-number-hash*) type-number))
+
+(defun find-type-number (type)
+  (etypecase type
+    (integer type)
+    (symbol (gethash type *type-to-number-hash*))
+    (pcl::class (gethash (class-name type) *type-to-number-hash*))))
+(defun type-from-number (type-number)
+  (gethash type-number *number-to-type-hash*))
+
+(defun type-number-of (object)
+  (find-type-number (type-of object)))
+
+
+
+;;;; Superclass for all metaclasses implementing some sort of virtual slots
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass virtual-class (pcl::standard-class))
+
+  (defclass direct-virtual-slot-definition (standard-direct-slot-definition)
+    ((location
+      :reader slot-definition-location
+      :initarg :location)))
+  
+  (defclass effective-virtual-slot-definition
+    (standard-effective-slot-definition)))
+  
+
+(defmethod direct-slot-definition-class ((class virtual-class) initargs)
+  (if (eq (getf initargs :allocation) :virtual)
+      (find-class 'direct-virtual-slot-definition)
+    (call-next-method)))
+
+
+(defmethod effective-slot-definition-class ((class virtual-class) initargs)
+  (if (eq (getf initargs :allocation) :virtual)
+      (find-class 'effective-virtual-slot-definition)
+    (call-next-method)))
+
+
+(defun %direct-slot-definitions-slot-value (slotds slot &optional default)
+  (let ((slotd
+        (find-if
+         #'(lambda (slotd)
+             (and
+              (slot-exists-p slotd slot)
+              (slot-boundp slotd slot)))
+         slotds)))
+    (if slotd
+       (slot-value slotd slot)
+      default)))
+  
+
+(defgeneric compute-virtual-slot-location (class slotd direct-slotds))
+
+(defmethod compute-virtual-slot-location
+    ((class virtual-class)
+     (slotd effective-virtual-slot-definition)
+     direct-slotds)
+    (let ((location
+          (%direct-slot-definitions-slot-value direct-slotds 'location)))
+      (if (and location (symbolp location))
+         (list location `(setf ,location))
+       location)))
+
+
+(defmethod compute-effective-slot-definition
+    ((class virtual-class) direct-slotds)
+  (let ((slotd (call-next-method)))
+    (when (typep slotd 'effective-virtual-slot-definition)
+      (setf
+       (slot-value slotd 'pcl::location)
+       (compute-virtual-slot-location class slotd direct-slotds)))
+    slotd))
+
+
+(defmethod slot-value-using-class
+    ((class virtual-class) (object standard-object)
+     (slotd effective-virtual-slot-definition))
+  (let ((reader (first (slot-definition-location slotd))))
+    (if reader
+       (funcall reader object)
+      (slot-unbound class object (slot-definition-name slotd)))))
+
+
+(defmethod slot-boundp-using-class
+    ((class virtual-class) (object standard-object)
+     (slotd effective-virtual-slot-definition))
+   (and (first (slot-definition-location slotd)) t))
+    
+
+
+(defmethod (setf slot-value-using-class)
+    (value (class virtual-class) (object standard-object)
+     (slotd effective-virtual-slot-definition))
+  (let ((writer (second (slot-definition-location slotd))))
+    (cond
+     ((null writer)
+      (error
+       "Can't set read-only slot ~A in ~A"
+       (slot-definition-name slotd)
+       object))
+     ((or (functionp writer) (symbolp writer))
+      (funcall writer value object)
+      object)
+     (t
+      (funcall (fdefinition writer) value object)
+      object))))
+       
+
+(defmethod validate-superclass
+    ((class virtual-class) (super pcl::standard-class))
+  t)
+
+
+
+;;;; Superclass for wrapping of C structures
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass alien-instance ()
+    ((location
+      :reader alien-instance-location
+      :type system-area-pointer)))
+
+  (defgeneric allocate-alien-storage (class))
+  (defgeneric reference-instance (object))
+  (defgeneric unreference-instance (object))
+  (defgeneric from-alien-initialize-instance (object &rest initargs))
+  (defgeneric instance-finalizer (object)))
+
+
+(internal *instance-cache*)
+(defvar *instance-cache* (make-hash-table :test #'eql))
+
+(defun cache-instance (object)
+  (setf
+   (gethash (system:sap-int (alien-instance-location object)) *instance-cache*)
+   (ext:make-weak-pointer object)))
+
+(defun find-cached-instance (location)
+  (let ((ref (gethash (system:sap-int location) *instance-cache*)))
+    (when ref
+      (ext:weak-pointer-value ref))))
+
+(defun remove-cached-instance (location)
+  (remhash (system:sap-int location) *instance-cache*))
+
+
+(defmethod initialize-instance :before ((instance alien-instance)
+                                       &rest initargs &key)
+  (declare (ignore initargs))
+  (setf
+   (slot-value instance 'location)
+   (allocate-alien-storage (class-of instance)))
+  (cache-instance instance)
+  (ext:finalize instance (instance-finalizer instance)))
+
+
+(defmethod from-alien-initialize-instance ((instance alien-instance)
+                                          &rest initargs &key location)
+  (declare (ignore initargs))
+  (setf (slot-value instance 'location) location)
+  (cache-instance instance))
+
+
+(deftype-method translate-type-spec alien-instance (type-spec)
+  (declare (ignore type-spec))
+  'system-area-pointer)
+
+
+
+;;;; Metaclass used for subclasses of alien-instance
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass alien-class (virtual-class)
+    ((size
+      :reader alien-class-size)))
+
+  (defclass direct-alien-slot-definition (direct-virtual-slot-definition)
+    ((allocation
+      :initform :alien)
+     (offset
+      :reader slot-definition-offset
+      :initarg :offset
+      :initform 0)))
+  
+  (defclass effective-alien-slot-definition (effective-virtual-slot-definition)
+    ((offset
+      :reader slot-definition-offset)))
+  
+  (defclass effective-virtual-alien-slot-definition
+    (effective-virtual-slot-definition))
+
+  (defmethod alien-class-superclass ((class alien-class))
+    (find-if
+     #'(lambda (class)
+        (subtypep (class-name class) 'alien-instance))
+     (pcl::class-direct-superclasses class)))
+
+
+  (defmethod shared-initialize ((class alien-class) names
+                               &rest initargs &key size alien-name name)
+    (declare (ignore initargs))
+    (call-next-method)
+
+    ;; For some reason I can't figure out, accessors for only the
+    ;; first direct slot in an alien class gets defined by
+    ;; PCL. Therefore it has to be done here.
+    (pcl::fix-slot-accessors class (class-direct-slots class) 'pcl::add)
+    
+    (when alien-name
+      (setf (alien-type-name (or name (class-name class))) (first alien-name)))
+    (when size
+      (setf (slot-value class 'size) (first size))))
+    
+
+  (defmethod shared-initialize :after ((class alien-class) names
+                                      &rest initargs &key)
+    (declare (ignore initargs names))
+    (let* ((super (alien-class-superclass class))
+          (actual-size
+           (if (eq (class-name super) 'alien-instance)
+               0
+             (alien-class-size super))))
+      (dolist (slotd (class-slots class))
+       (when (eq (slot-definition-allocation slotd) :alien)
+         (with-slots (offset type) slotd
+           (setq actual-size (max actual-size (+ offset (size-of type)))))))
+      (cond
+       ((not (slot-boundp class 'size))
+       (setf (slot-value class 'size) actual-size))
+       ((> actual-size (slot-value class 'size))
+       (warn "The actual size of class ~A is lager than specified" class)))))
+
+
+  (defmethod direct-slot-definition-class ((class alien-class) initargs)
+    (case (getf initargs :allocation)
+      ((nil :alien) (find-class 'direct-alien-slot-definition))
+;      (:instance (error "Allocation :instance not allowed in class ~A" class))
+      (t (call-next-method))))
+
+
+  (defmethod effective-slot-definition-class ((class alien-class) initargs)
+    (case (getf initargs :allocation)
+      (:alien (find-class 'effective-alien-slot-definition))
+      (:virtual (find-class 'effective-virtual-alien-slot-definition))
+      (t (call-next-method))))
+  
+  
+  (defmethod compute-virtual-slot-location
+      ((class alien-class) (slotd effective-alien-slot-definition)
+       direct-slotds)
+    (with-slots (offset type) slotd
+      (setf offset (%direct-slot-definitions-slot-value direct-slotds 'offset))
+      (let ((reader (get-reader-function type))
+           (writer (get-writer-function type))
+           (destroy (get-destroy-function type)))
+       (list
+        #'(lambda (object)
+            (funcall reader (alien-instance-location object) offset))
+        #'(lambda (value object)
+            (let ((location (alien-instance-location object)))
+              (funcall destroy location offset)
+              (funcall writer value location offset)))))))
+            
+  
+  (defmethod compute-virtual-slot-location
+      ((class alien-class)
+       (slotd effective-virtual-alien-slot-definition)
+       direct-slotds)
+    (let ((location (call-next-method)))
+      (if (or (stringp location) (consp location))
+         (destructuring-bind (reader &optional writer) (mklist location)
+           (with-slots (type) slotd
+              (list
+              (if (stringp reader)
+                  (let* ((alien-type (translate-type-spec type))
+                         (alien
+                          (alien::%heap-alien
+                           (alien::make-heap-alien-info
+                            :type (alien::parse-alien-type
+                                   `(function ,alien-type system-area-pointer))
+                            :sap-form (system:foreign-symbol-address reader))))
+                         (from-alien (get-from-alien-function type)))
+                    #'(lambda (object)
+                        (funcall
+                         from-alien
+                         (alien-funcall
+                          alien (alien-instance-location object)))))
+                reader)
+              (if (stringp writer)
+                  (let* ((alien-type (translate-type-spec type))
+                         (alien
+                          (alien::%heap-alien
+                           (alien::make-heap-alien-info
+                            :type (alien::parse-alien-type
+                                   `(function
+                                     void ,alien-type system-area-pointer))
+                            :sap-form (system:foreign-symbol-address writer))))
+                         (to-alien (get-to-alien-function type))
+                         (cleanup  (get-cleanup-function type)))
+                    #'(lambda (value object)
+                        (let ((alien-value (funcall to-alien value))
+                              (location (alien-instance-location object)))
+                          (alien-funcall alien location alien-value)
+                          (funcall cleanup alien-value))))
+                writer))))
+       location)))
+
+
+  (defmethod compute-slots ((class alien-class))
+    ;; Translating the user supplied relative (to previous slot) offsets
+    ;; to absolute offsets.
+    ;; This code is broken and have to be fixed for real use.
+    (with-slots (direct-slots) class
+      (let* ((super (alien-class-superclass class))
+            (slot-offset
+             (if (eq (class-name super) 'alien-instance)
+                 0
+               (alien-class-size super))))
+       (dolist (slotd direct-slots)
+         (when (eq (slot-definition-allocation slotd) :alien)
+           (with-slots (offset type) slotd
+             (setf
+              offset (+ slot-offset offset)
+              slot-offset (+ offset (size-of type)))))))
+    
+      ;; Reverse the direct slot definitions so the effective slots
+      ;; will be in correct order.
+      (setf direct-slots (nreverse direct-slots)))
+    (call-next-method))
+
+
+  (defmethod validate-superclass ((class alien-class)
+                                 (super pcl::standard-class))
+     (subtypep (class-name super) 'alien-instance))
+
+  (defgeneric make-instance-from-alien (class location &rest initargs &key)))
+
+(defmethod make-instance-from-alien ((class symbol) location
+                                    &rest initargs &key)
+  (apply #'make-instance-from-alien (find-class class) location initargs))
+
+(defmethod make-instance-from-alien ((class alien-class) location
+                                    &rest initargs &key)
+  (let ((instance (allocate-instance class)))
+    (apply
+     #'from-alien-initialize-instance
+     instance :location location initargs)
+    instance))
+
+(defun ensure-alien-instance (class location &rest initargs)
+  (or
+   (find-cached-instance location)
+   (apply #'make-instance-from-alien class location initargs)))
+
+(defmethod allocate-alien-storage ((class alien-class))
+  (allocate-memory (alien-class-size class)))
+
+
+
+;;;; Superclass for wrapping structures with reference counting
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass alien-object (alien-instance)
+    ()
+    (:metaclass alien-class)
+    (:size 0)))
+
+(define-type-method-fun alien-ref (type-spec))
+(define-type-method-fun alien-unref (type-spec))
+
+(defmethod from-alien-initialize-instance ((object alien-object)
+                                          &rest initargs &key)
+  (declare (ignore initargs))
+  (call-next-method)
+  (reference-instance object))
+
+(defmethod instance-finalizer ((object alien-object))
+  (let ((location (alien-instance-location object))
+       (unref (fdefinition (alien-unref (class-of object)))))
+    (declare (type system-area-pointer location) (type function unref))
+    #'(lambda ()
+       (remove-cached-instance location)
+       (funcall unref location))))
+
+(defmethod reference-instance ((object alien-object))
+  (funcall (alien-ref (class-of object)) object)
+  object)
+
+(defmethod unreference-instance ((object alien-object))
+  (funcall (alien-unref (class-of object)) object)
+  nil)
+
+(deftype-method translate-to-alien
+    alien-object (type-spec object &optional copy)
+  (if copy
+      `(,(alien-ref type-spec) ,object)
+    `(alien-instance-location ,object)))
+
+(deftype-method translate-from-alien
+    alien-object (type-spec location &optional alloc)
+  (declare (ignore alloc))
+  `(let ((location ,location))
+     (unless (null-pointer-p location)
+       (ensure-alien-instance ',type-spec location))))
+
+(deftype-method
+    cleanup-alien alien-object (type-spec sap &optional copied)
+  (when copied
+    `(let ((sap ,sap))
+       (unless (null-pointer-p sap)
+        (,(alien-unref type-spec) sap)))))
+
+
+
+;;;; Superclass for wrapping of non-refcounted structures
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass alien-structure (alien-instance)
+    ((static
+      :allocation :instance
+      :reader alien-structure-static-p
+      :initform nil
+      :type boolean))
+    (:metaclass alien-class)
+    (:size 0)))
+
+(define-type-method-fun alien-copier (type-spec))
+(define-type-method-fun alien-deallocator (type-spec))
+
+(defmethod from-alien-initialize-instance ((structure alien-structure)
+                                          &rest initargs &key static)
+  (declare (ignore initargs))
+  (call-next-method)
+  (setf (slot-value structure 'static) static))
+
+(defmethod instance-finalizer ((structure alien-structure))
+  (let ((location (alien-instance-location structure)))
+    (declare (type system-area-pointer location))
+    (if (alien-structure-static-p structure)
+       #'(lambda ()
+           (remove-cached-instance location))
+      (let ((deallocator
+            (fdefinition (alien-deallocator (class-of structure)))))
+       (declare (type function deallocator))
+       #'(lambda ()
+           (remove-cached-instance location)
+           (funcall deallocator location))))))
+
+
+(deftype-method alien-copier alien-structure (type-spec)
+  (declare (ignore type-spec))
+  'copy-memory)
+
+(deftype-method alien-deallocator alien-structure (type-spec)
+  (declare (ignore type-spec))
+  'deallocate-memory)
+
+(deftype-method translate-to-alien
+    alien-structure (type-spec object &optional copy)
+  `(let ((object ,object))
+     (if (and ,copy (not (alien-structure-static-p object)))
+        (,(alien-copier type-spec)
+         `(alien-instance-location object)
+         ,(alien-class-size (find-class type-spec)))
+       (alien-instance-location object))))
+
+(deftype-method translate-from-alien
+    alien-structure (type-spec location &optional (alloc :dynamic))
+  `(let ((location ,location))
+     (unless (null-pointer-p location)
+       ,(ecase alloc
+         (:dynamic `(ensure-alien-instance ',type-spec location))
+         (:static `(ensure-alien-instance ',type-spec location :static t))
+         (:copy `(ensure-alien-instance
+                  ',type-spec
+                  `(,(alien-copier type-spec)
+                    location ,(alien-class-size (find-class type-spec)))))))))
+
+(deftype-method cleanup-alien alien-structure (type-spec sap &optional copied)
+  (when copied
+    `(let ((sap ,sap))
+       (unless (or
+               (null-pointer-p sap)
+               (alien-structure-static-p (find-cached-instance sap)))
+        (,(alien-deallocator type-spec) sap)))))
+
+
+
+;;;; Superclass for static structures such as gdk:visual
+
+(defclass static-structure (alien-structure)
+  ()
+  (:metaclass alien-class)
+  (:size 0))
+
+
+(defmethod from-alien-initialize-instance ((structure alien-structure)
+                                     &rest initargs)
+  (declare (ignore initargs))
+  (call-next-method)
+  (setf (slot-value structure 'static) t))
+
+
+
+;;;; Superclass wrapping types in the glib type system
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass gtype (alien-object)
+    ()
+    (:metaclass alien-class)
+    (:size 4 #|(size-of 'pointer)|#)))
+
+
+(defun %alien-instance-type-number (location)
+  (let ((class (sap-ref-sap location 0)))
+    (sap-ref-unsigned class 0)))
+
+
+(deftype-method translate-from-alien gtype (type-spec location &optional alloc)
+  (declare (ignore type-spec alloc))
+  `(let ((location ,location))
+     (unless (null-pointer-p location)
+       (ensure-alien-instance
+       (type-from-number (%alien-instance-type-number location))
+       location))))
+
+
+
+;;;; Metaclass for subclasses of gtype-class
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass gtype-class (alien-class)))
+
+
+(defmethod shared-initialize ((class gtype-class) names
+                             &rest initargs &key name)
+  (declare (ignore initargs names))
+  (call-next-method)
+  (setf
+   (slot-value class 'size)
+   (type-instance-size (find-type-number (or name (class-name class))))))
+
+
+(defmethod validate-superclass
+    ((class gtype-class) (super pcl::standard-class))
+  (subtypep (class-name super) 'gtype))
+
+
+(defmethod allocate-alien-storage ((class gtype-class))
+  (type-create-instance (find-type-number class)))
+
+
+;;;; Initializing type numbers
+
+(setf (alien-type-name 'invalid) "invalid")
+(setf (alien-type-name 'char) "gchar")
+(setf (alien-type-name 'unsigned-char) "guchar")
+(setf (alien-type-name 'boolean) "gboolean")
+(setf (alien-type-name 'int) "gint")
+(setf (alien-type-name 'unsigned-int) "guint")
+(setf (alien-type-name 'long) "glong")
+(setf (alien-type-name 'unsigned-long) "gulong")
+(setf (alien-type-name 'enum) "GEnum")
+(setf (alien-type-name 'flags) "GFlags")
+(setf (alien-type-name 'single-float) "gfloat")
+(setf (alien-type-name 'double-float) "gdouble")
+(setf (alien-type-name 'string) "gstring")
+(setf (find-type-number 'fixnum) (find-type-number 'int))
diff --git a/glib/gutils.lisp b/glib/gutils.lisp
new file mode 100644 (file)
index 0000000..cf939c3
--- /dev/null
@@ -0,0 +1,85 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gutils.lisp,v 1.1 2000/08/14 16:44:34 espen Exp $
+
+
+(in-package "KERNEL")
+
+(defun type-expand-1 (form)
+  (let ((def (cond ((symbolp form)
+                   (info type expander form))
+                  ((and (consp form) (symbolp (car form)))
+                   (info type expander (car form)))
+                  (t nil))))
+    (if def
+       (values (funcall def (if (consp form) form (list form))) t)
+      (values form nil))))
+
+
+(in-package "GLIB")
+
+
+(defun type-expand-to (type form)
+  (labels ((expand (form0)
+             (if (eq (first (mklist form0)) type)
+                form0
+              (multiple-value-bind (expanded-form expanded-p)
+                  (type-expand-1 form0)
+                (if expanded-p
+                    (expand expanded-form)
+                  (error "~A can not be expanded to ~A" form type))))))
+    (expand form)))
+
+(defmacro with-gc-disabled (&body body)
+  (let ((gc-inhibit (make-symbol "GC-INHIBIT")))
+    `(progn
+       (let ((,gc-inhibit lisp::*gc-inhibit*))
+        (ext:gc-off)
+        (unwind-protect
+            ,@body
+          (unless ,gc-inhibit
+            (ext:gc-on)))))))
+
+(defun mklist (obj)
+  (if (atom obj) (list obj) obj))
+
+(defun namep (obj)
+  (and (symbolp obj) (not (member obj '(t nil)))))
+
+(defun all-equal (&rest objects)
+  (or
+   (null objects)
+   (null (rest objects))
+   (and
+    (equal (first objects) (second objects))
+    (apply #'all-equal (rest objects)))))
+
+(defun neq (obj1 obj2)
+  (not (eq obj1 obj2)))
+
+(defmacro return-if (form)
+  (let ((result (make-symbol "RESULT")))
+    `(let ((,result ,form))
+       (when ,result
+        (return ,result)))))
+
+(defun make-pointer (address)
+  (int-sap address))
+  
+(defun null-pointer-p (pointer)
+  (zerop (sap-int pointer)))
diff --git a/gtk/gtk-export.lisp b/gtk/gtk-export.lisp
new file mode 100644 (file)
index 0000000..a014726
--- /dev/null
@@ -0,0 +1,8 @@
+(in-package "GTK")
+
+;;; Autogenerating exported symbols
+(export-from-file #p"clg:gtk;gtkenums.lisp")
+(export-from-file #p"clg:gtk;gtktypes.lisp")
+(export-from-file #p"clg:gtk;gtkwidget.lisp")
+(export-from-file #p"clg:gtk;gtkcontainer.lisp")
+(export-from-file #p"clg:gtk;gtk.lisp")
diff --git a/gtk/gtk-package.lisp b/gtk/gtk-package.lisp
new file mode 100644 (file)
index 0000000..ec4ca40
--- /dev/null
@@ -0,0 +1,15 @@
+(defpackage "GTK"
+  (:use "GLIB" "COMMON-LISP" "PCL" "ALIEN" "AUTOEXPORT")
+  (:shadowing-import-from "GLIB" "DEFTYPE")
+  (:shadowing-import-from "PCL"
+   "CLASS-NAME" "BUILT-IN-CLASS" "CLASS-OF" "FIND-CLASS" "LOCATION"
+   "ALLOCATION" "DIRECT-SLOTS")
+  (:export "OBJECT" "OBJECT-ARG" "OBJECT-SINK")
+  (:export "REGISTER-USER-DATA" "FIND-USER-DATA" "REGISTER-CALLBACK-FUNCTION"
+          "*CALLBACK-MARSHAL*" "*DESTROY-MARSHAL*")
+  (:export "EVENTS-PENDING-P" "MAIN-DO-EVENT" "MAIN" "MAIN-LEVEL" "MAIN-QUIT"
+          "MAIN-ITERATION" "MAIN-ITERATE-ALL")
+  (:export "SIGNAL-EMIT-STOP" "SIGNAL-CONNECT" "SIGNAL-DISCONNECT"
+          "SIGNAL-HANDLER-BLOCK" "SIGNAL-HANDLER-UNBLOCK")
+  (:export "OBJECT-CLASS" "WIDGET-CLASS" "CONTAINER-CLASS" "CHILD-CLASS"))
\ No newline at end of file
diff --git a/gtk/gtk.lisp b/gtk/gtk.lisp
new file mode 100644 (file)
index 0000000..0a1ba3d
--- /dev/null
@@ -0,0 +1,3090 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gtk.lisp,v 1.1 2000/08/14 16:44:51 espen Exp $
+
+
+(in-package "GTK")
+
+;;; Gtk version
+
+(define-foreign check-version () string
+  (required-major unsigned-int)
+  (required-minor unsigned-int)
+  (required-micro unsigned-int))
+
+(define-foreign query-version () nil
+  (major unsigned-int :out)
+  (minor unsigned-int :out)
+  (micro unsigned-int :out))
+
+(defun gtk-version ()
+  (multiple-value-bind (major minor micro)
+      (query-version)
+    (if (zerop micro)
+       (format nil "Gtk+ v~A.~A" major minor) 
+      (format nil "Gtk+ v~A.~A.~A" major minor micro))))
+
+(export '*clg-version*)
+
+
+
+;;; InitializationInitialization, exit, mainloop and miscellaneous routines
+
+
+(define-foreign grab-add () nil
+  (widget widget))
+
+(define-foreign grab-get-current () widget)
+
+(define-foreign grab-remove () nil
+  (widget widget))
+
+(define-foreign ("gtk_timeout_add_full" timeout-add)
+    (interval function) unsigned-int
+  (interval (unsigned 32))
+  (0 unsigned-long)
+  (*callback-marshal* pointer)
+  ((register-callback-function function) unsigned-long)
+  (*destroy-marshal* pointer))
+
+(define-foreign timeout-remove () nil
+  (timeout-handler-id unsigned-int))
+  
+(define-foreign ("gtk_idle_add_full" idle-add)
+    (function &optional (priority 200)) unsigned-int
+  (priority int)
+  (0 unsigned-long)
+  (*callback-marshal* pointer)
+  ((register-callback-function function) unsigned-long)
+  (*destroy-marshal* pointer))
+
+(define-foreign idle-remove () nil
+  (idle-handler-id unsigned-int))
+
+(define-foreign get-current-event () gdk:event)
+
+(define-foreign get-event-widget () widget
+  (event gdk:event))
+
+
+;;; should be moved to gobject
+
+; (define-foreign ("gtk_object_set_data_full" object-set-data)
+;                  (object key data &optional destroy-function) nil
+;   (object object)             
+;   ((string key) string)
+;   ((register-user-data data destroy-function) unsigned-long)
+;   (*destroy-marshal* pointer))
+
+; (defun (setf object-data) (data object key)
+;   (object-set-data object key data)
+;   data)
+
+; (define-foreign %object-get-data (object key) unsigned-long
+;   (object object)             
+;   ((string key) string))
+
+; (defun object-data (object key)
+;   (find-user-data (%object-get-data object key)))
+
+; (define-foreign object-remove-data (object key) nil
+;   (object object)
+;   ((string key) string))
+
+; (defun object-user-data (object)
+;   (object-data object :user-data))
+
+; (defun (setf object-user-data) (data object)
+;   (setf (object-data object :user-data) data))
+
+
+;;; Label
+
+(define-foreign label-new () label
+  (text string))
+
+(define-foreign label-parse-uline () unsigned-int
+  (label label)
+  (string string))
+
+
+
+;;; Acccel label
+
+(define-foreign accel-label-new () accel-label
+  (text string))
+
+(define-foreign accel-label-refetch () boolean
+  (accel-label accel-label))
+
+
+
+;;; Tips query
+
+(define-foreign tips-query-new () tips-query)
+
+(define-foreign tips-query-start-query () nil
+  (tips-query tips-query))
+
+(define-foreign tips-query-stop-query () nil
+  (tips-query tips-query))
+
+
+
+;;; Arrow
+
+(define-foreign arrow-new () arrow
+  (arrow-type arrow-type)
+  (shadow-type shadow-type))
+
+
+
+;;; Pixmap
+
+; (defun %pixmap-create (source)
+;   (cond
+;    ((not source) nil)
+;    ((typep source gdk:pixmap) source)
+;    ((and (consp source) (typep (first source) gdk:pixmap)) (values-list source))
+;    (t (gdk:pixmap-create source))))
+
+(define-foreign %pixmap-new () pixmap
+  (pixmap gdk:pixmap)
+  (mask (or null gdk:bitmap)))
+
+(defun pixmap-new (source)
+  (multiple-value-bind (pixmap mask)
+      (%pixmap-create source)
+    (%pixmap-new pixmap mask)))
+
+(define-foreign %pixmap-set () nil
+  (pixmap pixmap)
+  (gdk:pixmap gdk:pixmap)
+  (mask (or null gdk:bitmap)))
+
+(defun (setf pixmap-pixmap) (source pixmap)
+  (multiple-value-bind (gdk:pixmap mask)
+      (%pixmap-create source)
+    (%pixmap-set pixmap gdk:pixmap mask)
+    (values gdk:pixmap mask)))
+
+(define-foreign ("gtk_pixmap_get" pixmap-pixmap) () nil
+  (pixmap pixmap)
+  (val gdk:pixmap :out)
+  (mask gdk:bitmap :out))
+
+
+
+;;; Bin
+
+(defun bin-child (bin)
+  (first (container-children bin)))
+
+(defun (setf bin-child) (child bin)
+  (let ((old-child (bin-child bin)))
+    (when old-child
+      (container-remove bin old-child)))
+  (container-add bin child)
+  child)
+
+
+;;; Alignment
+
+(define-foreign alignment-new () alignment
+  (xalign single-float)
+  (ylign single-float)
+  (xscale single-float)
+  (yscale single-float))
+
+
+
+;;; Frame
+
+(define-foreign frame-new (&optional label) frame
+  (label string))
+
+
+
+;;; Aspect frame
+
+(define-foreign aspect-frame-new () alignment
+  (xalign single-float)
+  (ylign single-float)
+  (ratio single-float)
+  (obey-child boolean))
+
+
+
+;;; Button
+
+(define-foreign %button-new () button)
+
+(define-foreign %button-new-with-label () button
+  (label string))
+
+(defun button-new (&optional label)
+  (if label
+      (%button-new-with-label label)
+    (%button-new)))
+
+(define-foreign button-pressed () nil
+  (button button))
+
+(define-foreign button-released () nil
+  (button button))
+
+(define-foreign button-clicked () nil
+  (button button))
+
+(define-foreign button-enter () nil
+  (button button))
+
+(define-foreign button-leave () nil
+  (button button))
+
+
+
+;;; Toggle button
+
+(define-foreign %toggle-button-new () toggle-button)
+
+(define-foreign %toggle-button-new-with-label () toggle-button
+  (label string))
+
+(defun toggle-button-new (&optional label)
+  (if label
+      (%toggle-button-new-with-label label)
+    (%toggle-button-new)))
+
+(define-foreign toggle-button-toggled () nil
+  (toggle-button toggle-button))
+
+
+
+;;; Check button
+
+(define-foreign %check-button-new () check-button)
+
+(define-foreign %check-button-new-with-label () check-button
+  (label string))
+
+(defun check-button-new (&optional label)
+  (if label
+      (%check-button-new-with-label label)
+    (%check-button-new)))
+
+
+
+;;; Radio button
+
+(define-foreign %radio-button-new () radio-button
+  (group (or null radio-button-group)))
+
+(define-foreign %radio-button-new-with-label-from-widget () radio-button
+  (widget (or null widget))
+  (label string))
+
+(define-foreign %radio-button-new-from-widget () radio-button
+  (widget (or null widget)))
+
+(define-foreign %radio-button-new-with-label () radio-button
+  (group (or null radio-button-group))
+  (label string))
+
+(defun radio-button-new (group &key label from-widget)
+  (cond
+   ((and from-widget label)
+    (%radio-button-new-with-label-from-widget group label))
+   (from-widget
+    (%radio-button-new-from-widget group))
+   (label
+    (%radio-button-new-with-label group label))
+   (t
+    (%radio-button-new group))))
+    
+(define-foreign radio-button-group () radio-button-group
+  (radio-button radio-button))
+
+
+
+;;; Option menu
+
+; (define-foreign option-menu-new () option-menu)
+
+; (define-foreign %option-menu-set-menu () nil
+;   (option-menu option-menu)
+;   (menu widget))
+
+; (define-foreign %option-menu-remove-menu () nil
+;   (option-menu option-menu))
+
+; (defun (setf option-menu-menu) (menu option-menu)
+;   (if (not menu)
+;       (%option-menu-remove-menu option-menu)
+;     (%option-menu-set-menu option-menu menu))
+;   menu)
+    
+
+
+;;; Item
+
+(define-foreign item-select () nil
+  (item item))
+
+(define-foreign item-deselect () nil
+  (item item))
+
+(define-foreign item-toggle () nil
+  (item item))
+
+
+
+;;; Menu item
+
+; (define-foreign %menu-item-new () menu-item)
+
+; (define-foreign %menu-item-new-with-label () menu-item
+;   (label string))
+
+; (defun menu-item-new (&optional label)
+;   (if label
+;       (%menu-item-new-with-label label)
+;     (%menu-item-new)))
+
+; (defun (setf menu-item-label) (label menu-item)
+;   (let ((accel-label (accel-label-new label)))
+;     (setf (misc-xalign accel-label) 0.0)
+;     (setf (misc-yalign accel-label) 0.5)
+
+;     (container-add menu-item accel-label)
+;     (setf (accel-label-accel-widget accel-label) menu-item)
+;     (widget-show accel-label))
+;   label)
+
+; (define-foreign %menu-item-set-submenu () nil
+;   (menu-item menu-item)
+;   (submenu menu))
+
+; (define-foreign %menu-item-remove-submenu () nil
+;   (menu-item menu-item))
+
+; (defun (setf menu-item-submenu) (submenu menu-item)
+;   (if (not submenu)
+;       (%menu-item-remove-submenu menu-item)
+;     (%menu-item-set-submenu menu-item submenu))
+;   submenu)
+
+; (define-foreign %menu-item-configure () nil
+;   (menu-item menu-item)
+;   (show-toggle-indicator boolean)
+;   (show-submenu-indicator boolean))
+
+; (defun (setf menu-item-toggle-indicator-p) (show menu-item)
+;   (%menu-item-configure
+;    menu-item
+;    show
+;    (menu-item-submenu-indicator-p menu-item))
+;   show)
+
+; (defun (setf menu-item-submenu-indicator-p) (show menu-item)
+;   (%menu-item-configure
+;    menu-item
+;    (menu-item-toggle-indicator-p menu-item)
+;    show))
+
+; (define-foreign menu-item-select () nil
+;   (menu-item menu-item))
+
+; (define-foreign menu-item-deselect () nil
+;   (menu-item menu-item))
+
+; (define-foreign menu-item-activate () nil
+;   (menu-item menu-item))
+
+; (define-foreign menu-item-right-justify () nil
+;   (menu-item menu-item))
+
+
+
+; ;;; Check menu item
+
+; (define-foreign %check-menu-item-new
+;     () check-menu-item)
+
+; (define-foreign %check-menu-item-new-with-label () check-menu-item
+;   (label string))
+
+; (defun check-menu-item-new (&optional label)
+;   (if label
+;       (%check-menu-item-new-with-label label)
+;     (%check-menu-item-new)))
+
+; (define-foreign check-menu-item-toggled () nil
+;   (check-menu-item check-menu-item))
+
+
+
+; ;;; Radio menu item
+
+; (define-foreign %radio-menu-item-new
+;                  () radio-menu-item
+;   (group (or null radio-menu-item-group)))
+
+; (define-foreign %radio-menu-item-new-with-label () radio-menu-item
+;   (group (or null radio-menu-item-group))
+;   (label string))
+
+; (defun radio-menu-item-new (group &optional label)
+;   (if label
+;       (%radio-menu-item-new-with-label group label)
+;     (%radio-menu-item-new group)))
+
+
+
+; ;;; Tearoff menu item
+
+; (define-foreign tearoff-menu-item-new () tearoff-menu-item)
+
+
+
+;;; List item
+
+(define-foreign %list-item-new () list-item)
+
+(define-foreign %list-item-new-with-label () list-item
+  (label string))
+
+(defun list-item-new (&optional label)
+  (if label
+      (%list-item-new-with-label label)
+    (%list-item-new)))
+      
+(define-foreign list-item-select () nil
+  (list-item list-item))
+
+(define-foreign list-item-deselect () nil
+  (list-item list-item))
+
+
+
+;;; Tree item
+
+(define-foreign %tree-item-new () tree-item)
+
+(define-foreign %tree-item-new-with-label () tree-item
+  (label string))
+
+(defun tree-item-new (&optional label)
+  (if label
+      (%tree-item-new-with-label label)
+    (%tree-item-new)))
+
+(define-foreign %tree-item-set-subtree () nil
+  (tree-item tree-item)
+  (subtree tree))
+
+(define-foreign %tree-item-remove-subtree () nil
+  (tree-item tree-item))
+
+(defun (setf tree-item-subtree) (subtree tree-item)
+  (if subtree
+      (%tree-item-set-subtree tree-item subtree)
+    (%tree-item-remove-subtree tree-item))
+  subtree)
+
+(define-foreign tree-item-select () nil
+  (tree-item tree-item))
+
+(define-foreign tree-item-deselect () nil
+  (tree-item tree-item))
+
+(define-foreign tree-item-expand () nil
+  (tree-item tree-item))
+
+(define-foreign tree-item-collapse () nil
+  (tree-item tree-item))
+
+
+
+;;; Window
+
+(define-foreign window-new () window
+  (type window-type))
+
+(define-foreign %window-set-wmclass () nil
+  (window window)
+  (wmclass-name string)
+  (wmclass-class string))
+
+(defun (setf window-wmclass) (wmclass window)
+  (%window-set-wmclass window (svref wmclass 0) (svref wmclass 1))
+  (values (svref wmclass 0) (svref wmclass 1)))
+
+;; cl-gtk.c
+(define-foreign window-wmclass () nil
+  (window window)
+  (wmclass-name string :out)
+  (wmclass-class string :out))
+
+(define-foreign window-add-accel-group () nil
+  (window window)
+  (accel-group accel-group))
+
+(define-foreign window-remove-accel-group () nil
+  (window window)
+  (accel-group accel-group))
+
+(define-foreign window-activate-focus () int
+  (window window))
+
+(define-foreign window-activate-default () int
+  (window window))
+
+(define-foreign window-set-transient-for () nil
+  (window window)
+  (parent window))
+
+;(define-foreign window-set-geometry-hints)
+
+
+
+;;; Color selection dialog
+
+; (define-foreign color-selection-dialog-new () color-selection-dialog
+;   (title string))
+
+
+
+;;; Dialog
+
+; (define-foreign dialog-new () dialog)
+
+
+
+;;; Input dialog
+
+; (define-foreign input-dialog-new () dialog)
+
+
+
+;;; File selection
+
+; (define-foreign file-selection-new () file-selection
+;   (title string))
+
+; (define-foreign file-selection-complete () nil
+;   (file-selection file-selection)
+;   (pattern string))
+
+; (define-foreign file-selection-show-fileop-buttons () nil
+;   (file-selection file-selection))
+
+; (define-foreign file-selection-hide-fileop-buttons () nil
+;   (file-selection file-selection))
+
+
+
+; ;;; Handle box
+
+; (define-foreign handle-box-new () handle-box)
+
+
+
+; ;;; Scrolled window
+
+(define-foreign scrolled-window-new
+    (&optional hadjustment vadjustment) scrolled-window
+  (hadjustment (or null adjustment))
+  (vadjustment (or null adjustment)))
+
+(defun (setf scrolled-window-scrollbar-policy) (policy window)
+  (setf (scrolled-window-hscrollbar-policy window) policy)
+  (setf (scrolled-window-vscrollbar-policy window) policy))
+
+(define-foreign scrolled-window-add-with-viewport () nil
+   (scrolled-window scrolled-window)
+   (child widget))
+
+
+
+; ;;; Viewport
+
+; (define-foreign viewport-new () viewport
+;   (hadjustment adjustment)
+;   (vadjustment adjustment))
+  
+
+
+;;; Box
+
+(define-foreign box-pack-start () nil
+  (box box)
+  (child widget)
+  (expand boolean)
+  (fill boolean)
+  (padding unsigned-int))
+
+(define-foreign box-pack-end () nil
+  (box box)
+  (child widget)
+  (expand boolean)
+  (fill boolean)
+  (padding unsigned-int))
+
+(defun box-pack (box child &key (pack :start) (expand t) (fill t) (padding 0))
+  (if (eq pack :start)
+      (box-pack-start box child expand fill padding)
+    (box-pack-end box child expand fill padding)))
+
+(define-foreign box-reorder-child () nil
+  (box box)
+  (child widget)
+  (position int))
+
+(define-foreign box-query-child-packing () nil
+  (box box)
+  (child widget :out)
+  (expand boolean :out)
+  (fill boolean :out)
+  (padding unsigned-int :out)
+  (pack-type pack-type :out))
+
+(define-foreign box-set-child-packing () nil
+  (box box)
+  (child widget)
+  (expand boolean)
+  (fill boolean)
+  (padding unsigned-int)
+  (pack-type pack-type))
+
+
+
+;;; Button box
+
+(define-foreign ("gtk_button_box_get_child_size_default"
+                 button-box-default-child-size) () nil
+  (min-width int :out)
+  (min-height int :out))
+
+(define-foreign ("gtk_button_box_get_child_ipadding_default"
+                 button-box-default-child-ipadding) () nil
+  (ipad-x int :out)
+  (ipad-y int :out))
+
+(define-foreign %button-box-set-child-size-default () nil
+  (min-width int)
+  (min-height int))
+
+(defun (setf button-box-default-child-size) (size)
+  (%button-box-set-child-size-default (svref size 0) (svref size 1))
+  (values (svref size 0) (svref size 1)))
+
+(define-foreign %button-box-set-child-ipadding-default () nil
+  (ipad-x int)
+  (ipad-y int))
+
+(defun (setf button-box-default-child-ipadding) (ipad)
+  (%button-box-set-child-ipadding-default (svref ipad 0) (svref ipad 1))
+  (values (svref ipad 0) (svref ipad 1)))
+
+(define-foreign
+    ("gtk_button_box_get_child_size" button-box-child-size) () nil
+  (button-box button-box)
+  (min-width int :out)
+  (min-height int :out))
+
+(define-foreign
+    ("gtk_button_box_get_child_ipadding" button-box-child-ipadding) () nil
+  (button-box button-box)  
+  (ipad-x int :out)
+  (ipad-y int :out))
+
+(define-foreign %button-box-set-child-size () nil
+  (button-box button-box)
+  (min-width int)
+  (min-height int))
+
+(defun (setf button-box-child-size) (size button-box)
+  (%button-box-set-child-size button-box (svref size 0) (svref size 1))
+  (values (svref size 0) (svref size 1)))
+
+(define-foreign %button-box-set-child-ipadding () nil
+  (button-box button-box)
+  (ipad-x int)
+  (ipad-y int))
+
+(defun (setf button-box-child-ipadding) (ipad button-box)
+  (%button-box-set-child-ipadding  button-box (svref ipad 0) (svref ipad 1))
+  (values (svref ipad 0) (svref ipad 1)))
+
+
+
+;;; HButton box
+
+;(define-foreign hbutton-box-new () hbutton-box)
+
+(define-foreign ("gtk_hbutton_box_get_spacing_default"
+                 hbutton-box-default-spacing) () int)
+
+(define-foreign ("gtk_hbutton_box_set_spacing_default"
+                 (setf hbutton-box-default-spacing)) () nil
+  (spacing int))
+  
+(define-foreign ("gtk_hbutton_box_get_layout_default"
+                 hbutton-box-default-layout) () button-box-style)
+
+(define-foreign ("gtk_hbutton_box_set_layout_default"
+                 (setf hbutton-box-default-layout)) () nil
+  (layout button-box-style))
+
+
+
+;;; VButton Box
+
+;(define-foreign vbutton-box-new () vbutton-box)
+
+(define-foreign ("gtk_vbutton_box_get_spacing_default"
+                 vbutton-box-default-spacing) () int)
+
+(define-foreign ("gtk_vbutton_box_set_spacing_default"
+                 (setf vbutton-box-default-spacing)) () nil
+  (spacing int))
+  
+(define-foreign ("gtk_vbutton_box_get_layout_default"
+                 vbutton-box-default-layout) () button-box-style)
+
+(define-foreign ("gtk_vbutton_box_set_layout_default"
+                 (setf vbutton-box-default-layout)) () nil
+  (layout button-box-style))
+
+
+
+;;; VBox
+
+(define-foreign vbox-new () vbox
+  (homogeneous boolean)
+  (spacing int))
+
+
+
+;;; Color selection
+
+; (define-foreign color-selection-new () color-selection)
+
+; ;; cl-gtk.c
+; (define-foreign %color-selection-set-color-by-values () nil
+;   (colorsel color-selection)
+;   (red double-float)
+;   (green double-float)
+;   (blue double-float)
+;   (opacity double-float))
+
+; (defun (setf color-selection-color) (color colorsel)
+;   (%color-selection-set-color-by-values
+;    colorsel
+;    (svref color 0) (svref color 1) (svref color 2)
+;    (if (> (length color) 3)
+;        (svref color 3)
+;      1.0))
+;   color)
+
+; ;; cl-gtk.c
+; (define-foreign %color-selection-get-color-as-values () nil
+;   (colorsel color-selection)
+;   (red double-float :out)
+;   (green double-float :out)
+;   (blue double-float :out)
+;   (opacity double-float :out))
+
+; (defun color-selection-color (colorsel)
+;   (multiple-value-bind (red green blue opacity)
+;       (%color-selection-get-color-as-values colorsel)
+;     (if (color-selection-use-opacity-p colorsel)
+;      (vector red green blue opacity)
+;       (vector red green blue))))
+
+
+
+
+; ;;; Gamma curve
+
+; (define-foreign gamma-curve-new () gamma-curve)
+
+
+
+;;; HBox
+
+(define-foreign hbox-new () hbox
+  (homogeneous boolean)
+  (spacing int))
+
+
+
+;;; Combo
+
+; (define-foreign combo-new () combo)
+
+; (define-foreign combo-set-value-in-list () nil
+;   (combo combo)
+;   (val boolean)
+;   (ok-if-empty boolean))
+
+; (define-foreign ("gtk_combo_set_item_string" (setf combo-item-string)) () nil
+;   (combo combo)
+;   (item item)
+;   (item-value string))
+
+; (define-foreign ("gtk_combo_set_popdown_strings"
+;                (setf combo-popdown-strings)) () nil
+;   (combo combo)
+;   (strings (double-list string)))
+  
+; (define-foreign combo-disable-activate () nil
+;   (combo combo))
+
+
+
+; ;;; Statusbar
+
+; (define-foreign statusbar-new () statusbar)
+
+; (define-foreign
+;     ("gtk_statusbar_get_context_id" statusbar-context-id) () unsigned-int
+;   (statusbar statusbar)
+;   (context-description string))
+
+; (define-foreign statusbar-push () unsigned-int
+;   (statusbar statusbar)
+;   (context-id unsigned-int)  
+;   (text string))
+
+; (define-foreign statusbar-pop () nil
+;   (statusbar statusbar)
+;   (context-id unsigned-int))
+
+; (define-foreign statusbar-remove () nil
+;   (statusbar statusbar)
+;   (context-id unsigned-int)
+;   (message-id unsigned-int))
+
+
+
+;;; CList
+
+; (define-foreign %clist-new () clist
+;   (columns int))
+
+; (define-foreign %clist-new-with-titles () clist
+;   (columns int)
+;   (titles pointer))
+
+; (defun clist-new (columns)
+;   (if (atom columns)
+;       (%clist-new columns)
+;     (with-array (titles :initial-contents columns :free-contents t)
+;       (%clist-new-with-titles (length columns) titles))))
+
+; (define-foreign ("gtk_clist_set_button_actions"
+;                (setf clist-button-actions)) () nil
+;   (clist clist)
+;   (button unsigned-int)
+;   (button-actions button-actions))
+
+; (define-foreign clist-freeze () nil
+;   (clist clist))
+
+; (define-foreign clist-thaw () nil
+;   (clist clist))
+
+; (define-foreign clist-column-titles-show () nil
+;   (clist clist))
+
+; (define-foreign clist-column-titles-hide () nil
+;   (clist clist))
+
+; (defun (setf clist-titles-visible-p) (visible clist)
+;   (if visible
+;       (clist-column-titles-hide clist)
+;     (clist-column-titles-show clist)))
+
+; (define-foreign clist-column-title-active () nil
+;   (clist clist)
+;   (column int))
+
+; (define-foreign clist-column-title-passive () nil
+;   (clist clist)
+;   (column int))
+
+; (define-foreign clist-column-titles-active () nil
+;   (clist clist))
+
+; (define-foreign clist-column-titles-passive () nil
+;   (clist clist))
+
+; (define-foreign ("gtk_clist_set_column_title"
+;                (setf clist-column-title)) () nil
+;   (clist clist)
+;   (column int)
+;   (title string))
+
+; (define-foreign ("gtk_clist_get_column_title" clist-column-title) () string
+;   (clist clist)
+;   (column int))
+
+; (define-foreign ("gtk_clist_set_column_widget"
+;                (setf clist-column-widget)) () nil
+;   (clist clist)
+;   (column int)
+;   (widget widget))
+
+; (define-foreign ("gtk_clist_get_column_widget" clist-column-widget) () widget
+;   (clist clist)
+;   (column int))
+
+; (define-foreign ("gtk_clist_set_column_justification"
+;                (setf clist-column-justification)) () nil
+;   (clist clist)
+;   (column int)
+;   (justification justification))
+
+; (define-foreign clist-column-justification (clist column) justification
+;   (clist clist)
+;   ((progn
+;      (assert (and (>= column 0) (< column (clist-n-columns clist))))
+;      column)
+;    int))
+
+; (define-foreign ("gtk_clist_set_column_visibility"
+;                (setf clist-column-visible-p)) () nil
+;   (clist clist)
+;   (column int)
+;   (visible boolean))
+
+; ;; cl-gtk.c
+; (define-foreign clist-column-visible-p (clist column) boolean
+;   (clist clist)
+;   ((progn
+;      (assert (and (>= column 0) (< column (clist-n-columns clist))))
+;      column)
+;    int))
+
+; (define-foreign ("gtk_clist_set_column_resizeable"
+;                (setf clist-column-resizeable-p)) () nil
+;   (clist clist)
+;   (column int)
+;   (resizeable boolean))
+
+; ;; cl-gtk.c
+; (define-foreign clist-column-resizeable-p (clist column) boolean
+;   (clist clist)
+;   ((progn
+;      (assert (and (>= column 0) (< column (clist-n-columns clist))))
+;      column)
+;    int))
+
+; (define-foreign ("gtk_clist_set_column_auto_resize"
+;                (setf clist-column-auto-resize-p)) () nil
+;   (clist clist)
+;   (column int)
+;   (auto-resize boolean))
+
+; ;; cl-gtk.c
+; (define-foreign clist-column-auto-resize-p (clist column) boolean
+;   (clist clist)
+;   ((progn
+;      (assert (and (>= column 0) (< column (clist-n-columns clist))))
+;      column)
+;    int))
+
+; (define-foreign clist-columns-autosize () int
+;   (clist clist))
+
+; (define-foreign clist-optimal-column-width () int
+;   (clist clist)
+;   (column int))
+
+; (define-foreign ("gtk_clist_set_column_width"
+;                (setf clist-column-width)) () nil
+;   (clist clist)
+;   (column int)
+;   (width int))
+
+; ;; cl-gtk.c
+; (define-foreign clist-column-width (clist column) int
+;   (clist clist)
+;   ((progn
+;      (assert (and (>= column 0) (< column (clist-n-columns clist))))
+;      column)
+;    int))
+
+; (define-foreign ("gtk_clist_set_column_min_width"
+;                (setf clist-column-min-width)) (min-width clist column) nil
+;   (clist clist)
+;   (column int)
+;   ((or min-width -1) int))
+
+; (define-foreign ("gtk_clist_set_column_max_width"
+;                (setf clist-column-max-width)) (max-width clist column) nil
+;   (clist clist)
+;   (column int)
+;   ((or max-width -1) int))
+
+; (define-foreign clist-moveto () nil
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (row-align single-float)
+;   (columnt-align single-float))
+
+; (define-foreign
+;     ("gtk_clist_row_is_visible" clist-row-visiblie-p) () visibility
+;   (clist clist)
+;   (row int))
+
+; (define-foreign ("gtk_clist_get_cell_type" clist-cell-type) () cell-type
+;   (clist clist)
+;   (row int)
+;   (column int))
+
+; (define-foreign ("gtk_clist_set_text" (setf clist-cell-text)) () nil
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (text string))
+
+; (define-foreign %clist-set-pixmap () nil
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (gdk:pixmap gdk:pixmap)
+;   (mask (or null gdk:bitmap)))
+
+; (defun (setf clist-cell-pixmap) (pixmap clist row column)
+;   (multiple-value-bind (gdk:pixmap mask)
+;       (%pixmap-create pixmap)
+;     (%clist-set-pixmap clist row column gdk:pixmap mask)
+;     (values pixmap mask)))
+
+; (define-foreign %clist-set-pixtext () nil
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (text string)
+;   (spacing uint8)
+;   (pixmap gdk:pixmap)
+;   (mask (or null gdk:bitmap)))
+
+; (defun clist-set-cell-pixtext (clist row column text spacing pixmap)
+;   (multiple-value-bind (gdk:pixmap mask)
+;       (%pixmap-create pixmap)
+;     (%clist-set-pixtext clist row column text spacing gdk:pixmap mask)))
+
+; (define-foreign %clist-get-text () boolean
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (text string :out))
+
+; (defun clist-cell-text (clist row column)
+;   (multiple-value-bind (success text)
+;       (%clist-get-text clist row column)
+;     (unless success
+;       (error
+;        "Cell at row ~D column ~D in ~A is not of type :text"
+;        row column clist))
+;     text))
+
+; (define-foreign ("gtk_clist_get_pixmap" %clist-get-pixmap) () boolean
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (pixmap gdk:pixmap :out)
+;   (mask gdk:bitmap :out))
+
+; (defun clist-cell-pixmap (clist row column)
+;   (multiple-value-bind (success pixmap mask)
+;       (%clist-get-pixmap clist row column)
+;     (unless success
+;       (error
+;        "Cell at row ~D column ~D in ~A is not of type :pixmap"
+;        row column clist))
+;     (values pixmap mask)))
+
+; (define-foreign %clist-get-pixtext () boolean
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (text string :out)
+;   (spacing unsigned-int :out)
+;   (pixmap gdk:pixmap :out)
+;   (mask gdk:bitmap :out))
+
+; (defun clist-cell-pixtext (clist row column)
+;   (multiple-value-bind (success text spacing pixmap mask)
+;       (%clist-get-pixtext clist row column)
+;     (unless success
+;       (error
+;        "Cell at row ~D column ~D in ~A is not of type :pixtext"
+;        row column clist))
+;     (values text spacing pixmap mask)))
+
+; (define-foreign %clist-set-foreground () nil
+;   (clist clist)
+;   (row int)
+;   (color gdk:color))
+
+; (defun (setf clist-foreground) (color clist row)
+;   (gdk:with-colors ((color color))
+;     (%clist-set-foreground clist row color))
+;   color)
+
+; (define-foreign %clist-set-background () nil
+;   (clist clist)
+;   (row int)
+;   (color gdk:color))
+
+; (defun (setf clist-background) (color clist row)
+;   (gdk:with-colors ((color color))
+;     (%clist-set-background clist row color))
+;   color)
+
+; (define-foreign ("gtk_clist_set_cell_style"
+;                (setf clist-cell-style)) () nil
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (style style))
+  
+; (define-foreign ("gtk_clist_get_cell_style" clist-cell-style) () style
+;   (clist clist)
+;   (row int)
+;   (column int))
+
+; (define-foreign ("gtk_clist_set_row_style"
+;                (setf clist-row-style)) () nil
+;   (clist clist)
+;   (row int)
+;   (style style))
+
+; (define-foreign ("gtk_clist_get_row_style" clist-row-style) () style
+;   (clist clist)
+;   (row int))
+
+; (define-foreign clist-set-shift () nil
+;   (clist clist)
+;   (row int)
+;   (column int)
+;   (vertical int)
+;   (horizontal int))
+
+; (define-foreign ("gtk_clist_set_selectable"
+;                (setf clist-selectable-p)) () nil
+;   (clist clist)
+;   (row int)
+;   (selectable boolean))
+
+; (define-foreign ("gtk_clist_get_selectable" clist-selectable-p) () boolean
+;   (clist clist)
+;   (row int))
+
+; (define-foreign ("gtk_clist_insert" %clist-insert) () int
+;   (clist clist)
+;   (row int)
+;   (text pointer))
+
+; (defun clist-insert (clist row text)
+;   (unless (= (length text) (clist-n-columns clist))
+;     (error "Wrong number of elements in ~A" text))
+;   (with-array (data :initial-contents text :free-contents t)
+;     (%clist-insert clist row data)))
+
+; (defun clist-prepend (clist text)
+;   (clist-insert clist 0 text))
+
+; (defun clist-append (clist text)
+;   (clist-insert clist -1 text))
+
+; (define-foreign clist-remove () nil
+;   (clist clist)
+;   (row int))
+
+; (define-foreign ("gtk_clist_set_row_data_full" clist-set-row-data)
+;                  (clist row data &optional destroy-function) nil
+;   (clist clist)
+;   (row int)
+;   ((register-user-data data destroy-function) unsigned-long)
+;   (*destroy-marshal* pointer))
+
+; (defun (setf clist-row-data) (data clist row)
+;   (clist-set-row-data clist row data)
+;   data)
+
+; (define-foreign %clist-get-row-data () unsigned-long
+;   (clist clist)
+;   (row int))
+
+; (defun clist-row-data (clist row)
+;   (find-user-data (%clist-get-row-data clist row)))
+
+; (define-foreign %clist-find-row-from-data () int
+;   (clist clist)
+;   (id unsigned-long))
+
+; (define-foreign clist-select-row (clist row &optional (column -1)) nil
+;   (clist clist)
+;   (row int)
+;   (column int))
+
+; (define-foreign clist-unselect-row (clist row &optional (column -1)) nil
+;   (clist clist)
+;   (row int)
+;   (column int))
+
+; (define-foreign clist-undo-selection () nil
+;   (clist clist))
+
+; (define-foreign clist-clear () nil
+;   (clist clist))
+
+; (define-foreign ("gtk_clist_get_selection_info" clist-selection-info) () int
+;   (clist clist)
+;   (x int)
+;   (y int)
+;   (row int :out)
+;   (column int :out))
+  
+; (define-foreign clist-select-all () nil
+;   (clist clist))
+
+; (define-foreign clist-unselect-all () nil
+;   (clist clist))
+
+; (define-foreign clist-swap-rows () nil
+;   (clist clist)
+;   (row1 int)
+;   (row2 int))
+
+; (define-foreign ("gtk_clist_row_move" clist-move-row) () nil
+;   (clist clist)
+;   (source-row int)
+;   (dest-row int))
+
+; ;(define-foreign clist-set-compare-func ...)
+
+; (define-foreign clist-sort () nil
+;   (clist clist))
+
+; (define-foreign ("gtk_clist_set_auto_sort"
+;                (setf clist-auto-sort-p)) () nil
+;   (clist clist)
+;   (auto-sort boolean))
+
+; ;; cl-gtk.c
+; (define-foreign clist-auto-sort-p () boolean
+;   (clist clist))
+
+; (defun clist-focus-row (clist)
+;   (let ((row (%clist-focus-row clist)))
+;     (when (>= row 0)
+;       row)))
+
+; ;; cl-gtk.c
+; (define-foreign clist-selection () (list int)
+;   (clist clist))
+
+
+
+; ;;; CTree
+
+; (define-foreign %ctree-new () ctree
+;   (columns int)
+;   (tree-column int))
+
+; (define-foreign %ctree-new-with-titles () ctree
+;   (columns int)
+;   (tree-column int)
+;   (titles pointer))
+
+; (defun ctree-new (columns &optional (tree-column 0))
+;   (if (atom columns)
+;       (%ctree-new columns tree-column)
+;     (with-array (titles :initial-contents columns :free-contents t)
+;       (%ctree-new-with-titles (length columns) tree-column titles))))
+
+; (define-foreign %ctree-insert-node () ctree-node
+;   (ctree ctree)
+;   (parent (or null ctree-node))
+;   (sibling (or null ctree-node)) 
+;   (text pointer)
+;   (spacing uint8)
+;   (pixmap-closed (or null gdk:pixmap))
+;   (bitmap-closed (or null gdk:bitmap))
+;   (pixmap-opened (or null gdk:pixmap))
+;   (bitmap-opened (or null gdk:bitmap))
+;   (leaf boolean)
+;   (expaned boolean))
+
+; (defun ctree-insert-node (ctree parent sibling text spacing
+;                        &key pixmap closed opened leaf expanded)
+;   (multiple-value-bind (pixmap-closed mask-closed)
+;       (%pixmap-create (or closed pixmap))
+;     (multiple-value-bind (pixmap-opened mask-opened)
+;      (%pixmap-create (or opened (and (not leaf) pixmap)))
+;       (with-array (data :clear t :initial-contents text :free-contents t)
+;         (%ctree-insert-node
+;       ctree parent sibling data spacing pixmap-closed mask-closed
+;       pixmap-opened mask-opened leaf expanded)))))
+
+; (define-foreign ctree-remove-node () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (defun ctree-insert-from-list (ctree parent tree function)
+;   (clist-freeze ctree)
+;   (labels ((insert-node (node parent)
+;           (let ((ctree-node
+;                  (ctree-insert-node
+;                   ctree parent nil
+;                   (make-list (clist-n-columns ctree) :initial-element "")
+;                   0 :leaf (not (rest node)))))
+;             (funcall function ctree-node (car node))
+;             (dolist (child (rest node))
+;               (insert-node child ctree-node)))))
+;     (if parent
+;      (insert-node tree parent)
+;       (dolist (node tree)
+;      (insert-node node nil))))
+;   (clist-thaw ctree))
+
+; (defun ctree-map-to-list (ctree node function)
+;   (labels ((map-children (child)
+;           (when child
+;             (let ((sibling (ctree-node-sibling child)))
+;               (cons
+;                (ctree-map-to-list ctree child function)
+;                (map-children sibling))))))
+;     (if node
+;      (cons
+;       (funcall function node)
+;       (map-children (ctree-node-child node)))
+;       (map-children (ctree-nth-node ctree 0)))))
+
+
+; (defun %ctree-apply-recursive (ctree node pre function depth)
+;   (when (and pre node (or (not depth) (<= (ctree-node-level node) depth)))
+;     (funcall function node))
+  
+;   (let ((first-child (if node
+;                       (ctree-node-child node)
+;                     (ctree-nth-node ctree 0))))
+;     (when (and
+;         first-child
+;         (or (not depth) (<= (ctree-node-level first-child) depth)))
+;       (labels ((foreach-child (child)
+;               (when child
+;                 (let ((sibling (ctree-node-sibling child)))
+;                   (%ctree-apply-recursive ctree child pre function depth)
+;                   (foreach-child sibling)))))
+;      (foreach-child first-child))))
+  
+;   (when (and
+;       (not pre) node (or (not depth) (<= (ctree-node-level node) depth)))
+;     (funcall function node)))
+
+; (defun ctree-apply-post-recursive (ctree node function &optional depth)
+;   (%ctree-apply-recursive ctree node nil function depth))
+
+; (defun ctree-apply-pre-recursive (ctree node function &optional depth)
+;   (%ctree-apply-recursive ctree node t function depth))
+
+; (define-foreign ("gtk_ctree_is_viewable" ctree-node-viewable-p) () boolean
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-last () ctree-node
+;   (ctree ctree))
+
+; (define-foreign ("gtk_ctree_node_nth" ctree-nth-node) () ctree-node
+;   (ctree ctree)
+;   (row int))
+
+; (define-foreign ctree-find () boolean
+;   (ctree ctree)
+;   (node ctree-node)
+;   (child ctree-node))
+
+; (define-foreign ("gtk_ctree_is_ancestor" ctree-ancestor-p) () boolean
+;   (ctree ctree)
+;   (node ctree-node)
+;   (child ctree-node))
+
+; (define-foreign %ctree-find-by-row-data () int
+;   (clist clist)
+;   (node ctree-node)
+;   (id unsigned-long))
+
+; (define-foreign ("gtk_ctree_is_hot_spot" ctree-hot-spot-p) () boolean
+;   (ctree ctree)
+;   (x int)
+;   (y int))
+
+; (define-foreign ctree-move () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (new-parent ctree-node)
+;   (new-sibling ctree-node))
+
+; (define-foreign ctree-expand () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-expand-recursive () nil
+;   (ctree ctree)
+;   (node (or null ctree-node)))
+
+; (define-foreign ctree-expand-to-depth () nil
+;   (ctree ctree)
+;   (node (or null ctree-node))
+;   (depth int))
+
+; (define-foreign ctree-collapse () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-collapse-recursive () nil
+;   (ctree ctree)
+;   (node (or null ctree-node)))
+
+; (define-foreign ctree-collapse-to-depth () nil
+;   (ctree ctree)
+;   (node (or null ctree-node))
+;   (depth int))
+
+; (define-foreign ctree-toggle-expansion () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-toggle-expansion-recursive () nil
+;   (ctree ctree)
+;   (node (or null ctree-node)))
+
+; (define-foreign ctree-select () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-unselect () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign %ctree-real-select-recursive () nil
+;   (ctree ctree)
+;   (node (or null ctree-node))
+;   (state boolean))
+
+; (defun ctree-select-recursive (ctree node)
+;   (%ctree-real-select-recursive ctree node t))
+
+; (defun ctree-unselect-recursive (ctree node)
+;   (%ctree-real-select-recursive ctree node nil))
+
+; (define-foreign ("gtk_ctree_node_set_text" (setf ctree-cell-text)) () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (text string))
+
+; (define-foreign %ctree-node-set-pixmap () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (gdk:pixmap gdk:pixmap)
+;   (mask (or null gdk:bitmap)))
+
+; (defun (setf ctree-cell-pixmap) (source ctree node column)
+;   (multiple-value-bind (pixmap mask)
+;       (%pixmap-create source)
+;     (%ctree-node-set-pixmap ctree node column pixmap mask)
+;     (values pixmap mask)))
+
+; (define-foreign %ctree-node-set-pixtext () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (text string)
+;   (spacing uint8)
+;   (pixmap gdk:pixmap)
+;   (mask (or null gdk:bitmap)))
+
+; (defun ctree-set-cell-pixtext (ctree node column text spacing source)
+;   (multiple-value-bind (pixmap mask)
+;       (%pixmap-create source)
+;     (%ctree-node-set-pixtext ctree node column text spacing pixmap mask)))
+
+; (define-foreign %ctree-set-node-info () ctree-node
+;   (ctree ctree)
+;   (node (or null ctree-node))
+;   (text string)
+;   (spacing uint8)
+;   (pixmap-closed (or null gdk:pixmap))
+;   (bitmap-closed (or null gdk:bitmap))
+;   (pixmap-opened (or null gdk:pixmap))
+;   (bitmap-opened (or null gdk:bitmap))
+;   (leaf boolean)
+;   (expaned boolean))
+
+; (defun ctree-set-node-info (ctree node text spacing
+;                          &key pixmap closed opened leaf expanded)
+;   (multiple-value-bind (pixmap-closed mask-closed)
+;       (%pixmap-create (or closed pixmap))
+;     (multiple-value-bind (pixmap-opened mask-opened)
+;      (%pixmap-create (or opened (and (not leaf) pixmap)))
+;       (%ctree-set-node-info
+;        ctree node text spacing pixmap-closed mask-closed
+;        pixmap-opened mask-opened leaf expanded))))
+
+; (define-foreign ("gtk_ctree_node_set_shift" ctree-set-shift) () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (vertical int)
+;   (horizontal int))
+
+; (define-foreign ("gtk_ctree_node_set_selectable"
+;                (setf ctree-selectable-p)) () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (selectable boolean))
+
+; (define-foreign ("gtk_ctree_node_get_selectable"
+;                ctree-selectable-p) () boolean
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ("gtk_ctree_node_get_cell_type" ctree-cell-type) () cell-type
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int))
+
+; (define-foreign %ctree-node-get-text () boolean
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (text string :out))
+
+; (defun ctree-cell-text (ctree node column)
+;   (multiple-value-bind (success text)
+;       (%ctree-node-get-text ctree node column)
+;     (unless success
+;       (error
+;        "Cell in node ~A, column ~D in ~A is not of type :text"
+;        node column ctree))
+;     text))
+
+; (define-foreign %ctree-node-get-pixmap () boolean
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (pixmap gdk:pixmap :out)
+;   (mask gdk:bitmap :out))
+
+; (defun ctree-cell-pixmap (ctree node column)
+;   (multiple-value-bind (success pixmap mask)
+;       (%ctree-node-get-pixmap ctree node column)
+;     (unless success
+;       (error
+;        "Cell in node ~A column ~D in ~A is not of type :text"
+;        node column ctree))
+;     (values pixmap mask)))
+
+; (define-foreign %ctree-node-get-pixtext () boolean
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (text string :out)
+;   (spacing unsigned-int :out)
+;   (pixmap gdk:pixmap :out)
+;   (mask gdk:bitmap :out))
+
+; (defun ctree-cell-pixtext (ctree node column)
+;   (multiple-value-bind (success text spacing pixmap mask)
+;       (%ctree-node-get-pixtext ctree node column)
+;     (unless success
+;       (error
+;        "Cell in node ~A column ~D in ~A is not of type :text"
+;        node column ctree))
+;     (values text spacing pixmap mask)))
+
+; (define-foreign ("gtk_ctree_get_node_info" ctree-node-info) () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (text string :out)
+;   (spacing unsigned-int :out)
+;   (pixmap-closed gdk:pixmap :out)
+;   (mask-closed gdk:bitmap :out)
+;   (pixmap-opened gdk:pixmap :out)
+;   (mask-opened gdk:bitmap :out)
+;   (leaf boolean :out)
+;   (expanded boolean :out))
+
+; (define-foreign ("gtk_ctree_node_set_row_style"
+;                (setf ctree-row-style)) () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (style (or null style)))
+
+; (define-foreign ("gtk_ctree_node_get_row_style" ctree-row-style) () style
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ("gtk_ctree_node_set_cell_style"
+;                (setf ctree-cell-style)) () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (style (or null style)))
+
+; (define-foreign ("gtk_ctree_node_get_cell_style"
+;                ctree-cell-style) () style
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int))
+
+; (define-foreign %ctree-node-set-foreground () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (color gdk:color))
+
+; (defun (setf ctree-node-foreground) (color clist row)
+;   (gdk:with-colors ((color color))
+;     (%ctree-node-set-foreground clist row color))
+;   color)
+
+; (define-foreign %ctree-node-set-background () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (color gdk:color))
+
+; (defun (setf ctree-node-background) (color clist row)
+;   (gdk:with-colors ((color color))
+;     (%ctree-node-set-background clist row color))
+;   color)
+
+; (define-foreign ("gtk_ctree_node_set_row_data_full" ctree-set-node-data)
+;                  (ctree node data &optional destroy-function) nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   ((register-user-data data destroy-function) unsigned-long)
+;   (*destroy-marshal* pointer))
+
+; (defun (setf ctree-node-data) (data ctree node)
+;   (ctree-set-node-data ctree node data)
+;   data)
+
+; (define-foreign %ctree-node-get-row-data () unsigned-long
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (defun ctree-node-data (ctree node)
+;   (find-user-data (%ctree-node-get-row-data ctree node)))
+
+; (define-foreign ctree-node-moveto () nil
+;   (ctree ctree)
+;   (node ctree-node)
+;   (column int)
+;   (row-aling single-float)
+;   (column-aling single-float))
+
+; (define-foreign ("gtk_ctree_node_is_visible"
+;                ctree-node-visibility) () visibility
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-sort-node () nil
+;   (ctree ctree)
+;   (node ctree-node))
+
+; (define-foreign ctree-sort-recursive (ctree &optional node) nil
+;   (ctree ctree)
+;   (node (or null ctree-node)))
+
+; ;; cl-gtk.c
+; (define-foreign ("gtk_clist_selection" ctree-selection) () (list ctree-node)
+;   (ctree ctree))
+
+; ;; cl-gtk.c
+; (define-foreign ctree-node-leaf-p () boolean
+;   (node ctree-node))
+
+; ;; cl-gtk.c
+; (define-foreign ctree-node-parent () ctree-node
+;   (node ctree-node))
+
+; ;; cl-gtk.c
+; (define-foreign ctree-node-child () ctree-node
+;   (node ctree-node))
+
+; ;; cl-gtk.c
+; (define-foreign ctree-node-sibling () ctree-node
+;   (node ctree-node))
+
+; ;; cl-gtk.c
+; (define-foreign ctree-node-level () int
+;   (node ctree-node))
+
+
+;;; Fixed
+
+; (define-foreign fixed-new () fixed)
+
+; (define-foreign fixed-put () nil
+;   (fixed fixed)
+;   (widget widget)
+;   (x int) (y int16))
+
+; (define-foreign fixed-move () nil
+;   (fixed fixed)
+;   (widget widget)
+;   (x int16) (y int16))
+
+
+
+; ;;; Notebook
+
+; (define-foreign notebook-new () notebook)
+
+; (define-foreign ("gtk_notebook_insert_page_menu" notebook-insert-page)
+;     (notebook position child tab-label &optional menu-label) nil
+;   (notebook notebook)
+;   (child widget)
+;   ((if (stringp tab-label)
+;        (label-new tab-label)
+;      tab-label) widget)
+;   ((if (stringp menu-label)
+;        (label-new menu-label)
+;      menu-label) (or null widget))
+;   (position int))
+
+; (defun notebook-append-page (notebook child tab-label &optional menu-label)
+;   (notebook-insert-page notebook -1 child tab-label menu-label))
+
+; (defun notebook-prepend-page (notebook child tab-label &optional menu-label)
+;   (notebook-insert-page notebook 0 child tab-label menu-label))
+  
+; (define-foreign notebook-remove-page () nil
+;   (notebook notebook)
+;   (page-num int))
+
+; (defun notebook-current-page-num (notebook)
+;   (let ((page-num (notebook-current-page notebook)))
+;     (if (= page-num -1)
+;      nil
+;       page-num)))
+
+; (define-foreign ("gtk_notebook_get_nth_page" notebook-nth-page) () widget
+;   (notebook notebook)
+;   (page-num int))
+
+; (define-foreign %notebook-page-num () int
+;   (notebook notebook)
+;   (page-num int))
+
+; (defun notebook-child-page-num (notebook child)
+;   (let ((page-num (%notebook-page-num notebook child)))
+;     (if (= page-num -1)
+;      nil
+;       page-num)))
+
+; (define-foreign notebook-next-page () nil
+;   (notebook notebook))
+
+; (define-foreign notebook-prev-page () nil
+;   (notebook notebook))
+
+; (define-foreign notebook-popup-enable () nil
+;   (notebook notebook))
+
+; (define-foreign notebook-popup-disable () nil
+;   (notebook notebook))
+
+; (define-foreign
+;     ("gtk_notebook_get_tab_label" notebook-tab-label) (notebook ref) widget
+;   (notebook notebook)
+;   ((if (widget-p ref)
+;        ref
+;      (notebook-nth-page notebook ref))
+;    widget))
+
+; (define-foreign %notebook-set-tab-label () nil
+;   (notebook notebook)
+;   (reference widget)
+;   (tab-label widget))
+
+; (defun (setf notebook-tab-label) (tab-label notebook reference)
+;   (let ((tab-label-widget (if (stringp tab-label)
+;                            (label-new tab-label)
+;                          tab-label)))
+;     (%notebook-set-tab-label
+;      notebook
+;      (if (widget-p reference)
+;       reference
+;        (notebook-nth-page notebook reference))
+;      tab-label-widget)
+;     (when (stringp tab-label)
+;       (widget-unref tab-label-widget))
+;     tab-label-widget))
+   
+; (define-foreign
+;     ("gtk_notebook_get_menu_label" notebook-menu-label) (notebook ref) widget
+;   (notebook notebook)
+;   ((if (widget-p ref)
+;        ref
+;      (notebook-nth-page notebook ref))
+;    widget))
+
+; (define-foreign %notebook-set-menu-label () nil
+;   (notebook notebook)
+;   (reference widget)
+;   (menu-label widget))
+
+; (defun (setf notebook-menu-label) (menu-label notebook reference)
+;   (let ((menu-label-widget (if (stringp menu-label)
+;                            (label-new menu-label)
+;                          menu-label)))
+;     (%notebook-set-menu-label
+;      notebook
+;      (if (widget-p reference)
+;       reference
+;        (notebook-nth-page notebook reference))
+;      menu-label-widget)
+;     (when (stringp menu-label)
+;       (widget-unref menu-label-widget))
+;     menu-label-widget))
+
+; (define-foreign notebook-query-tab-label-packing (notebook ref) nil
+;   (notebook notebook)
+;   ((if (widget-p ref)
+;        ref
+;      (notebook-nth-page notebook ref))
+;    widget)
+;   (expand boolean :out)
+;   (fill boolean :out)
+;   (pack-type pack-type :out))
+
+; (define-foreign
+;     notebook-set-tab-label-packing (notebook ref expand fill pack-type) nil
+;   (notebook notebook)
+;   ((if (widget-p ref)
+;        ref
+;      (notebook-nth-page notebook ref))
+;    widget)
+;   (expand boolean)
+;   (fill boolean)
+;   (pack-type pack-type))
+
+; (define-foreign notebook-reorder-child () nil
+;   (notebook notebook)
+;   (child widget)
+;   (position int))
+
+
+
+; ;;; Font selection
+
+
+
+
+; ;;; Paned
+
+; (define-foreign paned-add1 () nil
+;   (paned paned)
+;   (child widget))
+
+; (define-foreign paned-add2 () nil
+;   (paned paned)
+;   (child widget))
+
+; (define-foreign paned-pack1 () nil
+;   (paned paned)
+;   (child widget)
+;   (resize boolean)
+;   (shrink boolean))
+
+; (define-foreign paned-pack2 () nil
+;   (paned paned)
+;   (child widget)
+;   (resize boolean)
+;   (shrink boolean))
+
+; ; (define-foreign ("gtk_paned_set_position" (setf paned-position)) () nil
+; ;   (paned paned)
+; ;   (position int))
+
+; ;; cl-gtk.c
+; (define-foreign paned-child1 () widget
+;   (paned paned)
+;   (resize boolean :out)
+;   (shrink boolean :out))
+
+; ;; cl-gtk.c
+; (define-foreign paned-child2 () widget
+;   (paned paned)
+;   (resize boolean :out)
+;   (shrink boolean :out))
+
+; (define-foreign vpaned-new () vpaned)
+
+; (define-foreign hpaned-new () hpaned)
+
+
+
+; ;;; Layout
+
+; (define-foreign layout-new (&optional hadjustment vadjustment) layout
+;   (hadjustment (or null adjustment))
+;   (vadjustment (or null adjustment)))
+
+; (define-foreign layout-put () nil
+;   (layout layout)
+;   (widget widget)
+;   (x int) (y int))
+
+; (define-foreign layout-move () nil
+;   (layout layout)
+;   (widget widget)
+;   (x int) (y int))
+
+; (define-foreign %layout-set-size () nil
+;   (layout layout)
+;   (width int)
+;   (height int))
+
+; (defun (setf layout-size) (size layout)
+;   (%layout-set-size layout (svref size 0) (svref size 1))
+;   (values (svref size 0) (svref size 1)))
+
+; ;; cl-gtk.c
+; (define-foreign layout-size () nil
+;   (layout layout)
+;   (width int :out)
+;   (height int :out))
+
+; (define-foreign layout-freeze () nil
+;   (layout layout))
+
+; (define-foreign layout-thaw () nil
+;   (layout layout))
+
+; (define-foreign layout-offset () nil
+;   (layout layout)
+;   (x int :out)
+;   (y int :out))
+
+
+
+;;; List
+
+; (define-foreign list-new () list-widget)
+
+; (define-foreign list-insert-items () nil
+;   (list list-widget)
+;   (items (list list-item))
+;   (position int))
+
+; (define-foreign list-append-items () nil
+;   (list list-widget)
+;   (items (double-list list-item)))
+
+; (define-foreign list-prepend-items () nil
+;   (list list-widget)
+;   (items (double-list list-item)))
+
+; (define-foreign %list-remove-items () nil
+;   (list list-widget)
+;   (items (double-list list-item)))
+
+; (define-foreign %list-remove-items-no-unref () nil
+;   (list list-widget)
+;   (items (double-list list-item)))
+
+; (defun list-remove-items (list items &key no-unref)
+;   (if no-unref
+;       (%list-remove-items-no-unref list items)
+;     (%list-remove-items list items)))
+
+; (define-foreign list-clear-items () nil
+;   (list list-widget)
+;   (start int)
+;   (end int))
+
+; (define-foreign list-select-item () nil
+;   (list list-widget)
+;   (item int))
+
+; (define-foreign list-unselect-item () nil
+;   (list list-widget)
+;   (item int))
+
+; (define-foreign list-select-child () nil
+;   (list list-widget)
+;   (child widget))
+
+; (define-foreign list-unselect-child () nil
+;   (list list-widget)
+;   (child widget))
+
+; (define-foreign list-child-position () int
+;   (list list-widget)
+;   (child widget))
+
+; (define-foreign list-extend-selection () nil
+;   (list list-widget)
+;   (scroll-type scroll-type)
+;   (position single-float)
+;   (auto-start-selection boolean))
+
+; (define-foreign list-start-selection () nil
+;   (list list-widget))
+
+; (define-foreign list-end-selection () nil
+;   (list list-widget))
+
+; (define-foreign list-select-all () nil
+;   (list list-widget))
+
+; (define-foreign list-unselect-all () nil
+;   (list list-widget))
+
+; (define-foreign list-scroll-horizontal () nil
+;   (list list-widget)
+;   (scroll-type scroll-type)
+;   (position single-float))
+
+; (define-foreign list-scroll-vertical () nil
+;   (list list-widget)
+;   (scroll-type scroll-type)
+;   (position single-float))
+
+; (define-foreign list-toggle-add-mode () nil
+;   (list list-widget))
+
+; (define-foreign list-toggle-focus-row () nil
+;   (list list-widget))
+
+; (define-foreign list-toggle-row () nil
+;   (list list-widget)
+;   (item list-item))
+
+; (define-foreign list-undo-selection () nil
+;   (list list-widget))
+
+; (define-foreign list-end-drag-selection () nil
+;   (list list-widget))
+
+; ;; cl-gtk.c
+; (define-foreign list-selection () (double-list list-item)
+;   (list list-widget))
+
+
+
+;;; Menu shell
+
+; (define-foreign menu-shell-insert () nil
+;   (menu-shell menu-shell)
+;   (menu-item menu-item)
+;   (position int))
+
+; (defun menu-shell-append (menu-shell menu-item)
+;   (menu-shell-insert menu-shell menu-item -1))
+
+; (defun menu-shell-prepend (menu-shell menu-item)
+;   (menu-shell-insert menu-shell menu-item 0))
+
+; (define-foreign menu-shell-deactivate () nil
+;   (menu-shell menu-shell))
+
+; (define-foreign menu-shell-select-item () nil
+;   (menu-shell menu-shell)
+;   (menu-item menu-item))
+
+; (define-foreign menu-shell-deselect () nil
+;   (menu-shell menu-shell))
+
+; (define-foreign menu-shell-activate-item () nil
+;   (menu-shell menu-shell)
+;   (menu-item menu-item)
+;   (fore-deactivate boolean))
+
+
+
+; ;;; Menu bar
+
+; (define-foreign menu-bar-new () menu-bar)
+
+; (define-foreign menu-bar-insert () nil
+;   (menu-bar menu-bar)
+;   (menu menu)
+;   (position int))
+
+; (defun menu-bar-append (menu-bar menu)
+;   (menu-bar-insert menu-bar menu -1))
+
+; (defun menu-bar-prepend (menu-bar menu)
+;   (menu-bar-insert menu-bar menu 0))
+
+
+
+; ;;; Menu
+
+; (define-foreign menu-new () menu)
+
+; (defun menu-insert (menu menu-item position)
+;   (menu-shell-insert menu menu-item position))
+
+; (defun menu-append (menu menu-item)
+;   (menu-shell-append menu menu-item))
+
+; (defun menu-prepend (menu menu-item)
+;   (menu-shell-prepend menu menu-item))
+
+; ;(defun menu-popup ...)
+
+; (define-foreign menu-reposition () nil
+;   (menu menu))
+
+; (define-foreign menu-popdown () nil
+;   (menu menu))
+
+; (define-foreign ("gtk_menu_get_active" menu-active) () widget
+;   (menu menu))
+
+; (define-foreign ("gtk_menu_set_active" (setf menu-active)) () nil
+;   (menu menu)
+;   (index unsigned-int))
+
+; ;(defun menu-attach-to-widget ...)
+
+; (define-foreign menu-detach () nil
+;   (menu menu))
+
+; (define-foreign ("gtk_menu_get_attach_widget" menu-attach-widget) () widget
+;   (menu menu))
+
+; (define-foreign menu-reorder-child () nil
+;   (menu menu)
+;   (menu-item menu-item)
+;   (position int))
+
+
+
+;;; Packer
+
+; (define-foreign packer-new () packer)
+
+; (define-foreign packer-add
+;     (packer child side anchor
+;      &key
+;      options
+;      (border-width (packer-default-border-width packer))
+;      (pad-x (packer-default-pad-x packer))
+;      (pad-y (packer-default-pad-y packer))
+;      (ipad-x (packer-default-ipad-x packer))
+;      (ipad-y (packer-default-ipad-y packer))) nil
+;   (packer packer)
+;   (child widget)
+;   (side side-type)
+;   (anchor anchor-type)
+;   (options packer-options)
+;   (border-width unsigned-int)
+;   (pad-x unsigned-int)
+;   (pad-y unsigned-int)
+;   (ipad-x unsigned-int)
+;   (ipad-y unsigned-int))
+
+; (define-foreign packer-set-child-packing () nil
+;   (packer packer)
+;   (child widget)
+;   (side side-type)
+;   (anchor anchor-type)
+;   (options packer-options)
+;   (border-width unsigned-int)
+;   (pad-x unsigned-int)
+;   (pad-y unsigned-int)
+;   (ipad-x unsigned-int)
+;   (ipad-y unsigned-int))
+
+; (define-foreign packer-reorder-child () nil
+;   (packer packer)
+;   (child widget)
+;   (position int))
+
+
+
+; ;;; Table
+
+; (define-foreign table-new () table
+;   (rows unsigned-int)
+;   (columns unsigned-int)
+;   (homogeneous boolean))
+
+; (define-foreign table-resize () nil
+;   (table table)
+;   (rows unsigned-int)
+;   (columns unsigned-int))
+
+; (define-foreign table-attach (table child left right top bottom
+;                             &key (x-options '(:expand :fill))
+;                                  (y-options '(:expand :fill))
+;                                  (x-padding 0) (y-padding 0)) nil
+;   (table table)
+;   (child widget)
+;   (left unsigned-int)
+;   (right unsigned-int)
+;   (top unsigned-int)
+;   (bottom unsigned-int)
+;   (x-options attach-options)
+;   (y-options attach-options)
+;   (x-padding unsigned-int)
+;   (y-padding unsigned-int))
+
+; (define-foreign ("gtk_table_set_row_spacing" (setf table-row-spacing)) () nil
+;   (table table)
+;   (row unsigned-int)
+;   (spacing unsigned-int))
+
+; ;; cl-gtk.c
+; (define-foreign table-row-spacing (table row) unsigned-int
+;   (table table)
+;   ((progn
+;      (assert (and (>= row 0) (< row (table-rows table))))
+;      row) unsigned-int))
+
+; (define-foreign ("gtk_table_set_col_spacing"
+;                (setf table-column-spacing)) () nil
+;   (table table)
+;   (col unsigned-int)
+;   (spacing unsigned-int))
+
+; ;; cl-gtk.c
+; (define-foreign table-column-spacing (table col) unsigned-int
+;   (table table)
+;   ((progn
+;      (assert (and (>= col 0) (< col (table-columns table))))
+;      col) unsigned-int))
+
+
+; (defun %set-table-child-option (object slot flag value)
+;   (let ((options (container-child-slot-value object slot)))
+;     (cond
+;      ((and value (not (member flag options)))
+;       (setf (container-child-slot-value object slot) (cons flag options)))
+;      ((and (not value) (member flag options))
+;       (setf
+;        (container-child-slot-value object slot) (delete flag options))))))
+
+
+; (macrolet ((define-option-accessor (name slot flag)
+;           `(progn
+;              (defun ,name (object)
+;                (member ,flag (container-child-slot-value object ,slot)))
+;              (defun (setf ,name) (value object)
+;                (%set-table-child-option object ,slot ,flag value)))))
+;   (define-option-accessor table-child-x-expand-p :x-options :expand)
+;   (define-option-accessor table-child-y-expand-p :y-options :expand)
+;   (define-option-accessor table-child-x-shrink-p :x-options :shrink)
+;   (define-option-accessor table-child-y-shrink-p :y-options :shrink)
+;   (define-option-accessor table-child-x-fill-p :x-options :fill)
+;   (define-option-accessor table-child-y-fill-p :y-options :fill))
+
+
+
+; ;;; Toolbar
+
+; (define-foreign toolbar-new () toolbar
+;   (orientation orientation)
+;   (style toolbar-style))
+
+
+; ;; cl-gtk.c
+; (define-foreign toolbar-num-children () int
+;   (toolbar toolbar))
+
+; (defun %toolbar-position-num (toolbar position)
+;   (case position
+;     (:prepend 0)
+;     (:append (toolbar-num-children toolbar))
+;     (t
+;      (assert (and (>= position 0) (< position (toolbar-num-children toolbar))))
+;      position)))
+
+; (define-foreign %toolbar-insert-element () widget
+;   (toolbar toolbar)
+;   (type toolbar-child-type)
+;   (widget (or null widget))
+;   (text string)
+;   (tooltip-text string)
+;   (tooltip-private-text string)
+;   (icon (or null widget))
+;   (nil null)
+;   (nil null)
+;   (position int))
+
+; (defun toolbar-insert-element (toolbar position
+;                             &key tooltip-text tooltip-private-text
+;                             type widget icon text callback)
+;   (let* ((icon-widget (typecase icon
+;                     ((or null widget) icon)
+;                     (t (pixmap-new icon))))
+;       (toolbar-child
+;        (%toolbar-insert-element
+;         toolbar (or type (and widget :widget) :button)
+;         widget text tooltip-text tooltip-private-text icon-widget
+;         (%toolbar-position-num toolbar position))))
+;     (when callback
+;       (signal-connect toolbar-child 'clicked callback))
+;     toolbar-child))
+
+; (defun toolbar-append-element (toolbar &key tooltip-text tooltip-private-text
+;                             type widget icon text callback)
+;   (toolbar-insert-element
+;    toolbar :append :type type :widget widget :icon icon :text text
+;    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
+;    :callback callback))
+
+; (defun toolbar-prepend-element (toolbar &key tooltip-text tooltip-private-text
+;                              type widget icon text callback)
+;   (toolbar-insert-element
+;    toolbar :prepend :type type :widget widget :icon icon :text text
+;    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text
+;    :callback callback))
+
+; (defun toolbar-insert-space (toolbar position)
+;   (toolbar-insert-element toolbar position :type :space))
+
+; (defun toolbar-append-space (toolbar)
+;   (toolbar-insert-space toolbar :append))
+
+; (defun toolbar-prepend-space (toolbar)
+;   (toolbar-insert-space toolbar :prepend))
+
+; (defun toolbar-insert-widget (toolbar widget position &key tooltip-text
+;                            tooltip-private-text callback)
+;   (toolbar-insert-element
+;    toolbar position :widget widget :tooltip-text tooltip-text
+;    :tooltip-private-text tooltip-private-text :callback callback))
+; (defun toolbar-append-widget (toolbar widget &key tooltip-text
+;                            tooltip-private-text callback)
+;   (toolbar-insert-widget
+;    toolbar widget :append :tooltip-text tooltip-text
+;    :tooltip-private-text tooltip-private-text :callback callback))
+
+; (defun toolbar-prepend-widget (toolbar widget &key tooltip-text
+;                             tooltip-private-text callback)
+;   (toolbar-insert-widget
+;    toolbar widget :prepend :tooltip-text tooltip-text
+;    :tooltip-private-text tooltip-private-text :callback callback))
+
+; (defun toolbar-insert-item (toolbar text icon position &key tooltip-text
+;                          tooltip-private-text callback)
+;   (toolbar-insert-element
+;    toolbar position :text text :icon icon :callback callback
+;    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
+
+; (defun toolbar-append-item (toolbar text icon &key tooltip-text
+;                          tooltip-private-text callback)
+;   (toolbar-insert-item
+;    toolbar text icon :append :callback callback
+;    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
+
+                      
+; (defun toolbar-prepend-item (toolbar text icon &key tooltip-text
+;                           tooltip-private-text callback)
+;   (toolbar-insert-item
+;    toolbar text icon :prepend :callback callback
+;    :tooltip-text tooltip-text :tooltip-private-text tooltip-private-text))
+
+; (defun toolbar-enable-tooltips (toolbar)
+;   (setf (toolbar-tooltips-p toolbar) t))
+
+; (defun toolbar-disable-tooltips (toolbar)
+;   (setf (toolbar-tooltips-p toolbar) nil))
+
+
+
+;;; Tree
+
+(define-foreign tree-new () tree)
+
+(define-foreign tree-append () nil
+  (tree tree)
+  (tree-item tree-item))
+
+(define-foreign tree-prepend () nil
+  (tree tree)
+  (tree-item tree-item))
+
+(define-foreign tree-insert () nil
+  (tree tree)
+  (tree-item tree-item)
+  (position int))
+
+; (define-foreign tree-remove-items () nil
+;   (tree tree)
+;   (items (double-list tree-item)))
+
+(define-foreign tree-clear-items () nil
+  (tree tree)
+  (start int)
+  (end int))
+
+(define-foreign tree-select-item () nil
+  (tree tree)
+  (item int))
+
+(define-foreign tree-unselect-item () nil
+  (tree tree)
+  (item int))
+
+(define-foreign tree-select-child () nil
+  (tree tree)
+  (tree-item tree-item))
+
+(define-foreign tree-unselect-child () nil
+  (tree tree)
+  (tree-item tree-item))
+
+(define-foreign tree-child-position () int
+  (tree tree)
+  (tree-item tree-item))
+
+(defun root-tree-p (tree)
+  (eq (tree-root-tree tree) tree))
+
+;; cl-gtk.c
+(define-foreign tree-selection () (double-list tree-item)
+  (tree tree))
+
+
+
+;;; Calendar
+
+(define-foreign calendar-new () calendar)
+
+(define-foreign calendar-select-month () int
+  (calendar calendar)
+  (month unsigned-int)
+  (year unsigned-int))
+
+(define-foreign calendar-select-day () nil
+  (calendar calendar)
+  (day unsigned-int))
+
+(define-foreign calendar-mark-day () int
+  (calendar calendar)
+  (day unsigned-int))
+
+(define-foreign calendar-unmark-day () int
+  (calendar calendar)
+  (day unsigned-int))
+
+(define-foreign calendar-clear-marks () nil
+  (calendar calendar))
+
+(define-foreign calendar-display-options () nil
+  (calendar calendar)
+  (options calendar-display-options))
+
+(define-foreign ("gtk_calendar_get_date" calendar-date) () nil
+  (calendar calendar)
+  (year unsigned-int :out)
+  (month unsigned-int :out)
+  (day unsigned-int :out))
+
+(define-foreign calendar-freeze () nil
+  (calendar calendar))
+
+(define-foreign calendar-thaw () nil
+  (calendar calendar))
+
+
+
+;;; Drawing area
+
+; (define-foreign drawing-area-new () drawing-area)
+
+; (define-foreign ("gtk_drawing_area_size" %drawing-area-set-size) () nil
+;   (drawing-area drawing-area)
+;   (width int)
+;   (height int))
+
+; (defun (setf drawing-area-size) (size drawing-area)
+;   (%drawing-area-set-size drawing-area (svref size 0) (svref size 1))
+;   (values (svref size 0) (svref size 1)))
+
+; ;; cl-gtk.c
+; (define-foreign ("gtk_drawing_area_get_size" drawing-area-size) () nil
+;   (drawing-area drawing-area)
+;   (width int :out)
+;   (height int :out))
+
+
+
+; ;;; Curve
+
+
+
+; ;;; Editable
+
+; (define-foreign editable-select-region () nil
+;   (editable editable)
+;   (start int)
+;   (end int))
+
+; (define-foreign editable-insert-text
+;     (editable text &optional (position 0)) nil
+;   (editable editable)
+;   (text string)
+;   ((length text) int)
+;   (position int))
+
+; (define-foreign editable-delete-text (editable &optional (start 0) end) nil
+;   (editable editable)
+;   (start int)
+;   ((or end -1) int))
+
+; (define-foreign ("gtk_editable_get_chars" editable-text)
+;     (editable &optional (start 0) end) string
+;   (editable editable)
+;   (start int)
+;   ((or end -1) int))
+
+; (defun (setf editable-text) (text editable)
+;   (editable-delete-text editable)
+;   (when text
+;     (editable-insert-text editable text))
+;   text)
+
+; (define-foreign editable-cut-clipboard () nil
+;   (editable editable))
+
+; (define-foreign editable-copy-clipboard () nil
+;   (editable editable))
+
+; (define-foreign editable-paste-clipboard () nil
+;   (editable editable))
+
+; (define-foreign editable-claim-selection () nil
+;   (editable editable)
+;   (claim boolean)
+;   (time unsigned-int))
+
+; (define-foreign editable-delete-selection () nil
+;   (editable editable))
+
+; (define-foreign editable-changed () nil
+;   (editable editable))
+
+
+
+; ;;; Entry
+
+; (define-foreign %entry-new() entry)
+
+; (define-foreign %entry-new-with-max-length () entry
+;   (max uint16))
+
+; (defun entry-new (&optional max)
+;   (if max
+;       (%entry-new-with-max-length max)
+;     (%entry-new)))
+
+; (define-foreign entry-append-text () nil
+;   (entry entry)
+;   (text string))
+
+; (define-foreign entry-prepend-text () nil
+;   (entry entry)
+;   (text string))
+
+; (define-foreign entry-select-region () nil
+;   (entry entry)
+;   (start int)
+;   (end int))
+
+
+
+; ;;; Spin button
+
+; (define-foreign spin-button-new () spin-button
+;   (adjustment adjustment)
+;   (climb-rate single-float)
+;   (digits unsigned-int))
+
+; (defun spin-button-value-as-int (spin-button)
+;   (round (spin-button-value spin-button)))
+
+; (define-foreign spin-button-spin () nil
+;   (spin-button spin-button)
+;   (direction spin-type)
+;   (increment single-float))
+
+; (define-foreign spin-button-update () nil
+;   (spin-button spin-button))
+
+
+
+; ;;; Text
+
+; (define-foreign text-new (&optional hadjustment vadjustment) text
+;   (hadjustment (or null adjustment))
+;   (vadjustment (or null adjustment)))
+
+; (define-foreign text-freeze () nil
+;   (text text))
+
+; (define-foreign text-thaw () nil
+;   (text text))
+
+; (define-foreign %text-insert () nil
+;   (text text)
+;   (font (or null gdk:font))
+;   (fore (or null gdk:color))
+;   (back (or null gdk:color))
+;   (string string)
+;   (-1 int))
+
+; (defun text-insert (text string &key font foreground background (start 0) end)
+;   (let ((real-font (gdk:ensure-font font)))
+;     (gdk:with-colors ((fore-color foreground)
+;                    (back-color background))
+;     (%text-insert
+;      text real-font fore-color back-color (subseq string start end))
+;     (gdk:font-maybe-unref real-font font))))
+
+; (define-foreign text-backward-delete () int
+;   (text text)
+;   (n-chars unsigned-int))
+
+; (define-foreign text-forward-delete () nil
+;   (text text)
+;   (nchars unsigned-int))
+
+
+
+; ;;; Ruler
+
+; (define-foreign ruler-set-range () nil
+;   (ruler ruler)
+;   (lower single-float)
+;   (upper single-float)
+;   (position single-float)
+;   (max-size single-float))
+
+; (define-foreign ruler-draw-ticks () nil
+;   (ruler ruler))
+
+; (define-foreign ruler-draw-pos () nil
+;   (ruler ruler))
+
+; (define-foreign hruler-new () hruler)
+
+; (define-foreign vruler-new () vruler)
+
+
+
+; ;;; Range
+
+; (define-foreign range-draw-background () nil
+;   (range range))
+
+; (define-foreign range-clear-background () nil
+;   (range range))
+
+; (define-foreign range-draw-trough () nil
+;   (range range))
+
+; (define-foreign range-draw-slider () nil
+;   (range range))
+
+; (define-foreign range-draw-step-forw () nil
+;   (range range))
+
+; (define-foreign range-slider-update () nil
+;   (range range))
+
+; (define-foreign range-trough-click () int
+;   (range range)
+;   (x int)
+;   (y int)
+;   (jump-perc single-float :out))
+
+; (define-foreign range-default-hslider-update () nil
+;   (range range))
+
+; (define-foreign range-default-vslider-update () nil
+;   (range range))
+
+; (define-foreign range-default-htrough-click () int
+;   (range range)
+;   (x int)
+;   (y int)
+;   (jump-perc single-float :out))
+
+; (define-foreign range-default-vtrough-click () int
+;   (range range)
+;   (x int)
+;   (y int)
+;   (jump-perc single-float :out))
+
+; (define-foreign range-default-hmotion () int
+;   (range range)
+;   (x-delta int)
+;   (y-delta int))
+
+; (define-foreign range-default-vmotion () int
+;   (range range)
+;   (x-delta int)
+;   (y-delta int))
+
+
+
+; ;;; Scale
+
+; (define-foreign scale-draw-value () nil
+;   (scale scale))
+
+; (define-foreign hscale-new () hscale
+;   (adjustment adjustment))
+
+; (define-foreign vscale-new () hscale
+;   (adjustment adjustment))
+
+
+
+; ;;; Scrollbar
+
+; (define-foreign hscrollbar-new () hscrollbar
+;   (adjustment adjustment))
+
+; (define-foreign vscrollbar-new () vscrollbar
+;   (adjustment adjustment))
+
+
+
+; ;;; Separator
+
+; (define-foreign vseparator-new () vseparator)
+
+; (define-foreign hseparator-new () hseparator)
+
+
+
+; ;;; Preview
+
+
+
+; ;;; Progress
+
+; (define-foreign progress-configure () adjustment
+;   (progress progress)
+;   (value single-float)
+;   (min single-float)
+;   (max single-float))
+
+; (define-foreign ("gtk_progress_get_text_from_value"
+;                progress-text-from-value) () string
+;   (progress progress))
+
+; (define-foreign ("gtk_progress_get_percentage_from_value"
+;                progress-percentage-from-value) () single-float
+;   (progress progress))
+
+
+
+; ;;; Progress bar
+
+; (define-foreign %progress-bar-new () progress-bar)
+
+; (define-foreign %progress-bar-new-with-adjustment () progress-bar
+;   (adjustment adjustment))
+
+; (defun progress-bar-new (&optional adjustment)
+;   (if adjustment
+;       (%progress-bar-new-with-adjustment adjustment)
+;     (%progress-bar-new)))
+
+; (define-foreign progress-bar-update () nil
+;   (progress-bar progress-bar)
+;   (percentage single-float))
+
+
+
+;;; Adjustment
+
+(define-foreign adjustment-new () adjustment
+  (value single-float)
+  (lower single-float)
+  (upper single-float)
+  (step-increment single-float)
+  (page-increment single-float)
+  (page-size single-float))
+
+(define-foreign adjustment-changed () nil
+  (adjustment adjustment))
+
+(define-foreign adjustment-value-changed () nil
+  (adjustment adjustment))
+
+(define-foreign adjustment-clamp-page () nil
+  (adjustment adjustment)
+  (lower single-float)
+  (upper single-float))
+
+
+
+;;; Tooltips
+
+; (define-foreign tooltips-new () tooltips)
+
+; (define-foreign tooltips-enable () nil
+;   (tooltips tooltips))
+
+; (define-foreign tooltips-disable () nil
+;   (tooltips tooltips))
+
+; (define-foreign tooltips-set-tip () nil
+;   (tooltips tooltips)
+;   (widget widget)
+;   (tip-text string)
+;   (tip-private string))
+
+; (declaim (inline tooltips-set-colors-real))
+; (define-foreign ("gtk_tooltips_set_colors" tooltips-set-colors-real) () nil
+;   (tooltips tooltips)
+;   (background gdk:color)
+;   (foreground gdk:color))
+
+; (defun tooltips-set-colors (tooltips background foreground)
+;   (gdk:with-colors ((background background)
+;                  (foreground foreground))
+;     (tooltips-set-colors-real tooltips background foreground)))
+
+; (define-foreign tooltips-force-window () nil
+;   (tooltips tooltips))
+
+
+
+
+; ;;; Rc
+
+; (define-foreign rc-add-default-file (filename) nil
+;   ((namestring (truename filename)) string))
+
+; (define-foreign rc-parse (filename) nil
+;   ((namestring (truename filename)) string))
+
+; (define-foreign rc-parse-string () nil
+;   (rc-string string))
+
+; (define-foreign rc-reparse-all () nil)
+
+; ;(define-foreign rc-get-style () style
+; ;  (widget widget))
+
+
+
+;;; Accelerator Groups
+
+(define-foreign accel-group-new () accel-group)
+
+(define-foreign accel-group-get-default () accel-group)
+
+(define-foreign accel-group-ref () accel-group
+  (accel-group accel-group))
+
+(define-foreign accel-group-unref () nil
+  (accel-group accel-group))
+
+(define-foreign accel-group-activate (accel-group key modifiers) boolean
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign accel-groups-activate (object key modifiers) boolean
+  (object object)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign accel-group-attach () nil
+  (accel-group accel-group)
+  (object object))
+
+(define-foreign accel-group-detach () nil
+  (accel-group accel-group)
+  (object object))
+
+(define-foreign accel-group-lock () nil
+  (accel-group accel-group))
+
+(define-foreign accel-group-unlock () nil
+  (accel-group accel-group))
+
+
+;;; Accelerator Groups Entries
+
+(define-foreign accel-group-get-entry (accel-group key modifiers) accel-entry
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign accel-group-lock-entry (accel-group key modifiers) nil
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign accel-group-unlock-entry (accel-group key modifiers) nil
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign accel-group-add
+    (accel-group key modifiers flags object signal) nil
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type)
+  (flags accel-flags)
+  (object object)
+  ((name-to-string signal) string))
+
+(define-foreign accel-group-add (accel-group key modifiers object) nil
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type)
+  (object object))
+
+
+;;; Accelerator Signals
+
+(define-foreign accel-group-handle-add
+    (object signal-id accel-group key modifiers flags) nil
+  (object object)
+  (signal-id unsigned-int)
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type)
+  (flags accel-flags))
+
+(define-foreign accel-group-handle-remove
+    (object accel-group key modifiers) nil
+  (object object)
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+
+
+;;; Style
+
+; (define-foreign style-new () style)
+
+; (define-foreign style-copy () style
+;   (style style))
+
+; (define-foreign style-ref () style
+;   (style style))
+
+; (define-foreign style-unref () nil
+;   (style style))
+
+; (define-foreign style-get-color () gdk:color
+;   (style style)
+;   (color-type color-type)
+;   (state-type state-type))
+
+; (define-foreign
+;     ("gtk_style_set_color" style-set-color-from-color) () gdk:color
+;   (style style)
+;   (color-type color-type)
+;   (state-type state-type)
+;   (color gdk:color))
+
+; (defun style-set-color (style color-type state-type color)
+;   (gdk:with-colors ((color color))
+;     (style-set-color-from-color style color-type state-type color)))
+
+; (define-foreign ("gtk_style_get_font" style-font) () gdk:font
+;   (style style))
+
+; (define-foreign style-set-font () gdk:font
+;   (style style)
+;   (font gdk:font))
+
+; (defun (setf style-font) (font style)
+;   (let ((font (gdk:ensure-font font)))
+;     (gdk:font-unref (style-font style))
+;     (style-set-font style font)))
+
+; (defun style-fg (style state)
+;   (style-get-color style :foreground state))
+
+; (defun (setf style-fg) (color style state)
+;   (style-set-color style :foreground state color))
+
+; (defun style-bg (style state)
+;   (style-get-color style :background state))
+
+; (defun (setf style-bg) (color style state)
+;   (style-set-color style :background state color))
+
+; (defun style-text (style state)
+;   (style-get-color style :text state))
+
+; (defun (setf style-text) (color style state)
+;   (style-set-color style :text state color))
+
+; (defun style-base (style state)
+;   (style-get-color style :base state))
+
+; (defun (setf style-base) (color style state)
+;   (style-set-color style :base state color))
+
+; (defun style-white (style)
+;   (style-get-color style :white :normal))
+
+; (defun (setf style-white) (color style)
+;   (style-set-color style :white :normal color))
+
+; (defun style-black (style)
+;   (style-get-color style :black :normal))
+
+; (defun (setf style-black) (color style)
+;   (style-set-color style :black :normal color))
+
+; (define-foreign style-get-gc
+;     (style color-type &optional (state-type :normal)) gdk:gc
+;   (style style)
+;   (color-type color-type)
+;   (state-type state-type))
+
+
+
+
+
+
+
+
diff --git a/gtk/gtkcontainer.lisp b/gtk/gtkcontainer.lisp
new file mode 100644 (file)
index 0000000..375b82f
--- /dev/null
@@ -0,0 +1,182 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gtkcontainer.lisp,v 1.1 2000/08/14 16:45:02 espen Exp $
+
+(in-package "GTK")
+
+(defclass container (widget)
+  ((border-width
+    :allocation :arg
+    :accessor container-border-width
+    :initarg :border-width
+    :type unsigned-long)
+   (resize-mode
+    :allocation :arg
+    :accessor container-resize-mode
+    :initarg :resize-mode
+    :type resize-mode)
+   (children
+    :allocation :virtual
+    :location container-children
+;    :initarg :children
+    )
+   (focus-child
+    :allocation :virtual
+    :location ("gtk_container_get_focus_child" "gtk_container_set_focus_child")
+    :accessor container-focus-child
+    :initarg :focus-child
+    :type widget)
+   (focus-hadjustment
+    :allocation :virtual
+    :location (nil "gtk_container_set_focus_hadjustment")
+    :writer (setf container-focus-hadjustment)
+    :initarg :focus-hadjustment
+    :type adjustment)   
+   (focus-vadjustment
+    :allocation :virtual
+    :location (nil "gtk_container_set_focus_vadjustment")
+    :writer (setf container-focus-vadjustment)
+    :initarg :focus-vadjustment
+    :type adjustment))
+  (:metaclass widget-class)
+  (:alien-name "GtkContainer"))
+
+
+(defmethod initialize-instance ((container container) &rest initargs
+                               &key children)
+  (declare (ignore initargs))
+  (call-next-method)
+  (dolist (child children)
+    (cond
+     ((consp child)
+      (container-add container (first child))
+      (setf
+       (slot-value (first child) 'child-slots)
+       (apply
+       #'make-instance
+       (slot-value (class-of container) 'child-class)
+       :parent container :child (first child) (cdr child))))
+     (t
+      (container-add container child)))))
+
+
+
+(define-foreign ("gtk_container_child_getv" container-child-get-arg) () nil
+  (container container)
+  (child widget)
+  (1 unsigned-int)
+  (arg arg))
+
+(define-foreign ("gtk_container_child_setv" container-child-set-arg) () nil
+  (container container)
+  (child widget)
+  (1 unsigned-int)
+  (arg arg))
+
+(defun container-child-arg (container child name)
+  (with-gc-disabled
+    (let ((arg (arg-new 0)))
+      (setf (arg-name arg) name)
+      (container-child-get-arg container child arg) ; probably memory leak
+      (let ((type (type-from-number (arg-type arg))))
+       (prog1
+           (arg-value arg type)
+         (arg-free arg nil))))))
+
+(defun (setf container-child-arg) (value container child name)
+  (with-gc-disabled
+    (let ((arg (arg-new 0)))
+      (setf (arg-name arg) name)
+      (container-child-get-arg container child arg) ; probably memory leak
+      (let ((type (type-from-number (arg-type arg))))
+       (setf (arg-value arg type) value)
+       (container-child-set-arg container child arg)
+       (arg-free arg nil))))
+  value)
+
+
+(define-foreign container-add () nil
+  (container container)
+  (widget widget))
+
+(define-foreign container-remove () nil
+  (container container)
+  (widget widget))
+
+(define-foreign container-check-resize () nil
+  (container container))
+
+(define-foreign ("gtk_container_foreach_full" %container-foreach)
+    (container function) nil
+  (container container)
+  (0 unsigned-long)
+  (*callback-marshal* pointer)
+  ((register-callback-function function) unsigned-long)
+  (*destroy-marshal* pointer))
+
+(defun map-container (seqtype func container)
+  (case seqtype
+    ((nil)
+     (%container-foreach container func)
+     nil)
+    (list
+     (let ((list nil))
+       (%container-foreach
+       container
+       #'(lambda (child)
+           (push (funcall func child) list)))
+       (nreverse list)))
+    (t
+     (let ((seq (make-sequence seqtype (container-num-children container)))
+          (index 0))
+       (%container-foreach
+       container
+       #'(lambda (child)
+           (setf (elt seq index) (funcall func child))
+           (incf index)))
+       seq))))
+
+(defmacro do-container ((var container &optional (result nil)) &body body)
+  (let ((continue (make-symbol "CONTINUE")))
+    `(let ((,continue t))
+       (%container-foreach
+       ,container
+       #'(lambda (,var)
+           (when ,continue
+             (setq ,continue nil)
+             (block nil
+               ,@body
+               (setq ,continue t)))))
+       ,result)))
+
+(define-foreign container-children () (double-list widget)
+  (container container))
+
+(defun (setf container-children) (children container)
+  (dolist (child (container-children container))
+    (container-remove container child))
+  (dolist (child children)
+    (container-add container child))
+  children)
+
+;; Should be implemented as a foreign function
+(defun container-num-children (container)
+  (length (container-children container)))
+
+(define-foreign container-resize-children () nil
+  (container container))
diff --git a/gtk/gtkenums.lisp b/gtk/gtkenums.lisp
new file mode 100644 (file)
index 0000000..f358cea
--- /dev/null
@@ -0,0 +1,582 @@
+;; generated by a modified makeenums.pl  ; -*- lisp -*-
+;; but edited by hand
+
+(in-package "GTK")
+
+; enumerations from "gtkaccelgroup.h"
+
+(deftype (accel-flags "GtkAccelFlags") ()
+  '(flags
+   (:visible  0)
+   (:signal-visible  1)
+   (:locked  2)
+;   (:mask  #x07 )
+  ))
+
+; enumerations from "gtkcalendar.h"
+
+(deftype (calendar-display-options "GtkCalendarDisplayOptions") ()
+  '(flags
+   (:show-heading  0)
+   (:show-day-names  1)
+   (:no-month-change  2)
+   (:show-week-numbers  3)
+   (:week-start-monday  4 )))
+
+; enumerations from "gtkclist.h"
+
+(deftype (cell-type "GtkCellType") ()
+  '(enum
+   :empty
+   :text
+   :pixmap
+   :pixtext
+   :widget))
+
+(deftype (c-list-drag-pos "GtkCListDragPos") ()
+  '(enum
+   :none
+   :before
+   :into
+   :after))
+
+(deftype (button-action "GtkButtonAction") ()
+  '(flags
+;   (:ignored  0)
+   (:selects  0)
+   (:drags  1)
+   (:expands  2 )))
+
+; enumerations from "gtkctree.h"
+
+(deftype (ctree-pos "GtkCTreePos") ()
+  '(enum
+   :before
+   :as-child
+   :after))
+
+(deftype (ctree-line-style "GtkCTreeLineStyle") ()
+  '(enum
+   :none
+   :solid
+   :dotted
+   :tabbed))
+
+(deftype (ctree-expander-style "GtkCTreeExpanderStyle") ()
+  '(enum
+   :none
+   :square
+   :triangle
+   :circular))
+
+(deftype (ctree-expansion-type "GtkCTreeExpansionType") ()
+  '(enum
+   :expand
+   :expand-recursive
+   :collapse
+   :collapse-recursive
+   :toggle
+   :toggle-recursive))
+
+; enumerations from "gtkdebug.h"
+
+(deftype (debug-flag "GtkDebugFlag") ()
+  '(flags
+   (:objects  0)
+   (:misc  1)
+   (:signals  2)
+   (:dnd 3)
+   (:plugsocket 4)
+   (:text 5 )))
+
+; enumerations from "gtkdnd.h"
+
+(deftype (dest-defaults "GtkDestDefaults") ()
+  '(flags
+   (:motion  0)
+   (:highlight  1)
+   (:drop  2)
+;  (:all  #x07 )
+  ))
+
+(deftype (target-flags "GtkTargetFlags") ()
+  '(flags
+   (:same-app  0)
+   (:same-widget  1  )))
+
+; enumerations from "gtkenums.h"
+
+(deftype (arrow-type "GtkArrowType") ()
+  '(enum
+   :up
+   :down
+   :left
+   :right))
+
+(deftype (attach-options "GtkAttachOptions") ()
+  '(flags
+   (:expand  0)
+   (:shrink  1)
+   (:fill  2 )))
+
+(deftype (button-box-style "GtkButtonBoxStyle") ()
+  '(enum
+   :default-style
+   :spread
+   :edge
+   :start
+   :end))
+
+(deftype (curve-type "GtkCurveType") ()
+  '(enum
+   :linear
+   :spline
+   :free))
+
+(deftype (direction-type "GtkDirectionType") ()
+  '(enum
+   :tab-forward
+   :tab-backward
+   :up
+   :down
+   :left
+   :right))
+
+(deftype (text-direction "GtkTextDirection") ()
+  '(enum
+   :none
+   :ltr
+   :rtl))
+
+(deftype (justification "GtkJustification") ()
+  '(enum
+   :left
+   :right
+   :center
+   :fill))
+
+(deftype (match-type "GtkMatchType") ()
+  '(enum
+   :all
+   :all-tail
+   :head
+   :tail
+   :exact
+   :last))
+
+(deftype (menu-direction-type "GtkMenuDirectionType") ()
+  '(enum
+   :parent
+   :child
+   :next
+   :prev))
+
+(deftype (menu-factory-type "GtkMenuFactoryType") ()
+  '(enum
+   :menu
+   :menu-bar
+   :option-menu))
+
+(deftype (metric-type "GtkMetricType") ()
+  '(enum
+   :pixels
+   :inches
+   :centimeters))
+
+(deftype (orientation "GtkOrientation") ()
+  '(enum
+   :horizontal
+   :vertical))
+
+(deftype (corner-type "GtkCornerType") ()
+  '(enum
+   :top-left
+   :bottom-left
+   :top-right
+   :bottom-right))
+
+(deftype (pack-type "GtkPackType") ()
+  '(enum
+   :start
+   :end))
+
+(deftype (path-priority-type "GtkPathPriorityType") ()
+  '(enum
+   (:lowest  0)
+   (:gtk  4)
+   (:application  8)
+   (:rc  12)
+   (:highest  15)
+;  (:mask  #x0f )
+   ))
+
+(deftype (path-type "GtkPathType") ()
+  '(enum
+   :widget
+   :widget-class
+   :class))
+
+(deftype (policy-type "GtkPolicyType") ()
+  '(enum
+   :always
+   :automatic
+   :never))
+
+(deftype (position-type "GtkPositionType") ()
+  '(enum
+   :left
+   :right
+   :top
+   :bottom))
+
+(deftype (preview-type "GtkPreviewType") ()
+  '(enum
+   :color
+   :grayscale))
+
+(deftype (relief-style "GtkReliefStyle") ()
+  '(enum
+   :normal
+   :half
+   :none))
+
+(deftype (resize-mode "GtkResizeMode") ()
+  '(enum
+   :parent
+   :queue
+   :immediate))
+
+(deftype (signal-run-type "GtkSignalRunType") ()
+  '(flags
+   (:first  0)
+   (:last  1)
+;   (:both  (GTK_RUN_FIRST | GTK_RUN_LAST))
+   (:no-recurse  2)
+   (:action  3)
+   (:no-hooks  4 )))
+
+(deftype (scroll-type "GtkScrollType") ()
+  '(enum
+   :none
+   :step-backward
+   :step-forward
+   :page-backward
+   :page-forward
+   :jump))
+
+(deftype (selection-mode "GtkSelectionMode") ()
+  '(enum
+   :single
+   :browse
+   :multiple
+   :extended))
+
+(deftype (shadow-type "GtkShadowType") ()
+  '(enum
+   :none
+   :in
+   :out
+   :etched-in
+   :etched-out))
+
+(deftype (state-type "GtkStateType") ()
+  '(enum
+   :normal
+   :active
+   :prelight
+   :selected
+   :insensitive))
+
+(deftype (submenu-direction "GtkSubmenuDirection") ()
+  '(enum
+   :left
+   :right))
+
+(deftype (submenu-placement "GtkSubmenuPlacement") ()
+  '(enum
+   :top-bottom
+   :left-right))
+
+(deftype (toolbar-style "GtkToolbarStyle") ()
+  '(enum
+   :icons
+   :text
+   :both
+   :both-horiz))
+
+(deftype (trough-type "GtkTroughType") ()
+  '(enum
+   :none
+   :start
+   :end
+   :jump))
+
+(deftype (update-type "GtkUpdateType") ()
+  '(enum
+   :continuous
+   :discontinuous
+   :delayed))
+
+(deftype (visibility "GtkVisibility") ()
+  '(enum
+   :none
+   :partial
+   :full))
+
+(deftype (window-position "GtkWindowPosition") ()
+  '(enum
+   :none
+   :center
+   :mouse
+   :center-always))
+
+(deftype (window-type "GtkWindowType") ()
+  '(enum
+   :toplevel
+   :dialog
+   :popup))
+
+(deftype (sort-type "GtkSortType") ()
+  '(enum
+   :ascending
+   :descending))
+
+; enumerations from "gtkobject.h"
+
+(deftype (object-flags "GtkObjectFlags") ()
+  '(flags
+   (:destroyed  0)
+   (:floating  1)
+   (:connected  2)
+   (:constructed  3 )))
+
+(deftype (arg-flags "GtkArgFlags") ()
+  '(flags
+   (:readable  0)
+   (:writable  1)
+   (:construct  2)
+   (:construct-only  3)
+   (:child-arg  4)
+;   (:mask  #x1f)
+;   (:readwrite  GTK_ARG_READABLE | GTK_ARG_WRITABLE )
+  ))
+
+; enumerations from "gtkpacker.h"
+
+(deftype (packer-options "GtkPackerOptions") ()
+  '(flags
+   (:expand  0)
+   (:fill-x  1)
+   (:fill-y  2 )))
+
+(deftype (side-type "GtkSideType") ()
+  '(enum
+   :top
+   :bottom
+   :left
+   :right))
+
+(deftype (anchor-type "GtkAnchorType") ()
+  '(enum
+   :center
+   :north
+   :north-west
+   :north-east
+   :south
+   :south-west
+   :south-east
+   :west
+   :east
+;   (:n        GTK_ANCHOR_NORTH)
+;   (:nw       GTK_ANCHOR_NORTH_WEST)
+;   (:ne       GTK_ANCHOR_NORTH_EAST)
+;   (:s        GTK_ANCHOR_SOUTH)
+;   (:sw       GTK_ANCHOR_SOUTH_WEST)
+;   (:se       GTK_ANCHOR_SOUTH_EAST)
+;   (:w        GTK_ANCHOR_WEST)
+;   (:e        GTK_ANCHOR_EAST )
+   ))
+
+; enumerations from "gtkprivate.h"
+
+(deftype (private-flags "GtkPrivateFlags") ()
+  '(flags
+   (:user-style  0)
+   (:resize-pending  2)
+   (:resize-needed  3)
+   (:leave-pending  4)
+   (:has-shape-mask  5)
+   (:in-reparent  6)
+   (:direction-set  7)
+   (:direction-ltr  8)))
+
+; enumerations from "gtkprogressbar.h"
+
+(deftype (progress-bar-style "GtkProgressBarStyle") ()
+  '(enum
+   :continuous
+   :discrete))
+
+(deftype (progress-bar-orientation "GtkProgressBarOrientation") ()
+  '(enum
+   :left-to-right
+   :right-to-left
+   :bottom-to-top
+   :top-to-bottom))
+
+; enumerations from "gtkrc.h"
+
+(deftype (rc-flags "GtkRcFlags") ()
+  '(flags
+   (:fg  0)
+   (:bg  1)
+   (:text  2)
+   (:base  3 )))
+
+(deftype (rc-token-type "GtkRcTokenType") ()
+  '(enum
+   (:invalid  G_TOKEN_LAST)
+   :include
+   :normal
+   :active
+   :prelight
+   :selected
+   :insensitive
+   :fg
+   :bg
+   :text
+   :base
+   :xthickness
+   :ythickness
+   :font
+   :fontset
+   :font-name
+   :bg-pixmap
+   :pixmap-path
+   :style
+   :binding
+   :bind
+   :widget
+   :widget-class
+   :class
+   :lowest
+   :gtk
+   :application
+   :rc
+   :highest
+   :engine
+   :module-path
+;   :last
+   ))
+
+; enumerations from "gtkspinbutton.h"
+
+(deftype (spin-button-update-policy "GtkSpinButtonUpdatePolicy") ()
+  '(enum
+   :always
+   :if-valid))
+
+(deftype (spin-type "GtkSpinType") ()
+  '(enum
+   :step-forward
+   :step-backward
+   :page-forward
+   :page-backward
+   :home
+   :end
+   :user-defined))
+
+; enumerations from "gtktexttag.h"
+
+(deftype (wrap-mode "GtkWrapMode") ()
+  '(enum
+   :none
+   :char
+   :word))
+
+; enumerations from "gtktexttypes.h"
+
+(deftype text-tab-align
+;  (text-tab-align "GtkTextTabAlign")
+  ()
+  '(enum
+   :left
+   :right
+   :center
+   :numeric))
+
+; enumerations from "gtktextview.h"
+
+(deftype (text-view-movement-step "GtkTextViewMovementStep") ()
+  '(enum
+   :char
+   :positions
+   :word
+   :line
+   :paragraph
+   :paragraph-ends
+   :buffer-ends))
+
+(deftype (text-view-scroll-type "GtkTextViewScrollType") ()
+  '(enum
+   :to-top
+   :to-bottom
+   :page-down
+   :page-up))
+
+(deftype (text-view-delete-type "GtkTextViewDeleteType") ()
+  '(enum
+   :char
+   :half-word
+   :whole-word
+   :half-line
+   :whole-line
+   :half-paragraph
+   :whole-paragraph
+   :whitespace
+   :whitespace-leave-one))
+
+; enumerations from "gtktoolbar.h"
+
+(deftype (toolbar-child-type "GtkToolbarChildType") ()
+  '(enum
+   :space
+   :button
+   :togglebutton
+   :radiobutton
+   :widget))
+
+(deftype (toolbar-space-style "GtkToolbarSpaceStyle") ()
+  '(enum
+   :empty
+   :line))
+
+; enumerations from "gtktree.h"
+
+(deftype (tree-view-mode "GtkTreeViewMode") ()
+  '(enum
+   :line
+   :item))
+
+; enumerations from "gtkwidget.h"
+
+(deftype (widget-flags "GtkWidgetFlags") ()
+  '(flags
+   (:toplevel  4)
+   (:no-window  5)
+   (:realized  6)
+   (:mapped  7)
+   (:visible  8)
+   (:sensitive  9)
+   (:parent-sensitive  10)
+   (:can-focus  11)
+   (:has-focus  12)
+   (:can-default  13)
+   (:has-default  14)
+   (:has-grab  15)
+   (:rc-style  16)
+   (:composite-child  17)
+   (:no-reparent  18)
+   (:app-paintable  19)
+   (:receives-default  20)
+   (:double-buffered  21 )))
diff --git a/gtk/gtkglue.c b/gtk/gtkglue.c
new file mode 100644 (file)
index 0000000..51c4801
--- /dev/null
@@ -0,0 +1,741 @@
+/* Common Lisp bindings for GTK+ v2.0
+ * Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* $Id: gtkglue.c,v 1.1 2000/08/14 16:45:01 espen Exp $ */
+
+
+#include <gtk/gtk.h>
+
+#ifdef CMUCL
+#include "lisp.h"
+
+extern lispobj funcall1(lispobj function, lispobj arg0);
+extern lispobj funcall3(lispobj function, lispobj arg0,
+                       lispobj arg1, lispobj arg2);
+
+lispobj callback_trampoline;
+lispobj destroy_user_data;
+#endif
+
+
+void callback_marshal (GtkObject *object,
+                      gpointer data,
+                      guint n_args,
+                      GtkArg *args)
+{
+#ifdef CMUCL
+  funcall3 (callback_trampoline, alloc_number ((unsigned long)data),
+           alloc_number (n_args), alloc_sap (args));
+
+  /*  lispobj lisp_args[4];
+
+  lisp_args[0] = alloc_sap (object);
+  lisp_args[1] = alloc_number ((unsigned long)data);
+  lisp_args[2] = alloc_number (n_args);
+  lisp_args[3] = alloc_sap (args);
+
+  call_into_lisp (callback_trampoline, lisp_args, 4);*/
+#elif defined(CLISP)
+  callback_trampoline ((unsigned long)data, n_args, (unsigned int) args);
+#endif
+}
+
+
+void destroy_marshal (gpointer data)
+{ 
+#ifdef CMUCL
+  funcall1 (destroy_user_data, alloc_number ((unsigned long)data));
+#elif defined(CLISP)
+  destroy_user_data ((unsigned long)data);
+#endif
+}
+
+#ifndef CMUCL
+void*
+callback_marshal_address ()
+{
+  return (void*)callback_marshal;
+}
+
+void*
+destroy_marshal_address ()
+{
+  return (void*)destroy_marshal;
+}
+#endif
+
+
+/*
+ *
+ * Gtk helper functions
+ *
+ */
+
+void
+gtk_query_version (guint *major, guint *minor, guint *micro)
+{
+  *major = gtk_major_version;
+  *minor = gtk_minor_version;
+  *micro = gtk_micro_version;
+}
+
+
+/* Is this necessary? */
+
+GtkType
+gtk_object_type (GtkObject *obj)
+{
+  return GTK_OBJECT_TYPE (obj);
+}
+
+
+
+/* Widget */
+
+GdkWindow*
+gtk_widget_get_window (GtkWidget *widget)
+{
+  return widget->window;
+}
+
+GtkStateType
+gtk_widget_get_state (GtkWidget *widget)
+{
+  return widget->state;
+}
+
+gboolean
+gtk_widget_mapped_p (GtkWidget *widget)
+{
+  return GTK_WIDGET_MAPPED (widget);
+}
+
+void
+gtk_widget_allocation (GtkWidget *widget, int *width, int *height)
+{
+  *width = widget->allocation.width;
+  *height = widget->allocation.height;
+}
+
+
+/* Container */
+
+GtkWidget*
+gtk_container_get_focus_child (GtkContainer *container)
+{
+  return container->focus_child;
+}
+
+
+
+/* Menu item */
+
+GtkWidget*
+gtk_menu_item_get_submenu (GtkMenuItem* menu_item)
+{
+  return menu_item->submenu;
+}
+
+gint
+gtk_menu_item_get_show_toggle (GtkMenuItem* menu_item)
+{
+  return menu_item->show_toggle_indicator;
+}
+
+gint
+gtk_menu_item_get_show_submenu (GtkMenuItem* menu_item)
+{
+  return menu_item->show_submenu_indicator;
+}
+
+
+
+/* Check menu item */
+
+gboolean
+gtk_check_menu_item_get_active (GtkCheckMenuItem* check_menu_item)
+{
+  return check_menu_item->active;
+}
+
+gboolean
+gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem* check_menu_item)
+{
+  return check_menu_item->always_show_toggle;
+}
+
+
+/* Tree item */
+
+GtkWidget*
+gtk_tree_item_get_subtree (GtkTreeItem* tree_item)
+{
+  return GTK_TREE_ITEM_SUBTREE (tree_item);
+}
+
+
+/* Window */
+
+void
+gtk_window_wmclass (GtkWindow* window, gchar* name, gchar* class)
+{
+  name = window->wmclass_name;
+  class = window->wmclass_class;
+}
+
+
+/* Color selection dialog */
+
+GtkWidget*
+gtk_color_selection_dialog_get_colorsel (GtkColorSelectionDialog* dialog)
+{
+  return dialog->colorsel;
+}
+
+/*  GtkWidget* */
+/*  gtk_color_selection_dialog_get_main_vbox (GtkColorSelectionDialog* dialog) */
+/*  { */
+/*    return dialog->main_vbox; */
+/*  } */
+
+GtkWidget*
+gtk_color_selection_dialog_get_ok_button (GtkColorSelectionDialog* dialog)
+{
+  return dialog->ok_button;
+}
+
+/*  GtkWidget* */
+/*  gtk_color_selection_dialog_get_reset_button (GtkColorSelectionDialog* dialog) */
+/*  { */
+/*    return dialog->reset_button; */
+/*  } */
+
+GtkWidget*
+gtk_color_selection_dialog_get_cancel_button (GtkColorSelectionDialog* dialog)
+{
+  return dialog->cancel_button;
+}
+
+GtkWidget*
+gtk_color_selection_dialog_get_help_button (GtkColorSelectionDialog* dialog)
+{
+  return dialog->help_button;
+}
+
+
+/* Dialog */
+
+GtkWidget*
+gtk_dialog_get_action_area (GtkDialog *dialog)
+{
+  return dialog->action_area;
+}
+
+
+GtkWidget*
+gtk_dialog_get_vbox (GtkDialog *dialog)
+{
+  return dialog->vbox;
+}
+
+
+/* File selection */
+
+GtkWidget*
+gtk_file_selection_get_action_area (GtkFileSelection *filesel)
+{
+  return filesel->action_area;
+}
+
+GtkWidget*
+gtk_file_selection_get_ok_button (GtkFileSelection *filesel)
+{
+  return filesel->ok_button;
+}
+
+GtkWidget*
+gtk_file_selection_get_cancel_button (GtkFileSelection *filesel)
+{
+  return filesel->cancel_button;
+}
+
+
+/* Color selection */
+
+void
+gtk_color_selection_set_color_by_values (GtkColorSelection *colorsel,
+                                        gdouble red,
+                                        gdouble green,
+                                        gdouble blue,
+                                        gdouble opacity)
+{
+  gdouble color[4];
+
+  color[0] = red;
+  color[1] = green;
+  color[2] = blue;
+  color[3] = opacity;
+
+  gtk_color_selection_set_color (colorsel, color);
+}
+
+void
+gtk_color_selection_get_color_as_values (GtkColorSelection *colorsel,
+                                        gdouble *red,
+                                        gdouble *green,
+                                        gdouble *blue,
+                                        gdouble *opacity)
+{
+  gdouble color[4];
+
+  gtk_color_selection_get_color (colorsel, color);
+
+  *red = color[0];
+  *green = color[1];
+  *blue = color[2];
+  *opacity = color[3];
+}
+
+
+/* Combo */
+
+GtkWidget*
+gtk_combo_get_entry (GtkCombo *combo)
+{
+  return combo->entry;
+}
+
+gboolean
+gtk_combo_get_use_arrows (GtkCombo *combo)
+{
+  return combo->use_arrows;
+}
+
+gboolean
+gtk_combo_get_use_arrows_always (GtkCombo *combo)
+{
+  return combo->use_arrows_always;
+}
+
+gboolean
+gtk_combo_get_case_sensitive (GtkCombo *combo)
+{
+  return combo->case_sensitive;
+}
+
+
+/* CList */
+
+#ifdef CLIST
+GList*
+gtk_clist_selection (GtkCList *clist)
+{
+  return clist->selection;
+}
+
+gint
+gtk_clist_get_titles_visible (GtkCList *clist)
+{
+  return (clist->title_window && GTK_WIDGET_VISIBLE (clist->title_window));
+}
+
+gint
+gtk_clist_get_n_rows (GtkCList *clist)
+{
+  return clist->rows;
+}
+
+gint
+gtk_clist_get_focus_row (GtkCList *clist)
+{
+  return clist->focus_row;
+}
+
+gint
+gtk_clist_get_sort_column (GtkCList *clist)
+{
+  return clist->sort_column;
+}
+
+GtkJustification
+gtk_clist_column_justification (GtkCList *clist,
+                                gint column)
+{
+  return clist->column[column].justification;
+}
+
+gboolean
+gtk_clist_column_visible_p (GtkCList *clist,
+                          gint column)
+{
+  return clist->column[column].visible;
+}
+
+gboolean
+gtk_clist_column_resizeable_p (GtkCList *clist,
+                            gint column)
+{
+  return clist->column[column].resizeable;
+}
+
+gboolean
+gtk_clist_column_auto_resize_p (GtkCList *clist,
+                               gint column)
+{
+  return clist->column[column].auto_resize;
+}
+
+gint
+gtk_clist_column_width (GtkCList *clist,
+                       gint column)
+{
+  return clist->column[column].width;
+}
+
+gboolean
+gtk_clist_auto_sort_p (GtkCList *clist)
+{
+  return GTK_CLIST_AUTO_SORT (clist);
+}
+#endif
+
+/* CTree */
+
+#ifdef CTREE
+gboolean
+gtk_ctree_node_leaf_p (GtkCTreeNode* node)
+{
+  return GTK_CTREE_ROW (node)->is_leaf;
+}
+
+GtkCTreeNode*
+gtk_ctree_node_child (GtkCTreeNode* node)
+{
+  return GTK_CTREE_ROW (node)->children;
+}
+
+GtkCTreeNode*
+gtk_ctree_node_parent (GtkCTreeNode* node)
+{
+  return GTK_CTREE_ROW (node)->parent;
+}
+
+GtkCTreeNode*
+gtk_ctree_node_sibling (GtkCTreeNode* node)
+{
+  return GTK_CTREE_ROW (node)->sibling;
+}
+
+gint
+gtk_ctree_node_level (GtkCTreeNode* node)
+{
+  return GTK_CTREE_ROW (node)->level;
+}
+#endif
+
+/* Paned */
+
+GtkWidget*
+gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
+{
+  *resize = paned->child1_resize;
+  *shrink = paned->child1_shrink;
+  
+  return paned->child1;
+}
+
+
+GtkWidget*
+gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
+{
+  *resize = paned->child2_resize;
+  *shrink = paned->child2_shrink;
+  
+  return paned->child2;
+}
+
+gint
+gtk_paned_get_position (GtkPaned *paned)
+{
+  if (paned->position_set == TRUE) 
+    return paned->child1_size;
+  else
+    return -1;
+}
+
+
+/* Layout */
+
+gint
+gtk_layout_size (GtkLayout *layout, gint *width, gint *height)
+                
+{
+  *width =  layout->width;
+  *height = layout->height;
+}
+
+void
+gtk_layout_offset (GtkLayout *layout, gint *x, gint *y)
+{
+  *x = layout->xoffset;
+  *y = layout->yoffset;  
+}
+
+
+GdkWindow*
+gtk_layout_get_bin_window (GtkLayout *layout)
+{
+  return layout->bin_window;
+}
+
+
+/* List */
+
+GList*
+gtk_list_selection (GtkList *list)
+{
+  return list->selection;
+}
+
+
+/* Table */
+
+guint
+gtk_table_row_spacing (GtkTable *table,
+                      guint row)
+{
+  return table->rows[row].spacing;
+}
+
+guint
+gtk_table_column_spacing (GtkTable *table,
+                         guint col)
+{
+  return table->cols[col].spacing;
+}
+
+
+/* Toolbar */
+
+gint
+gtk_toolbar_num_children (GtkToolbar *toolbar)
+{
+  return toolbar->num_children;
+}
+
+
+/* Tree */
+
+GtkSelectionMode
+gtk_tree_get_selection_mode (GtkTree *tree)
+{
+  return tree->selection_mode;
+}
+
+GtkSelectionMode
+gtk_tree_get_view_mode (GtkTree *tree)
+{
+  return tree->view_mode;
+}
+
+GtkSelectionMode
+gtk_tree_get_view_lines (GtkTree *tree)
+{
+  return tree->view_mode;
+}
+
+GtkTree*
+gtk_tree_get_root_tree (GtkTree *tree)
+{
+  return GTK_TREE_ROOT_TREE (tree);
+}
+
+GList*
+gtk_tree_selection (GtkTree *tree)
+{
+  return GTK_TREE_SELECTION (tree);
+}
+
+
+/* Drawing area */
+
+void
+gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
+{
+  GtkWidget *widget;
+
+  widget = GTK_WIDGET (darea);
+  *width = widget->allocation.width;
+  *height = widget->allocation.height;
+}
+
+
+/* Progress */
+
+gchar*
+gtk_progress_get_format_string (GtkProgress *progress)
+{
+  return progress->format;
+}
+
+GtkAdjustment*
+gtk_progress_get_adjustment (GtkProgress *progress)
+{
+  return progress->adjustment;
+}
+
+
+/* Scrolled window */
+     
+GtkWidget*
+gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *window)
+{
+  return window->hscrollbar;
+}
+
+GtkWidget*
+gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *window)
+{
+  return window->vscrollbar;
+}
+
+
+
+/* Tooltips */
+
+guint
+gtk_tooltips_get_delay (GtkTooltips *tooltips)
+{
+  return tooltips->delay;
+}
+
+
+
+
+
+/* GtkStyle accessor functions */
+
+typedef enum {
+  GTK_COLOR_FG,
+  GTK_COLOR_BG,
+  GTK_COLOR_LIGHT,
+  GTK_COLOR_DARK,
+  GTK_COLOR_MID,
+  GTK_COLOR_TEXT,
+  GTK_COLOR_BASE,
+  GTK_COLOR_WHITE,
+  GTK_COLOR_BLACK
+} GtkColorType;
+
+GdkColor*
+gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
+                    GtkStateType state)
+{
+  switch (color_type)
+    {
+    case GTK_COLOR_WHITE:
+      return &style->white;
+    case GTK_COLOR_BLACK:
+      return &style->black;
+    case GTK_COLOR_FG:
+      return &style->fg[state];
+    case GTK_COLOR_BG:
+      return &style->bg[state];
+    case GTK_COLOR_LIGHT:
+      return &style->light[state];
+    case GTK_COLOR_DARK:
+      return &style->dark[state];
+    case GTK_COLOR_MID:
+      return &style->mid[state];
+    case GTK_COLOR_TEXT:
+      return &style->text[state];
+    case GTK_COLOR_BASE:
+      return &style->base[state];
+    }
+}
+
+
+GdkColor*
+gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
+                    GtkStateType state, GdkColor *color)
+{
+  switch (color_type)
+    {
+    case GTK_COLOR_WHITE:
+      style->white = *color; break;
+    case GTK_COLOR_BLACK:
+      style->black = *color; break;
+    case GTK_COLOR_FG:
+      style->fg[state] = *color; break;
+    case GTK_COLOR_BG:
+      style->bg[state]  = *color; break;
+    case GTK_COLOR_LIGHT:
+      style->light[state]  = *color; break;
+    case GTK_COLOR_DARK:
+      style->dark[state]  = *color; break;
+    case GTK_COLOR_MID:
+      style->mid[state]  = *color; break;
+    case GTK_COLOR_TEXT:
+      style->text[state]  = *color; break;
+    case GTK_COLOR_BASE:
+      style->base[state]  = *color; break;
+    }
+
+  return gtk_style_get_color (style, color_type, state);
+}
+
+
+GdkFont*
+gtk_style_get_font (GtkStyle *style)
+{
+  return style->font;
+}
+
+
+GdkFont*
+gtk_style_set_font (GtkStyle *style, GdkFont *font)
+{
+  return style->font = font;
+}
+
+
+GdkGC*
+gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
+{
+  switch (color_type)
+    {
+    case GTK_COLOR_WHITE:
+      return style->white_gc;
+    case GTK_COLOR_BLACK:
+      return style->black_gc;
+    case GTK_COLOR_FG:
+      return style->fg_gc[state];
+    case GTK_COLOR_BG:
+      return style->bg_gc[state];
+    case GTK_COLOR_LIGHT:
+      return style->light_gc[state];
+    case GTK_COLOR_DARK:
+      return style->dark_gc[state];
+    case GTK_COLOR_MID:
+      return style->mid_gc[state];
+    case GTK_COLOR_TEXT:
+      return style->text_gc[state];
+    case GTK_COLOR_BASE:
+      return style->base_gc[state];
+    }
+}
diff --git a/gtk/gtkobject.lisp b/gtk/gtkobject.lisp
new file mode 100644 (file)
index 0000000..5bef67b
--- /dev/null
@@ -0,0 +1,534 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gtkobject.lisp,v 1.1 2000/08/14 16:44:54 espen Exp $
+
+
+(in-package "GTK")
+
+;;;; Misc utils
+
+(defun name-to-string (name)
+  (substitute #\_ #\- (string-downcase (string name))))
+
+(defun string-to-name (name &optional (package "KEYWORD"))
+  (intern (substitute #\- #\_ (string-upcase name)) package))
+
+
+;;;; Argument stuff
+
+(deftype arg () 'pointer)
+
+(defconstant +arg-type-offset+ 0)
+(defconstant +arg-name-offset+ 4)
+(defconstant +arg-value-offset+ 8)
+(defconstant +arg-size+ 16)
+
+(define-foreign arg-new () arg
+  (type type-number))
+
+(define-foreign %arg-free () nil
+  (arg arg)
+  (free-contents boolean))
+
+(defun arg-free (arg free-contents &optional alien)
+  (cond
+   (alien (%arg-free arg free-contents))
+   (t
+    (unless (null-pointer-p arg)
+      (when free-contents
+       (funcall
+        (get-destroy-function (type-from-number (arg-type arg)))
+        arg +arg-value-offset+))
+      (deallocate-memory arg)))))
+
+(define-foreign %arg-reset () nil
+  (arg arg))
+
+(defun arg-name (arg)
+  (funcall (get-reader-function '(static string)) arg +arg-name-offset+))
+
+(defun (setf arg-name) (name arg)
+  (funcall (get-writer-function '(static string)) name arg +arg-name-offset+)
+  name)
+
+(defun arg-type (arg)
+  (system:sap-ref-32 arg +arg-type-offset+))
+
+(defun (setf arg-type) (type arg)
+  (setf (system:sap-ref-32 arg +arg-type-offset+) type))
+
+(defun arg-value (arg &optional (type (type-from-number (arg-type arg))))
+  (funcall (get-reader-function type) arg +arg-value-offset+))
+
+;; One should never call this function on an arg whose value is already set
+(defun (setf arg-value)
+    (value arg &optional (type (type-from-number (arg-type arg))))
+  (funcall (get-writer-funcation type) value arg +arg-value-offset+)
+  value)
+
+(defun (setf return-arg-value)
+    (value arg &optional (type (type-from-number (arg-type arg))))
+  ; this is probably causing a memory leak
+  (funcall (get-writer-function type) value (arg-value arg 'pointer) 0)
+  value)
+
+(defun arg-array-ref (arg0 index)
+  (system:sap+ arg0 (* index +arg-size+)))
+
+
+;;;; Superclass for the gtk class hierarchy
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass object (gobject)
+    ()
+;   ((flags
+;     :allocation :alien
+;     :accessor object-flags
+;     :type object-flags))
+    (:metaclass gobject-class)
+    (:alien-name "GtkObject")))
+
+
+(defmethod shared-initialize ((object object) names &rest initargs &key signals)
+  (declare (ignore initargs names))
+  (call-next-method)
+  (dolist (signal signals)
+    (apply #'signal-connect object signal)))
+
+
+(defmethod initialize-instance :after ((object object) &rest initargs &key)
+  (declare (ignore initargs))
+  (object-default-construct object)
+  (reference-instance object)
+  (object-sink object))
+
+
+(defmethod from-alien-initialzie-instance ((object object) &rest initargs)
+  (declare (ignore initargs))
+  (call-next-method)
+  (object-sink object))
+
+
+(define-foreign object-default-construct () nil
+  (object object))
+
+(define-foreign object-sink () nil
+  (object object))
+
+(define-foreign ("gtk_object_getv" object-get-arg) () nil
+  (object object)
+  (1 unsigned-int)
+  (arg arg))
+
+(define-foreign ("gtk_object_setv" object-set-arg) () nil
+  (object object)
+  (1 unsigned-int)
+  (arg arg))
+
+(defun object-arg (object name)
+  (with-gc-disabled
+    (let ((arg (arg-new 0)))
+      (setf (arg-name arg) name)
+      (object-get-arg object arg)
+      (let ((type (type-from-number (arg-type arg))))
+       (prog1
+           (arg-value arg type)
+         (arg-free arg t))))))
+
+(defun (setf object-arg) (value object name)
+  (with-gc-disabled
+    (let ((arg (arg-new 0)))
+      (setf (arg-name arg) name)
+      (object-get-arg object arg)
+      (let ((type (type-from-number (arg-type arg))))
+       (%arg-reset arg)
+       (setf (arg-value arg type) value)
+       (object-set-arg object arg)
+       (arg-free arg t))))
+  value)
+
+
+;;;; Callback and user data mechanism
+
+(declaim (fixnum *user-data-count*))
+
+(defvar *user-data* (make-hash-table))
+(defvar *user-data-count* 0)
+
+(defun register-user-data (object &optional destroy-function)
+  (check-type destroy-function (or null symbol function))
+;  (incf *user-data-count*)
+  (setq *user-data-count* (the fixnum (1+ *user-data-count*)))
+  (setf
+   (gethash *user-data-count* *user-data*)
+   (cons object destroy-function))
+  *user-data-count*)
+
+
+(defun find-user-data (id)
+  (check-type id fixnum)
+  (multiple-value-bind (user-data p) (gethash id *user-data*)
+    (values (car user-data) p)))
+
+
+(defun register-callback-function (function)
+  (check-type function (or null symbol function))
+  ; We treat callbacks just as ordinary user data
+  (register-user-data function))
+
+
+(defun callback-trampoline (callback-id nargs arg-array)
+  (declare (fixnum callback-id nargs))
+  (let* ((return-arg (unless (null-pointer-p arg-array)
+                      (arg-array-ref arg-array nargs)))
+        (return-type (if return-arg
+                         (type-from-number (arg-type return-arg))
+                       nil))
+        (args nil)
+        (callback-function (find-user-data callback-id)))
+    
+    (dotimes (n nargs)
+      (push (arg-value (arg-array-ref arg-array (- nargs n 1))) args))
+
+    (labels ((invoke-callback ()
+              (restart-case
+                  (unwind-protect
+                      (let ((return-value (apply callback-function args)))
+                        (when return-type
+                          (setf (return-arg-value return-arg) return-value))))
+               
+                (continue nil :report "Return from callback function"
+                 (when return-type
+                   (format
+                    *query-io*
+                    "Enter return value of type ~S: "
+                    return-type)
+                   (force-output *query-io*)
+                   (setf
+                    (return-arg-value return-arg)
+                    (eval (read *query-io*)))))
+                (re-invoke nil :report "Re-invoke callback function"
+                 (invoke-callback)))))
+      (invoke-callback))))
+
+
+(defun destroy-user-data (id)
+  (check-type id fixnum)
+  (let ((user-data (gethash id *user-data*)))
+    (when (cdr user-data)
+      (funcall (cdr user-data) (car user-data))))
+  (remhash id *user-data*))
+
+
+(defvar *callback-marshal* (system:foreign-symbol-address "callback_marshal"))
+(defvar *destroy-marshal* (system:foreign-symbol-address "destroy_marshal"))
+
+(defun after-gc-hook ()
+  (setf
+   (extern-alien "callback_trampoline" system-area-pointer)
+   (make-pointer (kernel:get-lisp-obj-address #'callback-trampoline))
+   (extern-alien "destroy_user_data" system-area-pointer)
+   (make-pointer (kernel:get-lisp-obj-address #'destroy-user-data))))
+
+(pushnew 'after-gc-hook ext:*after-gc-hooks*)
+(after-gc-hook)
+
+
+
+;;;; Main loop
+
+(declaim (inline events-pending-p main-iteration))
+
+(define-foreign ("gtk_events_pending" events-pending-p) () boolean)
+
+(define-foreign main-do-event () nil
+  (event gdk:event))
+
+(define-foreign main () nil)
+
+(define-foreign main-level () int)
+
+(define-foreign main-quit () nil)
+
+(define-foreign
+    ("gtk_main_iteration_do" main-iteration) (&optional (blocking t)) boolean
+  (blocking boolean))
+
+(defun main-iterate-all (&rest args)
+  (declare (ignore args))
+  (when (events-pending-p)
+    (main-iteration nil)
+    (main-iterate-all)))
+
+(system:add-fd-handler (gdk:event-poll-fd) :input #'main-iterate-all)
+(setq lisp::*periodic-polling-function* #'main-iterate-all)
+(setq lisp::*max-event-to-sec* 0)
+(setq lisp::*max-event-to-usec* 1000)
+
+
+
+;;;; Signals
+
+(define-foreign %signal-emit-stop () nil
+  (object object)
+  (signal-id unsigned-int))
+
+(define-foreign %signal-emit-stop-by-name (object signal) nil
+  (object object)
+  ((name-to-string signal) string))
+
+(defun signal-emit-stop (object signal)
+  (if (numberp signal)
+      (%signal-emit-stop object signal)
+    (%signal-emit-stop-by-name object signal)))
+
+(define-foreign %signal-connect-full
+    (object signal function after) unsigned-int
+  (object object)
+  ((name-to-string signal) string)
+  (0 unsigned-long)
+  (*callback-marshal* pointer)
+  ((register-callback-function function) unsigned-long)
+  (*destroy-marshal* pointer)
+  (nil boolean)
+  (after boolean))
+
+(defun signal-connect (object signal function
+                      &key after ((:object callback-object)))
+  (let* ((callback-object (if (eq callback-object t)
+                             object
+                           callback-object))
+        (callback-function
+         (if callback-object
+             #'(lambda (&rest args) (apply function callback-object args))
+           function)))
+    (%signal-connect-full object signal callback-function after)))
+
+(define-foreign signal-disconnect () nil
+  (object object)
+  (handler unsigned-int))
+
+(define-foreign signal-handler-block () nil
+  (object object)
+  (handler unsigned-int))
+
+(define-foreign signal-handler-unblock () nil
+  (object object)
+  (handler unsigned-int))
+
+
+;;;; Metaclass used for subclasses of object
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass object-class (gobject-class))
+
+  (defclass direct-object-slot-definition (direct-virtual-slot-definition))
+
+  (defclass effective-object-slot-definition
+    (effective-virtual-slot-definition)))
+
+
+(defmethod initialize-instance :after ((slotd direct-object-slot-definition)
+                                  &rest initargs &key)
+  (declare (ignore initargs))
+  (unless (slot-boundp slotd 'location)
+    (with-slots (pcl::name location pcl::class) slotd
+      (setf
+       location 
+       (format nil "~A::~A"
+        (alien-type-name (class-name pcl::class))
+       (name-to-string pcl::name))))))
+
+
+(defmethod direct-slot-definition-class ((class object-class) initargs)
+  (case (getf initargs :allocation)
+    (:arg (find-class 'direct-object-slot-definition))
+    (t (call-next-method))))
+
+
+(defmethod effective-slot-definition-class ((class object-class) initargs)
+  (case (getf initargs :allocation)
+    (:arg (find-class 'effective-object-slot-definition))
+    (t (call-next-method))))
+  
+
+(defmethod compute-virtual-slot-location
+    ((class object-class) (slotd effective-object-slot-definition)
+     direct-slotds)
+  (with-slots (type) slotd
+    (let ((location (slot-definition-location (first direct-slotds)))
+         (type-number (find-type-number type))
+         (reader (get-reader-function type))
+         (writer (get-writer-function type))
+         (destroy (get-destroy-function type)))
+      (list
+       #'(lambda (object)
+          (with-gc-disabled
+            (let ((arg (arg-new type-number)))
+              (setf (arg-name arg) location)
+              (object-get-arg object arg)
+              (prog1
+                  (funcall reader arg +arg-value-offset+)
+                (arg-free arg t t)))))
+       #'(lambda (value object)
+          (with-gc-disabled
+            (let ((arg (arg-new type-number)))
+              (setf (arg-name arg) location)
+              (funcall writer value arg +arg-value-offset+)
+              (object-set-arg object arg)
+              (funcall destroy arg +arg-value-offset+)
+              (arg-free arg nil)
+              value)))))))
+
+
+(defmethod validate-superclass ((class object-class)
+                               (super pcl::standard-class))
+  (subtypep (class-name super) 'object))
+  
+
+;;;; Metaclasses used for widgets and containers
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass widget-class (object-class))
+
+  (defclass container-class (widget-class)
+    (child-class)))
+
+
+(defvar *child-to-container-class-mappings* (make-hash-table))
+
+(defmethod shared-initialize ((class container-class) names
+                             &rest initargs &key name child-class)
+  (declare (ignore initargs))
+  (call-next-method)
+  (with-slots ((child-class-slot child-class)) class
+    (setf
+     child-class-slot
+     (or
+      (first child-class)
+      (intern (format nil "~A-CHILD" (or name (class-name class)))))
+     (gethash child-class-slot *child-to-container-class-mappings*)
+     class)))
+
+
+(defmethod validate-superclass ((class widget-class)
+                               (super pcl::standard-class))
+  (subtypep (class-name super) 'widget))
+
+(defmethod validate-superclass ((class container-class)
+                               (super pcl::standard-class))
+  (subtypep (class-name super) 'container))
+
+
+
+;;;; Metaclass for child classes
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass child-class (virtual-class))
+
+  (defclass direct-child-slot-definition (direct-virtual-slot-definition))
+
+  (defclass effective-child-slot-definition
+    (effective-virtual-slot-definition)))
+
+
+(defmethod initialize-instance  ((slotd direct-child-slot-definition)
+                                &rest initargs &key)
+  (declare (ignore initargs))
+  (call-next-method)
+  (unless (slot-boundp slotd 'location)
+    (with-slots (pcl::name location pcl::class) slotd
+      (setf
+       location 
+       (format nil "~A::~A"
+        (alien-type-name
+        (gethash (class-name pcl::class) *child-to-container-class-mappings*))
+       (name-to-string pcl::name))))))
+
+
+(defmethod direct-slot-definition-class ((class child-class) initargs)
+  (case (getf initargs :allocation)
+    (:arg (find-class 'direct-child-slot-definition))
+    (t (call-next-method))))
+
+
+(defmethod effective-slot-definition-class ((class child-class) initargs)
+  (case (getf initargs :allocation)
+    (:arg (find-class 'effective-child-slot-definition))
+    (t (call-next-method))))
+  
+
+(defmethod compute-virtual-slot-location
+    ((class child-class) (slotd effective-child-slot-definition) direct-slotds)
+  (with-slots (type) slotd
+    (let ((location (slot-definition-location (first direct-slotds)))
+         (type-number (find-type-number type))
+         (reader (get-reader-function type))
+         (writer (get-writer-function type))
+         (destroy (get-destroy-function type)))
+      (list
+       #'(lambda (object)
+          (with-slots (parent child) object       
+            (with-gc-disabled
+              (let ((arg (arg-new type-number)))
+                (setf (arg-name arg) location)
+                (container-child-get-arg parent child arg)
+                (prog1
+                    (funcall reader arg +arg-value-offset+)
+                  (arg-free arg t t))))))
+       #'(lambda (value object)
+          (with-slots (parent child) object       
+            (with-gc-disabled
+              (let ((arg (arg-new type-number)))
+                (setf (arg-name arg) location)
+                (funcall writer value arg +arg-value-offset+)
+                (container-child-set-arg parent child arg)
+                (funcall destroy arg +arg-value-offset+)
+                (arg-free arg nil)
+                value))))))))
+
+
+(defmethod pcl::add-reader-method ((class child-class) generic-function slot-name)
+  (add-method
+   generic-function
+   (make-instance 'standard-method
+                 :specializers (list (find-class 'widget))
+                 :lambda-list '(widget)
+                 :function #'(lambda (args next-methods)
+                               (declare (ignore next-methods))
+                               (child-slot-value (first args) slot-name)))))
+
+(defmethod pcl::add-writer-method
+    ((class child-class) generic-function slot-name)
+  (add-method
+   generic-function
+   (make-instance 'standard-method
+                 :specializers (list (find-class t) (find-class 'widget))
+                 :lambda-list '(value widget)
+                 :function #'(lambda (args next-methods)
+                               (declare (ignore next-methods))
+                               (destructuring-bind (value widget) args
+                                 (setf
+                                  (child-slot-value widget slot-name)
+                                  value))))))
+
+
+(defmethod validate-superclass ((class child-class) (super pcl::standard-class))
+  (subtypep (class-name super) 'container-child))
+
+
diff --git a/gtk/gtktypes.lisp b/gtk/gtktypes.lisp
new file mode 100644 (file)
index 0000000..926e29a
--- /dev/null
@@ -0,0 +1,1066 @@
+;; Common Lisp bindings for GTK+ v2.0.x
+;; Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gtktypes.lisp,v 1.1 2000/08/14 16:44:59 espen Exp $
+
+
+
+(in-package "GTK")
+
+
+; (deftype color-type
+;   (enum
+;    :foreground
+;    :background
+;    :light
+;    :dark
+;    :mid
+;    :text
+;    :base
+;    :white
+;    :black))
+
+
+(defclass  style (gobject)
+  ()
+  (:metaclass gobject-class)
+  (:alien-name "GtkStyle"))
+
+; (define-boxed accel-group :c-name "GtkAccelGroup")
+
+
+(deftype (accel-group "GtkAccelGroup") () 'pointer)
+
+(deftype accel-entry () 'pointer)
+(deftype radio-button-group () 'pointer)
+(deftype radio-menu-item-group () 'pointer)
+; (define-boxed ctree-node :c-name "GtkCTreeNode")
+
+
+(defclass data (object)
+  ()
+  (:metaclass object-class)
+  (:alien-name "GtkData"))
+
+
+(defclass adjustment (data)
+  ((lower
+    :allocation :alien
+    :accessor adjustment-lower
+    :initarg :lower
+    :type single-float)
+   (upper
+    :allocation :alien
+    :accessor adjustment-upper
+    :initarg :upper
+    :type single-float)
+   (value
+    :allocation :alien
+    :accessor adjustment-value
+    :initarg :value
+    :type single-float)
+   (step-increment
+    :allocation :alien
+    :accessor adjustment-step-increment
+    :initarg :step-increment
+    :type single-float)
+   (page-increment
+    :allocation :alien
+    :accessor adjustment-page-increment
+    :initarg :page-increment
+    :type single-float)
+   (page-size
+    :allocation :alien
+    :accessor adjustment-page-size
+    :initarg :page-size
+    :type single-float))
+  (:metaclass object-class)
+  (:alien-name "GtkAdjustment"))
+  
+
+; (define-class tooltips data
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((delay                  :type unsigned-int)))
+
+
+;; Forward declaration, the real definition is in gtkwidget.lisp
+(defclass widget (object)
+  ()
+  (:metaclass object-class)
+  (:alien-name "GtkWidget"))
+
+
+(defclass misc (widget)
+  ((xalign
+    :allocation :arg
+    :accessor misc-xalign
+    :initarg :xalign
+    :type single-float)
+   (yalign
+    :allocation :arg
+    :accessor misc-yalign
+    :initarg :yalign
+    :type single-float)
+   (xpad
+    :allocation :arg
+    :accessor misc-xpad
+    :initarg :xpad
+    :type int)
+   (ypad
+    :allocation :arg
+    :accessor misc-ypad
+    :initarg :ypad
+    :type int))
+  (:metaclass widget-class)
+  (:alien-name "GtkMisc"))
+
+
+(defclass label (misc)
+  ((label
+    :allocation :arg
+    :accessor label-label
+    :initarg :label
+    :type string)
+   (pattern
+    :allocation :arg
+    :accessor label-pattern
+    :initarg :pattern
+    :type string)
+   (justify
+    :allocation :arg
+    :accessor label-justify
+    :initarg :justify
+    :type justification)
+   (wrap
+    :allocation :arg
+    :accessor label-line-wrap-p
+    :initarg :wrap
+    :type boolean))
+  (:metaclass widget-class)
+  (:alien-name "GtkLabel"))
+
+
+(defclass accel-label (label)
+  ((widget
+    :allocation :arg
+    :location "GtkAccelLabel::accel_widget"
+    :accessor accel-widget
+    :initarg :widget
+    :type widget)
+   (width
+    :allocation :virtual
+    :location "gtk_accel_label_get_accel_width"
+    :reader width
+    :type unsigned-int))
+  (:metaclass widget-class)
+  (:alien-name "GtkAccelLabel"))
+
+
+(defclass tips-query (label)
+  ((emit-always
+    :allocation :arg
+    :accessor tips-query-emit-always-p
+    :initarg :emit-always
+    :type boolean)
+   (caller
+    :allocation :arg
+    :accessor tips-query-caller
+    :initarg :caller
+    :type widget)
+   (label-inactive
+    :allocation :arg
+    :accessor tips-query-label-inactive
+    :initarg :label-inactive
+    :type string)
+   (label-no-tip
+    :allocation :arg
+    :accessor tips-query-label-no-tip
+    :initarg :label-no-tip
+    :type string))
+  (:metaclass widget-class)
+  (:alien-name "GtkTipsQuery"))
+
+
+(defclass arrow (misc)
+  ((arrow-type
+    :allocation :arg
+    :accessor arrow-arrow-type
+    :initarg :arrow-type
+    :type arrow-type)
+   (shadow-type
+    :allocation :arg
+    :accessor arrow-shadow-type
+    :initarg :shadow-type
+    :type shadow-type))
+  (:metaclass widget-class)
+  (:alien-name "GtkArrow"))
+
+
+(defclass image (misc)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkImage"))
+
+
+(defclass pixmap (misc)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkPixmap"))
+
+
+;; Forward declaration, the real definition is in gtkcontainer.lisp
+(defclass container (widget)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkContainer"))
+
+(defclass container-child ()
+  ((parent
+    :initarg :parent
+    :type container)
+   (child
+    :initarg :child
+    :type widget)))
+
+
+(defclass bin (container)
+  ((child
+    :allocation :virtual
+    :location bin-child
+    :initarg :child
+    :type widget))
+  (:metaclass container-class)
+  (:alien-name "GtkBin"))
+
+(defclass bin-child (container-child))
+
+
+(defclass alignment (bin)
+  ((xalign
+    :allocation :arg
+    :accessor alignment-xalign
+    :initarg :xalign
+    :type single-float)
+   (yalign
+    :allocation :arg
+    :accessor alignment-yalign
+    :initarg :yalign
+    :type single-float)
+   (xscale
+    :allocation :arg
+    :accessor alignment-xscale
+    :initarg :xscale
+    :type single-float)
+   (yscale
+    :allocation :arg
+    :accessor alignment-yscale
+    :initarg :yscale
+    :type single-float))
+  (:metaclass container-class)
+  (:alien-name "GtkAlignment"))
+
+(defclass alignment-child (bin-child))
+
+
+(defclass frame (bin)
+  ((label
+    :allocation :arg
+    :accessor frame-label
+    :initarg :label
+    :type string)
+   (label-xalign
+    :allocation :arg
+    :accessor frame-label-xalign
+    :initarg :label-xalign
+    :type single-float)
+   (label-yalign
+    :allocation :arg
+    :accessor frame-label-yalign
+    :initarg :label-yalign
+    :type single-float)
+   (shadow-type
+    :allocation :arg
+    :location "GtkFrame::shadow"
+    :accessor frame-shadow-type
+    :initarg :shadow-type
+    :type shadow-type))
+  (:metaclass container-class)
+  (:alien-name "GtkFrame"))
+
+(defclass frame-child (bin-child))
+  
+
+; (defclass aspect-frame (frame)
+;   ((xalign
+;     :allocation :arg
+;     :accessor aspect-frame-xalign
+;     :initarg :xalign
+;     :type single-float)
+;    (yalign
+;     :allocation :arg
+;     :accessor aspect-frame-yalign
+;     :initarg :yalign
+;     :type single-float)
+;    (ratio
+;     :allocation :arg
+;     :accessor aspect-frame-ratio
+;     :initarg :ratio
+;     :type single-float)
+;    (obey-child
+;     :allocation :arg
+;     :accessor aspect-frame-obey-child-p
+;     :initarg :obey-child
+;     :type boolean))
+;   (:metaclass container-class)
+;   (:alien-name "GtkAspectFrame"))
+
+; (defclass aspect-frame-child (aspect-child))
+
+
+(defclass button (bin)
+  ((label
+    :allocation :arg
+    :accessor button-label
+    :initarg :label
+    :type string)
+   (relief
+    :allocation :arg
+    :accessor button-relief
+    :initarg :relief
+    :type relief-style))
+  (:metaclass container-class)
+  (:alien-name "GtkButton"))
+
+(defclass button-child (bin-child))
+  
+
+(defclass toggle-button (button)
+  ((active
+    :allocation :arg
+    :accessor toggle-button-active-p
+    :initarg :active
+    :type boolean)
+   (draw-indicator
+    :allocation :arg
+    :accessor toggle-button-draw-indicator-p
+    :initarg :draw-indicator
+    :type boolean))
+  (:metaclass container-class)
+  (:alien-name "GtkToggleButton"))
+
+(defclass toggle-button-child (button-child))
+
+
+(defclass check-button (toggle-button)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkCheckButton"))
+
+(defclass check-button-child (toggle-button-child))
+
+
+(defclass radio-button (check-button)
+  ((group
+    :allocation :arg
+    :initarg :group
+;    :access :write-only
+    :type pointer)) ;radio-button-group))
+  (:metaclass container-class)
+  (:alien-name "GtkRadioButton"))
+
+(defclass radio-button-child (check-button-child))
+  
+
+(defclass option-menu (button)
+  ((menu
+    :allocation :virtual
+    :location ("gtk_option_menu_get_menu" (setf option-menu-menu))
+    :reader option-menu-menu
+    :initarg :menu
+    :type widget)
+   (history
+    :allocation :virtual
+    :location (nil "gtk_option_menu_set_history")
+    :writer (setf option-menu-history)
+    :initarg :history
+    :type unsigned-int))
+  (:metaclass container-class)
+  (:alien-name "GtkOptionMenu"))
+
+(defclass option-menu-child (button-child))
+
+
+(defclass item (bin)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkOptionMenu"))
+
+(defclass item-child (bin-child))
+
+
+(defclass menu-item (item)
+  ()
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((label                  :write-only t :access-method :lisp :type string)
+;    (submenu                :write-method :lisp :type menu-item)
+;    (placement              :write-only t :type submenu-placement)
+;    (toggle-indicator       :c-reader "gtk_menu_item_get_show_toggle"
+;                         :write-method :lisp :type boolean)
+;    (submenu-indicator      :c-reader "gtk_menu_item_get_show_submenu"
+;                         :write-method :lisp :type boolean)))
+  (:metaclass container-class)
+  (:alien-name "GtkMenuItem"))
+  
+(defclass menu-item-child (item-child))
+
+  
+(defclass check-menu-item (menu-item)
+  ()
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((active :type boolean)
+;    (toggle-indicator       :c-writer "gtk_check_menu_item_set_show_toggle"
+;                         :c-reader "gtk_check_menu_item_get_show_toggle"
+;                         :type boolean)))
+  (:metaclass container-class)
+  (:alien-name "GtkCheckMenuItem"))
+
+(defclass check-menu-item-child (menu-item-child))
+
+(defclass radio-menu-item (check-menu-item)
+  ()
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((group                  :c-reader "gtk_radio_menu_item_group"
+;                         :type radio-menu-item-group)))
+  (:metaclass container-class)
+  (:alien-name "GtkRadioMenuItem"))
+
+(defclass radio-menu-item-child (check-menu-item-child))
+
+
+(defclass tearoff-menu-item (menu-item)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkTearoffMenuItem"))
+
+(defclass tearoff-menu-item-child (menu-item-child))
+
+(defclass list-item (item)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkListItem"))
+
+(defclass list-item-child (item-child))
+  
+
+(defclass tree-item (item)
+  ()
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((subtree                :write-method :lisp :type tree-item)))
+  (:metaclass container-class)
+  (:alien-name "GtkTreeItem"))
+
+(defclass tree-item-child (item-child))
+
+
+(defclass window (bin)
+  ((type
+    :allocation :arg
+    :accessor window-type
+    :initarg :type
+    :type window-type)
+   (title
+    :allocation :arg
+    :accessor window-title
+    :initarg :title
+    :type string)
+   (auto-shrink
+    :allocation :arg
+    :accessor window-auto-shrink-p
+    :initarg :auto-shrink
+    :type boolean)
+   (allow-shrink
+    :allocation :arg
+    :accessor window-allow-shrink-p
+    :initarg :allow-shrink
+    :type boolean)
+   (allow-grow
+    :allocation :arg
+    :accessor window-allow-grow-p
+    :initarg :allow-grow
+    :type boolean)
+   (modal
+    :allocation :arg
+    :accessor window-modal-p
+    :initarg :modal
+    :type boolean)
+   (position
+    :allocation :arg
+    :location "GtkWindow::window_position"
+    :accessor window-position
+    :initarg :position
+    :type window-position)
+   (default-width
+    :allocation :arg
+    :accessor window-default-width
+    :initarg :default-width
+    :type int)
+   (default-height
+    :allocation :arg
+    :accessor window-default-height
+    :initarg :default-height
+    :type int))
+  (:metaclass container-class)
+  (:alien-name "GtkWindow"))
+
+(defclass window-child (bin-child))
+
+
+; (defclass color-selection-dialog window
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((colorsel               :read-only t :type widget)
+;    (main-vbox              :read-only t :type widget)
+;    (ok-button              :read-only t :type widget)
+;    (reset-button           :read-only t :type widget)
+;    (cancel-button          :read-only t :type widget)
+;    (help-button            :read-only t :type widget)))
+
+; (defclass dialog window
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((action-area            :read-only t :type widget)
+;    (vbox                   :read-only t :type widget)))
+
+; (defclass input-dialog dialog)
+
+; (defclass file-selection window
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((filename               :type string)
+;    (action-area            :read-only t :type widget)
+;    (ok-button              :read-only t :type widget)
+;    (cancel-button          :read-only t :type widget)))
+
+; (defclass plug window)
+
+; (defclass event-box bin)
+
+; (defclass handle-box bin
+;   :slots
+;   ((shadow-type            :read-method :arg :arg-name "shadow"
+;                         :type shadow-type)
+;    (handle-position        :read-method :arg :type position-type)
+;    (snap-edge              :read-method :arg :type position-type)))
+
+(defclass scrolled-window (bin)
+  ((hadjustment
+    :allocation :arg
+    :accessor scrolled-window-hadjustment
+    :initarg :hadjustment
+    :type adjustment)   
+   (vadjustment
+    :allocation :arg
+    :accessor scrolled-window-vadjustment
+    :initarg :vadjustment
+    :type adjustment)
+   (hscrollbar-policy
+    :allocation :arg
+    :accessor scrolled-window-hscrollbar-policy
+    :initarg :hscrollbar-policy
+    :type policy-type)
+   (vscrollbar-policy
+    :allocation :arg
+    :accessor scrolled-window-vscrollbar-policy
+    :initarg :vscrollbar-policy
+    :type policy-type)
+   (placement
+    :allocation :arg
+    :location "GtkScrolledWindow::window_placement"
+    :accessor scrolled-window-placement
+    :initarg :placement
+    :type corner-type)
+   (shadow-type
+    :allocation :arg
+    :location "GtkScrolledWindow::shadow"
+    :accessor scrolled-window-shadow-type
+    :initarg :shadow-type
+    :type shadow-type)
+   (hscrollbar
+    :allocation :virtual
+    :location "gtk_scrolled_window_get_hscrollbar"
+    :accessor scrolled-window-hscrollbar
+    :type widget)
+   (vscrollbar
+    :allocation :virtual
+    :location "gtk_scrolled_window_get_vscrollbar"
+    :accessor scrolled-window-vscrollbar
+    :type widget))
+  (:metaclass container-class)
+  (:alien-name "GtkScrolledWindow"))
+
+(defclass scrolled-window-child (bin-child))
+
+
+
+; (defclass viewport bin
+;   :slots
+;   ((hadjustment            :read-method :arg :type adjustment)
+;    (vadjustment            :read-method :arg :type adjustment)
+;    (shadow-type            :read-method :arg :type shadow-type)))
+
+(defclass box (container)
+  ((spacing
+    :allocation :arg
+    :accessor box-spacing
+    :initarg :spacing
+    :type int)
+   (homogeneous
+    :allocation :arg
+    :accessor box-homogeneous-p
+    :initarg :homogeneous
+    :type boolean))
+  (:metaclass container-class)
+  (:alien-name "GtkBox"))
+
+(defclass box-child (container-child)
+  ((expand
+    :allocation :arg
+    :accessor box-child-expand-p
+    :initarg :expand
+    :type boolean)
+   (fill
+    :allocation :arg
+    :accessor box-child-fill-p
+    :initarg :fill
+    :type boolean)
+   (padding
+    :allocation :arg
+    :accessor box-child-padding
+    :initarg :padding
+    :type unsigned-long)
+   (pack-type
+    :allocation :arg
+    :accessor box-child-pack-type
+    :initarg :pack-type
+    :type pack-type)
+   (position
+    :allocation :arg
+    :accessor box-child-position
+    :initarg :position
+    :type long))
+  (:metaclass child-class))
+   
+
+(defclass button-box (box)
+  ((spacing
+    :allocation :virtual
+    :location ("gtk_button_box_get_spacing" "gtk_button_box_set_spacing")
+    :accessor button-box-spacing
+    :type int)
+   (layout
+    :allocation :virtual
+    :location ("gtk_button_box_get_layout" "gtk_button_box_set_layout")
+    :accessor button-box-layout
+    :type button-box-style))
+  (:metaclass container-class)
+  (:alien-name "GtkButtonBox"))
+
+(defclass button-box-child (box-child)
+  ()
+  (:metaclass child-class))
+
+(defclass hbutton-box (button-box)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkHButtonBox"))
+
+(defclass hbutton-box-child (button-box-child)
+  ()
+  (:metaclass child-class))
+
+(defclass vbutton-box-child (button-box-child)
+  ()
+  (:metaclass child-class))
+
+(defclass vbox (box)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkVBox"))
+
+(defclass vbox-child (box-child)
+  ()
+  (:metaclass child-class))
+
+
+
+; (defclass color-selection vbox
+;   :slots
+;   ((policy                 :c-writer "gtk_color_selection_set_update_policy"
+;                         :read-method :arg :type update-type)
+;    (use-opacity            :c-writer "gtk_color_selection_set_opacity"
+;                         :read-method :arg :type boolean)
+;    ;; slots not accessible through the arg mechanism
+;    (color                  :access-method :lisp)))
+
+; (defclass gamma-curve vbox)
+
+(defclass hbox (box)
+  ()
+  (:metaclass container-class)
+  (:alien-name "GtkHBox"))
+
+(defclass hbox-child (box-child)
+  ()
+  (:metaclass child-class))
+
+
+
+; (defclass statusbar hbox)
+
+; (defclass clist container
+;   :c-name "GtkCList"
+;   :c-prefix "gtk_clist_"
+;   :slots
+;   ((n-columns              :read-only t :initarg t :access-method :arg
+;                         :type unsigned-int)
+;    (shadow-type            :read-method :arg :type shadow-type)
+;    (selection-mode         :read-method :arg :type selection-mode)
+;    (row-height             :read-method :arg :type unsigned-int)
+;    (reorderable            :read-method :arg :type boolean)
+;    (titles-visible         :write-method :lisp :type boolean)
+;    (titles-active          :access-method :arg :type boolean)
+;    (use-drag-icons         :read-method :arg :type boolean)
+;    (sort-type              :read-method :arg :type sort-type)
+;    ;; slots not accessible through the arg mechanism
+;    (hadjustment            :type adjustment)
+;    (vadjustment            :type adjustment)
+;    (sort-column            :type int)
+;    (focus-row              :reader %clist-focus-row :read-only t :type int)
+;    (n-rows                 :read-only t :type int)))
+
+; (defclass ctree clist
+;   :c-name "GtkCTree"
+;   :c-prefix "gtk_ctree_"
+;   :slots
+;   ((n-columns              :read-only t :initarg t :access-method :arg
+;                         :type unsigned-int)
+;    (tree-column            :read-only t :initarg t :access-method :arg
+;                         :type unsigned-int)
+;    (indent                 :read-method :arg :type unsigned-int)
+;    (spacing                :read-method :arg :type unsigned-int)
+;    (show-stub              :read-method :arg :type boolean)
+;    (line-style             :read-method :arg :type ctree-line-style)
+;    (expander-style         :read-method :arg :type ctree-expander-style)))
+
+; (defclass fixed container)
+
+; (defclass notebook container
+;   :slots
+;   ((show-tabs              :read-method :arg :type boolean)
+;    (show-border            :read-method :arg :type boolean)
+;    (scrollable             :read-method :arg :type boolean)
+;    (enable-popup           :access-method :arg :type boolean)
+;    (homogeneous            :c-writer "gtk_notebook_set_homogeneous_tabs"
+;                         :read-method :arg :type boolean)
+;    (current-page           :c-writer "gtk_notebook_set_page" :type int)
+;    (tab-pos                :read-method :arg :type position-type)
+;    (tab-border             :read-method :arg :type unsigned-int)
+;    (tab-hborder            :read-method :arg :type unsigned-int)
+;    (tab-vborder            :read-method :arg :type unsigned-int))
+;   :child-slots
+;   ((tab-label              :access-method :arg :type string)
+;    (menu-label             :access-method :arg :type string)
+;    (tab-fill               :access-method :arg :type boolean)
+;    (tab-pack               :access-method :arg :type boolean)
+;    (position               :access-method :arg :type int)))
+
+; (defclass font-selection notebook)
+
+; (defclass paned container
+;   :constructor nil
+;   :slots
+;   ((handle-size            :read-method :arg :type unsigned-int)
+;    (gutter-size            :read-method :arg :type unsigned-int)
+;    ;; slots not accessible through the arg mechanism
+;    (position               :write-only t :type int)))
+
+; (defclass hpaned paned)
+
+; (defclass vpaned paned)
+
+; (defclass layout container
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((hadjustment            :type adjustment)
+;    (vadjustment            :type adjustment)
+;    (bin-window             :read-only t :type gdk:window)))
+
+; (defclass list-widget container
+;   :c-name "GtkList"
+;   :slots
+;   ((selection-mode         :read-method :arg :accessor list-selection-mode
+;                         :c-writer "gtk_list_set_selection_mode"
+;                         :type selection-mode)))
+
+; (defclass menu-shell container :constructor nil)
+
+; (defclass menu-bar menu-shell
+;   :slots
+;   ((shadow-type            :read-method :arg :arg-name "shadow"
+;                         :type shadow-type)))
+
+; (defclass menu menu-shell
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((accel-group            :type accel-group)
+;    (tearoff-state          :write-only t :type boolean)
+;    (title                  :write-only t :type string)))
+
+; (defclass packer container
+;   :slots
+;   ((spacing                :read-method :arg :type unsigned-int)
+;    (default-border-width   :read-method :arg :type unsigned-int)
+;    (default-pad-x          :access-method :arg :type unsigned-int)
+;    (default-pad-y          :access-method :arg :type unsigned-int)
+;    (default-ipad-x         :access-method :arg :type unsigned-int)
+;    (default-ipad-y         :access-method :arg :type unsigned-int))
+;   :child-slots
+;   ((side                   :access-method :arg :type side-type)
+;    (anchor                 :access-method :arg :type anchor-type)
+;    (expand                 :access-method :arg :type boolean)
+;    (fill-x                 :access-method :arg :type boolean)
+;    (fill-y                 :access-method :arg :type boolean)
+;    (use-default            :access-method :arg :type boolean)
+;    (border-width           :access-method :arg :type unsigned-int)
+;    (pad-x                  :access-method :arg :type unsigned-int)
+;    (pad-y                  :access-method :arg :type unsigned-int)
+;    (ipad-x                 :access-method :arg :type unsigned-int)
+;    (ipad-y                 :access-method :arg :type unsigned-int)
+;    (position               :access-method :arg :type long)))
+
+; (defclass socket container)
+
+; (defclass table container
+;   :slots
+;   ((rows                   :access-method :arg :arg-name "n_rows"
+;                         :type unsigned-int)
+;    (columns                :access-method :arg :arg-name "n_columns"
+;                         :type unsigned-int)
+;    (row-spacing            :c-writer "gtk_table_set_row_spacings"
+;                         :accessor table-row-spacings
+;                         :read-method :arg :type unsigned-int)
+;    (column-spacing         :c-writer "gtk_table_set_col_spacings"
+;                         :accessor table-column-spacings
+;                         :read-method :arg  :type unsigned-int)
+;    (homogeneous            :read-method :arg :type boolean))
+;   :child-slots
+;   ((left-attach            :access-method :arg :type unsigned-int)
+;    (right-attach           :access-method :arg :type unsigned-int)
+;    (top-attach             :access-method :arg :type unsigned-int)
+;    (bottom-attach          :access-method :arg :type unsigned-int)
+;    (x-options              :access-method :arg :type attach-options)
+;    (y-options              :access-method :arg :type attach-options)
+;    (x-padding              :access-method :arg :type unsigned-int)
+;    (y-padding              :access-method :arg :type unsigned-int)
+;    ;; Slots added for convenience sake
+;    (x-expand               :access-method :lisp :type boolean)
+;    (y-expand               :access-method :lisp :type boolean)
+;    (x-shrink               :access-method :lisp :type boolean)
+;    (y-shrink               :access-method :lisp :type boolean)
+;    (x-fill                 :access-method :lisp :type boolean)
+;    (y-fill                 :access-method :lisp :type boolean)))
+
+; (defclass toolbar container
+;   :slots
+;   ((orientation            :read-method :arg :type orientation)
+;    (toolbar-style          :accessor toolbar-style
+;                            :c-writer "gtk_toolbar_set_style"
+;                         :read-method :arg :type toolbar-style)
+;    (space-size             :read-method :arg :type unsigned-int)
+;    (space-style            :read-method :arg :type toolbar-space-style)
+;    (relief                 :c-writer "gtk_toolbar_set_button_relief"
+;                         :read-method :arg :type relief-style)
+;    ;; slots not accessible through the arg mechanism
+;    (tooltips               :write-only t :type boolean)))
+
+(defclass tree (container)
+  ()
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((selection-mode         :type selection-mode)
+;    (view-mode              :type tree-view-mode)
+;    (view-lines             :type boolean)
+;    (root-tree              :read-only t :type tree)))
+  (:metaclass container-class)
+  (:alien-name "GtkTree"))
+
+
+(defclass calendar (widget)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkCalendar"))
+
+
+; (defclass drawing-area widget)
+
+; (defclass curve drawing-area
+;   :slots
+;   ((curve-type             :read-method :arg :type curve-type)
+;    (min-x                  :access-method :arg :type single-float)
+;    (max-x                  :access-method :arg :type single-float)
+;    (min-y                  :access-method :arg :type single-float)
+;    (max-y                  :access-method :arg :type single-float)))
+
+; (defclass editable widget
+;   :slots
+;   ((position               :type int)
+;    (editable               :read-method :arg :type boolean)
+;    ;; slots not accessible through the arg mechanism
+;    (text                   :access-method :lisp :type string)))
+
+; (defclass entry editable
+;   :slots
+;   ((max-length             :read-method :arg :type unsigned-int)
+;    (visibility             :read-method :arg :accessor entry-visible-p
+;                         :type boolean)
+;    ;; slots not accessible through the arg mechanism
+;    (text                   :type string)))
+
+; (defclass combo hbox
+;   :slots
+;   ;; slots not accessible through the arg mechanism
+;   ((entry                  :read-only t :type entry)
+;    (use-arrows             :type boolean)
+;    (use-arrows-always      :type boolean)
+;    (case-sensitive         :type boolean)))
+
+; (defclass spin-button entry
+;   :slots
+;   ((adjustment             :access-method :arg :type adjustment)
+;    (climb-rate             :access-method :arg :type single-float)
+;    (digits                 :access-method :arg :type unsigned-int)
+;    (snap-to-ticks          :read-method :arg :type boolean)
+;    (numeric                :read-method :arg :type boolean)
+;    (wrap                   :read-method :arg :type boolean)
+;    (update-policy          :read-method :arg :type spin-button-update-policy)
+;    (shadow-type            :read-method :arg :type shadow-type)
+;    (value                  :read-method :arg :type single-float)))
+
+; (defclass text editable
+;   :slots
+;   ((hadjustment            :access-method :arg :type adjustment)
+;    (vadjustment            :access-method :arg :type adjustment)
+;    (line-wrap              :read-method :arg :type boolean)
+;    (word-wrap              :read-method :arg :type boolean)
+;    ;; slots not accessible through the arg mechanism
+;    (point                  :type unsigned-int)
+;    (length                 :read-only t :type unsigned-int)))
+
+; (defclass ruler widget
+;   :constructor nil
+;   :slots
+;   ((lower                  :access-method :arg :type single-float)
+;    (upper                  :access-method :arg :type single-float)
+;    (position               :access-method :arg :type single-float)
+;    (max-size               :access-method :arg :type single-float)
+;    ;; slots not accessible through the arg mechanism
+;    (:metric                :write-only t :type metric-type)))
+
+; (defclass hruler ruler)
+
+; (defclass vruler ruler)
+
+; (defclass range widget
+;   :slots
+;   ((update-policy          :read-method :arg :type update-type)
+;    ;; slots not accessible through the arg mechanism
+;    (adjustment             :type adjustment)))
+
+; (defclass scale range
+;   :constructor nil
+;   :slots
+;   ((digits                 :read-method :arg :type unsigned-int)
+;    (draw-value             :read-method :arg :type boolean)
+;    (value-pos              :read-method :arg :type position-type)
+;    ;; slots not accessible through the arg mechanism
+;    (value-width            :read-only t :type int)))
+
+; (defclass hscale scale)
+
+; (defclass vscale scale)
+
+; (defclass scrollbar range :constructor nil)
+
+; (defclass hscrollbar scrollbar)
+
+; (defclass vscrollbar scrollbar)
+
+(defclass separator (widget)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkSeparator"))
+
+
+(defclass hseparator (separator)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkHSeparator"))
+
+
+(defclass vseparator (separator)
+  ()
+  (:metaclass widget-class)
+  (:alien-name "GtkVSeparator"))
+
+
+; (defclass preview widget
+;   :slots
+;   ((expand                 :read-method :arg :type boolean)))
+
+; (defclass progress widget
+;   :slots
+;   ((activity-mode          :read-method :arg :type boolean)
+;    (show-text              :read-method :arg :type boolean)
+;    (text-xalign            :access-method :arg :type single-float)
+;    (text-yalign            :access-method :arg :type single-float)
+;    ;; slots not accessible through the arg mechanism
+;    (format-string          :type string)
+;    (adjustment             :type adjustment)
+;    (percentage             :c-reader "gtk_progress_get_current_percentage"
+;                         :type single-float)
+;    (value                  :type single-float)
+;    (text                   :c-reader "gtk_progress_get_current_text"
+;                         :read-only t :type string)))
+
+; (defclass progress-bar progress
+;   :slots
+;   ((adjustment             :c-writer "gtk_progress_set_adjustment"
+;                         :read-method :arg :type adjustment)
+;    (orientation            :read-method :arg :type progress-bar-orientation)
+;    (bar-style              :read-method :arg :accessor progress-bar-style
+;                         :type progress-bar-style)
+;    (activity-step          :read-method :arg :type unsigned-int)
+;    (activity-blocks        :read-method :arg :type unsigned-int)
+;    (discrete-blocks        :read-method :arg :type unsigned-int)))
+
+; (defclass item-factory object)
+
diff --git a/gtk/gtkwidget.lisp b/gtk/gtkwidget.lisp
new file mode 100644 (file)
index 0000000..429f822
--- /dev/null
@@ -0,0 +1,393 @@
+;; Common Lisp bindings for GTK+ v2.0
+;; Copyright (C) 2000 Espen S. Johnsen <espejohn@online.no>
+;;
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 2 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+;; $Id: gtkwidget.lisp,v 1.1 2000/08/14 16:45:02 espen Exp $
+
+(in-package "GTK")
+
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass widget (object)
+    ((child-slots
+      :allocation :instance
+      :accessor widget-child-slots
+      :type container-child)
+     (name
+      :allocation :arg
+      :accessor widget-name
+      :initarg :name
+      :type string)
+     (parent
+      :allocation :arg
+      :accessor widget-parent
+;     :initarg :parent
+      :type container)
+     (x
+      :allocation :arg
+      :accessor widget-x-position
+      :initarg :x
+      :type int)
+     (y
+      :allocation :arg
+      :accessor widget-y-position
+      :initarg :y
+      :type int)
+     (width
+      :allocation :arg
+      :accessor widget-width
+      :initarg :width
+      :type int)
+     (height
+      :allocation :arg
+      :accessor widget-height
+      :initarg :height
+      :type int)
+     (visible
+      :allocation :arg
+      :accessor widget-visible-p
+      :initarg :visible
+      :type boolean)
+     (sensitive
+      :allocation :arg
+      :accessor widget-sensitive-p
+      :initarg :sensitive
+      :type boolean)
+     (app-paintable
+      :allocation :arg
+      :reader widget-app-paintable-p
+;     :access :read-only
+      :type boolean)
+     (can-focus
+      :allocation :arg
+      :accessor widget-can-focus-p
+      :initarg :can-focus
+      :type boolean)
+     (has-focus
+      :allocation :arg
+      :accessor widget-has-focus-p
+      :initarg :has-focus
+      :type boolean)
+     (can-default
+      :allocation :arg
+      :accessor widget-can-default-p
+      :initarg :can-default
+      :type boolean)
+     (has-default
+      :allocation :arg
+      :accessor widget-has-default-p
+      :initarg :has-default
+      :type boolean)
+     (receives-default
+      :allocation :arg
+      :accessor widget-receives-default-p
+      :initarg :receives-default
+      :type boolean)
+     (composite-child
+      :allocation :arg
+      :accessor widget-composite-child-p
+      :initarg :composite-child
+      :type boolean)
+;    (style
+;     :allocation :arg
+;     :accessor widget-style
+;     :initarg :style
+;     :type style)
+     (events
+      :allocation :arg
+      :accessor widget-events
+      :initarg :events
+      :type gdk:event-mask)
+     (extension-events
+      :allocation :arg
+      :accessor widget-extension-events
+      :initarg :extpension-events
+      :type gdk:event-mask)
+     (state
+      :allocation :virtual
+      :location ("gtk_widget_get_state" "gtk_widget_set_state")
+      :accessor widget-state
+      :initarg :state
+      :type state-type)
+     (window
+      :allocation :virtual
+      :location "gtk_widget_get_window"
+      :reader widget-window
+      :type gdk:window)
+     (colormap
+      :allocation :virtual
+      :location "gtk_widget_get_colormap"
+      :reader widget-colormap
+      :type gdk:colormap)
+     (visual
+      :allocation :virtual
+      :location "gtk_widget_get_visual"
+      :reader widget-visual
+      :type gdk:visual))
+    (:metaclass object-class)
+    (:alien-name "GtkWidget")))
+
+
+(defmethod initialize-instance ((widget widget) &rest initargs &key parent)
+  (declare (ignore initargs))
+  (cond
+   ((consp parent)
+    (with-slots ((container parent) child-slots) widget
+      (setf
+       container (car parent)
+       child-slots
+       (apply
+       #'make-instance
+       (slot-value (class-of container) 'child-class)
+       :parent container :child widget (cdr parent)))))
+   (parent
+    (setf (slot-value widget 'parent) parent)))
+    (call-next-method))
+
+
+(defmethod slot-unbound ((class object-class) (object widget) slot)
+  (cond
+   ((and (eq slot 'child-slots) (slot-value object 'parent))
+    (with-slots (parent child-slots) object
+      (setf
+       child-slots
+       (make-instance
+       (slot-value (class-of parent) 'child-class)
+       :parent parent :child object))))
+   (t (call-next-method))))
+
+
+(defun child-slot-value (widget slot)
+  (slot-value (widget-child-slots widget) slot))
+
+(defun (setf child-slot-value) (value widget slot)
+  (setf (slot-value (widget-child-slots widget) slot) value))
+
+(defmacro with-child-slots (slots widget &body body)
+  `(with-slots ,slots (widget-child-slots ,widget)
+     ,@body))
+
+(defmacro widget-destroyed (place)
+  `(setf ,place nil))
+
+(define-foreign widget-destroy () nil
+  (widget widget))
+
+(define-foreign widget-unparent () nil
+  (widget widget))
+
+(define-foreign widget-show () nil
+  (widget widget))
+
+(define-foreign widget-show-now () nil
+  (widget widget))
+
+(define-foreign widget-hide () nil
+  (widget widget))
+
+(define-foreign widget-show-all () nil
+  (widget widget))
+
+(define-foreign widget-hide-all () nil
+  (widget widget))
+
+(define-foreign widget-map () nil
+  (widget widget))
+
+(define-foreign widget-unmap () nil
+  (widget widget))
+
+(define-foreign widget-realize () nil
+  (widget widget))
+
+(define-foreign widget-unrealize () nil
+  (widget widget))
+
+(define-foreign widget-add-accelerator
+    (widget signal accel-group key modifiers flags) nil
+  (widget widget)
+  ((name-to-string signal) string)
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type)
+  (flags accel-flags))
+
+(define-foreign widget-remove-accelerator
+    (widget accel-group key modifiers) nil
+  (widget widget)
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign widget-accelerator-signal
+    (widget accel-group key modifiers) unsigned-int
+  (widget widget)
+  (accel-group accel-group)
+  ((gdk:keyval-from-name key) unsigned-int)
+  (modifiers gdk:modifier-type))
+
+(define-foreign widget-lock-accelerators () nil
+  (widget widget))
+
+(define-foreign widget-unlock-accelerators () nil
+  (widget widget))
+
+(define-foreign
+    ("gtk_widget_accelerators_locked" widget-accelerators-locked-p) () boolean
+  (widget widget))
+
+(define-foreign widget-event () int
+  (widget widget)
+  (event gdk:event))
+
+(define-foreign widget-activate () boolean
+  (widget widget))
+
+(define-foreign widget-set-scroll-adjustments () boolean
+  (widget widget)
+  (hadjustment adjustment)
+  (vadjustment adjustment))
+
+(define-foreign widget-reparent () nil
+  (widget widget)
+  (new-parent widget))
+
+(define-foreign widget-popup () nil
+  (widget widget)
+  (x int)
+  (y int))
+
+(define-foreign widget-grab-focus () nil
+  (widget widget))
+
+(define-foreign widget-grab-default () nil
+  (widget widget))
+
+;; cl-gtk.c
+(define-foreign widget-allocation () nil
+  (widget widget)
+  (width int :out)
+  (height int :out))
+
+
+(define-foreign widget-set-uposition (widget &key (x t) (y t)) nil
+  (widget widget)
+  ((case x
+     ((t) -2)
+     ((nil) -1)
+     (otherwise x)) int)
+  ((case y
+     ((t) -2)
+     ((nil) -1)
+     (otherwise y)) int))
+
+(define-foreign widget-add-events () nil
+  (widget widget)
+  (events gdk:event-mask))
+
+(define-foreign ("gtk_widget_get_toplevel" widget-toplevel) () widget
+  (widget widget))
+
+(define-foreign ("gtk_widget_get_ancestor"
+                 widget-ancestor) (widget type) widget
+  (widget widget)
+  ((find-type-number type) type-number))
+
+; (define-foreign ("gtk_widget_get_colormap" widget-colormap) () gdk:colormap
+;   (widget widget))
+
+; (define-foreign ("gtk_widget_get_visual" widget-visual) () gdk:visual
+;   (widget widget))
+
+(define-foreign ("gtk_widget_get_pointer" widget-pointer) () nil
+  (widget widget)
+  (x int :out)
+  (y int :out))
+
+(define-foreign ("gtk_widget_is_ancestor" widget-is-ancestor-p) () boolean
+  (widget widget)
+  (ancestor widget))
+
+(define-foreign widget-set-rc-style () nil
+  (widget widget))
+
+(define-foreign widget-ensure-style () nil
+  (widget widget))
+
+(define-foreign widget-restore-default-style () nil
+  (widget widget))
+
+(define-foreign widget-reset-rc-styles () nil
+  (widget widget))
+
+(defun (setf widget-cursor) (cursor-type widget)
+  (let ((cursor (gdk:cursor-new cursor-type))
+       (window (widget-window widget)))
+    (gdk:window-set-cursor window cursor)
+    ;(gdk:cursor-destroy cursor)
+    ))
+
+;; Push/pop pairs, to change default values upon a widget's creation.
+;; This will override the values that got set by the
+;; widget-set-default-* functions.
+
+(define-foreign widget-push-style () nil
+  (style style))
+
+(define-foreign widget-push-colormap () nil
+  (colormap gdk:colormap))
+
+; (define-foreign widget-push-visual () nil
+;   (visual gdk:visual))
+
+(define-foreign widget-push-composite-child () nil)
+
+(define-foreign widget-pop-style () nil)
+
+(define-foreign widget-pop-colormap () nil)
+
+;(define-foreign widget-pop-visual () nil)
+
+(define-foreign widget-pop-composite-child () nil)
+
+
+;; Set certain default values to be used at widget creation time.
+
+(define-foreign widget-set-default-style () nil
+  (style style))
+
+(define-foreign widget-set-default-colormap () nil
+  (colormap gdk:colormap))
+
+; (define-foreign widget-set-default-visual () nil
+;   (visual gdk:visual))
+
+(define-foreign widget-get-default-style () style)
+
+(define-foreign widget-get-default-colormap () gdk:colormap)
+
+(define-foreign widget-get-default-visual () gdk:visual)
+
+(define-foreign widget-shape-combine-mask () nil
+  (widget widget)
+  (shape-mask gdk:bitmap)
+  (x-offset int)
+  (y-offset int))
+
+;; cl-gtk.c
+(define-foreign widget-mapped-p () boolean
+  (widget widget))
+
diff --git a/hello-world.lisp b/hello-world.lisp
new file mode 100644 (file)
index 0000000..d89a585
--- /dev/null
@@ -0,0 +1,15 @@
+(use-package "GTK")
+
+(make-instance 'window
+ :type :toplevel
+ :title "Test"
+ :border-width 5
+ :visible t
+ :child (make-instance 'button
+        :label "Hello World!"
+        :visible t
+        :signals
+        (list (list 'clicked #'(lambda () (write-line "Button clicked"))))))
+
+
+
diff --git a/tools/autoexport.lisp b/tools/autoexport.lisp
new file mode 100644 (file)
index 0000000..b4e479c
--- /dev/null
@@ -0,0 +1,115 @@
+(defpackage "AUTOEXPORT"
+  (:use "COMMON-LISP")
+  (:export "LIST-AUTOEXPORTED-SYMBOLS" "LIST-AUTOEXPORTED-SYMBOLS-IN-FILE"
+          "DEFEXPORT" "EXPORT-FROM-FILE" "INTERNAL"))
+
+(in-package "AUTOEXPORT")
+
+(declaim (special *internal*))
+
+(defvar *export-handlers* (make-hash-table))
+(defvar *noexport-prefix* #\%)
+
+(defmacro defexport (operator lambda-list &body body)
+  `(setf
+    (gethash ',operator *export-handlers*)
+    #'(lambda ,lambda-list
+       ,@body)))
+
+(defmacro internal (&rest symbols)
+  (declare (ignore symbols))
+  nil)
+
+(defun list-autoexported-symbols (form)
+  (let ((handler (gethash (first form) *export-handlers*)))
+    (when handler
+      (let ((export (apply handler (cdr form))))
+       (delete-if
+        #'(lambda (symbol)
+            (char= (char (string symbol) 0) *noexport-prefix*))
+        (if (atom export)
+            (list export)
+          export))))))
+
+(defun export-fname (fname)
+  (if (atom fname)
+      fname
+    (second fname)))
+
+(defun list-autoexported-symbols-in-file (file)
+  (let ((*internal* nil))
+    (declare (special *internal*))
+    (with-open-file (in file)
+      (labels ((read-file (in)
+                (let ((form (read in nil nil)))
+                  (when form
+                    (delete-if
+                     #'(lambda (symbol)
+                         (member symbol *internal*))
+                     (delete-duplicates
+                      (nconc
+                       (list-autoexported-symbols form)
+                       (read-file in))))))))
+       (read-file in)))))
+  
+(defmacro export-from-file (file)
+  `(export ',(list-autoexported-symbols-in-file file)))
+
+
+;;;; Exporting standard forms
+
+(defexport defun (fname &rest rest)
+  (declare (ignore rest))
+  (export-fname fname))
+
+(defexport defvar (name &rest rest)
+  (declare (ignore rest))
+  name)
+
+(defexport defconstant (name &rest rest)
+  (declare (ignore rest))
+  name)
+
+(defexport defparameter (name &rest rest)
+  (declare (ignore rest))
+  name)
+
+(defexport defmacro (name &rest rest)
+  (declare (ignore rest))
+  name)
+
+(defexport deftype (name &rest rest)
+  (declare (ignore rest))
+  name)
+
+(defexport defclass (class superclasses &optional slotdefs &rest options)
+  (declare (ignore superclasses options))
+  (cons
+   class
+   (apply
+    #'nconc
+    (map
+     'list
+     #'(lambda (slotdef)
+        (if (symbolp slotdef)
+            (list slotdef)
+          (destructuring-bind
+              (name &key reader writer accessor &allow-other-keys) slotdef
+            (delete nil (list name reader (export-fname writer) accessor)))))
+     slotdefs))))
+
+(defexport defgeneric (fname &rest args)
+  (declare (ignore args))
+  (export-fname fname))
+  
+(defexport progn (&rest body)
+  (apply #'nconc (map 'list #'list-autoexported-symbols body)))
+
+(defexport eval-when (case &rest body)
+  (declare (ignore case))
+  (apply #'nconc (map 'list #'list-autoexported-symbols body)))
+
+(defexport internal (&rest symbols)
+  (setq *internal* (nconc *internal* symbols))
+  nil)
+
diff --git a/tools/config.lisp b/tools/config.lisp
new file mode 100644 (file)
index 0000000..fa335fa
--- /dev/null
@@ -0,0 +1,16 @@
+(defun configure-cflags (config-program)
+  (let ((process
+        (run-program
+         config-program '("--cflags") :wait t :output :stream)))
+    (unless process
+      (error "Unable to run %A" config-program))
+    (labels ((split (string)
+              (let ((position (position #\sp string)))
+                (if position
+                    (cons
+                     (subseq string 0 position)
+                     (split (subseq string (1+ position))))
+                  (list string)))))
+    (prog1
+       (split (read-line (process-output process)))
+      (process-close process)))))
diff --git a/tools/makeenums.pl b/tools/makeenums.pl
new file mode 100644 (file)
index 0000000..7f219dd
--- /dev/null
@@ -0,0 +1,245 @@
+#!/usr/bin/perl -w
+
+# Information about the current enumeration
+# Modifed to generate output for clg
+
+
+my $flags;                     # Is enumeration a bitmask
+my $seenbitshift;                      # Have we seen bitshift operators?
+my $prefix;                    # Prefix for this enumeration
+my $enumname;                  # Name for this enumeration
+my $firstenum = 1;             # Is this the first enumeration in file?
+my @entries;                   # [ $name, $val ] for each entry
+
+sub parse_options {
+    my $opts = shift;
+    my @opts;
+
+    for $opt (split /\s*,\s*/, $opts) {
+       my ($key,$val) = $opt =~ /\s*(\w+)(?:=(\S+))?/;
+       defined $val or $val = 1;
+       push @opts, $key, $val;
+    }
+    @opts;
+}
+sub parse_entries {
+    my $file = shift;
+
+    while (<$file>) {
+       # Read lines until we have no open comments
+       while (m@/\*
+              ([^*]|\*(?!/))*$
+              @x) {
+           my $new;
+           defined ($new = <$file>) || die "Unmatched comment";
+           $_ .= $new;
+       }
+       # Now strip comments
+       s@/\*(?!<)
+           ([^*]+|\*(?!/))*
+          \*/@@gx;
+       
+       s@\n@ @;
+       
+       next if m@^\s*$@;
+
+       # Handle include files
+       if (/^\#include\s*<([^>]*)>/ ) {
+            my $file= "../$1";
+           open NEWFILE, $file or die "Cannot open include file $file: $!\n";
+           
+           if (parse_entries (\*NEWFILE)) {
+               return 1;
+           } else {
+               next;
+           }
+       }
+       
+       if (/^\s*\}\s*(\w+)/) {
+           $enumname = $1;
+           return 1;
+       }
+
+       if (m@^\s*
+              (\w+)\s*                  # name
+              (?:=(                      # value
+                   (?:[^,/]|/(?!\*))*
+                  ))?,?\s*
+              (?:/\*<                   # options 
+                (([^*]|\*(?!/))*)
+               >\*/)?
+              \s*$
+             @x) {
+           my ($name, $value, $options) = ($1,$2,$3);
+
+           if (!defined $flags && defined $value && $value =~ /<</) {
+               $seenbitshift = 1;
+           }
+           if (defined $options) {
+               my %options = parse_options($options);
+               if (!defined $options{skip}) {
+                   push @entries, [ $name, $value, $options{nick} ];
+               }
+           } else {
+               push @entries, [ $name, $value ];
+           }
+       } else {
+           print STDERR "Can't understand: $_\n";
+       }
+    }
+    return 0;
+}
+
+sub make_lispname {
+    my $enumname = shift;
+
+    $enumname =~ s/([A-Z])/-$1/g;
+    return substr (lc ($enumname), 5);
+}
+
+
+my $gen_arrays = 0;
+my $gen_defs = 0;
+
+# Parse arguments
+
+if (@ARGV) {
+    if ($ARGV[0] eq "arrays") {
+       shift @ARGV;
+       $gen_arrays = 1;
+    } elsif ($ARGV[0] eq "defs") {
+       shift @ARGV;
+       $gen_defs = 1;
+    } else {
+       $gen_defs = 1;
+    }
+    
+}
+
+if ($gen_defs) {
+    print ";; generated by a modified makeenums.pl  ; -*- lisp -*-\n\n";
+} else {
+    print "/* Generated by makeenums.pl */\n\n";
+}
+
+ENUMERATION:
+while (<>) {
+    if (eof) {
+       close (ARGV);           # reset line numbering
+       $firstenum = 1;         # Flag to print filename at next enum
+    }
+
+    if (m@^\s*typedef\s+enum\s*
+           ({)?\s*
+           (?:/\*<
+             (([^*]|\*(?!/))*)
+            >\*/)?
+         @x) {
+       if (defined $2) {
+           my %options = parse_options($2);
+           $prefix = $options{prefix};
+           $flags = $options{flags};
+       } else {
+           $prefix = undef;
+           $flags = undef;
+       }
+       # Didn't have trailing '{' look on next lines
+       if (!defined $1) {
+           while (<>) {
+               if (s/^\s*\{//) {
+                   last;
+               }
+           }
+       }
+
+       $seenbitshift = 0;
+       @entries = ();
+
+       # Now parse the entries
+       parse_entries (\*ARGV);
+
+       # figure out if this was a flags or enums enumeration
+
+       if (!defined $flags) {
+           $flags = $seenbitshift;
+       }
+
+       # Autogenerate a prefix
+
+       if (!defined $prefix) {
+           for (@entries) {
+               my $name = $_->[0];
+               if (defined $prefix) {
+                   my $tmp = ~ ($name ^ $prefix);
+                   ($tmp) = $tmp =~ /(^\xff*)/;
+                   $prefix = $prefix & $tmp;
+               } else {
+                   $prefix = $name;
+               }
+           }
+           # Trim so that it ends in an underscore
+           $prefix =~ s/_[^_]*$/_/;
+       }
+       
+       for $entry (@entries) {
+           my ($name,$value,$nick) = @{$entry};
+
+            if (!defined $nick) {
+               ($nick = $name) =~ s/^$prefix//;
+               $nick =~ tr/_/-/;
+               $nick = lc($nick);
+               @{$entry} = ($name, $value, $nick);
+            }
+       }
+
+       # Spit out the output
+
+       if ($gen_defs) {
+           if ($firstenum) {
+               print qq(\n; enumerations from "$ARGV"\n);
+               $firstenum = 0;
+           }
+           
+           my $lispname = make_lispname ($enumname);
+           print "\n(deftype (".$lispname." \"".$enumname."\") ()\n  '(". ($flags ? "flags" : "enum");
+
+           my $comment;
+           for (@entries) {
+               my ($name,$value,$nick) = @{$_};
+
+               $comment = 0;
+               if (defined $value) {
+                   $value =~ s/0x/\#x/;
+                   
+                   print "\n";
+                   if ($flags && not ($value =~ s/1\s+<<\s+(\d+)/$1/)) {
+                       print ";";
+                       $comment = 1;
+                   }
+                   
+                   print "    (:$nick $value)";
+               } else {
+                   print "\n    :$nick";
+               }
+           }
+           if ($comment) {
+               print "\n   ";
+           }
+           print "))\n";
+
+       } else {
+           my $valuename = $enumname;
+            $valuename =~ s/([^A-Z])([A-Z])/$1_$2/g;
+            $valuename =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
+            $valuename = lc($valuename);
+
+           print "static const GtkEnumValue _${valuename}_values[] = {\n";
+           for (@entries) {
+               my ($name,$value,$nick) = @{$_};
+               print qq(  { $name, "$name", "$nick" },\n);
+           }
+           print "  { 0, NULL, NULL }\n";
+           print "};\n";
+       }
+    }
+}
diff --git a/tools/sharedlib.lisp b/tools/sharedlib.lisp
new file mode 100644 (file)
index 0000000..8ef77d1
--- /dev/null
@@ -0,0 +1,17 @@
+(in-package "ALIEN")
+(export '(load-shared-library))
+(in-package "SYSTEM")
+(import 'alien:load-shared-library)
+
+(defun load-shared-library (file &key init prototype initargs)
+  (format t ";;; Loading shared library ~A~%" file)
+  (load-object-file file)
+  (when init
+    (apply
+     #'alien:alien-funcall
+     (alien::%heap-alien
+      (alien::make-heap-alien-info
+       :type (alien::parse-alien-type (or prototype `(function c-call:void)))
+       :sap-form (system:foreign-symbol-address init)))
+     initargs)))
+