September 16, 2010
For some time I wasn’t making much progress with cl-gtk2 (though I have plans to improve it) because I’ve been busy with adding native threads support for SBCL on Windows that are necessary for developing cross-platform GUI applications with SBCL and cl-gtk2. Threads are pretty much working right now and I’m now asking to test and evaluate it. The sources are available at http://github.com/dmitryvk/sbcl-win32-threads and the binary installer is available at https://sites.google.com/site/dmitryvksite/sbcl-distr/sbcl-1.0.40-threads-2.msi.
There are still some I/O issues waiting to be resolved that affect threads (Win32 is quite weird when it comes to I/O). Lucky for me, Anton Kovalenko made improvements in SBCL’s I/O for Win32.
cl-gtk2 seems to work in multithreaded SBCL on Windows (though I didn’t test it a lot). There is an issue that affects cl-gtk2: loading it from the SLIME REPL hangs during initialization of Gtk+ due to some deadlock in windows’ C runtime – you’ll just have to enter anything in SLIME’s *inferior-lisp* buffer to unhang it. Hopefully, this will be resolved with help from Anton Kovalenko.
January 25, 2010
Minimum version checking
When loading cl-gtk2, it now checks for Gtk+ version and raises a compile-time error Gtk+ version is too old and is not supported by cl-gtk2. I’ve had several questions about errors during loading cl-gtk2 when the Gtk+ is old. Now it should be immediately clear and will note require decrypting much less comprehensible error messages about missing functions.
Support for multiple Gtk+ versions
There is now some support for several Gtk+ versions. Upon loading, cl-gtk2 pushes symbols to
*features* that allow to conditionally compile or not compile bindings for particular classes/methods/functions depending on versions of libraries. This means that while minimum supported Gtk+ version is 2.16, methods and classes from Gtk+ 2.18 will be available to you (of course, this requires writing bindings to them – I haven’t yet written complete bindings to Gtk+ 2.16 or Gtk+ 2.18). But the way this is implemented (by using reader conditionals) requires to recompile cl-gtk2 when Gtk+ is updated.
Improvements to gtk demo
I’ve improved the gtk demo a bit. Now it looks like a text page with links to various demos.
Improvements to main loop handling
I’ve made ensure-gtk-main/within-main-loop/leave-gtk-main/join-gtk-main more consistent between multi-threaded lisps and unithreaded lisps.
The suggested use for them is the following. In the ‘main’ function you have code like this:
(within-main-loop (your-application-code) ;; somewhere in your application you call leave-gtk-main ) (join-gtk-main)
E.g., to call the cl-gtk2 demonstration in this way, you just call:
(progn (gtk-demo:demo) (gtk:join-gtk-main))
This code will finish when the application quits the main loop, thereby quitting the application. This will work in multi-threaded and non-multi-threaded lisps.
In multi-threaded lisps, during development you can use within-main-loop (without join-gtk-main) to start the application in the background thread and do the development while the application is running.
Fixing the finalizing of GBoxed instances by making finalization of them thread-safe
That was one of rare-occuring bugs (at least for me) so this bug slipt past me. But now I’ve fixed it, and random crashes occur less often.
January 8, 2010
I have uploaded neccessary source archives and created necessary cliki.net pages to make cl-gtk2 installable with ASDF-INSTALL.
This means that it is possible to install cl-gtk2 with the following commands at the REPL:
(asdf:oos 'asdf:load-op :asdf-install)
January 3, 2010
I’ve tagged and released the current sources of cl-gtk2 as version 0.1.1.
The primary motivation for this was the recent release of closer-mop library which breaks cl-gtk2-0.1 by causing symbol conflicts.
Other than that, there were several bugfixes and addition of binding to most parts of Gdk, see the full changelog for details.
October 25, 2009
I’ve tagged and released the current state of cl-gtk2 as a version 0.1. The source code is avaiable at http://common-lisp.net/project/cl-gtk2/files/cl-gtk2-0.1.tar.gz with installation instructions located at installation page.
This was done mainly to make installation and packaging easy – having a version and source tarball helps.
Also, for Gentoo Linux I’ve made an overlay with necessary ebuilds that can be installed with layman:
layman -a lisp layman --overlays=http://github.com/dmitryvk/cl-gtk2-overlay/raw/master/layman-list.xml -a cl-gtk2
I made several changes to support CLISP (they fix my incorrect usage of CLOS MOP). cl-gtk2 runs on some versions of clisp and does not run on some others. It seems that clisp in Gentoo (I don’t know yet whether it’s distro-specific or not) is broken on amd64: callbacks do not work at all since clisp-2.47 (or maybe earlier). I’ve tested on unithreaded clisp-2.48 on Windows, and cl-gtk2 ran fine there. However, this requires checking on multi-threaded builds and on other platforms.
I’ve also improved parts of bindings: GtkTextView, GtkTreePath and GtkTreeRowReference, GtkWidget, GtkContainer child properties, GtkFileChooser, GtkHSV, GtkTextBuffer serialization, GtkTreeModelSort, GtkTreeStore, GtkListStore.
New gtk:timer class is available. Instance of this class manages a single `timeout’ – a function that is called by GLib main loop every n milliseconds.
The important addition is integration with cl-cairo2. This allows to draw on widgets with Cairo.
October 4, 2009
cl-gtk2 is becoming more portable. I’ve added support for Microft Windows and Clozure CL. Several other popular lisp implementations are not yet supported: clisp, ecl, abcl.
SBCL on windows is unithreaded only. I haven’t been able to make cl-gtk2 work if SBCL is started from SLIME (however, I haven’t tried very hard), but running from command-line works. And SBCL is experiencing some rare crashes.
Clozure CL had a bug with its CLOS MOP implementation that had only been fixed today. In order to run cl-gtk2 under Clozure, you need to have Clozure from SVN (revision 12905 or newer). Clozure works fine on windows, has threads and is quite fast. This makes CCL more useful for development or installing on Windows.
But I haven’t yet added support for saving Lisp images with Clozure.UPD:Support for saving images with CCL has been added.
Using shared libraries seems more fragile on Windows (SBCL on Windows does not tolerate missing symbols like it does on Linux), and Gtk+-2.16 is a requirement for cl-gtk2.
Some obligatory screenshots: a simple text editor and rotating OpenGL teapot.
September 7, 2009
I’ve been debugging and fixing several bugs related to memory management of cl-gtk2.
There were two main bugs that required fixing:
- Object denaturation. Object denaturation means that we pass a reference to an object of some type derived from GObject type but then we receive object of some other base type. E.g., we create a custom-window deriving from gtk-window with some fields containing application data. And if there are no references to custom-window and we receive a pointer to corresponding object, we receive it as a gtk-window, not custom-window.
GObject’s toggle references are designed exactly to avoid this problem in language bindings. Toggle references let the binding know when the “foreign” side has no more references to an object (and this means that we will now never receive pointer to this object) and when the “foreign” side has some references (and may potentially pass object back to us).
- References leak. There were cases when references were leaked: the cl-gtk2-gobject increased the objects’ refcount more than it should. Several generic cases of it have been fixed (references were increased twice when receiving the pointer from foreign code for the first time; functions that return already g_object_ref’ed objects).
- Simplification of creation of GObject instances and instances of lisp-implemented GObject classes.
The changes are in git now.
But there is at least one case of reference leaking is present. Creating interface with GtkBuilder leaks some references.