Michael Urman <[EMAIL PROTECTED]> writes: > But what I still can't figure out is how to communicate these to the > user. There must be a way to tell GTK that i can't drop from that > source row to this dest row, so the DND doesn't look like it's going to > happen. > > I've tried connected 'drag-motion' events and conditionally calling > drag_context.set_reply(False, time) from it. Which does nothing until i > kill the normal handler, but then it just stops all drops. > > http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtktreedragdest.html > row_drop_possible() looks like the right idea, but i don't know how to > hook it up. Any suggestions?
This is an interesting question. I think the answer might require help from the experts like James Henstridge. >From what I can see, row_drop_possible() is part of the gtkTreeDragDest interface. It's a function provided by the treemodel. There isn't any gtk+ API provided to set it, although in C you might be able to assign to the appropriate structure element directly. A cleaner alternative in C would be to derive a subclass from TreeStore or ListStore and use your row_drop_possible() function in it. Unfortunately this doesn't help with pygtk, since although we can easily derive subclasses from TreeStore and ListStore to add methods, we can't override methods used internally in C by those objects. The row_drop_possible() method isn't associated with a signal, so that seems to be a dead end too. The pygtk GenericTreeModel lets you customize all of the basic methods of a TreeModel, but it doesn't include the gtkTreeDragDest and gtkTreeDragSource interfaces. Even if GenericTreeModel did include the gtkTreeDrag* interfaces it wouldn't be ideal for your situation. You really want to start from a standard TreeStore or ListStore and specify a tiny bit of custom dnd behavior rather than writing all the essential TreeModel methods yourself. An interesting contrast is provided by the gtkTreeSortable interface. It provides methods to set the sort function so we can customize the sorting behavior without having to subclass or muck about on the C level. It may be that the gtkTreeDragSource and gtkTreeDragDest interfaces don't provide any setter methods because it was thought that if the default dnd behavior wasn't satisfactory, you should either subclass or handle all the details by hand. I think that's a shame. Just being able to specify the row_draggable() and row_drop_possible() functions might cover a significant number of use cases. So, you need to check this with someone who really understands the details to make sure I haven't gotten it all wrong. I see three possibilities: 1) lobby the gtk+ treeview crew to add setter methods to the gtkTreeDragDest and gtkTreeDragSource interfaces, 2) enhance the pygtk GenericTreeModel to include support for those interfaces or 3) handle the drag and drop details yourself. _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
