]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
* prefer playlist item's meta title over its name, if available. This work-arounds...
[vlc] / modules / gui / macosx / playlist.m
index f9176885b06a2af9c9bb7562c964d9f8f8b8ddb0..aeba4123db44de9b6e763d23d30dbbcd27ed9b5c 100644 (file)
 
     if( i_return <= 0 )
         i_return = 0;
-NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name ); 
+
     return i_return;
 }
 
@@ -198,9 +198,7 @@ NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name );
     vlc_object_release( p_playlist );
 
     o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
-    #if 0
-    NSLog( @"%s", p_return->p_input->psz_name);
-    #endif
+
     if( o_value == nil )
     {
         o_value = [[NSValue valueWithPointer: p_return] retain];
@@ -231,11 +229,7 @@ NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name );
     }
     vlc_object_release( p_playlist );
 
-NSLog( @"expandable" ); 
-    if( i_return <= 0 )
-        return NO;
-    else
-        return YES;
+    return (i_return > 0);
 }
 
 /* retrieve the string values for the cells */
@@ -243,20 +237,50 @@ NSLog( @"expandable" );
 {
     id o_value = nil;
     playlist_item_t *p_item;
-    
-    if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
+
+    /* For error handling */
+    static BOOL attempted_reload = NO;
+
+    if( item == nil || ![item isKindOfClass: [NSValue class]] )
+    {
+        /* Attempt to fix the error by asking for a data redisplay
+         * This might cause infinite loop, so add a small check */
+        if( !attempted_reload )
+        {
+            attempted_reload = YES;
+            [outlineView reloadData];
+        }
+        return @"error" ;
+    }
     
     p_item = (playlist_item_t *)[item pointerValue];
-    if( p_item == NULL )
+    if( !p_item || !p_item->p_input )
     {
-        return( @"error");
+        /* Attempt to fix the error by asking for a data redisplay
+         * This might cause infinite loop, so add a small check */
+        if( !attempted_reload )
+        {
+            attempted_reload = YES;
+            [outlineView reloadData];
+        }
+        return @"error";
     }
-//NSLog( @"values for %p", p_item ); 
     
+    attempted_reload = NO;
+
     if( [[o_tc identifier] isEqualToString:@"1"] )
     {
         /* sanity check to prevent the NSString class from crashing */
-        if( p_item->p_input->psz_name != NULL )
+        if( p_item->p_input->p_meta && p_item->p_input->p_meta->psz_title && 
+            *p_item->p_input->p_meta->psz_title )
+        {
+            o_value = [NSString stringWithUTF8String:
+                p_item->p_input->p_meta->psz_title];
+            if( o_value == NULL )
+                o_value = [NSString stringWithCString:
+                    p_item->p_input->p_meta->psz_title];
+        } 
+        else if( p_item->p_input->psz_name != NULL )
         {
             o_value = [NSString stringWithUTF8String:
                 p_item->p_input->psz_name];
@@ -1459,6 +1483,13 @@ NSLog( @"expandable" );
         }
     }
 
+    /* Don't allow on drop on playlist root element's child */
+    if( !item && index != NSOutlineViewDropOnItemIndex)
+    {
+        vlc_object_release( p_playlist );
+        return NSDragOperationNone;
+    }
+
     /* We refuse to drop an item in anything else than a child of the General
        Node. We still accept items that would be root nodes of the outlineview
        however, to allow drop in an empty playlist. */