vlc | branch: master | Felix Paul Kühne <[email protected]> | Mon Jul  8 19:53:22 
2019 +0200| [0def47bd2533cd74519990e2948a3b9e386e7196] | committer: Felix Paul 
Kühne

macosx: drag and drop cleanup

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

 modules/gui/macosx/library/VLCLibraryDataTypes.h   |  2 +
 modules/gui/macosx/library/VLCLibraryDataTypes.m   |  2 +
 .../gui/macosx/library/VLCLibraryVideoDataSource.m |  5 +--
 .../gui/macosx/playlist/VLCPlaylistDataSource.m    |  6 +--
 modules/gui/macosx/views/VLCDragDropView.m         |  2 +-
 .../VLCConvertAndSaveWindowController.m            | 48 ++++------------------
 6 files changed, 17 insertions(+), 48 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h 
b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index f496d60dd9..d81be57384 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -25,6 +25,8 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+extern NSString *VLCMediaLibraryMediaItemPasteboardType;
+
 @class VLCMediaLibraryMediaItem;
 @class VLCInputItem;
 
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m 
b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index ffced77f9e..eb56aca49a 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -28,6 +28,8 @@
 
 #import <vlc_url.h>
 
+NSString *VLCMediaLibraryMediaItemPasteboardType = 
@"VLCMediaLibraryMediaItemPasteboardType";
+
 const CGFloat VLCMediaLibrary4KWidth = 3840.;
 const CGFloat VLCMediaLibrary4KHeight = 2160.;
 const CGFloat VLCMediaLibrary720pWidth = 1280.;
diff --git a/modules/gui/macosx/library/VLCLibraryVideoDataSource.m 
b/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
index fd3f6afb09..b6939fa5bc 100644
--- a/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
+++ b/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
@@ -111,9 +111,8 @@ writeItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
     }
 
     NSData *data = [NSKeyedArchiver archivedDataWithRootObject:mutableArray];
-    NSString *pasteboardType = NSStringFromClass([VLCMediaLibraryMediaItem 
class]);
-    [pasteboard declareTypes:@[pasteboardType] owner:self];
-    [pasteboard setData:data forType:pasteboardType];
+    [pasteboard declareTypes:@[VLCMediaLibraryMediaItemPasteboardType] 
owner:self];
+    [pasteboard setData:data forType:VLCMediaLibraryMediaItemPasteboardType];
 
     return YES;
 }
diff --git a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m 
b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
index d10c4b61b7..61a8b39391 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
@@ -50,8 +50,7 @@ static NSString *VLCPlaylistCellIdentifier = 
@"VLCPlaylistCellIdentifier";
 
 - (void)prepareForUse
 {
-    NSString *pasteboardType = NSStringFromClass([VLCMediaLibraryMediaItem 
class]);
-    [_tableView registerForDraggedTypes:@[pasteboardType, 
NSFilenamesPboardType]];
+    [_tableView 
registerForDraggedTypes:@[VLCMediaLibraryMediaItemPasteboardType, 
NSFilenamesPboardType]];
 }
 
 - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
