source available for DnD *out* of a treeview



i've spent several days fooling around with models to support DnD out of
treeview widget. i was very disappointed to find that GTK2 still
supports only within-treeview DnD by default, and has no support at all
for dragging anything out of a treeview (as opposed to drop support,
which is relatively easy to provide).

via the links below, you can see what i came up. its not as type safe as
i would like, but its a first step in the right direction. this derived
DnDTreeView has an additional signal, called "object_drop", which
provides handlers with a data type name, a count and a set of pointers.
if someone call DnDTreeView::add_object_drag (int col, std::string
typename) on the tree, then drags from the treeview to any other drag
destination that supports "typename" as a drop target will use this
format. 

typical use: you have a treemodel with N columns visible in a treeview
plus a hidden column containing a pointer to some kind of object. you
call add_object_drag (hidden_column_index, "sometypeofobject") on the
DnDTreeView, and then add "sometypeofobject" to another widget's drop
target. a simple example is dragging between 2 DnDTreeViews: just call
add_object_drag on each one, and they can they have stuff d-n-d'ed
between them. when someone does DnD between two widgets that accept
"sometypeofobject", the destination will receive data as a
DnDTreeView::SerializedObjectPointers object. if the destination is
another DnDTreeView, it will take that object apart, and emit
"object_drop" with 3 arguments as described above. handlers for this
signal can then grab the objects that were being dragged and do
something with them.

You can see the results here. I would love feedback on the general idea,
as well as the implementation.

http://ardour.org/cgi-
bin/viewcvs.cgi/*checkout*/ardour2/libs/gtkmm2ext/dndtreeview.cc?
rev=1.1&content-type=text/plain

http://ardour.org/cgi-
bin/viewcvs.cgi/*checkout*/ardour2/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h?rev=1.1&content-type=text/plain





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]