[cl-gtk2-devel] [PATCH] Support for DND

Ryan Pavlik rpavlik at gmail.com
Wed Aug 24 20:54:36 UTC 2011


Attached is a patch for the majority of the drag'n'drop API, along
with a rather simple test program.  The API is mostly similar to the
native gtk with cl-gtk2 naming conventions; exceptions of note:

  * selection-set selection-data data &key type

    This is a generic function for easily modifying the content of
    selection-data objects.  There are currently methods for data as a
    string and a gdk:pixbuf.

  * selection-get selection-data => string-or-array type format

    This will return a lisp string or array of integers for the
    selection-data, along with the type ("text/plain") and format
    (bits-per-unit).  It should be noted that gtk will currently not
    correctly handle format=32 on 64-bit systems.  (I have filed a bug
    report.)

The test program should allow drags within itself and to other
receivers; "text/plain" is fairly common.  Another common type is
"text/uri-list", but each line must be terminated with CRLF.

I have not tested every API call, particularly the image setting,
though I have tested quite a few more than are in the demo.  As I'm
using this for a project I will be testing more shortly.

A few more things:

  * I have not used (C)FFI much prior to this, and I am not intimately
    familiar with gtk, or cl-gtk2's gobject wrapper, though I did
    consult the source when questions arose.  But there may be
    glaring issues of which I'm not aware.

  * selection-data is now boxed-opaque instead of boxed-cstruct, in
    order to support "out" parameters.  Additionally, I have removed
    the call to boxed-copy-fn from boxed-parse-g-value for
    boxed-opaque types.

    My main concern here is values being double-freed by GC hooks, but
    having tested and looked at the code, this does not appear to
    happen: opaque instances are only finalized if they are allocated
    with make-instance, which will not be the case when calling
    g-boxed-copy.

    I am actually wondering if it's a memory leak as it was.

Also, it'd be nice if cl-gtk2 included the do-gtk macro in the
demo... within-main-loop deadlocks when used recursively...

hth,

-- 
Ryan Pavlik <rpavlik at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cl-gtk2-dnd.patch
Type: text/x-patch
Size: 12893 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cl-gtk2-devel/attachments/20110824/11800089/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gtk-dnd-test.lisp
Type: application/octet-stream
Size: 2033 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cl-gtk2-devel/attachments/20110824/11800089/attachment.obj>


More information about the cl-gtk2-devel mailing list