]> git.sesse.net Git - vlc/commitdiff
* Some fixes
authorBenjamin Pracht <bigben@videolan.org>
Thu, 30 Jun 2005 15:08:08 +0000 (15:08 +0000)
committerBenjamin Pracht <bigben@videolan.org>
Thu, 30 Jun 2005 15:08:08 +0000 (15:08 +0000)
* Store object to move in the class itself, since I just don't manage to deal with NSPasteboards...

modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index 05bd72fbc5893c3e7a81878e0fd513f93a77d4ee..d285b95905fa42c36aafcbb4bbcfec59601cb1b8 100644 (file)
@@ -70,6 +70,8 @@
     NSImage *o_descendingSortingImage;
     NSImage *o_ascendingSortingImage;
 
+    NSMutableArray *o_nodes_array;
+    NSMutableArray *o_items_array;
     NSMutableDictionary *o_outline_dict;
 
     BOOL b_selected_item_met;
index b99a80e0c23f495760a0f8d219d9b99cc47f0c2f..23ffeca18f96f240a7f5f45b75b76a57f3e17946 100644 (file)
     if ( self != nil )
     {
         o_outline_dict = [[NSMutableDictionary alloc] init];
+        o_nodes_array = [[NSMutableArray alloc] init];
+        o_items_array = [[NSMutableArray alloc] init];
+
+
         //i_moveRow = -1;
     }
     return self;
@@ -365,6 +369,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
         return NO;
     }
 
+    if( p_node == p_item ) return YES;
+
     if ( p_temp_item )
     {
         int i;
@@ -1353,14 +1359,11 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     unsigned int i,j;
     playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
                                                FIND_ANYWHERE );
-    NSMutableArray *o_nodes_array = [NSMutableArray array];
-    NSMutableArray *o_items_array = [NSMutableArray array];
-    NSMutableArray *o_objects_array = [NSMutableArray array];
 
-    if( !p_playlist ) return NO;
+    [o_items_array removeAllObjects];
+    [o_nodes_array removeAllObjects];
 
-    [pboard declareTypes: [NSArray arrayWithObjects:
-        @"VLCPlaylistItemPboardType", NSFilenamesPboardType, nil] owner: self];
+    if( !p_playlist ) return NO;
 
     for( i = 0 ; i < [items count] ; i++ )
     {
@@ -1408,21 +1411,13 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
                 i--;
                 break;
             }
-            if( j == [o_nodes_array count] ) i++;
         }
     }
 
-    [o_objects_array addObjectsFromArray: o_nodes_array];
-    [o_objects_array addObjectsFromArray: o_items_array];
-
-    if( ![pboard setPropertyList: o_objects_array
-            forType:@"VLCPlaylistItemPboardType"] ||
-            ![pboard setPropertyList: [NSArray array]
-            forType:@"VLCPlaylistItemPboardType"])
-    {
-        vlc_object_release(p_playlist);
-        return NO;
-    }
+    [pboard declareTypes: [NSArray arrayWithObjects:
+        @"VLCPlaylistItemPboardType",NSFilenamesPboardType, nil] owner: self];
+    [pboard setPropertyList:[NSArray array]
+                                        forType:NSFilenamesPboardType];
 
     vlc_object_release(p_playlist);
     return YES;
@@ -1436,17 +1431,28 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
     if( !p_playlist ) return NSDragOperationNone;
 
+    if( ![self isItem: [item pointerValue] inNode: p_playlist->p_general] )
+    return NSDragOperationNone;
+
     /* Drop from the Playlist */
-    if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] &&
-        [self isItem: [item pointerValue] inNode: p_playlist->p_general])
+    if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
     {
+        unsigned int i;
+        for( i = 0 ; i < [o_nodes_array count] ; i++ )
+        {
+            if( [self isItem: [item pointerValue] inNode:
+                            [[o_nodes_array objectAtIndex: i] pointerValue]]  )
+            {
+                vlc_object_release(p_playlist);
+                return NSDragOperationNone;
+            }
+        }
         vlc_object_release(p_playlist);
         return NSDragOperationMove;
     }
 
     /* Drop from the Finder */
-    else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] &&
-        ![[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"])
+    else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
     {
         vlc_object_release(p_playlist);
         return NSDragOperationGeneric;