+ if( p_item && index < p_item->i_children && index >= 0 )
+ p_return = p_item->pp_children[index];
+
+ vlc_object_release( p_playlist );
+
+ o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
+ NSLog( @"%s", p_return->p_input->psz_name);
+ if( o_value == nil )
+ {
+ o_value = [[NSValue valueWithPointer: p_return] retain];
+ NSLog( @"error missing value" );
+ }
+ return o_value;
+}
+
+/* is the item expandable */
+- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
+{
+ int i_return = 0;
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ return NO;
+
+ if( item == nil )
+ {
+ /* root object */
+ if( p_playlist->p_root_category )
+ {
+ i_return = p_playlist->p_root_category->i_children;
+ }
+ }
+ else
+ {
+ playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
+ if( p_item )
+ i_return = p_item->i_children;
+ }
+ vlc_object_release( p_playlist );
+
+NSLog( @"expandable" );
+ if( i_return <= 0 )
+ return NO;
+ else
+ return YES;
+}
+
+/* retrieve the string values for the cells */
+- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
+{
+ id o_value = nil;
+ intf_thread_t *p_intf = VLCIntf;
+ playlist_t *p_playlist;
+ playlist_item_t *p_item;
+
+ if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
+
+ /* Check to see if the playlist is present */
+ p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+ if( p_playlist == NULL ) return( @"error");
+ vlc_object_release( p_playlist);
+
+ p_item = (playlist_item_t *)[item pointerValue];
+ if( p_item == NULL )
+ {
+ return( @"error");
+ }
+//NSLog( @"values for %p", p_item );
+
+ if( [[o_tc identifier] isEqualToString:@"1"] )
+ {
+ o_value = [NSString stringWithUTF8String:
+ p_item->p_input->psz_name];
+ if( o_value == NULL )
+ o_value = [NSString stringWithCString:
+ p_item->p_input->psz_name];
+ }
+ 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"] )
+ {
+ char psz_duration[MSTRTIME_MAX_SIZE];
+ mtime_t dur = p_item->p_input->i_duration;
+ if( dur != -1 )
+ {
+ secstotimestr( psz_duration, dur/1000000 );
+ o_value = [NSString stringWithUTF8String: psz_duration];
+ }
+ else
+ {
+ o_value = @"-:--:--";
+ }
+ }
+
+ return( o_value );
+}
+
+@end
+
+/*****************************************************************************
+ * VLCPlaylistWizard implementation
+ *****************************************************************************/
+@implementation VLCPlaylistWizard
+
+- (IBAction)reloadOutlineView
+{
+ /* Only reload the outlineview if the wizard window is open since this can
+ be quite long on big playlists */
+ if( [[o_outline_view window] isVisible] )
+ {
+ [o_outline_view reloadData];
+ }
+}
+
+@end
+
+/*****************************************************************************
+ * extension to NSOutlineView's interface to fix compilation warnings
+ * and let us access these 2 functions properly
+ * this uses a private Apple-API, but works fine on all current OSX releases
+ * keep checking for compatiblity with future releases though
+ *****************************************************************************/
+
+@interface NSOutlineView (UndocumentedSortImages)
++ (NSImage *)_defaultTableHeaderSortImage;
++ (NSImage *)_defaultTableHeaderReverseSortImage;
+@end
+
+
+/*****************************************************************************
+ * VLCPlaylist implementation
+ *****************************************************************************/
+@implementation VLCPlaylist
+
+- (id)init
+{
+ self = [super init];
+ if ( self != nil )
+ {
+ o_nodes_array = [[NSMutableArray alloc] init];
+ o_items_array = [[NSMutableArray alloc] init];
+ }
+ return self;
+}
+
+- (void)awakeFromNib
+{
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE,
+ FIND_ANYWHERE );
+
+ int i_index;
+
+ [super awakeFromNib];
+
+ [o_outline_view setDoubleAction: @selector(playItem:)];
+
+ [o_outline_view registerForDraggedTypes:
+ [NSArray arrayWithObjects: NSFilenamesPboardType,
+ @"VLCPlaylistItemPboardType", nil]];
+ [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
+
+ /* this uses private Apple API which works fine until 10.4,
+ * but keep checking in the future!
+ * These methods are being added artificially to NSOutlineView's interface above */
+ o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
+ o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];