Summary of recent changes to cl-gtk2 in git

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:

  (your-application-code) ;; somewhere in your application you call leave-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.


4 Responses to “Summary of recent changes to cl-gtk2 in git”

  1. Leo Says:

    Hello Kalyanov,

    Many thanks for developing this. I think CL seriously needs a good GUI toolkit.


  2. Erik Winkels Says:

    Hi Dmitry,

    Thanks again for cl-gtk2. I’m currently using it in a toy project:

  3. I was going to add Glade support to cl-gtk2 but recently noticed it was already there. 🙂 Great work!
    I’ve almost switched to cl-gtk2 from clg – only discovery of cl-plplot with clg binding stopped me. But next time, definitely cl-gtk2 🙂
    By the way, it seems that recent SBCL renamed TYPE-EXPAND to TYPEXPAND. clg was bitten by that.

  4. psilocide Says:

    Kalyanov and cl-gtk2-developers,

    I think I have found an approach to getting cl-gtk2 to work with Mac OS X. I am running OS X 10.6.6 and SBCL 1.0.24 with quicklisp.

    This isn’t the prettiest, and I am still a little stuck. If someone would be able to show me how to get pkgconfig and gtkglext installed on Mac OS X 10.6 I would be highly appreciative.

    I’ve not introduced variable pathnames, so they are
    hardcoded and need to be changed with each environment. I would think a more matured developer would be able to implement the same things that I have with an ability to be multi-environed.

    Some of the things on here has strange dependencies. E.G. jhbuild cannot have Fink or MacPorts installed to work.

    1) Download these packages:
    gtk-osx ://
    cl-cairo2 ://
    gtkglext ://
    cl-gtk2 ://

    2) Then you build the script for gtk-osx, which may need sudo.
    After the script installs jhbuild, do NOT run bootstrap yet.
    Change ~/.jhbuildrc-custom and add
    moduleset =
    “://” (add
    protocol, I removed it for spam.)
    or (GTK-OSX explains the difference.)
    moduleset = “://
    (same here.)
    and comment out (setup_sdk … where target=_target and archs=[default] ).

    setup_universal_build(target=”10.5″, sdk_version=”10.5″,
    architectures=[“ppc”, “i386”])

    , unless you are on 10.4, this should work.
    save, may need sudo. x86_64 glib does not work, and this ensures greatest

    3) Run jhbuild bootstrap, then jhbuild and this will place gtk in ~/gtk/ with libraries at ~/gtk/inst/lib/

    4) In cl-gtk2 edit these files: pango.init.lisp, gdk.package.lisp, glib.lisp, by changing define-foreign-function to

    (eval-when (:compile-toplevel :load-toplevel :execute)
    (define-foreign-library glib
    ((:and :unix (:not :darwin)) (:or “” “”))
    (:darwin (:or
    (:windows “libglib-2.0-0.dll”)
    (t (:default “libglib-2.0″))))

    5) In cl-cairo2 edit this file: load-libraries.lisp, by doing similar change to define-foreign-function.

    6) In cl-gtk2, gtk.main_loop_events.lisp comment out
    (sb-unix::enable-interrupt … sb-unix::sigpipe-handler).
    For some reason my SBCL, 1.0.24, does not have this function defined. Go figure.

    OPTIONAL: If you can get pkg-config installed and have libglib set, then install
    gtkglext and change file gtkglext.package.lisp similarly with
    define-foreign-function. I could not get pkg-config installed, so I could not
    get gtkglext installed.

    7) Now clear quicklisp cache in ~/.cache of any cl-gtk2, cl-cairo2 installs.

    8) In SBCL, push these values
    (push #p”(PATH-TO-CHANGED-LISP-SOURCE-FILES)” asdf:*central-registry*)
    You will need to do this 5 or 6 times for each:
    cl-gtk2-glib,pango,gdk,gtk,cairo,gtkglext, and cl-cairo2.

    9) Now use quicklisp to load:
    (ql:quickload “cl-cairo2”)
    (ql:quickload “cl-gtk2-glib”)
    (ql:quickload “cl-gtk2-pango”)
    (ql:quickload “cl-gtk2-gdk”)
    (ql:quickload “cl-gtk2-gtk”)
    (ql:quickload “cl-gtk2-cairo”)
    (ql:quickload “cl-gtk2-gtkglext”) — if you have it installed.

    10) Should work now.

    Maybe the next release will have a fix. It seems CFFI does not have a proper method of searching for libraries on OS X, or that OS X poorly handles new libraries and does not place them appropriately, i.e. /usr/lib. I tried changing the *foreign-library-directories* variable with (pushnew ) and it did not work, so that is how I came to that conclusion.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: