vlc | branch: master | Felix Paul Kühne <[email protected]> | Mon Jul  8 21:58:49 
2019 +0200| [88f70b22e59c40f80b6ac5f14fca7eb7a40611f2] | committer: Felix Paul 
Kühne

macosx/library: allow exporting files to other apps / open in other apps

This way, you can drag media to Mail or other apps to further process them

The file in question is neither moved nor modified through this operation

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

 modules/gui/macosx/library/VLCLibraryVideoDataSource.m | 17 +++++++++++++----
 modules/gui/macosx/library/VLCLibraryWindow.m          |  1 +
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryVideoDataSource.m 
b/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
index b6939fa5bc..7217ff962e 100644
--- a/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
+++ b/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
@@ -104,14 +104,23 @@ writeItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
         mediaArray = [_libraryModel listOfVideoMedia];
     }
 
-    NSMutableArray *mutableArray = [NSMutableArray 
arrayWithCapacity:indexPaths.count];
+    NSUInteger numberOfIndexPaths = indexPaths.count;
+    NSMutableArray *encodedLibraryItemsArray = [NSMutableArray 
arrayWithCapacity:numberOfIndexPaths];
+    NSMutableArray *filePathsArray = [NSMutableArray 
arrayWithCapacity:numberOfIndexPaths];
     for (NSIndexPath *indexPath in indexPaths) {
         VLCMediaLibraryMediaItem *mediaItem = mediaArray[indexPath.item];
-        [mutableArray addObject:mediaItem];
+        [encodedLibraryItemsArray addObject:mediaItem];
+
+        VLCMediaLibraryFile *file = mediaItem.files.firstObject;
+        if (file) {
+            NSURL *url = [NSURL URLWithString:file.MRL];
+            [filePathsArray addObject:url.path];
+        }
     }
 
-    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:mutableArray];
-    [pasteboard declareTypes:@[VLCMediaLibraryMediaItemPasteboardType] 
owner:self];
+    NSData *data = [NSKeyedArchiver 
archivedDataWithRootObject:encodedLibraryItemsArray];
+    [pasteboard declareTypes:@[VLCMediaLibraryMediaItemPasteboardType, 
NSFilenamesPboardType] owner:self];
+    [pasteboard setPropertyList:filePathsArray forType:NSFilenamesPboardType];
     [pasteboard setData:data forType:VLCMediaLibraryMediaItemPasteboardType];
 
     return YES;
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m 
b/modules/gui/macosx/library/VLCLibraryWindow.m
index 500cebcd55..97f091fb91 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -218,6 +218,7 @@ static int ShowController(vlc_object_t *p_this, const char 
*psz_variable,
     _recentVideoLibraryCollectionView.dataSource = _libraryVideoDataSource;
     _recentVideoLibraryCollectionView.delegate = _libraryVideoDataSource;
     [_recentVideoLibraryCollectionView 
registerClass:[VLCLibraryCollectionViewItem class] 
forItemWithIdentifier:VLCLibraryCellIdentifier];
+    [_videoLibraryCollectionView 
setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];
 
     _libraryAudioDataSource = [[VLCLibraryAudioDataSource alloc] init];
     _libraryAudioDataSource.libraryModel = 
mainInstance.libraryController.libraryModel;

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to