1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2004 VideoLAN
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Derk-Jan Hartman <hartman at videolan dot org>
9 * Benjamin Pracht <bigben at videolab dot org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
27 * add 'icons' for different types of nodes? (http://www.cocoadev.com/index.pl?IconAndTextInTableCell)
28 * create a new 'playlist toggle' that hides the playlist and in effect give you the old controller
29 * create a new search field build with pictures from the 'regular' search field, so it can be emulated on 10.2
30 * create toggle buttons for the shuffle, repeat one, repeat all functions.
31 * implement drag and drop and item reordering.
32 * reimplement enable/disable item
33 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
34 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
39 /*****************************************************************************
41 *****************************************************************************/
42 #include <stdlib.h> /* malloc(), free() */
43 #include <sys/param.h> /* for MAXPATHLEN */
46 #include <sys/mount.h>
55 #define REF_HEIGHT 500
58 /*****************************************************************************
59 * VLCPlaylistView implementation
60 *****************************************************************************/
61 @implementation VLCPlaylistView
63 - (NSMenu *)menuForEvent:(NSEvent *)o_event
65 return( [[self delegate] menuForEvent: o_event] );
68 - (void)keyDown:(NSEvent *)o_event
72 if( [[o_event characters] length] )
74 key = [[o_event characters] characterAtIndex: 0];
79 case NSDeleteCharacter:
80 case NSDeleteFunctionKey:
81 case NSDeleteCharFunctionKey:
82 case NSBackspaceCharacter:
83 [[self delegate] deleteItem:self];
87 [super keyDown: o_event];
94 /*****************************************************************************
95 * VLCPlaylist implementation
96 *****************************************************************************/
97 @implementation VLCPlaylist
111 [o_outline_view setTarget: self];
112 [o_outline_view setDelegate: self];
113 [o_outline_view setDataSource: self];
115 [o_outline_view setDoubleAction: @selector(playItem:)];
117 [o_outline_view registerForDraggedTypes:
118 [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
119 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
121 /* We need to check whether _defaultTableHeaderSortImage exists, since it
122 belongs to an Apple hidden private API, and then can "disapear" at any time*/
124 if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderSortImage)] )
126 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
130 o_ascendingSortingImage = nil;
133 if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)] )
135 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
139 o_descendingSortingImage = nil;
142 o_outline_dict = [[NSMutableDictionary alloc] init];
143 o_tc_sortColumn = nil;
146 //[self playlistUpdated];
151 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
152 [o_mi_play setTitle: _NS("Play")];
153 [o_mi_delete setTitle: _NS("Delete")];
154 [o_mi_selectall setTitle: _NS("Select All")];
155 [o_mi_info setTitle: _NS("Properties")];
156 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
157 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
158 [[o_tc_name headerCell] setStringValue:_NS("Name")];
159 [[o_tc_author headerCell] setStringValue:_NS("Author")];
160 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
161 [o_status_field setStringValue: [NSString stringWithFormat:
162 _NS("0 items in playlist")]];
164 [o_random_ckb setTitle: _NS("Random")];
166 [o_search_button setTitle: _NS("Search")];
168 [o_btn_playlist setToolTip: _NS("Playlist")];
169 [[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
170 [[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
171 [[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
174 - (IBAction)toggleWindow:(id)sender
177 /*First, check if the playlist is visible*/
178 if ( [o_controller frame].size.height == [o_controller minSize].height )
180 /*Check if the stored heigth of the controller is usable (!= minSize)*/
181 if ([o_controller getSizeWithPlaylist].height !=
182 [o_controller minSize].height)
184 o_rect.size.height = [o_controller getSizeWithPlaylist].height;
188 /*If the stored height is not usable, use a reference one*/
189 o_rect.size.height = REF_HEIGHT;
192 /*Check if the controller width is the minimum one*/
193 if ( [o_controller frame].size.width == [o_controller minSize].width)
195 /*If the controller width is minimum, check if the stored height
196 of the playlist makes it visible*/
197 if ([o_controller getSizeWithPlaylist].height !=
198 [o_controller minSize].height)
200 o_rect.size.width = [o_controller getSizeWithPlaylist].width;
204 /*If not, use a reference width*/
205 o_rect.size.width = REF_WIDTH;
210 o_rect.size.width = [o_controller frame].size.width;
212 o_rect.origin.x = [o_controller frame].origin.x;
213 o_rect.origin.y = [o_controller frame].origin.y - o_rect.size.height +
214 [o_controller minSize].height;
216 [o_btn_playlist setState: YES];
220 o_rect.size = [o_controller minSize];
221 o_rect.origin.x = [o_controller frame].origin.x;
222 /*Calculate the position of the lower right corner after resize*/
223 o_rect.origin.y = [o_controller frame].origin.y +
224 [o_controller frame].size.height - [o_controller minSize].height;
226 [o_btn_playlist setState: NO];
229 [o_controller setFrame: o_rect display:YES animate: YES];
232 - (void)playlistUpdated
236 /* Clear indications of any existing column sorting*/
237 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
239 [o_outline_view setIndicatorImage:nil inTableColumn:
240 [[o_outline_view tableColumns] objectAtIndex:i]];
243 [o_outline_view setHighlightedTableColumn:nil];
244 o_tc_sortColumn = nil;
245 [o_outline_dict removeAllObjects];
246 [o_outline_view reloadData];
249 - (void)updateTogglePlaylistState
251 if ([o_controller getSizeWithPlaylist].height ==
252 [o_controller minSize].height)
254 [o_btn_playlist setState: NO];
258 [o_btn_playlist setState: YES];
262 - (bool)isItem:(playlist_item_t *)p_item inNode:(playlist_item_t *)p_node
264 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
266 playlist_item_t * p_temp_item = p_item;
268 if ( p_playlist == NULL )
273 while ( p_temp_item->i_parents > 0 )
276 for (i = 0; i < p_temp_item->i_parents ; i++)
278 if (p_temp_item->pp_parents[i]->i_view == VIEW_SIMPLE)
280 if (p_temp_item->pp_parents[i]->p_parent == p_node)
282 vlc_object_release(p_playlist);
287 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
294 vlc_object_release(p_playlist);
299 - (IBAction)playItem:(id)sender
301 intf_thread_t * p_intf = VLCIntf;
302 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
305 if( p_playlist != NULL )
307 playlist_item_t *p_item;
308 playlist_item_t *p_node = NULL;
311 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
315 if (p_item->i_children == -1)
317 for (i = 0 ; i < p_item->i_parents ; i++)
319 if (p_item->pp_parents[i]->i_view == VIEW_SIMPLE)
321 p_node = p_item->pp_parents[i]->p_parent;
328 if (p_node->pp_children[0]->i_children == -1 &&
329 p_node->i_children > 0)
331 p_item = p_node->pp_children[0];
339 // p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
342 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_SIMPLE, p_node, p_item );
343 // playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_SIMPLE, p_view ? p_view->p_root : NULL, p_item );
345 vlc_object_release( p_playlist );
349 - (IBAction)selectAll:(id)sender
351 [o_outline_view selectAll: nil];
354 - (IBAction)deleteItem:(id)sender
357 NSMutableArray *o_to_delete;
360 playlist_t * p_playlist;
361 intf_thread_t * p_intf = VLCIntf;
363 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
366 if ( p_playlist == NULL )
370 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
371 c = [o_to_delete count];
373 for( i = 0; i < c; i++ ) {
374 playlist_item_t * p_item;
375 o_number = [o_to_delete lastObject];
376 i_row = [o_number intValue];
378 [o_to_delete removeObject: o_number];
379 [o_outline_view deselectRow: i_row];
380 p_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_row]pointerValue];
381 if (p_item->i_children > -1)
383 if (p_playlist->status.i_status)
385 if ([self isItem:p_playlist->status.p_item inNode: p_item]
386 == YES && p_playlist->status.i_status)
388 playlist_Stop( p_playlist );
391 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE);
395 if( p_playlist->status.p_item == [[o_outline_view itemAtRow: i_row]
396 pointerValue] && p_playlist->status.i_status )
398 playlist_Stop( p_playlist );
400 playlist_LockDelete( p_playlist, p_item->input.i_id );
402 [self playlistUpdated];
406 - (IBAction)sortNodeByName:(id)sender
408 [self sortNode: SORT_TITLE];
411 - (IBAction)sortNodeByAuthor:(id)sender
413 [self sortNode: SORT_AUTHOR];
416 - (void)sortNode:(int)i_mode
418 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
420 playlist_item_t * p_item;
422 if (p_playlist == NULL)
427 if ([o_outline_view selectedRow] > -1)
429 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
433 /*If no item is selected, sort the whole playlist*/
435 playlist_view_t * p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
436 p_item = p_view->p_root;
439 if (p_item->i_children > -1)
441 vlc_mutex_lock(&p_playlist->object_lock );
442 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
443 vlc_mutex_unlock(&p_playlist->object_lock );
449 for (i = 0 ; i < p_item->i_parents ; i++)
451 if (p_item->pp_parents[i]->i_view == VIEW_SIMPLE)
453 vlc_mutex_lock(&p_playlist->object_lock );
454 playlist_RecursiveNodeSort( p_playlist,
455 p_item->pp_parents[i]->p_parent, i_mode, ORDER_NORMAL );
456 vlc_mutex_unlock(&p_playlist->object_lock );
461 vlc_object_release(p_playlist);
462 [self playlistUpdated];
465 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
468 intf_thread_t * p_intf = VLCIntf;
469 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
472 if( p_playlist == NULL )
477 for ( i_item = 0; i_item < (int)[o_array count]; i_item++ )
480 NSDictionary *o_one_item;
481 int j, i_total_options = 0, i_new_id = -1;
482 int i_mode = PLAYLIST_INSERT;
483 BOOL b_rem = FALSE, b_dir = FALSE;
484 NSString *o_uri, *o_name;
487 char **ppsz_options = NULL;
490 o_one_item = [o_array objectAtIndex: i_item];
491 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
492 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
493 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
495 /* If no name, then make a guess */
496 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
498 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
499 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
500 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
502 /* All of this is to make sure CD's play when you D&D them on VLC */
503 /* Converts mountpoint to a /dev file */
506 buf = (struct statfs *) malloc (sizeof(struct statfs));
507 statfs( [o_uri fileSystemRepresentation], buf );
508 psz_dev = strdup(buf->f_mntfromname);
509 o_uri = [NSString stringWithCString: psz_dev ];
512 if( o_options && [o_options count] > 0 )
514 /* Count the input options */
515 i_total_options = [o_options count];
517 /* Allocate ppsz_options */
518 for( j = 0; j < i_total_options; j++ )
521 ppsz_options = (char **)malloc( sizeof(char *) * i_total_options );
523 ppsz_options[j] = strdup([[o_options objectAtIndex:j] UTF8String]);
528 i_new_id = playlist_AddExt( p_playlist, [o_uri fileSystemRepresentation],
529 [o_name UTF8String], i_mode,
530 i_position == -1 ? PLAYLIST_END : i_position + i_item,
531 0, (ppsz_options != NULL ) ? (const char **)ppsz_options : 0, i_total_options );
534 for( j = 0; j < i_total_options; j++ )
535 free( ppsz_options[j] );
536 if( ppsz_options ) free( ppsz_options ); */
538 /* Recent documents menu */
539 o_true_file = [NSURL fileURLWithPath: o_uri];
540 if( o_true_file != nil )
542 [[NSDocumentController sharedDocumentController]
543 noteNewRecentDocumentURL: o_true_file];
546 if( i_item == 0 && !b_enqueue )
548 playlist_Goto( p_playlist, playlist_GetPositionById( p_playlist, i_new_id ) );
549 playlist_Play( p_playlist );
553 vlc_object_release( p_playlist );
556 - (IBAction)handlePopUp:(id)sender
559 intf_thread_t * p_intf = VLCIntf;
560 vlc_value_t val1,val2;
561 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
563 if( p_playlist == NULL )
568 switch ([o_loop_popup indexOfSelectedItem])
573 var_Set( p_playlist, "loop", val1 );
575 var_Set( p_playlist, "repeat", val1 );
576 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
581 var_Set( p_playlist, "repeat", val1 );
583 var_Set( p_playlist, "loop", val1 );
584 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
588 var_Get( p_playlist, "repeat", &val1 );
589 var_Get( p_playlist, "loop", &val2 );
590 if (val1.b_bool || val2.b_bool)
593 var_Set( p_playlist, "repeat", val1 );
594 var_Set( p_playlist, "loop", val1 );
595 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
599 vlc_object_release( p_playlist );
600 [self playlistUpdated];
603 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
605 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
607 playlist_item_t * p_selected_item;
608 int i_current, i_selected_row;
613 i_selected_row = [o_outline_view selectedRow];
614 if (i_selected_row < 0)
617 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
618 i_selected_row] pointerValue];
620 for (i_current = 0; i_current < p_item->i_children ; i_current++)
623 NSString * o_current_name, * o_current_author;
625 vlc_mutex_lock( &p_playlist->object_lock );
626 o_current_name = [NSString stringWithUTF8String:
627 p_item->pp_children[i_current]->input.psz_name];
628 psz_temp = playlist_ItemGetInfo(p_item ,_("Meta-information"),_("Author") );
629 o_current_author = [NSString stringWithUTF8String: psz_temp];
631 vlc_mutex_unlock( &p_playlist->object_lock );
633 if (p_selected_item == p_item->pp_children[i_current] &&
634 b_selected_item_met == NO)
636 b_selected_item_met = YES;
638 else if (p_selected_item == p_item->pp_children[i_current] &&
639 b_selected_item_met == YES)
641 vlc_object_release(p_playlist);
644 else if (b_selected_item_met == YES &&
645 ([o_current_name rangeOfString:[o_search_field
646 stringValue] options:NSCaseInsensitiveSearch ].length ||
647 [o_current_author rangeOfString:[o_search_field
648 stringValue] options:NSCaseInsensitiveSearch ].length))
650 vlc_object_release(p_playlist);
651 /*Adds the parent items in the result array as well, so that we can
653 return [NSMutableArray arrayWithObject: [NSValue
654 valueWithPointer: p_item->pp_children[i_current]]];
656 if (p_item->pp_children[i_current]->i_children > 0)
658 id o_result = [self subSearchItem:
659 p_item->pp_children[i_current]];
660 if (o_result != NULL)
662 vlc_object_release(p_playlist);
663 [o_result insertObject: [NSValue valueWithPointer:
664 p_item->pp_children[i_current]] atIndex:0];
669 vlc_object_release(p_playlist);
673 - (IBAction)searchItem:(id)sender
675 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
677 playlist_view_t * p_view;
683 b_selected_item_met = NO;
685 if( p_playlist == NULL )
688 p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
692 /*First, only search after the selected item:*
693 *(b_selected_item_met = NO) */
694 o_result = [self subSearchItem:p_view->p_root];
695 if (o_result == NULL)
697 /* If the first search failed, search again from the beginning */
698 o_result = [self subSearchItem:p_view->p_root];
700 if (o_result != NULL)
702 for (i = 0 ; i < [o_result count] - 1 ; i++)
704 [o_outline_view expandItem: [o_outline_dict objectForKey:
705 [NSString stringWithFormat: @"%p",
706 [[o_result objectAtIndex: i] pointerValue]]]];
708 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
709 [NSString stringWithFormat: @"%p",
710 [[o_result objectAtIndex: [o_result count] - 1 ]
715 [o_outline_view selectRow:i_row byExtendingSelection: NO];
716 [o_outline_view scrollRowToVisible: i_row];
719 vlc_object_release(p_playlist);
723 - (NSMenu *)menuForEvent:(NSEvent *)o_event
727 vlc_bool_t b_item_sel;
729 pt = [o_outline_view convertPoint: [o_event locationInWindow]
731 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
732 [o_outline_view selectedRow] != -1 );
733 b_rows = [o_outline_view numberOfRows] != 0;
735 [o_mi_play setEnabled: b_item_sel];
736 [o_mi_delete setEnabled: b_item_sel];
737 [o_mi_selectall setEnabled: b_rows];
738 [o_mi_info setEnabled: b_item_sel];
740 return( o_ctx_menu );
743 - (playlist_item_t *)selectedPlaylistItem
745 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
749 - (void) outlineView:(NSTableView*)o_tv
750 didClickTableColumn:(NSTableColumn *)o_tc
752 intf_thread_t * p_intf = VLCIntf;
753 playlist_t *p_playlist =
754 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
756 playlist_view_t * p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
757 int i_mode = 0, i_type;
759 if( p_playlist == NULL )
764 /* Check whether the selected table column header corresponds to a
765 sortable table column*/
766 if ( !(o_tc == o_tc_name || o_tc == o_tc_author))
771 if( o_tc_sortColumn == o_tc )
773 b_isSortDescending = !b_isSortDescending;
777 b_isSortDescending = VLC_FALSE;
780 if (o_tc == o_tc_name)
784 else if (o_tc == o_tc_author)
786 i_mode = SORT_AUTHOR;
789 if (b_isSortDescending)
791 i_type = ORDER_REVERSE;
795 i_type = ORDER_NORMAL;
798 vlc_mutex_lock(&p_playlist->object_lock );
799 playlist_RecursiveNodeSort(p_playlist, p_view->p_root, i_mode, i_type);
800 vlc_mutex_unlock(&p_playlist->object_lock );
802 vlc_object_release( p_playlist );
803 [self playlistUpdated];
805 o_tc_sortColumn = o_tc;
806 [o_outline_view setHighlightedTableColumn:o_tc];
808 if (b_isSortDescending)
810 [o_outline_view setIndicatorImage:o_descendingSortingImage
815 [o_outline_view setIndicatorImage:o_ascendingSortingImage
822 @implementation VLCPlaylist (NSOutlineViewDataSource)
824 /* return the number of children for Obj-C pointer item */ /* DONE */
825 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
828 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
830 if( p_playlist == NULL )
836 playlist_view_t *p_view;
837 p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
838 if( p_view && p_view->p_root )
839 i_return = p_view->p_root->i_children;
843 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
845 i_return = p_item->i_children;
847 vlc_object_release( p_playlist );
848 if( i_return == -1 ) i_return = 0;
849 msg_Dbg( p_playlist, "I have %d children", i_return );
853 /* return the child at index for the Obj-C pointer item */ /* DONE */
854 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
856 playlist_item_t *p_return = NULL;
857 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
861 if( p_playlist == NULL )
867 playlist_view_t *p_view;
868 p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
869 if( p_view && index < p_view->p_root->i_children )
870 p_return = p_view->p_root->pp_children[index];
874 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
875 if( p_item && index < p_item->i_children )
877 p_return = p_item->pp_children[index];
881 [o_status_field setStringValue: [NSString stringWithFormat:
882 _NS("%i items in playlist"), p_playlist->i_size]];
884 vlc_object_release( p_playlist );
885 msg_Dbg( p_playlist, "childitem with index %d", index );
887 o_value = [NSValue valueWithPointer: p_return];
889 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p", p_return]];
893 /* is the item expandable */
894 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
897 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
899 if( p_playlist == NULL )
905 playlist_view_t *p_view;
906 p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
907 if( p_view && p_view->p_root )
908 i_return = p_view->p_root->i_children;
912 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
914 i_return = p_item->i_children;
916 vlc_object_release( p_playlist );
918 if( i_return == -1 || i_return == 0 )
924 /* retrieve the string values for the cells */
925 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
928 intf_thread_t * p_intf = VLCIntf;
929 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
931 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
933 if( p_playlist == NULL || p_item == NULL )
938 if( [[o_tc identifier] isEqualToString:@"1"] )
940 o_value = [NSString stringWithUTF8String:
941 p_item->input.psz_name];
942 if( o_value == NULL )
943 o_value = [NSString stringWithCString:
944 p_item->input.psz_name];
946 else if( [[o_tc identifier] isEqualToString:@"2"] )
949 psz_temp = playlist_ItemGetInfo( p_item ,_("Meta-information"),_("Artist") );
951 if( psz_temp == NULL )
955 o_value = [NSString stringWithUTF8String: psz_temp];
956 if( o_value == NULL )
958 o_value = [NSString stringWithCString: psz_temp];
963 else if( [[o_tc identifier] isEqualToString:@"3"] )
965 char psz_duration[MSTRTIME_MAX_SIZE];
966 mtime_t dur = p_item->input.i_duration;
969 secstotimestr( psz_duration, dur/1000000 );
970 o_value = [NSString stringWithUTF8String: psz_duration];
974 o_value = @"-:--:--";
978 vlc_object_release( p_playlist );
983 /* Required for drag & drop and reordering */
984 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
989 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
991 return NSDragOperationNone;
994 /* Delegate method of NSWindow */
995 /*- (void)windowWillClose:(NSNotification *)aNotification
997 [o_btn_playlist setState: NSOffState];