Merge remote-tracking branch 'andy128k/master'
[cl-gtk2.git] / doc / doc.html
blob4ef6e3d4ef8f9222db1f45678333ecc136a484fd
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>CL-GTK2 - a Gtk+ binding for Common Lisp</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" title="CL-GTK2 - a Gtk+ binding for Common Lisp"><div class="titlepage"><div><div><h1 class="title"><a name="id304785"></a>CL-GTK2 - a Gtk+ binding for Common Lisp</h1></div><div><div class="author"><h3 class="author"><span class="firstname">Dmitry</span> <span class="surname">Kalyanov</span></h3></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="chapter"><a href="#id514435">1. TODO</a></span></dt><dt><span class="chapter"><a href="#id514474">2. Introduction</a></span></dt><dt><span class="chapter"><a href="#id514485">3. Goals</a></span></dt><dt><span class="chapter"><a href="#id514534">4. Development history</a></span></dt><dt><span class="chapter"><a href="#id514590">5. Features</a></span></dt><dt><span class="chapter"><a href="#id514639">6. GObject binding</a></span></dt></dl></div><div class="chapter" title="Chapter 1. TODO"><div class="titlepage"><div><div><h2 class="title"><a name="id514435"></a>Chapter 1. TODO</h2></div></div></div><p>Installation and requirements</p><p>*Introduction</p><p>Goals</p><p>Development History</p><p>Features</p><p>*Examples</p><p>*GObject binding: using objects, handling memory</p><p>*Using Gtk+ in Lisp: Gtk+, Widgets, main loop, threading</p><p>*Advanced GObject: defining objects, creating custom gobject classes, overriding and implementing methods and properties</p><p>*Internals: how gobject binding is implemented</p></div><div class="chapter" title="Chapter 2. Introduction"><div class="titlepage"><div><div><h2 class="title"><a name="id514474"></a>Chapter 2. Introduction</h2></div></div></div><p>CL-GTK2 package is a Common Lisp binding for Gtk+ and related libraries. This package enables Lisp developers to develop Gtk+-based GUI applications.</p></div><div class="chapter" title="Chapter 3. Goals"><div class="titlepage"><div><div><h2 class="title"><a name="id514485"></a>Chapter 3. Goals</h2></div></div></div><p>The goal of CL-GTK2 is to provide portable (modulo threading, metaobject protocol, FFI), extensible and feature-complete binding for Gtk+ and set of related libraries (GLib, GObject, Gdk, Pango, Cairo, GdkPixbuf, GtkSourceView, etc.)</p><p>Gtk+ is writtent in C and uses object-oriented style of programming with support of GObject library. GObject provides classes, objects, memory management via reference counters, classes introspection, signals, properties. Goal includes "lispy" interface to GObject-based libraries. This means that GObject classes should map into CLOS classes, GObject instance into CLOS instances, properties should match to slots, it should be possible to attach closures as signal handlers. It should be possible to define GObject classes, implement properties, methods, signals, interfaces from lisp.</p><p>All memory management (object instances, closures, signal handlers, etc.) should be automatic. When applicable, optional support for manual management (using refcounts) should be provided for perfomance reasons.</p><p>All Gtk+ classes should be mapped, and the rest of the API should be mapped in lispy way. Support for NIH features should not be provided (e.g., do not expose GSList, GList, GHashtable, GUri but rather transparently convert to/from them).</p><p>Error handling should be provided; GObject/Gtk warnings and errors should be exposed as conditions. It should not be possible to bring Gtk+ into incostistent state when error in lisp code called from Gtk occurs (e.g., error in signal handler should not cause fatal errors but rather should be handleable).</p><p>CL-GTK2 should be threadsafe: it should be possible to make actions under the Gdk lock, and make actions from withing the GUI thread.</p><p>Ease of extending and updating to reflect progress of Gtk+ is also important.</p><p>CL-GTK2 should run main-loop threadedly; it should be possible to interactively modify the code while the GUI program is running.</p></div><div class="chapter" title="Chapter 4. Development history"><div class="titlepage"><div><div><h2 class="title"><a name="id514534"></a>Chapter 4. Development history</h2></div></div></div><p>This project was started by Kalyanov Dmitry in 2008. It was a hobby project to address the (perceived or real) lack of good portable GUI libraries for Common Lisp and to be able to use it for writing diploma (or is it called "graduate"?) project during final course of the university.</p><p>Initial intent was to use SWIG<sup>[<a name="id514548" href="#ftn.id514548" class="footnote">1</a>]</sup> in order to be able to generate all of the code. After some experimenting, it was found out that use of SWIG would not help to achieve the goals. First of all, in order to create "lispy" bindings, a lot of integration should be done: object systems, memory management, passing closure and values, type mapping (G(S)List to list, GCallback/GCLosure to functions, etc.). SWIG is not of much help here.</p><p>So, it was decided to use CFFI and manually map all of the API. First, base infrastructure was created (definition of basic types, maps for basic types, integration with GObject object system and memory management, introspection of GObject types). Then large chunks of API were mapped with automatic generation of classes definitions. Then missing properties were added and functions were mapped.</p><p>In order to map GtkTreeModel, preliminary support for subclassing and implementing GObjects was introduced. With its help, lispy ArrayListStore (analog for GtkListStore) was implemented.</p><p>At the moment, next version of GObject binding using the CLOS MOP is being developed. It pretty much obsoletes class generation macroses and is neede in order to be able to make lispy maps of GObject methods into CLOS generic functions and to subclass GObject classes.</p><p>For future development, using GObjectIntrospection seems the definite way.</p><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a name="ftn.id514548" href="#id514548" class="para">1</a>] </sup><a class="ulink" href="http://www.swig.org/" target="_top">Simplified Wrapper and Interface Generator</a>; a program that automatically parses C and C++ header files and generates the binding code for many languages, including Common Lisp (targetting CFFI).</p></div></div></div><div class="chapter" title="Chapter 5. Features"><div class="titlepage"><div><div><h2 class="title"><a name="id514590"></a>Chapter 5. Features</h2></div></div></div><p>Short summary of features provided by CL-GTK2:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Mapping from GObject to CLOS with (partial) support for creating subclasses, overriding methods</p></li><li class="listitem"><p>Automatic memory management (with optional support for manual reference counting)</p></li><li class="listitem"><p>Lispy interface to related libraries (currently only to GLib, GObject, Gdk, Gtk)</p></li><li class="listitem"><p>Lispy mapping of Gtk+ API</p></li><li class="listitem"><p>Custom ListStore (TreeStore to be done) for GtkTreeModel</p></li><li class="listitem"><p>Partial error management (closures are invoked with restarts making it possible to cancel signal handling without crashing Gtk+)</p></li><li class="listitem"><p>Some high-level features based on Gtk+ API: with-progress-bar, with-message-error-handler</p></li></ul></div></div><div class="chapter" title="Chapter 6. GObject binding"><div class="titlepage"><div><div><h2 class="title"><a name="id514639"></a>Chapter 6. GObject binding</h2></div></div></div><p>At the base of Gtk+ is the GObject library. This library provides basic object-oriented system and various services. </p></div></div></body></html>