[pygtk] A ListView component with easier API
François Ingelrest
athropos at gmail.com
Wed Oct 10 14:16:53 WST 2007
Hi,
On 10/10/07, Seltzer <squabbit7 at gmail.com> wrote:
> i was wondering how you accomplished "Prevents moving a row into another
> row".
> was it a settings thing? or a check if it happed and stop it?
You have to connect an handler to the drag-motion signal. Then you
have to change the accepted targets to something invalid when the drop
position is not something you want to accept, or to your normal
targets when it's a correct position.
So your handler would look like this:
def onDragMotion(self, tree, context, x, y, time):
drop = self.get_dest_row_at_pos(int(x), int(y))
if drop is not None and (drop[1] == gtk.TREE_VIEW_DROP_INTO_OR_AFTER
or drop[1] == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
self.enable_model_drag_dest([('invalid-position', 0, -1)],
gdk.ACTION_DEFAULT)
else:
self.enable_model_drag_dest(self.dndTargets, gdk.ACTION_DEFAULT)
This assumes that self.dndTargets contain a list of your standard targets.
More information about the pygtk
mailing list