Re: Enable drag and drop for treeview?



On Thu, 2007-05-03 at 07:12 -0500, Jonathon Jongsma wrote:
> hmm, OK.  I just checked a project of mine where I save the state of a
> treeview when something is changed, and I handle the case of a
> drag/drop re-order.  And the signals I connect to are
> Gtk::TreeView::signal_drag_end() and
> Gtk::TreeModel::signal_rows_reordered () and it seems to work fine for
> my purposes.  So maybe the drag_end() one is the one you want?  Or
> maybe Chris's suggestion is better.  I've not done extensive testing
> on mine, so I'm not sure if there are cases that might not get caught,
> but it seems to work for what I need it to do.

I am not sure I tried Gtk::Widget::signal_drag_end() for this purpose.
When (rarely) using the high level Gtk::TreeView/Gtk::TreeModel drag and
drop interface I think I generally stick to only that high level
interface, because I am not convinced I understand the relationship
between it and the normal gtk+ interface.  In practice it probably does
just as well or better than using signal_row_deleted() for this purpose.

Except in the simplest usage, I use the basic gtk/gtkwidget drag and
drop stuff.  It is in my experience pretty easy to use once you get the
hang of it, and it can do more or less anything.  I notice that Paul
"Audio" Davis managed to get cross-TreeView row drag and drop to work
using the high level interface.  I gave up trying to do that (probably
because I am more of a quitter than he is), and I adopt the more
straightforward approach of using the low level gtk+ drag and drop
interface and recreating the relevant row in the receiving widget from
the data transferred.  I expect that under the hood that is what the
high level interface does.  Using this approach there is also some stuff
to be done in validating both the drop site and the source site which,
although not well explained in the documentation, is not too difficult.

When all is said and done, dragging between different widgets is not
always meaningful.  The receiving widget may or may not be designed to
receive and interpret the data that is being dragged onto it.  That is a
problem that has to be solved whatever approach is adopted.

Chris





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