@@ -116,8 +115,7 @@ static NSString *VLCPlaylistCellIdentifier = 
@"VLCPlaylistCellIdentifier";
               row:(NSInteger)row
     dropOperation:(NSTableViewDropOperation)dropOperation
 {
-    NSString *pasteboardType = NSStringFromClass([VLCMediaLibraryMediaItem 
class]);
-    NSData *data = [info.draggingPasteboard dataForType:pasteboardType];
+    NSData *data = [info.draggingPasteboard 
dataForType:VLCMediaLibraryMediaItemPasteboardType];
     if (!data) {
         id propertyList = [info.draggingPasteboard 
propertyListForType:NSFilenamesPboardType];
         if (propertyList == nil) {
diff --git a/modules/gui/macosx/views/VLCDragDropView.m 
b/modules/gui/macosx/views/VLCDragDropView.m
index 5daa1f5e77..7c96461be2 100644
--- a/modules/gui/macosx/views/VLCDragDropView.m
+++ b/modules/gui/macosx/views/VLCDragDropView.m
@@ -47,7 +47,7 @@
 
 - (void)enablePlaylistItems
 {
-    [self registerForDraggedTypes:[NSArray 
arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
+    [self registerForDraggedTypes:[NSArray 
arrayWithObjects:NSFilenamesPboardType, nil]];
 }
 
 - (BOOL)mouseDownCanMoveWindow
diff --git 
a/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m 
b/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m
index 13a4248dcd..c60a964286 100644
--- 
a/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m
+++ 
b/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m
@@ -331,9 +331,8 @@ NSString *VLCConvertAndSaveProfileNamesKey = 
@"CASProfileNames";
     [openPanel setResolvesAliases:YES];
     [openPanel setAllowsMultipleSelection:NO];
     [openPanel beginSheetModalForWindow:self.window 
completionHandler:^(NSInteger returnCode) {
-        if (returnCode == NSModalResponseOK)
-        {
-            [self setMRL: toNSStr(vlc_path2uri([[[openPanel URL] path] 
UTF8String], NULL))];
+        if (returnCode == NSModalResponseOK) {
+            [self setMRL: [[openPanel URL] absoluteString]];
             [self updateOKButton];
             [self updateDropView];
         }
@@ -641,7 +640,7 @@ NSString *VLCConvertAndSaveProfileNamesKey = 
@"CASProfileNames";
 
 - (BOOL)handlePasteBoardFromDragSession:(NSPasteboard *)paste
 {
-    NSArray *types = [NSArray arrayWithObjects:NSFilenamesPboardType, 
@"VLCPlaylistItemPboardType", nil];
+    NSArray *types = [NSArray arrayWithObjects:NSFilenamesPboardType, nil];
     NSString *desired_type = [paste availableTypeFromArray: types];
     NSData *carried_data = [paste dataForType: desired_type];
 
@@ -652,48 +651,17 @@ NSString *VLCConvertAndSaveProfileNamesKey = 
@"CASProfileNames";
         NSArray *values = [[paste propertyListForType: NSFilenamesPboardType] 
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
 
         if ([values count] > 0) {
-            [self setMRL: toNSStr(vlc_path2uri([[values firstObject] 
UTF8String], NULL))];
+            NSURL *url = [NSURL fileURLWithPath:[values firstObject] 
isDirectory:NO];
+            if (!url) {
+                return NO;
+            }
+            [self setMRL:url.absoluteString];
             [self updateOKButton];
             [self updateDropView];
             return YES;
         }
     }
 
-#if 0
-    // FIXME: re-implement drag-n-drop from the new playlist
-    else if ([desired_type isEqualToString:@"VLCPlaylistItemPboardType"]) {
-        NSArray *draggedItems = [[[VLCMain sharedInstance] playlist] 
draggedItems];
-
-        // Return early to prevent unnecessary playlist access/locking
-        if ([draggedItems count] <= 0) {
-            return NO;
-        }
-
-        playlist_t *p_playlist = pl_Get(getIntf());
-        playlist_item_t *p_item = NULL;
-
-        PL_LOCK;
-        for (VLCPLItem *draggedItem in draggedItems) {
-            p_item = playlist_ItemGetById(p_playlist, [draggedItem plItemId]);
-
-            // Check if the item is usable
-            if (!p_item || !p_item->p_input || !p_item->p_input->psz_uri) {
-                // Item not usable, reset it.
-                p_item = NULL;
-                continue;
-            }
-
-            // First usable item found
-            [self setMRL: toNSStr(p_item->p_input->psz_uri)];
-            [self updateDropView];
-            [self updateOKButton];
-            break;
-        }
-        PL_UNLOCK;
-
-        return (p_item != NULL) ? YES : NO;
-    }
-#endif
     return NO;
 }
 

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

Reply via email to