I have a 'feature' I discovered and can't decide whether to file a
bug, or a faq entry or what.

Make a TreeView which has some rows, but there is space at the end
where there are no rows (i.e. the window/scrolledwindow is bigger than
the TreeView). Enable drag&drop. Drag a row so that it would be
dropped on the empty space at the end. Notice that there _is_ a line
after the last row indicating that it will be dropped there. Drop the
row, and notice that the app raises an exception and doesn't do the
drop. (As an example app the one provided in
http://www.daa.com.au/pipermail/pygtk/2003-November/006304.html
is perfect.)

Reason: the 'drag-data-received' signal's handler uses
TreeView.get_dest_row_at_pos(x, y) to find out the place of the
drop. In this case, however, as the drop position doesn't have rows
underneath, it returns None.
And TreeView.get_drag_dest_row() returns None in this case, too. (Try
it out by catching the exception in the above example code and
printing the values)

The real suprise is that in the UI, the line appears, so one would
guess the drop should work, and so should .get_dest_row_at_pos(x, y),
but it doesn't.

This is at least a documentation bug, as
gtk.TreeView.get_drag_dest_row()'s entry in the API docs says

    "Returns: a 2-tuple containing the tree path and the drop position
    relative to the tree path"

That is, it doesn't mention returning None.

However, I think only fixing this as a documentiation bug isn't the
best idea.

Making a work-around for this isn't too dificult, as the return values
in both cases should be (to match what the UI is showing with the
black line):

       ((len(TreeView.get_model()),) ,gtk.TREE_VIEW_DROP_AFTER)

(at least I think so, not tested.)
so one can simply catch the exception and use these values.

However, this would mean every drag&drop-handling TreeView would need
this workaround, which would be really unfortunate (and not at all
pythonic, and so on.)

For somebody writing an App which uses dnd in a TreeView, the best
solution would be if TreeView.get_dest_row_at_pos(x, y) would work in
this case, too. (So this is what I would like, if it doesn't break
something else.)

-- 
Abel Daniel

ps. all this with 
 >>> gtk.gtk_version
(2, 4, 4)
I'm using the 2.3.94-1 .deb package from debian experimental
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to