if( i_return <= 0 )
i_return = 0;
-NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name );
+
return i_return;
}
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];
}
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 */
{
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 )
+ char *psz_title = input_item_GetTitle( p_item->p_input );
+ if( !EMPTY_STR( psz_title ) )
{
- o_value = [NSString stringWithUTF8String:
- p_item->p_input->psz_name];
+ o_value = [NSString stringWithUTF8String: psz_title];
if( o_value == NULL )
- o_value = [NSString stringWithCString:
- p_item->p_input->psz_name];
+ o_value = [NSString stringWithCString: psz_title];
+ }
+ else
+ {
+ char *psz_name = input_item_GetName( p_item->p_input );
+ if( psz_name != NULL )
+ {
+ o_value = [NSString stringWithUTF8String: psz_name];
+ if( o_value == NULL )
+ o_value = [NSString stringWithCString: psz_name];
+ }
+ free( psz_name );
}
+ free( psz_title );
}
- else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
- p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
- {
- o_value = [NSString stringWithUTF8String:
- p_item->p_input->p_meta->psz_artist];
- if( o_value == NULL )
- o_value = [NSString stringWithCString:
- p_item->p_input->p_meta->psz_artist];
- }
- else if( [[o_tc identifier] isEqualToString:@"3"] )
+ else
{
- char psz_duration[MSTRTIME_MAX_SIZE];
- mtime_t dur = p_item->p_input->i_duration;
- if( dur != -1 )
+ char *psz_artist = input_item_GetArtist( p_item->p_input );
+ if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
{
- secstotimestr( psz_duration, dur/1000000 );
- o_value = [NSString stringWithUTF8String: psz_duration];
+ o_value = [NSString stringWithUTF8String: psz_artist];
+ if( o_value == NULL )
+ o_value = [NSString stringWithCString: psz_artist];
}
- else
+ else if( [[o_tc identifier] isEqualToString:@"3"] )
{
- o_value = @"-:--:--";
+ char psz_duration[MSTRTIME_MAX_SIZE];
+ mtime_t dur = input_item_GetDuration( p_item->p_input );
+ if( dur != -1 )
+ {
+ secstotimestr( psz_duration, dur/1000000 );
+ o_value = [NSString stringWithUTF8String: psz_duration];
+ }
+ else
+ {
+ o_value = @"-:--:--";
+ }
}
+ free( psz_artist );
}
return( o_value );
NSMenuItem *o_mi = (NSMenuItem *)sender;
NSString *o_string = [o_mi representedObject];
playlist_t * p_playlist = pl_Yield( VLCIntf );
- if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string cString] ) )
- playlist_ServicesDiscoveryAdd( p_playlist, [o_string cString] );
+ if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
+ playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
else
- playlist_ServicesDiscoveryRemove( p_playlist, [o_string cString] );
+ playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
[o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
- [o_string cString] ) ? YES : NO];
+ [o_string UTF8String] ) ? YES : NO];
vlc_object_release( p_playlist );
[self playlistUpdated];
{
playlist_item_t *p_item;
p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_item );
}
else
{
playlist_item_t *p_item;
p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
- playlist_Control( p_playlist, PLAYLIST_PREPARSE, VLC_TRUE, p_item );
+ playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
}
}
[self playlistUpdated];
{
playlist_item_t *p_item;
p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_item );
}
else
{
playlist_item_t *p_item;
p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
- playlist_Control( p_playlist, PLAYLIST_PREPARSE, VLC_TRUE, p_item );
+ playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
}
}
[self playlistUpdated];
}
}
+ /* 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. */