]> git.sesse.net Git - vlc/commitdiff
macosx: implemented drag & drop from playlist to media library and vice verca. additi...
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 8 Apr 2012 19:20:47 +0000 (21:20 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 8 Apr 2012 19:21:19 +0000 (21:21 +0200)
extras/package/macosx/Resources/English.lproj/MainMenu.xib
modules/gui/macosx/MainWindow.m
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index 5078bf5899c3814ce59f2c80d84aa16ab0482bdf..11ee3ff7a4f454a8b5667fbea6b161f578ae5603 100644 (file)
     <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
       <bool key="EncodedWithXMLCoder">YES</bool>
       <integer value="4850"/>
-      <integer value="29"/>
+      <integer value="2770"/>
       <integer value="4596"/>
-      <integer value="4722"/>
-      <integer value="21"/>
       <integer value="1617"/>
-      <integer value="2730"/>
+      <integer value="29"/>
+      <integer value="4722"/>
       <integer value="4948"/>
-      <integer value="2770"/>
       <integer value="915"/>
+      <integer value="2730"/>
+      <integer value="21"/>
     </object>
     <object class="NSArray" key="IBDocument.PluginDependencies">
       <bool key="EncodedWithXMLCoder">YES</bool>
@@ -89,7 +89,7 @@
                             <bool key="EncodedWithXMLCoder">YES</bool>
                             <object class="NSOutlineView" id="1064884668">
                               <reference key="NSNextResponder" ref="18556274"/>
-                              <int key="NSvFlags">4354</int>
+                              <int key="NSvFlags">258</int>
                               <string key="NSFrameSize">{199, 272}</string>
                               <reference key="NSSuperview" ref="18556274"/>
                               <int key="NSViewLayerContentsRedrawPolicy">2</int>
index 1373befd38a7ad6f38ae3719449126e032348d15..e83ebbd3c99a184b4e09cbb189e83a01efa19a3d 100644 (file)
@@ -446,6 +446,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
     for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
         [o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
     [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
+    [o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
+    [o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
 
     if( b_dark_interface )
     {
@@ -2239,6 +2241,72 @@ static VLCMainWindow *_o_sharedInstance = nil;
     PL_UNLOCK;
 }
 
+- (NSDragOperation)sourceList:(PXSourceList *)aSourceList validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
+{
+    if ([[item identifier] isEqualToString:@"playlist"] || [[item identifier] isEqualToString:@"medialibrary"] )
+    {
+        NSPasteboard *o_pasteboard = [info draggingPasteboard];
+        if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] || [[o_pasteboard types] containsObject: NSFilenamesPboardType])
+            return NSDragOperationGeneric;
+    }
+    return NSDragOperationNone;
+}
+
+- (BOOL)sourceList:(PXSourceList *)aSourceList acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
+{
+    NSPasteboard *o_pasteboard = [info draggingPasteboard];
+
+    playlist_t * p_playlist = pl_Get( VLCIntf );
+    playlist_item_t *p_node;
+
+    if ([[item identifier] isEqualToString:@"playlist"])
+        p_node = p_playlist->p_local_category;
+    else
+        p_node = p_playlist->p_ml_category;
+
+    if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
+    {
+        NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
+        NSUInteger count = [o_values count];
+        NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
+
+        for( NSUInteger i = 0; i < count; i++)
+        {
+            NSDictionary *o_dic;
+            char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL);
+            if( !psz_uri )
+                continue;
+
+            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+
+            free( psz_uri );
+
+            [o_array addObject: o_dic];
+        }
+
+        [[[VLCMain sharedInstance] playlist] appendNodeArray:o_array inNode: p_node atPos:-1 enqueue:YES];
+        return YES;
+    }
+    else if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
+    {
+        NSArray * array = [[[VLCMain sharedInstance] playlist] draggedItems];
+
+        NSUInteger count = [array count];
+        playlist_item_t * p_item = NULL;
+
+        PL_LOCK;
+        for( NSUInteger i = 0; i < count; i++ )
+        {
+            p_item = [[array objectAtIndex:i] pointerValue];
+            if( !p_item ) continue;
+            playlist_NodeAddCopy( p_playlist, p_item, p_node, PLAYLIST_END );
+        }
+        PL_UNLOCK;
+
+        return YES;
+    }
+    return NO;
+}
 @end
 
 @implementation VLCDetachedVideoWindow
index 00d405b8a5b7dbd3e84ad229b84bf07dec9a2968..8fc879ea4b4f6b84e52b784592ce83393d20c474 100644 (file)
 - (IBAction)recursiveExpandNode:(id)sender;
 
 - (id)playingItem;
+- (NSArray *)draggedItems;
 
 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue;
 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue;
index 26a257712e6a4f71e8471b7c9930e09564e9c8ed..14c0f2b42c6f4c846145189c8c92845e3a19b789 100644 (file)
 
     return o_playing_item;
 }
+
+- (NSArray *)draggedItems
+{
+    return [[o_nodes_array arrayByAddingObjectsFromArray: o_items_array] retain];
+}
 @end
 
 @implementation VLCPlaylist (NSOutlineViewDataSource)
     {
         id o_item = [items objectAtIndex: i];
 
-        /* Refuse to move items that are not in the General Node
-           (Service Discovery) */
-        if( (![self isItem: [o_item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] &&
-            var_CreateGetBool( p_playlist, "media-library" ) && ![self isItem: [o_item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO]) ||
-            [o_item pointerValue] == p_playlist->p_local_category ||
-            [o_item pointerValue] == p_playlist->p_ml_category )
-        {
-            return NO;
-        }
         /* Fill the items and nodes to move in 2 different arrays */
         if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
             [o_nodes_array addObject: o_item];
     {
         int i_row, i_removed_from_node = 0;
         playlist_item_t *p_new_parent, *p_item = NULL;
-        NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
-                                                                o_items_array];
+        NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray: o_items_array];
         /* If the item is to be dropped as root item of the outline, make it a
            child of the respective general node, if is either the pl or the ml
            Else, choose the proposed parent as parent. */