[vlc-commits] macosx: accept file drops on playlist

Felix Paul Kühne git at videolan.org
Mon Jul 8 21:38:04 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Jul  8 19:43:05 2019 +0200| [660c3e961f54adeaec72bcf87b073831c1af82f5] | committer: Felix Paul Kühne

macosx: accept file drops on playlist

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=660c3e961f54adeaec72bcf87b073831c1af82f5
---

 .../gui/macosx/playlist/VLCPlaylistDataSource.m    | 26 +++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
index c3110fde3c..d10c4b61b7 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
@@ -30,6 +30,7 @@
 #import "views/VLCDragDropView.h"
 #import "library/VLCLibraryDataTypes.h"
 #import "library/VLCInputItem.h"
+#import "windows/VLCOpenInputMetadata.h"
 
 static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
 
@@ -50,7 +51,7 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
 - (void)prepareForUse
 {
     NSString *pasteboardType = NSStringFromClass([VLCMediaLibraryMediaItem class]);
-    [_tableView registerForDraggedTypes:@[pasteboardType]];
+    [_tableView registerForDraggedTypes:@[pasteboardType, NSFilenamesPboardType]];
 }
 
 - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
@@ -118,6 +119,29 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
     NSString *pasteboardType = NSStringFromClass([VLCMediaLibraryMediaItem class]);
     NSData *data = [info.draggingPasteboard dataForType:pasteboardType];
     if (!data) {
+        id propertyList = [info.draggingPasteboard propertyListForType:NSFilenamesPboardType];
+        if (propertyList == nil) {
+            return NO;
+        }
+
+        NSArray *mediaPaths = [propertyList sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
+        NSUInteger mediaCount = [mediaPaths count];
+        if (mediaCount > 0) {
+            NSMutableArray *metadataArray = [NSMutableArray arrayWithCapacity:mediaCount];
+            for (NSUInteger i = 0; i < mediaCount; i++) {
+                VLCOpenInputMetadata *inputMetadata;
+                NSURL *url = [NSURL fileURLWithPath:mediaPaths[i] isDirectory:NO];
+                if (!url) {
+                    continue;
+                }
+                inputMetadata = [[VLCOpenInputMetadata alloc] init];
+                inputMetadata.MRLString = url.absoluteString;
+                [metadataArray addObject:inputMetadata];
+            }
+            [_playlistController addPlaylistItems:metadataArray];
+
+            return YES;
+        }
         return NO;
     }
     NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:data];



More information about the vlc-commits mailing list