[vlc-commits] macosx: playlist context menu: Improve add files

David Fuhrmann git at videolan.org
Sun Feb 12 13:14:02 CET 2017


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Feb 12 13:12:28 2017 +0100| [e52a34f924e0bf9438df23c6e8de796fe7a50e56] | committer: David Fuhrmann

macosx: playlist context menu: Improve add files

Only enqueue the files. Add them under the selected item.

refs #17726

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

 modules/gui/macosx/VLCMainMenu.m             |  4 +++-
 modules/gui/macosx/VLCOpenWindowController.h |  3 ++-
 modules/gui/macosx/VLCOpenWindowController.m |  6 ++----
 modules/gui/macosx/VLCPlaylist.h             |  4 ++--
 modules/gui/macosx/VLCPlaylist.m             | 19 ++++++++++++++++++-
 5 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index 920137c..73c467e 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -1074,7 +1074,9 @@
 
 - (IBAction)intfOpenFile:(id)sender
 {
-    [[[VLCMain sharedInstance] open] openFile];
+    [[[VLCMain sharedInstance] open] openFileWithAction:^(NSArray *files) {
+        [[[VLCMain sharedInstance] playlist] addPlaylistItems:files];
+    }];
 }
 
 - (IBAction)intfOpenFileGeneric:(id)sender
diff --git a/modules/gui/macosx/VLCOpenWindowController.h b/modules/gui/macosx/VLCOpenWindowController.h
index c1f5633..c481d78 100644
--- a/modules/gui/macosx/VLCOpenWindowController.h
+++ b/modules/gui/macosx/VLCOpenWindowController.h
@@ -230,5 +230,6 @@
 - (IBAction)panelCancel:(id)sender;
 - (IBAction)panelOk:(id)sender;
 
-- (void)openFile;
+- (void)openFileWithAction:(void (^)(NSArray *files))action;
+
 @end
diff --git a/modules/gui/macosx/VLCOpenWindowController.m b/modules/gui/macosx/VLCOpenWindowController.m
index 8ffafb3..139b191 100644
--- a/modules/gui/macosx/VLCOpenWindowController.m
+++ b/modules/gui/macosx/VLCOpenWindowController.m
@@ -610,7 +610,7 @@ static NSString *kCaptureTabViewId  = @"capture";
     [self openTarget: kCaptureTabViewId];
 }
 
-- (void)openFile
+- (void)openFileWithAction:(void (^)(NSArray *files))action;
 {
     NSOpenPanel *openPanel = [NSOpenPanel openPanel];
     [openPanel setAllowsMultipleSelection: YES];
@@ -633,13 +633,11 @@ static NSString *kCaptureTabViewId  = @"capture";
             if (!psz_uri)
                 continue;
             dictionary = [NSDictionary dictionaryWithObject:toNSStr(psz_uri) forKey:@"ITEM_URL"];
-            NSLog(@"dict: %@", dictionary);
             free(psz_uri);
             [array addObject: dictionary];
         }
 
-        NSLog(@"adding %@", array);
-        [[[VLCMain sharedInstance] playlist] addPlaylistItems:array];
+        action(array);
     }
 }
 
diff --git a/modules/gui/macosx/VLCPlaylist.h b/modules/gui/macosx/VLCPlaylist.h
index cb80656..6416708 100644
--- a/modules/gui/macosx/VLCPlaylist.h
+++ b/modules/gui/macosx/VLCPlaylist.h
@@ -74,9 +74,9 @@
 
 /**
  * Simplified version to add new items at the end of the current playlist
- * @param o_array array of items. Each item is a Dictionary with meta info.
+ * @param array array of items. Each item is a Dictionary with meta info.
  */
-- (void)addPlaylistItems:(NSArray*)o_array;
+- (void)addPlaylistItems:(NSArray*)array;
 
 /**
  * Add new items to playlist, with the possibility to check if an item can be added
diff --git a/modules/gui/macosx/VLCPlaylist.m b/modules/gui/macosx/VLCPlaylist.m
index dced430..70170fd 100644
--- a/modules/gui/macosx/VLCPlaylist.m
+++ b/modules/gui/macosx/VLCPlaylist.m
@@ -341,7 +341,24 @@
 
 - (IBAction)addFilesToPlaylist:(id)sender
 {
-    [[[VLCMain sharedInstance] open] openFile];
+    NSIndexSet *selectedRows = [_outlineView selectedRowIndexes];
+
+    NSInteger position = -1;
+    VLCPLItem *parentItem = [[self model] rootItem];
+
+    if (selectedRows.count >= 1) {
+        position = selectedRows.firstIndex + 1;
+        parentItem = [_outlineView itemAtRow:selectedRows.firstIndex];
+        if ([parentItem parent] != nil)
+            parentItem = [parentItem parent];
+    }
+
+    [[[VLCMain sharedInstance] open] openFileWithAction:^(NSArray *files) {
+        [self addPlaylistItems:files
+              withParentItemId:[parentItem plItemId]
+                         atPos:position
+                 startPlayback:NO];
+    }];
 }
 
 - (IBAction)deleteItem:(id)sender



More information about the vlc-commits mailing list