1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2009 VLC authors and VideoLAN
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 * reimplement enable/disable item
29 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
30 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
34 /*****************************************************************************
36 *****************************************************************************/
37 #include <stdlib.h> /* malloc(), free() */
38 #include <sys/param.h> /* for MAXPATHLEN */
41 #include <sys/mount.h>
46 #import "playlistinfo.h"
52 #import <vlc_services_discovery.h>
54 #import <vlc_interface.h>
59 /*****************************************************************************
60 * VLCPlaylistView implementation
61 *****************************************************************************/
62 @implementation VLCPlaylistView
64 - (NSMenu *)menuForEvent:(NSEvent *)o_event
66 return( [[self delegate] menuForEvent: o_event] );
69 - (void)keyDown:(NSEvent *)o_event
73 if( [[o_event characters] length] )
75 key = [[o_event characters] characterAtIndex: 0];
80 case NSDeleteCharacter:
81 case NSDeleteFunctionKey:
82 case NSDeleteCharFunctionKey:
83 case NSBackspaceCharacter:
84 [[self delegate] deleteItem:self];
87 case NSEnterCharacter:
88 case NSCarriageReturnCharacter:
89 [(VLCPlaylist *)[[VLCMain sharedInstance] playlist] playItem:self];
93 [super keyDown: o_event];
100 /*****************************************************************************
101 * VLCPlaylistCommon implementation
103 * This class the superclass of the VLCPlaylist and VLCPlaylistWizard.
104 * It contains the common methods and elements of these 2 entities.
105 *****************************************************************************/
106 @implementation VLCPlaylistCommon
113 o_outline_dict = [[NSMutableDictionary alloc] init];
119 playlist_t * p_playlist = pl_Get( VLCIntf );
120 [o_outline_view setTarget: self];
121 [o_outline_view setDelegate: self];
122 [o_outline_view setDataSource: self];
123 [o_outline_view setAllowsEmptySelection: NO];
124 [o_outline_view expandItem: [o_outline_view itemAtRow:0]];
126 [o_outline_view_other setTarget: self];
127 [o_outline_view_other setDelegate: self];
128 [o_outline_view_other setDataSource: self];
129 [o_outline_view_other setAllowsEmptySelection: NO];
136 [[o_tc_name headerCell] setStringValue:_NS("Name")];
137 [[o_tc_author headerCell] setStringValue:_NS("Author")];
138 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
140 [[o_tc_name_other headerCell] setStringValue:_NS("Name")];
141 [[o_tc_author_other headerCell] setStringValue:_NS("Author")];
142 [[o_tc_duration_other headerCell] setStringValue:_NS("Duration")];
145 - (void)swapPlaylists:(id)newList
147 if(newList != o_outline_view)
149 id o_outline_view_temp = o_outline_view;
150 id o_tc_author_temp = o_tc_author;
151 id o_tc_duration_temp = o_tc_duration;
152 id o_tc_name_temp = o_tc_name;
153 o_outline_view = o_outline_view_other;
154 o_tc_author = o_tc_author_other;
155 o_tc_duration = o_tc_duration_other;
156 o_tc_name = o_tc_name_other;
157 o_outline_view_other = o_outline_view_temp;
158 o_tc_author_other = o_tc_author_temp;
159 o_tc_duration_other = o_tc_duration_temp;
160 o_tc_name_other = o_tc_name_temp;
164 - (NSOutlineView *)outlineView
166 return o_outline_view;
169 - (playlist_item_t *)selectedPlaylistItem
171 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
177 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
179 /* return the number of children for Obj-C pointer item */ /* DONE */
180 - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
183 playlist_item_t *p_item = NULL;
184 playlist_t * p_playlist = pl_Get( VLCIntf );
185 //assert( outlineView == o_outline_view );
189 p_item = p_playlist->p_root_category;
191 p_item = (playlist_item_t *)[item pointerValue];
194 i_return = p_item->i_children;
197 return i_return > 0 ? i_return : 0;
200 /* return the child at index for the Obj-C pointer item */ /* DONE */
201 - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
203 playlist_item_t *p_return = NULL, *p_item = NULL;
205 playlist_t * p_playlist = pl_Get( VLCIntf );
211 p_item = p_playlist->p_root_category;
215 p_item = (playlist_item_t *)[item pointerValue];
217 if( p_item && index < p_item->i_children && index >= 0 )
218 p_return = p_item->pp_children[index];
221 o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
225 /* FIXME: Why is there a warning if that happens all the time and seems
226 * to be normal? Add an assert and fix it.
227 * msg_Warn( VLCIntf, "playlist item misses pointer value, adding one" ); */
228 o_value = [[NSValue valueWithPointer: p_return] retain];
233 /* is the item expandable */
234 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
237 playlist_t *p_playlist = pl_Get( VLCIntf );
243 if( p_playlist->p_root_category )
245 i_return = p_playlist->p_root_category->i_children;
250 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
252 i_return = p_item->i_children;
256 return (i_return >= 0);
259 /* retrieve the string values for the cells */
260 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
263 playlist_item_t *p_item;
265 /* For error handling */
266 static BOOL attempted_reload = NO;
268 if( item == nil || ![item isKindOfClass: [NSValue class]] )
270 /* Attempt to fix the error by asking for a data redisplay
271 * This might cause infinite loop, so add a small check */
272 if( !attempted_reload )
274 attempted_reload = YES;
275 [outlineView reloadData];
280 p_item = (playlist_item_t *)[item pointerValue];
281 if( !p_item || !p_item->p_input )
283 /* Attempt to fix the error by asking for a data redisplay
284 * This might cause infinite loop, so add a small check */
285 if( !attempted_reload )
287 attempted_reload = YES;
288 [outlineView reloadData];
293 attempted_reload = NO;
295 if( [[o_tc identifier] isEqualToString:@"name"] )
297 /* sanity check to prevent the NSString class from crashing */
298 char *psz_title = input_item_GetTitleFbName( p_item->p_input );
301 o_value = [NSString stringWithUTF8String: psz_title];
305 else if( [[o_tc identifier] isEqualToString:@"artist"] )
307 char *psz_artist = input_item_GetArtist( p_item->p_input );
309 o_value = [NSString stringWithUTF8String: psz_artist];
312 else if( [[o_tc identifier] isEqualToString:@"duration"] )
314 char psz_duration[MSTRTIME_MAX_SIZE];
315 mtime_t dur = input_item_GetDuration( p_item->p_input );
318 secstotimestr( psz_duration, dur/1000000 );
319 o_value = [NSString stringWithUTF8String: psz_duration];
324 else if( [[o_tc identifier] isEqualToString:@"status"] )
326 if( input_item_HasErrorWhenReading( p_item->p_input ) )
328 o_value = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertCautionIcon)];
329 [o_value setSize: NSMakeSize(16,16)];
337 /*****************************************************************************
338 * VLCPlaylistWizard implementation
339 *****************************************************************************/
340 @implementation VLCPlaylistWizard
342 - (IBAction)reloadOutlineView
344 /* Only reload the outlineview if the wizard window is open since this can
345 be quite long on big playlists */
346 if( [[o_outline_view window] isVisible] )
348 [o_outline_view reloadData];
354 /*****************************************************************************
355 * extension to NSOutlineView's interface to fix compilation warnings
356 * and let us access these 2 functions properly
357 * this uses a private Apple-API, but works fine on all current OSX releases
358 * keep checking for compatiblity with future releases though
359 *****************************************************************************/
361 @interface NSOutlineView (UndocumentedSortImages)
362 + (NSImage *)_defaultTableHeaderSortImage;
363 + (NSImage *)_defaultTableHeaderReverseSortImage;
367 /*****************************************************************************
368 * VLCPlaylist implementation
369 *****************************************************************************/
370 @implementation VLCPlaylist
377 o_nodes_array = [[NSMutableArray alloc] init];
378 o_items_array = [[NSMutableArray alloc] init];
385 [o_nodes_array release];
386 [o_items_array release];
392 playlist_t * p_playlist = pl_Get( VLCIntf );
396 [super awakeFromNib];
398 [o_outline_view setDoubleAction: @selector(playItem:)];
399 [o_outline_view_other setDoubleAction: @selector(playItem:)];
401 [o_outline_view registerForDraggedTypes:
402 [NSArray arrayWithObjects: NSFilenamesPboardType,
403 @"VLCPlaylistItemPboardType", nil]];
404 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
406 [o_outline_view_other registerForDraggedTypes:
407 [NSArray arrayWithObjects: NSFilenamesPboardType,
408 @"VLCPlaylistItemPboardType", nil]];
409 [o_outline_view_other setIntercellSpacing: NSMakeSize (0.0, 1.0)];
411 /* This uses private Apple API which works fine until 10.5.
412 * We need to keep checking in the future!
413 * These methods are being added artificially to NSOutlineView's interface above */
414 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
415 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
417 o_tc_sortColumn = nil;
420 char ** ppsz_services = vlc_sd_GetNames( VLCIntf, &ppsz_name, NULL );
424 for( i = 0; ppsz_services[i]; i++ )
429 char * name = ppsz_name[i] ? ppsz_name[i] : ppsz_services[i];
430 /* Check whether to enable these menuitems */
431 b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, ppsz_services[i] );
433 /* Create the menu entries used in the playlist menu */
434 o_lmi = [[o_mi_services submenu] addItemWithTitle:
435 [NSString stringWithUTF8String: name]
436 action: @selector(servicesChange:)
438 [o_lmi setTarget: self];
439 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
440 if( b_enabled ) [o_lmi setState: NSOnState];
442 /* Create the menu entries for the main menu */
443 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
444 [NSString stringWithUTF8String: name]
445 action: @selector(servicesChange:)
447 [o_lmi setTarget: self];
448 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
449 if( b_enabled ) [o_lmi setState: NSOnState];
451 free( ppsz_services[i] );
452 free( ppsz_name[i] );
454 free( ppsz_services );
458 - (void)searchfieldChanged:(NSNotification *)o_notification
460 [o_search_field setStringValue:[[o_notification object] stringValue]];
467 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
468 [o_mi_play setTitle: _NS("Play")];
469 [o_mi_delete setTitle: _NS("Delete")];
470 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
471 [o_mi_selectall setTitle: _NS("Select All")];
472 [o_mi_info setTitle: _NS("Media Information...")];
473 [o_mi_dl_cover_art setTitle: _NS("Download Cover Art")];
474 [o_mi_preparse setTitle: _NS("Fetch Meta Data")];
475 [o_mi_revealInFinder setTitle: _NS("Reveal in Finder")];
476 [o_mm_mi_revealInFinder setTitle: _NS("Reveal in Finder")];
477 [[o_mm_mi_revealInFinder menu] setAutoenablesItems: NO];
478 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
479 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
480 [o_mi_services setTitle: _NS("Services discovery")];
481 [o_mm_mi_services setTitle: _NS("Services discovery")];
483 [o_search_field setToolTip: _NS("Search in Playlist")];
484 [o_search_field_other setToolTip: _NS("Search in Playlist")];
486 [o_save_accessory_text setStringValue: _NS("File Format:")];
487 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
488 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
489 [[o_save_accessory_popup itemAtIndex:2] setTitle: _NS("HTML Playlist")];
492 - (void)swapPlaylists:(id)newList
494 if(newList != o_outline_view)
496 id o_search_field_temp = o_search_field;
497 o_search_field = o_search_field_other;
498 o_search_field_other = o_search_field_temp;
499 [super swapPlaylists:newList];
500 [self playlistUpdated];
504 - (void)playlistUpdated
506 /* Clear indications of any existing column sorting */
507 NSUInteger count = [[o_outline_view tableColumns] count];
508 for( NSUInteger i = 0 ; i < count ; i++ )
510 [o_outline_view setIndicatorImage:nil inTableColumn:
511 [[o_outline_view tableColumns] objectAtIndex:i]];
514 [o_outline_view setHighlightedTableColumn:nil];
515 o_tc_sortColumn = nil;
516 // TODO Find a way to keep the dict size to a minimum
517 //[o_outline_dict removeAllObjects];
518 [o_outline_view reloadData];
519 [[[[VLCMain sharedInstance] wizard] playlistWizard] reloadOutlineView];
520 [[[[VLCMain sharedInstance] bookmarks] dataTable] reloadData];
522 [self outlineViewSelectionDidChange: nil];
523 [[VLCMain sharedInstance] updateMainWindow];
526 - (void)outlineViewSelectionDidChange:(NSNotification *)notification
529 playlist_item_t * p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
533 /* update the state of our Reveal-in-Finder menu items */
534 NSMutableString *o_mrl;
535 char *psz_uri = input_item_GetURI( p_item->p_input );
537 [o_mi_revealInFinder setEnabled: NO];
538 [o_mm_mi_revealInFinder setEnabled: NO];
541 o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
543 /* perform some checks whether it is a file and if it is local at all... */
544 NSRange prefix_range = [o_mrl rangeOfString: @"file:"];
545 if( prefix_range.location != NSNotFound )
546 [o_mrl deleteCharactersInRange: prefix_range];
548 if( [o_mrl characterAtIndex:0] == '/' )
550 [o_mi_revealInFinder setEnabled: YES];
551 [o_mm_mi_revealInFinder setEnabled: YES];
556 /* update our info-panel to reflect the new item */
557 [[[VLCMain sharedInstance] info] updatePanelWithItem:p_item->p_input];
561 - (BOOL)isSelectionEmpty
563 return [o_outline_view selectedRow] == -1;
566 - (void)updateRowSelection
569 playlist_t *p_playlist = pl_Get( VLCIntf );
570 playlist_item_t *p_item, *p_temp_item;
571 NSMutableArray *o_array = [NSMutableArray array];
574 p_item = playlist_CurrentPlayingItem( p_playlist );
581 p_temp_item = p_item;
582 while( p_temp_item->p_parent )
584 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
585 p_temp_item = p_temp_item->p_parent;
589 NSUInteger count = [o_array count];
590 for( NSUInteger j = 0; j < count - 1; j++ )
593 if( ( o_item = [o_outline_dict objectForKey:
594 [NSString stringWithFormat: @"%p",
595 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
597 [o_outline_view expandItem: o_item];
602 /* Check if p_item is a child of p_node recursively. We need to check the item
603 existence first since OSX sometimes tries to redraw items that have been
604 deleted. We don't do it when not required since this verification takes
605 quite a long time on big playlists (yes, pretty hacky). */
607 - (BOOL)isItem: (playlist_item_t *)p_item
608 inNode: (playlist_item_t *)p_node
609 checkItemExistence:(BOOL)b_check
610 locked:(BOOL)b_locked
613 playlist_t * p_playlist = pl_Get( VLCIntf );
614 playlist_item_t *p_temp_item = p_item;
616 if( p_node == p_item )
619 if( p_node->i_children < 1)
625 if(!b_locked) PL_LOCK;
629 /* Since outlineView: willDisplayCell:... may call this function with
630 p_items that don't exist anymore, first check if the item is still
631 in the playlist. Any cleaner solution welcomed. */
632 for( i = 0; i < p_playlist->all_items.i_size; i++ )
634 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
635 else if ( i == p_playlist->all_items.i_size - 1 )
637 if(!b_locked) PL_UNLOCK;
645 p_temp_item = p_temp_item->p_parent;
646 if( p_temp_item == p_node )
648 if(!b_locked) PL_UNLOCK;
652 if(!b_locked) PL_UNLOCK;
657 - (BOOL)isItem: (playlist_item_t *)p_item
658 inNode: (playlist_item_t *)p_node
659 checkItemExistence:(BOOL)b_check
661 return [self isItem:p_item inNode:p_node checkItemExistence:b_check locked:NO];
664 /* This method is useful for instance to remove the selected children of an
665 already selected node */
666 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
668 NSUInteger itemCount = [o_items count];
669 NSUInteger nodeCount = [o_nodes count];
670 for( NSUInteger i = 0 ; i < itemCount ; i++ )
672 for ( NSUInteger j = 0 ; j < nodeCount ; j++ )
674 if( o_items == o_nodes)
676 if( j == i ) continue;
678 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
679 inNode: [[o_nodes objectAtIndex:j] pointerValue]
680 checkItemExistence: NO locked:NO] )
682 [o_items removeObjectAtIndex:i];
683 /* We need to execute the next iteration with the same index
684 since the current item has been deleted */
692 - (IBAction)savePlaylist:(id)sender
694 playlist_t * p_playlist = pl_Get( VLCIntf );
696 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
697 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
699 [o_save_panel setTitle: _NS("Save Playlist")];
700 [o_save_panel setPrompt: _NS("Save")];
701 [o_save_panel setAccessoryView: o_save_accessory_view];
703 if( [o_save_panel runModalForDirectory: nil
704 file: o_name] == NSOKButton )
706 NSString *o_filename = [[o_save_panel URL] path];
708 if( [o_save_accessory_popup indexOfSelectedItem] == 0 )
710 NSString * o_real_filename;
712 range.location = [o_filename length] - [@".m3u" length];
713 range.length = [@".m3u" length];
715 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
716 range: range] != NSOrderedSame )
718 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
722 o_real_filename = o_filename;
724 playlist_Export( p_playlist,
725 [o_real_filename fileSystemRepresentation],
726 p_playlist->p_local_category, "export-m3u" );
728 else if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
730 NSString * o_real_filename;
732 range.location = [o_filename length] - [@".xspf" length];
733 range.length = [@".xspf" length];
735 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
736 range: range] != NSOrderedSame )
738 o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
742 o_real_filename = o_filename;
744 playlist_Export( p_playlist,
745 [o_real_filename fileSystemRepresentation],
746 p_playlist->p_local_category, "export-xspf" );
750 NSString * o_real_filename;
752 range.location = [o_filename length] - [@".html" length];
753 range.length = [@".html" length];
755 if( [o_filename compare:@".html" options: NSCaseInsensitiveSearch
756 range: range] != NSOrderedSame )
758 o_real_filename = [NSString stringWithFormat: @"%@.html", o_filename];
762 o_real_filename = o_filename;
764 playlist_Export( p_playlist,
765 [o_real_filename fileSystemRepresentation],
766 p_playlist->p_local_category, "export-html" );
771 /* When called retrieves the selected outlineview row and plays that node or item */
772 - (IBAction)playItem:(id)sender
774 intf_thread_t * p_intf = VLCIntf;
775 playlist_t * p_playlist = pl_Get( p_intf );
777 playlist_item_t *p_item;
778 playlist_item_t *p_node = NULL;
780 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
785 if( p_item->i_children == -1 )
787 p_node = p_item->p_parent;
792 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
794 p_item = p_node->pp_children[0];
801 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, p_node, p_item );
806 - (IBAction)revealItemInFinder:(id)sender
808 playlist_item_t * p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
809 NSMutableString * o_mrl = nil;
811 if(! p_item || !p_item->p_input )
814 char *psz_uri = decode_URI( input_item_GetURI( p_item->p_input ) );
816 o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
818 /* perform some checks whether it is a file and if it is local at all... */
819 NSRange prefix_range = [o_mrl rangeOfString: @"file:"];
820 if( prefix_range.location != NSNotFound )
821 [o_mrl deleteCharactersInRange: prefix_range];
823 if( [o_mrl characterAtIndex:0] == '/' )
824 [[NSWorkspace sharedWorkspace] selectFile: o_mrl inFileViewerRootedAtPath: o_mrl];
827 /* When called retrieves the selected outlineview row and plays that node or item */
828 - (IBAction)preparseItem:(id)sender
831 NSIndexSet *o_selected_indexes;
832 intf_thread_t * p_intf = VLCIntf;
833 playlist_t * p_playlist = pl_Get( p_intf );
834 playlist_item_t *p_item = NULL;
836 o_selected_indexes = [o_outline_view selectedRowIndexes];
837 i_count = [o_selected_indexes count];
839 NSUInteger indexes[i_count];
840 [o_selected_indexes getIndexes:indexes maxCount:i_count inIndexRange:nil];
841 for (int i = 0; i < i_count; i++)
843 p_item = [[o_outline_view itemAtRow:indexes[i]] pointerValue];
844 [o_outline_view deselectRow: indexes[i]];
848 if( p_item->i_children == -1 )
849 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
851 msg_Dbg( p_intf, "preparsing nodes not implemented" );
854 [self playlistUpdated];
857 - (IBAction)downloadCoverArt:(id)sender
860 NSIndexSet *o_selected_indexes;
861 intf_thread_t * p_intf = VLCIntf;
862 playlist_t * p_playlist = pl_Get( p_intf );
863 playlist_item_t *p_item = NULL;
865 o_selected_indexes = [o_outline_view selectedRowIndexes];
866 i_count = [o_selected_indexes count];
868 NSUInteger indexes[i_count];
869 [o_selected_indexes getIndexes:indexes maxCount:i_count inIndexRange:nil];
870 for (int i = 0; i < i_count; i++)
872 p_item = [[o_outline_view itemAtRow: indexes[i]] pointerValue];
873 [o_outline_view deselectRow: indexes[i]];
875 if( p_item && p_item->i_children == -1 )
876 playlist_AskForArtEnqueue( p_playlist, p_item->p_input );
878 [self playlistUpdated];
881 - (IBAction)servicesChange:(id)sender
883 NSMenuItem *o_mi = (NSMenuItem *)sender;
884 NSString *o_string = [o_mi representedObject];
885 playlist_t * p_playlist = pl_Get( VLCIntf );
886 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
887 playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
889 playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
891 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
892 [o_string UTF8String] ) ? YES : NO];
894 [self playlistUpdated];
898 - (IBAction)selectAll:(id)sender
900 [o_outline_view selectAll: nil];
903 - (IBAction)deleteItem:(id)sender
906 NSIndexSet *o_selected_indexes;
907 playlist_t * p_playlist;
908 intf_thread_t * p_intf = VLCIntf;
910 o_selected_indexes = [o_outline_view selectedRowIndexes];
911 i_count = [o_selected_indexes count];
913 p_playlist = pl_Get( p_intf );
915 NSUInteger indexes[i_count];
916 [o_selected_indexes getIndexes:indexes maxCount:i_count inIndexRange:nil];
917 for (int i = 0; i < i_count; i++)
919 id o_item = [o_outline_view itemAtRow: indexes[i]];
920 [o_outline_view deselectRow: indexes[i]];
923 playlist_item_t *p_item = [o_item pointerValue];
925 msg_Dbg( p_intf, "deleting item %i (of %i) with id \"%i\", pointerValue \"%p\" and %i children", i+1, i_count,
926 p_item->p_input->i_id, [o_item pointerValue], p_item->i_children +1 );
929 if( p_item->i_children != -1 )
930 //is a node and not an item
932 if( playlist_Status( p_playlist ) != PLAYLIST_STOPPED &&
933 [self isItem: playlist_CurrentPlayingItem( p_playlist ) inNode: ((playlist_item_t *)[o_item pointerValue])
934 checkItemExistence: NO locked:YES] == YES )
935 // if current item is in selected node and is playing then stop playlist
936 playlist_Control(p_playlist, PLAYLIST_STOP, pl_Locked );
938 playlist_NodeDelete( p_playlist, p_item, true, false );
941 playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
944 [o_outline_dict removeObjectForKey:[NSString stringWithFormat:@"%p", [o_item pointerValue]]];
948 [self playlistUpdated];
951 - (IBAction)sortNodeByName:(id)sender
953 [self sortNode: SORT_TITLE];
956 - (IBAction)sortNodeByAuthor:(id)sender
958 [self sortNode: SORT_ARTIST];
961 - (void)sortNode:(int)i_mode
963 playlist_t * p_playlist = pl_Get( VLCIntf );
964 playlist_item_t * p_item;
966 if( [o_outline_view selectedRow] > -1 )
968 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]] pointerValue];
971 /*If no item is selected, sort the whole playlist*/
973 p_item = p_playlist->p_root_category;
977 if( p_item->i_children > -1 ) // the item is a node
979 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
983 playlist_RecursiveNodeSort( p_playlist,
984 p_item->p_parent, i_mode, ORDER_NORMAL );
987 [self playlistUpdated];
990 - (input_item_t *)createItem:(NSDictionary *)o_one_item
992 intf_thread_t * p_intf = VLCIntf;
993 playlist_t * p_playlist = pl_Get( p_intf );
995 input_item_t *p_input;
996 BOOL b_rem = FALSE, b_dir = FALSE;
997 NSString *o_uri, *o_name;
1002 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
1003 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
1004 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
1006 /* Find the name for a disc entry (i know, can you believe the trouble?) */
1007 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
1010 struct statfs *mounts = NULL;
1012 i_count = getmntinfo (&mounts, MNT_NOWAIT);
1013 /* getmntinfo returns a pointer to static data. Do not free. */
1014 for( int i_index = 0 ; i_index < i_count; i_index++ )
1016 NSMutableString *o_temp, *o_temp2;
1017 o_temp = [NSMutableString stringWithString: o_uri];
1018 o_temp2 = [NSMutableString stringWithUTF8String: mounts[i_index].f_mntfromname];
1019 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
1020 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ];
1021 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ];
1023 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
1025 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithUTF8String:mounts[i_index].f_mntonname]];
1030 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
1031 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
1032 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
1034 /* All of this is to make sure CD's play when you D&D them on VLC */
1035 /* Converts mountpoint to a /dev file */
1038 NSMutableString *o_temp;
1040 buf = (struct statfs *) malloc (sizeof(struct statfs));
1041 statfs( [o_uri fileSystemRepresentation], buf );
1042 psz_dev = strdup(buf->f_mntfromname);
1043 o_temp = [NSMutableString stringWithUTF8String: psz_dev ];
1044 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
1045 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
1046 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
1050 p_input = input_item_New( [o_uri fileSystemRepresentation], o_name ? [o_name UTF8String] : NULL );
1056 NSUInteger count = [o_options count];
1057 for( NSUInteger i = 0; i < count; i++ )
1059 input_item_AddOption( p_input, [[o_options objectAtIndex:i] UTF8String],
1060 VLC_INPUT_OPTION_TRUSTED );
1064 /* Recent documents menu */
1065 o_true_file = [NSURL URLWithString: o_uri];
1066 if( o_true_file != nil && (BOOL)config_GetInt( p_playlist, "macosx-recentitems" ) == YES )
1068 [[NSDocumentController sharedDocumentController]
1069 noteNewRecentDocumentURL: o_true_file];
1074 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
1076 playlist_t * p_playlist = pl_Get( VLCIntf );
1077 NSUInteger count = [o_array count];
1080 for( NSUInteger i_item = 0; i_item < count; i_item++ )
1082 input_item_t *p_input;
1083 NSDictionary *o_one_item;
1086 o_one_item = [o_array objectAtIndex: i_item];
1087 p_input = [self createItem: o_one_item];
1094 /* FIXME: playlist_AddInput() can fail */
1096 playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT, i_position == -1 ? PLAYLIST_END : i_position + i_item, true,
1099 vlc_gc_decref( p_input );
1102 if( i_position == -1 )
1103 i_position = [o_outline_dict count] - 1;
1105 [self playlistUpdated];
1108 [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_position] byExtendingSelection:NO];
1109 [self playItem:nil];
1113 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1115 playlist_t * p_playlist = pl_Get( VLCIntf );
1116 NSUInteger count = [o_array count];
1118 for( NSUInteger i_item = 0; i_item < count; i_item++ )
1120 input_item_t *p_input;
1121 NSDictionary *o_one_item;
1124 o_one_item = [o_array objectAtIndex: i_item];
1125 p_input = [self createItem: o_one_item];
1127 if( !p_input ) continue;
1131 playlist_NodeAddInput( p_playlist, p_input, p_node,
1134 PLAYLIST_END : i_position + i_item,
1138 if( i_item == 0 && !b_enqueue )
1140 playlist_item_t *p_item;
1141 p_item = playlist_ItemGetByInput( p_playlist, p_input );
1142 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, p_node, p_item );
1145 vlc_gc_decref( p_input );
1147 [self playlistUpdated];
1150 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1152 playlist_t *p_playlist = pl_Get( VLCIntf );
1153 playlist_item_t *p_selected_item;
1156 i_selected_row = [o_outline_view selectedRow];
1157 if (i_selected_row < 0)
1160 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_selected_row] pointerValue];
1162 for( NSUInteger i_current = 0; i_current < p_item->i_children ; i_current++ )
1165 NSString *o_current_name, *o_current_author;
1168 o_current_name = [NSString stringWithUTF8String:
1169 p_item->pp_children[i_current]->p_input->psz_name];
1170 psz_temp = input_item_GetInfo( p_item->p_input ,
1171 _("Meta-information"),_("Artist") );
1172 o_current_author = [NSString stringWithUTF8String: psz_temp];
1176 if( p_selected_item == p_item->pp_children[i_current] &&
1177 b_selected_item_met == NO )
1179 b_selected_item_met = YES;
1181 else if( p_selected_item == p_item->pp_children[i_current] &&
1182 b_selected_item_met == YES )
1186 else if( b_selected_item_met == YES &&
1187 ( [o_current_name rangeOfString:[o_search_field
1188 stringValue] options:NSCaseInsensitiveSearch].length ||
1189 [o_current_author rangeOfString:[o_search_field
1190 stringValue] options:NSCaseInsensitiveSearch].length ) )
1192 /*Adds the parent items in the result array as well, so that we can
1194 return [NSMutableArray arrayWithObject: [NSValue
1195 valueWithPointer: p_item->pp_children[i_current]]];
1197 if( p_item->pp_children[i_current]->i_children > 0 )
1199 id o_result = [self subSearchItem:
1200 p_item->pp_children[i_current]];
1201 if( o_result != NULL )
1203 [o_result insertObject: [NSValue valueWithPointer:
1204 p_item->pp_children[i_current]] atIndex:0];
1212 - (IBAction)searchItem:(id)sender
1214 playlist_t * p_playlist = pl_Get( VLCIntf );
1219 b_selected_item_met = NO;
1221 /*First, only search after the selected item:*
1222 *(b_selected_item_met = NO) */
1223 o_result = [self subSearchItem:p_playlist->p_root_category];
1224 if( o_result == NULL )
1226 /* If the first search failed, search again from the beginning */
1227 o_result = [self subSearchItem:p_playlist->p_root_category];
1229 if( o_result != NULL )
1232 if( [[o_result objectAtIndex: 0] pointerValue] == p_playlist->p_local_category )
1236 NSUInteger count = [o_result count];
1238 for( NSUInteger i = i_start ; i < count - 1 ; i++ )
1240 [o_outline_view expandItem: [o_outline_dict objectForKey:
1241 [NSString stringWithFormat: @"%p",
1242 [[o_result objectAtIndex: i] pointerValue]]]];
1244 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1245 [NSString stringWithFormat: @"%p",
1246 [[o_result objectAtIndex: count - 1 ]
1251 [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
1252 [o_outline_view scrollRowToVisible: i_row];
1256 - (IBAction)recursiveExpandNode:(id)sender
1258 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1259 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1261 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1262 isItemExpandable: o_item] )
1264 o_item = [o_outline_dict objectForKey: [NSString stringWithFormat: @"%p", p_item->p_parent]];
1267 /* We need to collapse the node first, since OSX refuses to recursively
1268 expand an already expanded node, even if children nodes are collapsed. */
1269 [o_outline_view collapseItem: o_item collapseChildren: YES];
1270 [o_outline_view expandItem: o_item expandChildren: YES];
1273 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1279 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1281 int row = [o_outline_view rowAtPoint:pt];
1283 [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
1285 b_item_sel = ( row != -1 && [o_outline_view selectedRow] != -1 );
1286 b_rows = [o_outline_view numberOfRows] != 0;
1288 [o_mi_play setEnabled: b_item_sel];
1289 [o_mi_delete setEnabled: b_item_sel];
1290 [o_mi_selectall setEnabled: b_rows];
1291 [o_mi_info setEnabled: b_item_sel];
1292 [o_mi_preparse setEnabled: b_item_sel];
1293 [o_mi_recursive_expand setEnabled: b_item_sel];
1294 [o_mi_sort_name setEnabled: b_item_sel];
1295 [o_mi_sort_author setEnabled: b_item_sel];
1297 return( o_ctx_menu );
1300 - (void)outlineView: (NSOutlineView *)o_tv
1301 didClickTableColumn:(NSTableColumn *)o_tc
1303 int i_mode, i_type = 0;
1304 intf_thread_t *p_intf = VLCIntf;
1306 playlist_t *p_playlist = pl_Get( p_intf );
1308 /* Check whether the selected table column header corresponds to a
1309 sortable table column*/
1310 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1315 if( o_tc_sortColumn == o_tc )
1317 b_isSortDescending = !b_isSortDescending;
1321 b_isSortDescending = false;
1324 if( o_tc == o_tc_name )
1326 i_mode = SORT_TITLE;
1328 else if( o_tc == o_tc_author )
1330 i_mode = SORT_ARTIST;
1333 if( b_isSortDescending )
1335 i_type = ORDER_REVERSE;
1339 i_type = ORDER_NORMAL;
1343 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1346 [self playlistUpdated];
1348 o_tc_sortColumn = o_tc;
1349 [o_outline_view setHighlightedTableColumn:o_tc];
1351 if( b_isSortDescending )
1353 [o_outline_view setIndicatorImage:o_descendingSortingImage
1354 inTableColumn:o_tc];
1358 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1359 inTableColumn:o_tc];
1364 - (void)outlineView:(NSOutlineView *)outlineView
1365 willDisplayCell:(id)cell
1366 forTableColumn:(NSTableColumn *)tableColumn
1369 playlist_t *p_playlist = pl_Get( VLCIntf );
1374 o_playing_item = [o_outline_dict objectForKey: [NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
1377 if( [self isItem: [o_playing_item pointerValue] inNode:
1378 [item pointerValue] checkItemExistence: YES]
1379 || [o_playing_item isEqual: item] )
1381 [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toHaveTrait:NSBoldFontMask]];
1385 [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toNotHaveTrait:NSBoldFontMask]];
1391 playlist_t *p_playlist = pl_Get( VLCIntf );
1396 o_playing_item = [o_outline_dict objectForKey: [NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
1399 return o_playing_item;
1403 @implementation VLCPlaylist (NSOutlineViewDataSource)
1405 - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
1407 id o_value = [super outlineView: outlineView child: index ofItem: item];
1409 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p", [o_value pointerValue]]];
1413 /* Required for drag & drop and reordering */
1414 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1416 playlist_t *p_playlist = pl_Get( VLCIntf );
1418 /* First remove the items that were moved during the last drag & drop
1420 [o_items_array removeAllObjects];
1421 [o_nodes_array removeAllObjects];
1423 NSUInteger itemCount = [items count];
1425 for( NSUInteger i = 0 ; i < itemCount ; i++ )
1427 id o_item = [items objectAtIndex: i];
1429 /* Refuse to move items that are not in the General Node
1430 (Service Discovery) */
1431 if( (![self isItem: [o_item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] &&
1432 var_CreateGetBool( p_playlist, "media-library" ) && ![self isItem: [o_item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO]) ||
1433 [o_item pointerValue] == p_playlist->p_local_category ||
1434 [o_item pointerValue] == p_playlist->p_ml_category )
1438 /* Fill the items and nodes to move in 2 different arrays */
1439 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1440 [o_nodes_array addObject: o_item];
1442 [o_items_array addObject: o_item];
1445 /* Now we need to check if there are selected items that are in already
1446 selected nodes. In that case, we only want to move the nodes */
1447 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1448 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1450 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1451 a Drop operation coming from the playlist. */
1453 [pboard declareTypes: [NSArray arrayWithObjects:
1454 @"VLCPlaylistItemPboardType", nil] owner: self];
1455 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1460 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
1462 playlist_t *p_playlist = pl_Get( VLCIntf );
1463 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1465 if( !p_playlist ) return NSDragOperationNone;
1467 /* Dropping ON items is not allowed if item is not a node */
1470 if( index == NSOutlineViewDropOnItemIndex &&
1471 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1473 return NSDragOperationNone;
1477 /* Don't allow on drop on playlist root element's child */
1478 if( !item && index != NSOutlineViewDropOnItemIndex)
1480 return NSDragOperationNone;
1483 /* We refuse to drop an item in anything else than a child of the General
1484 Node. We still accept items that would be root nodes of the outlineview
1485 however, to allow drop in an empty playlist. */
1486 if( !( ([self isItem: [item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] ||
1487 ( var_CreateGetBool( p_playlist, "media-library" ) && [self isItem: [item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO] ) ) || item == nil ) )
1489 return NSDragOperationNone;
1492 /* Drop from the Playlist */
1493 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1495 NSUInteger count = [o_nodes_array count];
1496 for( NSUInteger i = 0 ; i < count ; i++ )
1498 /* We refuse to Drop in a child of an item we are moving */
1499 if( [self isItem: [item pointerValue] inNode:
1500 [[o_nodes_array objectAtIndex: i] pointerValue]
1501 checkItemExistence: NO] )
1503 return NSDragOperationNone;
1506 return NSDragOperationMove;
1509 /* Drop from the Finder */
1510 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1512 return NSDragOperationGeneric;
1514 return NSDragOperationNone;
1517 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
1519 playlist_t * p_playlist = pl_Get( VLCIntf );
1520 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1522 /* Drag & Drop inside the playlist */
1523 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1525 int i_row, i_removed_from_node = 0;
1526 playlist_item_t *p_new_parent, *p_item = NULL;
1527 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1529 /* If the item is to be dropped as root item of the outline, make it a
1530 child of the General node.
1531 Else, choose the proposed parent as parent. */
1532 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1533 else p_new_parent = [item pointerValue];
1535 /* Make sure the proposed parent is a node.
1536 (This should never be true) */
1537 if( p_new_parent->i_children < 0 )
1542 NSUInteger count = [o_all_items count];
1543 for( NSUInteger i = 0; i < count; i++ )
1545 playlist_item_t *p_old_parent = NULL;
1546 int i_old_index = 0;
1548 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1549 p_old_parent = p_item->p_parent;
1552 /* We may need the old index later */
1553 if( p_new_parent == p_old_parent )
1555 for( NSInteger j = 0; j < p_old_parent->i_children; j++ )
1557 if( p_old_parent->pp_children[j] == p_item )
1566 // Actually detach the item from the old position
1567 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1571 /* Calculate the new index */
1574 /* If we move the item in the same node, we need to take into
1575 account that one item will be deleted */
1578 if ((p_new_parent == p_old_parent && i_old_index < index + (int)i) )
1580 i_removed_from_node++;
1582 i_new_index = index + i - i_removed_from_node;
1584 // Reattach the item to the new position
1585 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1589 [self playlistUpdated];
1590 i_row = [o_outline_view rowForItem:[o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", [[o_all_items objectAtIndex: 0] pointerValue]]]];
1594 i_row = [o_outline_view rowForItem:[o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1597 [o_outline_view deselectAll: self];
1598 [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
1599 [o_outline_view scrollRowToVisible: i_row];
1604 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1606 playlist_item_t *p_node = [item pointerValue];
1608 NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType]
1609 sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
1610 NSUInteger count = [o_values count];
1611 NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
1613 for( NSUInteger i = 0; i < count; i++)
1615 NSDictionary *o_dic;
1616 char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL);
1620 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1624 [o_array addObject: o_dic];
1629 [self appendArray:o_array atPos:index enqueue: YES];
1633 assert( p_node->i_children != -1 );
1634 [self appendNodeArray:o_array inNode: p_node atPos:index enqueue:YES];