1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2006 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Derk-Jan Hartman <hartman at videola/n 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
27 * add 'icons' for different types of nodes? (http://www.cocoadev.com/index.pl?IconAndTextInTableCell)
28 * create toggle buttons for the shuffle, repeat one, repeat all functions.
29 * reimplement enable/disable item
30 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
31 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
35 /*****************************************************************************
37 *****************************************************************************/
38 #include <stdlib.h> /* malloc(), free() */
39 #include <sys/param.h> /* for MAXPATHLEN */
42 #include <sys/mount.h>
48 #import "playlistinfo.h"
53 #import <vlc_interface.h>
55 /*****************************************************************************
56 * VLCPlaylistView implementation
57 *****************************************************************************/
58 @implementation VLCPlaylistView
60 - (NSMenu *)menuForEvent:(NSEvent *)o_event
62 return( [[self delegate] menuForEvent: o_event] );
65 - (void)keyDown:(NSEvent *)o_event
69 if( [[o_event characters] length] )
71 key = [[o_event characters] characterAtIndex: 0];
76 case NSDeleteCharacter:
77 case NSDeleteFunctionKey:
78 case NSDeleteCharFunctionKey:
79 case NSBackspaceCharacter:
80 [[self delegate] deleteItem:self];
83 case NSEnterCharacter:
84 case NSCarriageReturnCharacter:
85 [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist]
90 [super keyDown: o_event];
98 /*****************************************************************************
99 * VLCPlaylistCommon implementation
101 * This class the superclass of the VLCPlaylist and VLCPlaylistWizard.
102 * It contains the common methods and elements of these 2 entities.
103 *****************************************************************************/
104 @implementation VLCPlaylistCommon
111 o_outline_dict = [[NSMutableDictionary alloc] init];
117 playlist_t * p_playlist = pl_Yield( VLCIntf );
118 [o_outline_view setTarget: self];
119 [o_outline_view setDelegate: self];
120 [o_outline_view setDataSource: self];
122 vlc_object_release( p_playlist );
128 [[o_tc_name headerCell] setStringValue:_NS("Name")];
129 [[o_tc_author headerCell] setStringValue:_NS("Author")];
130 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
133 - (NSOutlineView *)outlineView
135 return o_outline_view;
138 - (playlist_item_t *)selectedPlaylistItem
140 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
146 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
148 /* return the number of children for Obj-C pointer item */ /* DONE */
149 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
152 playlist_item_t *p_item = NULL;
153 playlist_t * p_playlist = pl_Yield( VLCIntf );
154 if( outlineView != o_outline_view )
156 vlc_object_release( p_playlist );
163 p_item = p_playlist->p_root_category;
167 p_item = (playlist_item_t *)[item pointerValue];
170 i_return = p_item->i_children;
171 vlc_object_release( p_playlist );
175 NSLog( @"%d children for %s", i_return, p_item->p_input->psz_name );
179 /* return the child at index for the Obj-C pointer item */ /* DONE */
180 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
182 playlist_item_t *p_return = NULL, *p_item = NULL;
184 playlist_t * p_playlist = pl_Yield( VLCIntf );
189 p_item = p_playlist->p_root_category;
193 p_item = (playlist_item_t *)[item pointerValue];
195 if( p_item && index < p_item->i_children && index >= 0 )
196 p_return = p_item->pp_children[index];
198 vlc_object_release( p_playlist );
200 o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
202 NSLog( @"%s", p_return->p_input->psz_name);
206 o_value = [[NSValue valueWithPointer: p_return] retain];
207 msg_Err( VLCIntf, "missing playlist item's pointer value" );
212 /* is the item expandable */
213 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
216 playlist_t *p_playlist = pl_Yield( VLCIntf );
221 if( p_playlist->p_root_category )
223 i_return = p_playlist->p_root_category->i_children;
228 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
230 i_return = p_item->i_children;
232 vlc_object_release( p_playlist );
234 NSLog( @"expandable" );
241 /* retrieve the string values for the cells */
242 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
245 playlist_item_t *p_item;
247 if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
249 p_item = (playlist_item_t *)[item pointerValue];
254 //NSLog( @"values for %p", p_item );
256 if( [[o_tc identifier] isEqualToString:@"1"] )
258 /* sanity check to prevent the NSString class from crashing */
259 if( p_item->p_input->psz_name != NULL )
261 o_value = [NSString stringWithUTF8String:
262 p_item->p_input->psz_name];
263 if( o_value == NULL )
264 o_value = [NSString stringWithCString:
265 p_item->p_input->psz_name];
268 else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
269 p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
271 o_value = [NSString stringWithUTF8String:
272 p_item->p_input->p_meta->psz_artist];
273 if( o_value == NULL )
274 o_value = [NSString stringWithCString:
275 p_item->p_input->p_meta->psz_artist];
277 else if( [[o_tc identifier] isEqualToString:@"3"] )
279 char psz_duration[MSTRTIME_MAX_SIZE];
280 mtime_t dur = p_item->p_input->i_duration;
283 secstotimestr( psz_duration, dur/1000000 );
284 o_value = [NSString stringWithUTF8String: psz_duration];
288 o_value = @"-:--:--";
297 /*****************************************************************************
298 * VLCPlaylistWizard implementation
299 *****************************************************************************/
300 @implementation VLCPlaylistWizard
302 - (IBAction)reloadOutlineView
304 /* Only reload the outlineview if the wizard window is open since this can
305 be quite long on big playlists */
306 if( [[o_outline_view window] isVisible] )
308 [o_outline_view reloadData];
314 /*****************************************************************************
315 * extension to NSOutlineView's interface to fix compilation warnings
316 * and let us access these 2 functions properly
317 * this uses a private Apple-API, but works fine on all current OSX releases
318 * keep checking for compatiblity with future releases though
319 *****************************************************************************/
321 @interface NSOutlineView (UndocumentedSortImages)
322 + (NSImage *)_defaultTableHeaderSortImage;
323 + (NSImage *)_defaultTableHeaderReverseSortImage;
327 /*****************************************************************************
328 * VLCPlaylist implementation
329 *****************************************************************************/
330 @implementation VLCPlaylist
337 o_nodes_array = [[NSMutableArray alloc] init];
338 o_items_array = [[NSMutableArray alloc] init];
345 playlist_t * p_playlist = pl_Yield( VLCIntf );
346 vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE,
351 [super awakeFromNib];
353 [o_outline_view setDoubleAction: @selector(playItem:)];
355 [o_outline_view registerForDraggedTypes:
356 [NSArray arrayWithObjects: NSFilenamesPboardType,
357 @"VLCPlaylistItemPboardType", nil]];
358 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
360 /* this uses private Apple API which works fine until 10.4,
361 * but keep checking in the future!
362 * These methods are being added artificially to NSOutlineView's interface above */
363 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
364 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
366 o_tc_sortColumn = nil;
368 for( i_index = 0; i_index < p_list->i_count; i_index++ )
370 vlc_bool_t b_enabled;
373 module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object ;
375 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
377 /* Check for submodules */
379 while( p_parser->pp_shortcuts[++i] != NULL ); i--;
381 /* Check whether to enable these menuitems */
382 objectname = i>=0 ? (char *)p_parser->pp_shortcuts[i] : (char *)p_parser->psz_object_name;
383 b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, objectname );
385 /* Create the menu entries used in the playlist menu */
386 o_lmi = [[o_mi_services submenu] addItemWithTitle:
387 [NSString stringWithUTF8String:
388 p_parser->psz_longname ? p_parser->psz_longname :
389 ( p_parser->psz_shortname ? p_parser->psz_shortname:
391 action: @selector(servicesChange:)
393 [o_lmi setTarget: self];
394 [o_lmi setRepresentedObject: [NSString stringWithCString: objectname]];
395 if( b_enabled ) [o_lmi setState: NSOnState];
397 /* Create the menu entries for the main menu */
398 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
399 [NSString stringWithUTF8String:
400 p_parser->psz_longname ? p_parser->psz_longname :
401 ( p_parser->psz_shortname ? p_parser->psz_shortname:
403 action: @selector(servicesChange:)
405 [o_lmi setTarget: self];
406 [o_lmi setRepresentedObject: [NSString stringWithCString:objectname]];
407 if( b_enabled ) [o_lmi setState: NSOnState];
410 vlc_list_release( p_list );
411 vlc_object_release( p_playlist );
413 //[self playlistUpdated];
416 - (void)searchfieldChanged:(NSNotification *)o_notification
418 [o_search_field setStringValue:[[o_notification object] stringValue]];
425 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
426 [o_mi_play setTitle: _NS("Play")];
427 [o_mi_delete setTitle: _NS("Delete")];
428 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
429 [o_mi_selectall setTitle: _NS("Select All")];
430 [o_mi_info setTitle: _NS("Information")];
431 [o_mi_preparse setTitle: _NS("Get Stream Information")];
432 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
433 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
434 [o_mi_services setTitle: _NS("Services discovery")];
435 [o_status_field setStringValue: [NSString stringWithFormat:
436 _NS("No items in the playlist")]];
439 [o_search_button setTitle: _NS("Search")];
441 [o_search_field setToolTip: _NS("Search in Playlist")];
442 [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];
444 [o_save_accessory_text setStringValue: _NS("File Format:")];
445 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
446 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
449 - (void)playlistUpdated
453 /* Clear indications of any existing column sorting */
454 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
456 [o_outline_view setIndicatorImage:nil inTableColumn:
457 [[o_outline_view tableColumns] objectAtIndex:i]];
460 [o_outline_view setHighlightedTableColumn:nil];
461 o_tc_sortColumn = nil;
462 // TODO Find a way to keep the dict size to a minimum
463 //[o_outline_dict removeAllObjects];
464 [o_outline_view reloadData];
465 [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];
466 [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];
468 playlist_t *p_playlist = pl_Yield( VLCIntf );
470 if( playlist_CurrentSize( p_playlist ) >= 2 )
472 [o_status_field setStringValue: [NSString stringWithFormat:
473 _NS("%i items in the playlist"),
474 playlist_CurrentSize( p_playlist )]];
478 if( playlist_IsEmpty( p_playlist ) )
479 [o_status_field setStringValue: _NS("No items in the playlist")];
481 [o_status_field setStringValue: _NS("1 item in the playlist")];
483 vlc_object_release( p_playlist );
486 - (void)playModeUpdated
488 playlist_t *p_playlist = pl_Yield( VLCIntf );
489 vlc_value_t val, val2;
491 var_Get( p_playlist, "loop", &val2 );
492 var_Get( p_playlist, "repeat", &val );
493 if( val.b_bool == VLC_TRUE )
495 [[[VLCMain sharedInstance] getControls] repeatOne];
497 else if( val2.b_bool == VLC_TRUE )
499 [[[VLCMain sharedInstance] getControls] repeatAll];
503 [[[VLCMain sharedInstance] getControls] repeatOff];
506 [[[VLCMain sharedInstance] getControls] shuffle];
508 vlc_object_release( p_playlist );
511 - (void)updateRowSelection
516 playlist_t *p_playlist = pl_Yield( VLCIntf );
517 playlist_item_t *p_item, *p_temp_item;
518 NSMutableArray *o_array = [NSMutableArray array];
520 p_item = p_playlist->status.p_item;
523 vlc_object_release(p_playlist);
527 p_temp_item = p_item;
528 while( p_temp_item->p_parent )
530 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
531 p_temp_item = p_temp_item->p_parent;
532 /*for (i = 0 ; i < p_temp_item->i_parents ; i++)
534 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
536 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
542 for( j = 0; j < [o_array count] - 1; j++ )
545 if( ( o_item = [o_outline_dict objectForKey:
546 [NSString stringWithFormat: @"%p",
547 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
549 [o_outline_view expandItem: o_item];
554 i_row = [o_outline_view rowForItem:[o_outline_dict
555 objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
557 [o_outline_view selectRow: i_row byExtendingSelection: NO];
558 [o_outline_view scrollRowToVisible: i_row];
560 vlc_object_release( p_playlist );
562 /* update our info-panel to reflect the new item */
563 [[[VLCMain sharedInstance] getInfo] updatePanel];
566 /* Check if p_item is a child of p_node recursively. We need to check the item
567 existence first since OSX sometimes tries to redraw items that have been
568 deleted. We don't do it when not required since this verification takes
569 quite a long time on big playlists (yes, pretty hacky). */
570 - (BOOL)isItem: (playlist_item_t *)p_item
571 inNode: (playlist_item_t *)p_node
572 checkItemExistence:(BOOL)b_check
575 playlist_t * p_playlist = pl_Yield( VLCIntf );
576 playlist_item_t *p_temp_item = p_item;
578 if( p_node == p_item )
580 vlc_object_release(p_playlist);
584 if( p_node->i_children < 1)
586 vlc_object_release(p_playlist);
593 vlc_mutex_lock( &p_playlist->object_lock );
597 /* Since outlineView: willDisplayCell:... may call this function with
598 p_items that don't exist anymore, first check if the item is still
599 in the playlist. Any cleaner solution welcomed. */
600 for( i = 0; i < p_playlist->all_items.i_size; i++ )
602 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
603 else if ( i == p_playlist->all_items.i_size - 1 )
605 vlc_object_release( p_playlist );
606 vlc_mutex_unlock( &p_playlist->object_lock );
614 p_temp_item = p_temp_item->p_parent;
615 if( p_temp_item == p_node )
617 vlc_mutex_unlock( &p_playlist->object_lock );
618 vlc_object_release( p_playlist );
622 vlc_mutex_unlock( &p_playlist->object_lock );
625 vlc_object_release( p_playlist );
629 /* This method is usefull for instance to remove the selected children of an
630 already selected node */
631 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
634 for( i = 0 ; i < [o_items count] ; i++ )
636 for ( j = 0 ; j < [o_nodes count] ; j++ )
638 if( o_items == o_nodes)
640 if( j == i ) continue;
642 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
643 inNode: [[o_nodes objectAtIndex:j] pointerValue]
644 checkItemExistence: NO] )
646 [o_items removeObjectAtIndex:i];
647 /* We need to execute the next iteration with the same index
648 since the current item has been deleted */
657 - (IBAction)savePlaylist:(id)sender
659 intf_thread_t * p_intf = VLCIntf;
660 playlist_t * p_playlist = pl_Yield( p_intf );
662 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
663 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
665 //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
666 [o_save_panel setTitle: _NS("Save Playlist")];
667 [o_save_panel setPrompt: _NS("Save")];
668 [o_save_panel setAccessoryView: o_save_accessory_view];
670 if( [o_save_panel runModalForDirectory: nil
671 file: o_name] == NSOKButton )
673 NSString *o_filename = [o_save_panel filename];
675 if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
677 NSString * o_real_filename;
679 range.location = [o_filename length] - [@".xspf" length];
680 range.length = [@".xspf" length];
682 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
683 range: range] != NSOrderedSame )
685 o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
689 o_real_filename = o_filename;
691 playlist_Export( p_playlist,
692 [o_real_filename fileSystemRepresentation],
693 p_playlist->p_local_category, "export-xspf" );
697 NSString * o_real_filename;
699 range.location = [o_filename length] - [@".m3u" length];
700 range.length = [@".m3u" length];
702 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
703 range: range] != NSOrderedSame )
705 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
709 o_real_filename = o_filename;
711 playlist_Export( p_playlist,
712 [o_real_filename fileSystemRepresentation],
713 p_playlist->p_local_category, "export-m3u" );
716 vlc_object_release( p_playlist );
719 /* When called retrieves the selected outlineview row and plays that node or item */
720 - (IBAction)playItem:(id)sender
722 intf_thread_t * p_intf = VLCIntf;
723 playlist_t * p_playlist = pl_Yield( p_intf );
725 playlist_item_t *p_item;
726 playlist_item_t *p_node = NULL;
728 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
732 if( p_item->i_children == -1 )
734 p_node = p_item->p_parent;
740 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
742 p_item = p_node->pp_children[0];
749 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_node, p_item );
751 vlc_object_release( p_playlist );
754 /* When called retrieves the selected outlineview row and plays that node or item */
755 - (IBAction)preparseItem:(id)sender
758 NSMutableArray *o_to_preparse;
759 intf_thread_t * p_intf = VLCIntf;
760 playlist_t * p_playlist = pl_Yield( p_intf );
762 o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
763 i_count = [o_to_preparse count];
767 playlist_item_t *p_item = NULL;
769 for( i = 0; i < i_count; i++ )
771 o_number = [o_to_preparse lastObject];
772 i_row = [o_number intValue];
773 p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
774 [o_to_preparse removeObject: o_number];
775 [o_outline_view deselectRow: i_row];
779 if( p_item->i_children == -1 )
781 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
785 msg_Dbg( p_intf, "preparse of nodes not yet implemented" );
789 vlc_object_release( p_playlist );
790 [self playlistUpdated];
793 - (IBAction)servicesChange:(id)sender
795 NSMenuItem *o_mi = (NSMenuItem *)sender;
796 NSString *o_string = [o_mi representedObject];
797 playlist_t * p_playlist = pl_Yield( VLCIntf );
798 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string cString] ) )
799 playlist_ServicesDiscoveryAdd( p_playlist, [o_string cString] );
801 playlist_ServicesDiscoveryRemove( p_playlist, [o_string cString] );
803 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
804 [o_string cString] ) ? YES : NO];
806 vlc_object_release( p_playlist );
807 [self playlistUpdated];
811 - (IBAction)selectAll:(id)sender
813 [o_outline_view selectAll: nil];
816 - (IBAction)deleteItem:(id)sender
818 int i, i_count, i_row;
819 NSMutableArray *o_to_delete;
822 playlist_t * p_playlist;
823 intf_thread_t * p_intf = VLCIntf;
825 p_playlist = pl_Yield( p_intf );
827 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
828 i_count = [o_to_delete count];
830 for( i = 0; i < i_count; i++ )
832 o_number = [o_to_delete lastObject];
833 i_row = [o_number intValue];
834 id o_item = [o_outline_view itemAtRow: i_row];
835 playlist_item_t *p_item = [o_item pointerValue];
836 [o_to_delete removeObject: o_number];
837 [o_outline_view deselectRow: i_row];
839 if( [[o_outline_view dataSource] outlineView:o_outline_view
840 numberOfChildrenOfItem: o_item] > 0 )
841 //is a node and not an item
843 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
844 [self isItem: p_playlist->status.p_item inNode:
845 ((playlist_item_t *)[o_item pointerValue])
846 checkItemExistence: NO] == YES )
848 // if current item is in selected node and is playing then stop playlist
849 playlist_Stop( p_playlist );
851 vlc_mutex_lock( &p_playlist->object_lock );
852 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
853 vlc_mutex_unlock( &p_playlist->object_lock );
857 playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id, VLC_FALSE );
860 [self playlistUpdated];
861 vlc_object_release( p_playlist );
864 - (IBAction)sortNodeByName:(id)sender
866 [self sortNode: SORT_TITLE];
869 - (IBAction)sortNodeByAuthor:(id)sender
871 [self sortNode: SORT_ARTIST];
874 - (void)sortNode:(int)i_mode
876 playlist_t * p_playlist = pl_Yield( VLCIntf );
877 playlist_item_t * p_item;
879 if( [o_outline_view selectedRow] > -1 )
881 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
885 /*If no item is selected, sort the whole playlist*/
887 p_item = p_playlist->p_root_category;
890 if( p_item->i_children > -1 ) // the item is a node
892 vlc_mutex_lock( &p_playlist->object_lock );
893 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
894 vlc_mutex_unlock( &p_playlist->object_lock );
898 vlc_mutex_lock( &p_playlist->object_lock );
899 playlist_RecursiveNodeSort( p_playlist,
900 p_item->p_parent, i_mode, ORDER_NORMAL );
901 vlc_mutex_unlock( &p_playlist->object_lock );
903 vlc_object_release( p_playlist );
904 [self playlistUpdated];
907 - (input_item_t *)createItem:(NSDictionary *)o_one_item
909 intf_thread_t * p_intf = VLCIntf;
910 playlist_t * p_playlist = pl_Yield( p_intf );
912 input_item_t *p_input;
914 BOOL b_rem = FALSE, b_dir = FALSE;
915 NSString *o_uri, *o_name;
920 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
921 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
922 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
924 /* Find the name for a disc entry ( i know, can you believe the trouble?) */
925 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
927 int i_count, i_index;
928 struct statfs *mounts = NULL;
930 i_count = getmntinfo (&mounts, MNT_NOWAIT);
931 /* getmntinfo returns a pointer to static data. Do not free. */
932 for( i_index = 0 ; i_index < i_count; i_index++ )
934 NSMutableString *o_temp, *o_temp2;
935 o_temp = [NSMutableString stringWithString: o_uri];
936 o_temp2 = [NSMutableString stringWithCString: mounts[i_index].f_mntfromname];
937 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:nil range:NSMakeRange(0, [o_temp length]) ];
938 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
939 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
941 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
943 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithCString:mounts[i_index].f_mntonname]];
947 /* If no name, then make a guess */
948 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
950 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
951 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
952 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
954 /* All of this is to make sure CD's play when you D&D them on VLC */
955 /* Converts mountpoint to a /dev file */
958 NSMutableString *o_temp;
960 buf = (struct statfs *) malloc (sizeof(struct statfs));
961 statfs( [o_uri fileSystemRepresentation], buf );
962 psz_dev = strdup(buf->f_mntfromname);
963 o_temp = [NSMutableString stringWithCString: psz_dev ];
964 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:nil range:NSMakeRange(0, [o_temp length]) ];
965 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
966 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
970 p_input = input_ItemNew( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
976 for( i = 0; i < (int)[o_options count]; i++ )
978 input_ItemAddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
982 /* Recent documents menu */
983 o_true_file = [NSURL fileURLWithPath: o_uri];
984 if( o_true_file != nil )
986 [[NSDocumentController sharedDocumentController]
987 noteNewRecentDocumentURL: o_true_file];
990 vlc_object_release( p_playlist );
994 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
997 playlist_t * p_playlist = pl_Yield( VLCIntf );
999 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1001 input_item_t *p_input;
1002 NSDictionary *o_one_item;
1005 o_one_item = [o_array objectAtIndex: i_item];
1006 p_input = [self createItem: o_one_item];
1013 playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
1014 i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE );
1016 if( i_item == 0 && !b_enqueue )
1018 playlist_item_t *p_item;
1019 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1020 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1024 playlist_item_t *p_item;
1025 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1026 playlist_Control( p_playlist, PLAYLIST_PREPARSE, VLC_TRUE, p_item );
1029 [self playlistUpdated];
1030 vlc_object_release( p_playlist );
1033 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1036 playlist_t * p_playlist = pl_Yield( VLCIntf );
1038 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1040 input_item_t *p_input;
1041 NSDictionary *o_one_item;
1044 o_one_item = [o_array objectAtIndex: i_item];
1045 p_input = [self createItem: o_one_item];
1052 playlist_NodeAddInput( p_playlist, p_input, p_node,
1055 PLAYLIST_END : i_position + i_item );
1058 if( i_item == 0 && !b_enqueue )
1060 playlist_item_t *p_item;
1061 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1062 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1066 playlist_item_t *p_item;
1067 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1068 playlist_Control( p_playlist, PLAYLIST_PREPARSE, VLC_TRUE, p_item );
1071 [self playlistUpdated];
1072 vlc_object_release( p_playlist );
1075 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1077 playlist_t *p_playlist = pl_Yield( VLCIntf );
1078 playlist_item_t *p_selected_item;
1079 int i_current, i_selected_row;
1081 i_selected_row = [o_outline_view selectedRow];
1082 if (i_selected_row < 0)
1085 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
1086 i_selected_row] pointerValue];
1088 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
1091 NSString *o_current_name, *o_current_author;
1093 vlc_mutex_lock( &p_playlist->object_lock );
1094 o_current_name = [NSString stringWithUTF8String:
1095 p_item->pp_children[i_current]->p_input->psz_name];
1096 psz_temp = input_ItemGetInfo( p_item->p_input ,
1097 _("Meta-information"),_("Artist") );
1098 o_current_author = [NSString stringWithUTF8String: psz_temp];
1100 vlc_mutex_unlock( &p_playlist->object_lock );
1102 if( p_selected_item == p_item->pp_children[i_current] &&
1103 b_selected_item_met == NO )
1105 b_selected_item_met = YES;
1107 else if( p_selected_item == p_item->pp_children[i_current] &&
1108 b_selected_item_met == YES )
1110 vlc_object_release( p_playlist );
1113 else if( b_selected_item_met == YES &&
1114 ( [o_current_name rangeOfString:[o_search_field
1115 stringValue] options:NSCaseInsensitiveSearch ].length ||
1116 [o_current_author rangeOfString:[o_search_field
1117 stringValue] options:NSCaseInsensitiveSearch ].length ) )
1119 vlc_object_release( p_playlist );
1120 /*Adds the parent items in the result array as well, so that we can
1122 return [NSMutableArray arrayWithObject: [NSValue
1123 valueWithPointer: p_item->pp_children[i_current]]];
1125 if( p_item->pp_children[i_current]->i_children > 0 )
1127 id o_result = [self subSearchItem:
1128 p_item->pp_children[i_current]];
1129 if( o_result != NULL )
1131 vlc_object_release( p_playlist );
1132 [o_result insertObject: [NSValue valueWithPointer:
1133 p_item->pp_children[i_current]] atIndex:0];
1138 vlc_object_release( p_playlist );
1142 - (IBAction)searchItem:(id)sender
1144 playlist_t * p_playlist = pl_Yield( VLCIntf );
1150 b_selected_item_met = NO;
1152 /*First, only search after the selected item:*
1153 *(b_selected_item_met = NO) */
1154 o_result = [self subSearchItem:p_playlist->p_root_category];
1155 if( o_result == NULL )
1157 /* If the first search failed, search again from the beginning */
1158 o_result = [self subSearchItem:p_playlist->p_root_category];
1160 if( o_result != NULL )
1163 if( [[o_result objectAtIndex: 0] pointerValue] ==
1164 p_playlist->p_local_category )
1169 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1171 [o_outline_view expandItem: [o_outline_dict objectForKey:
1172 [NSString stringWithFormat: @"%p",
1173 [[o_result objectAtIndex: i] pointerValue]]]];
1175 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1176 [NSString stringWithFormat: @"%p",
1177 [[o_result objectAtIndex: [o_result count] - 1 ]
1182 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1183 [o_outline_view scrollRowToVisible: i_row];
1185 vlc_object_release( p_playlist );
1188 - (IBAction)recursiveExpandNode:(id)sender
1190 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1191 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1193 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1194 isItemExpandable: o_item] )
1196 o_item = [o_outline_dict objectForKey: [NSString
1197 stringWithFormat: @"%p", p_item->p_parent]];
1200 /* We need to collapse the node first, since OSX refuses to recursively
1201 expand an already expanded node, even if children nodes are collapsed. */
1202 [o_outline_view collapseItem: o_item collapseChildren: YES];
1203 [o_outline_view expandItem: o_item expandChildren: YES];
1206 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1210 vlc_bool_t b_item_sel;
1212 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1214 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
1215 [o_outline_view selectedRow] != -1 );
1216 b_rows = [o_outline_view numberOfRows] != 0;
1218 [o_mi_play setEnabled: b_item_sel];
1219 [o_mi_delete setEnabled: b_item_sel];
1220 [o_mi_selectall setEnabled: b_rows];
1221 [o_mi_info setEnabled: b_item_sel];
1222 [o_mi_preparse setEnabled: b_item_sel];
1223 [o_mi_recursive_expand setEnabled: b_item_sel];
1224 [o_mi_sort_name setEnabled: b_item_sel];
1225 [o_mi_sort_author setEnabled: b_item_sel];
1227 return( o_ctx_menu );
1230 - (void)outlineView: (NSTableView*)o_tv
1231 didClickTableColumn:(NSTableColumn *)o_tc
1233 int i_mode = 0, i_type;
1234 intf_thread_t *p_intf = VLCIntf;
1236 playlist_t *p_playlist = pl_Yield( p_intf );
1238 /* Check whether the selected table column header corresponds to a
1239 sortable table column*/
1240 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1242 vlc_object_release( p_playlist );
1246 if( o_tc_sortColumn == o_tc )
1248 b_isSortDescending = !b_isSortDescending;
1252 b_isSortDescending = VLC_FALSE;
1255 if( o_tc == o_tc_name )
1257 i_mode = SORT_TITLE;
1259 else if( o_tc == o_tc_author )
1261 i_mode = SORT_ARTIST;
1264 if( b_isSortDescending )
1266 i_type = ORDER_REVERSE;
1270 i_type = ORDER_NORMAL;
1273 vlc_mutex_lock( &p_playlist->object_lock );
1274 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1275 vlc_mutex_unlock( &p_playlist->object_lock );
1277 vlc_object_release( p_playlist );
1278 [self playlistUpdated];
1280 o_tc_sortColumn = o_tc;
1281 [o_outline_view setHighlightedTableColumn:o_tc];
1283 if( b_isSortDescending )
1285 [o_outline_view setIndicatorImage:o_descendingSortingImage
1286 inTableColumn:o_tc];
1290 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1291 inTableColumn:o_tc];
1296 - (void)outlineView:(NSOutlineView *)outlineView
1297 willDisplayCell:(id)cell
1298 forTableColumn:(NSTableColumn *)tableColumn
1301 playlist_t *p_playlist = pl_Yield( VLCIntf );
1305 o_playing_item = [o_outline_dict objectForKey:
1306 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1308 if( [self isItem: [o_playing_item pointerValue] inNode:
1309 [item pointerValue] checkItemExistence: YES]
1310 || [o_playing_item isEqual: item] )
1312 [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1316 [cell setFont: [NSFont systemFontOfSize: 0]];
1318 vlc_object_release( p_playlist );
1321 - (IBAction)addNode:(id)sender
1323 /* we have to create a new thread here because otherwise we would block the
1324 * interface since the interaction-stuff and this code would run in the same
1326 [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
1327 toTarget: self withObject:nil];
1328 [self playlistUpdated];
1331 - (void)addNodeThreadedly
1333 NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
1335 /* simply adds a new node to the end of the playlist */
1336 playlist_t * p_playlist = pl_Yield( VLCIntf );
1337 vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
1340 char *psz_name = NULL;
1341 playlist_item_t * p_item;
1342 ret_v = intf_UserStringInput( p_playlist, _("New Node"),
1343 _("Please enter a name for the new node."), &psz_name );
1344 if( psz_name != NULL && psz_name != "" )
1345 p_item = playlist_NodeCreate( p_playlist, psz_name,
1346 p_playlist->p_local_category, 0 );
1348 p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
1349 p_playlist->p_local_category, 0 );
1352 msg_Warn( VLCIntf, "node creation failed" );
1354 vlc_object_release( p_playlist );
1360 @implementation VLCPlaylist (NSOutlineViewDataSource)
1362 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1364 id o_value = [super outlineView: outlineView child: index ofItem: item];
1365 playlist_t *p_playlist = pl_Yield( VLCIntf );
1367 if( playlist_CurrentSize( p_playlist ) >= 2 )
1369 [o_status_field setStringValue: [NSString stringWithFormat:
1370 _NS("%i items in the playlist"),
1371 playlist_CurrentSize( p_playlist )]];
1375 if( playlist_IsEmpty( p_playlist ) )
1377 [o_status_field setStringValue: _NS("No items in the playlist")];
1381 [o_status_field setStringValue: _NS("1 item in the playlist")];
1384 vlc_object_release( p_playlist );
1386 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
1387 [o_value pointerValue]]];
1388 msg_Dbg( VLCIntf, "adding item %p", [o_value pointerValue] );
1393 /* Required for drag & drop and reordering */
1394 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1397 playlist_t *p_playlist = pl_Yield( VLCIntf );
1399 /* First remove the items that were moved during the last drag & drop
1401 [o_items_array removeAllObjects];
1402 [o_nodes_array removeAllObjects];
1404 for( i = 0 ; i < [items count] ; i++ )
1406 id o_item = [items objectAtIndex: i];
1408 /* Refuse to move items that are not in the General Node
1409 (Service Discovery) */
1410 if( ![self isItem: [o_item pointerValue] inNode:
1411 p_playlist->p_local_category checkItemExistence: NO])
1413 vlc_object_release(p_playlist);
1416 /* Fill the items and nodes to move in 2 different arrays */
1417 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1418 [o_nodes_array addObject: o_item];
1420 [o_items_array addObject: o_item];
1423 /* Now we need to check if there are selected items that are in already
1424 selected nodes. In that case, we only want to move the nodes */
1425 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1426 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1428 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1429 a Drop operation coming from the playlist. */
1431 [pboard declareTypes: [NSArray arrayWithObjects:
1432 @"VLCPlaylistItemPboardType", nil] owner: self];
1433 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1435 vlc_object_release(p_playlist);
1439 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1441 playlist_t *p_playlist = pl_Yield( VLCIntf );
1442 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1444 if( !p_playlist ) return NSDragOperationNone;
1446 /* Dropping ON items is not allowed if item is not a node */
1449 if( index == NSOutlineViewDropOnItemIndex &&
1450 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1452 vlc_object_release( p_playlist );
1453 return NSDragOperationNone;
1457 /* We refuse to drop an item in anything else than a child of the General
1458 Node. We still accept items that would be root nodes of the outlineview
1459 however, to allow drop in an empty playlist. */
1460 if( !([self isItem: [item pointerValue] inNode: p_playlist->p_local_category
1461 checkItemExistence: NO] || item == nil) )
1463 vlc_object_release( p_playlist );
1464 return NSDragOperationNone;
1467 /* Drop from the Playlist */
1468 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1471 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1473 /* We refuse to Drop in a child of an item we are moving */
1474 if( [self isItem: [item pointerValue] inNode:
1475 [[o_nodes_array objectAtIndex: i] pointerValue]
1476 checkItemExistence: NO] )
1478 vlc_object_release( p_playlist );
1479 return NSDragOperationNone;
1482 vlc_object_release( p_playlist );
1483 return NSDragOperationMove;
1486 /* Drop from the Finder */
1487 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1489 vlc_object_release( p_playlist );
1490 return NSDragOperationGeneric;
1492 vlc_object_release( p_playlist );
1493 return NSDragOperationNone;
1496 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1498 playlist_t * p_playlist = pl_Yield( VLCIntf );
1499 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1501 /* Drag & Drop inside the playlist */
1502 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1504 int i_row, i_removed_from_node = 0;
1506 playlist_item_t *p_new_parent, *p_item = NULL;
1507 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1509 /* If the item is to be dropped as root item of the outline, make it a
1510 child of the General node.
1511 Else, choose the proposed parent as parent. */
1512 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1513 else p_new_parent = [item pointerValue];
1515 /* Make sure the proposed parent is a node.
1516 (This should never be true) */
1517 if( p_new_parent->i_children < 0 )
1519 vlc_object_release( p_playlist );
1523 for( i = 0; i < [o_all_items count]; i++ )
1525 playlist_item_t *p_old_parent = NULL;
1526 int i_old_index = 0;
1528 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1529 p_old_parent = p_item->p_parent;
1532 /* We may need the old index later */
1533 if( p_new_parent == p_old_parent )
1536 for( j = 0; j < p_old_parent->i_children; j++ )
1538 if( p_old_parent->pp_children[j] == p_item )
1546 vlc_mutex_lock( &p_playlist->object_lock );
1547 // Acually detach the item from the old position
1548 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1552 /* Calculate the new index */
1555 /* If we move the item in the same node, we need to take into
1556 account that one item will be deleted */
1559 if ((p_new_parent == p_old_parent &&
1560 i_old_index < index + (int)i) )
1562 i_removed_from_node++;
1564 i_new_index = index + i - i_removed_from_node;
1566 // Reattach the item to the new position
1567 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1569 vlc_mutex_unlock( &p_playlist->object_lock );
1571 [self playlistUpdated];
1572 i_row = [o_outline_view rowForItem:[o_outline_dict
1573 objectForKey:[NSString stringWithFormat: @"%p",
1574 [[o_all_items objectAtIndex: 0] pointerValue]]]];
1578 i_row = [o_outline_view rowForItem:[o_outline_dict
1579 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1582 [o_outline_view deselectAll: self];
1583 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1584 [o_outline_view scrollRowToVisible: i_row];
1586 vlc_object_release( p_playlist );
1590 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1593 playlist_item_t *p_node = [item pointerValue];
1595 NSArray *o_array = [NSArray array];
1596 NSArray *o_values = [[o_pasteboard propertyListForType:
1597 NSFilenamesPboardType]
1598 sortedArrayUsingSelector:
1599 @selector(caseInsensitiveCompare:)];
1601 for( i = 0; i < (int)[o_values count]; i++)
1603 NSDictionary *o_dic;
1604 o_dic = [NSDictionary dictionaryWithObject:[o_values
1605 objectAtIndex:i] forKey:@"ITEM_URL"];
1606 o_array = [o_array arrayByAddingObject: o_dic];
1611 [self appendArray: o_array atPos: index enqueue: YES];
1613 /* This should never occur */
1614 else if( p_node->i_children == -1 )
1616 vlc_object_release( p_playlist );
1621 [self appendNodeArray: o_array inNode: p_node
1622 atPos: index enqueue: YES];
1624 vlc_object_release( p_playlist );
1627 vlc_object_release( p_playlist );
1631 /* Delegate method of NSWindow */
1632 /*- (void)windowWillClose:(NSNotification *)aNotification
1634 [o_btn_playlist setState: NSOffState];