// Call this from a DragDrop event to receive the dragged widget
public static void Drop(Gdk.DragContext ctx, uint time, ObjectWrapper targetWrapper, string dropData)
{
if (dropCallback == null)
{
Gtk.Widget w = Drop(ctx, (Gtk.Widget)targetWrapper.Wrapped, time);
targetWrapper.DropObject(dropData, w);
return;
}
Cancel();
Gtk.Drag.Finish(ctx, true, true, time);
Gtk.Application.Invoke(delegate
{
IProject project = targetWrapper.Project;
string uid = targetWrapper.UndoId;
string tname = ((Wrapper.Widget)targetWrapper).GetTopLevel().Wrapped.Name;
// This call may cause the project to be reloaded
dragWidget = dropCallback();
if (dragWidget == null)
{
return;
}
if (targetWrapper.IsDisposed)
{
// The project has been reloaded. Find the wrapper again.
Gtk.Widget twidget = project.GetTopLevel(tname);
ObjectWrapper ow = ObjectWrapper.Lookup(twidget);
if (ow != null)
{
targetWrapper = ow.FindObjectByUndoId(uid);
}
else
{
targetWrapper = null;
}
if (targetWrapper == null)
{
// Target wrapper not found. Just ignore the drop.
return;
}
}
targetWrapper.DropObject(dropData, dragWidget);
});
}