/// <summary> /// Emitted on the drag source when the drag finishes /// </summary> void HandleDragEnd(object o, DragEndArgs args) { if (RepositionMode) { Owner.CursorTracker.CursorPositionChanged -= HandleCursorPositionChanged; } if (!drag_canceled && drag_item != null) { if (!Owner.DockHovered) { // Remove from dock AbstractDockItemProvider provider = ProviderForItem(drag_item); bool poof = false; if (provider != null && provider.ItemCanBeRemoved(drag_item)) { // provider can manually remove provider.RemoveItem(drag_item); if (FileApplicationProvider.WindowManager != null) { FileApplicationProvider.WindowManager.UpdateTransientItems(); } poof = true; } if (poof) { PoofWindow window = new PoofWindow(128); window.SetCenterPosition(Owner.CursorTracker.Cursor); window.Run(); } } else { // Dropped somewhere on dock AbstractDockItem item = Owner.HoveredItem; if (item != null && item.CanAcceptDrop(drag_item)) { item.AcceptDrop(drag_item); } } } InternalDragActive = false; drag_item = null; Keyboard.Ungrab(Gtk.Global.CurrentEventTime); Owner.AnimatedDraw(); Owner.CursorTracker.CancelHighResolution(this); }
/// <summary> /// Emitted on the drop site when the user drops data on the widget. /// </summary> void HandleDragDrop(object o, DragDropArgs args) { args.RetVal = true; Gtk.Drag.Finish(args.Context, true, false, args.Time); if (drag_data == null) { return; } AbstractDockItem item = Owner.HoveredItem; if (ItemAcceptsDrop()) { item.AcceptDrop(drag_data); } else if (providersAcceptDrops) { AbstractDockItem rightMost = Owner.RightMostItem; int newPosition = rightMost != null ? rightMost.Position : 0; foreach (string s in drag_data) { AbstractDockItemProvider provider; if (Owner.HoveredProvider != null && Owner.HoveredProvider.CanAcceptDrop(s)) { provider = Owner.HoveredProvider; } else if (Owner.Preferences.DefaultProvider.CanAcceptDrop(s)) { provider = Owner.Preferences.DefaultProvider; } else { // nothing will take it, continue! continue; } provider.AcceptDrop(s, newPosition); if (FileApplicationProvider.WindowManager != null) { FileApplicationProvider.WindowManager.UpdateTransientItems(); } } } ExternalDragActive = false; }