+- (BOOL)tableView:(NSTableView *)o_tv
+ writeRows:(NSArray*)o_rows
+ toPasteboard:(NSPasteboard*)o_pasteboard
+{
+ int i_rows = [o_rows count];
+ NSArray *o_filenames = [NSArray array];
+
+ [o_pasteboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:self];
+ [o_pasteboard setPropertyList:o_filenames forType:NSFilenamesPboardType];
+ if ( i_rows == 1 )
+ {
+ i_moveRow = [[o_rows objectAtIndex:0]intValue];
+ return YES;
+ }
+ return NO;
+}
+
+- (NSDragOperation)tableView:(NSTableView*)o_tv
+ validateDrop:(id <NSDraggingInfo>)o_info
+ proposedRow:(int)i_row
+ proposedDropOperation:(NSTableViewDropOperation)o_operation
+{
+ if ( o_operation == NSTableViewDropAbove )
+ {
+ if ( i_moveRow >= 0 )
+ {
+ if ( i_row != i_moveRow )
+ {
+ return NSDragOperationMove;
+ }
+ /* what if in the previous run, the row wasn't actually moved?
+ then we can't drop new files on this location */
+ return NSDragOperationNone;
+ }
+ return NSDragOperationGeneric;
+ }
+ return NSDragOperationNone;
+}
+
+- (BOOL)tableView:(NSTableView*)o_tv
+ acceptDrop:(id <NSDraggingInfo>)o_info
+ row:(int)i_proposed_row
+ dropOperation:(NSTableViewDropOperation)o_operation
+{
+ if ( i_moveRow >= 0 )
+ {
+ if (i_moveRow != -1 && i_proposed_row != -1)
+ {
+ intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+
+ if( p_playlist == NULL )
+ {
+ i_moveRow = -1;
+ return NO;
+ }
+
+ playlist_Move( p_playlist, i_moveRow, i_proposed_row );
+
+ vlc_object_release( p_playlist );
+ }
+ [self playlistUpdated];
+ i_moveRow = -1;
+ return YES;
+ }
+ else
+ {
+ NSArray * o_values;
+ NSPasteboard * o_pasteboard;
+
+ intf_thread_t * p_intf = [NSApp getIntf];
+ o_pasteboard = [o_info draggingPasteboard];
+
+ if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
+ {
+ o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType]
+ sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
+ [self appendArray: o_values atPos: i_proposed_row enqueue:YES];
+
+ config_PutPsz( p_intf, "sub-file", "" );
+ config_PutInt( p_intf, "sub-delay", 0 );
+ config_PutFloat( p_intf, "sub-fps", 0.0 );
+ config_PutPsz( p_intf, "sout", "" );
+
+ return( YES );
+ }
+
+ return( NO );
+ }
+ [self updateRowSelection];
+}
+