+
+- (void)outlineView:(NSOutlineView *)outlineView
+ willDisplayCell:(id)cell
+ forTableColumn:(NSTableColumn *)tableColumn
+ item:(id)item
+{
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
+
+ if( !p_playlist ) return;
+
+ if( ( p_item == p_playlist->status.p_item ) ||
+ ( p_item->i_children != 0 &&
+ [self isItem: p_playlist->status.p_item inNode: p_item] ) )
+ {
+ [cell setFont: [NSFont boldSystemFontOfSize: 0]];
+ }
+ else
+ {
+ [cell setFont: [NSFont systemFontOfSize: 0]];
+ }
+ vlc_object_release( p_playlist );
+}
+
+@end
+
+@implementation VLCPlaylist (NSOutlineViewDataSource)
+
+/* return the number of children for Obj-C pointer item */ /* DONE */
+- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
+{
+ int i_return = 0;
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL || outlineView != o_outline_view )
+ return 0;
+
+ if( item == nil )
+ {
+ /* root object */
+ playlist_view_t *p_view;
+ p_view = playlist_ViewFind( p_playlist, i_current_view );
+ if( p_view && p_view->p_root )
+ {
+ i_return = p_view->p_root->i_children;
+ if( i_current_view == VIEW_CATEGORY )
+ {
+ i_return--; /* remove the GENERAL item from the list */
+ i_return += p_playlist->p_general->i_children; /* add the items of the general node */
+ }
+ }
+ }
+ 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 );
+
+ if( i_return <= 0 )
+ i_return = 0;
+
+ return i_return;
+}
+
+/* return the child at index for the Obj-C pointer item */ /* DONE */
+- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
+{
+ playlist_item_t *p_return = NULL;
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ NSValue *o_value;
+
+ if( p_playlist == NULL )
+ return nil;
+
+ if( item == nil )
+ {
+ /* root object */
+ playlist_view_t *p_view;
+ p_view = playlist_ViewFind( p_playlist, i_current_view );
+ if( p_view && p_view->p_root ) p_return = p_view->p_root->pp_children[index];
+
+ if( i_current_view == VIEW_CATEGORY )
+ {
+ if( p_playlist->p_general->i_children && index >= 0 && index < p_playlist->p_general->i_children )
+ {
+ p_return = p_playlist->p_general->pp_children[index];
+ }
+ else if( p_view && p_view->p_root && index >= 0 && index - p_playlist->p_general->i_children < p_view->p_root->i_children )
+ {
+ p_return = p_view->p_root->pp_children[index - p_playlist->p_general->i_children + 1];
+
+ }
+ }
+ }
+ else
+ {
+ playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
+ if( p_item && index < p_item->i_children && index >= 0 )
+ p_return = p_item->pp_children[index];
+ }
+
+ if( p_playlist->i_size >= 2 )
+ {
+ [o_status_field setStringValue: [NSString stringWithFormat:
+ _NS("%i items in playlist"), p_playlist->i_size]];
+ }
+ else
+ {
+ if( p_playlist->i_size == 0 )
+ {
+ [o_status_field setStringValue: [NSString stringWithFormat:
+ _NS("no items in playlist"), p_playlist->i_size]];
+ }
+ else
+ {
+ [o_status_field setStringValue: [NSString stringWithFormat:
+ _NS("1 item in playlist"), p_playlist->i_size]];
+ }
+ }
+
+ vlc_object_release( p_playlist );
+
+ o_value = [[NSValue valueWithPointer: p_return] retain];
+
+ [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p", p_return]];
+ 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 */
+ playlist_view_t *p_view;
+ p_view = playlist_ViewFind( p_playlist, i_current_view );
+ if( p_view && p_view->p_root ) i_return = p_view->p_root->i_children;
+
+ if( i_current_view == VIEW_CATEGORY )
+ {
+ i_return--;
+ i_return += p_playlist->p_general->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 );
+
+ 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