1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2005 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 search field build with pictures from the 'regular' search field, so it can be emulated on 10.2
29 * create toggle buttons for the shuffle, repeat one, repeat all functions.
30 * implement drag and drop and item reordering.
31 * reimplement enable/disable item
32 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
33 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
37 /*****************************************************************************
39 *****************************************************************************/
40 #include <stdlib.h> /* malloc(), free() */
41 #include <sys/param.h> /* for MAXPATHLEN */
44 #include <sys/mount.h>
53 /*****************************************************************************
54 * VLCPlaylistView implementation
55 *****************************************************************************/
56 @implementation VLCPlaylistView
58 - (NSMenu *)menuForEvent:(NSEvent *)o_event
60 return( [[self delegate] menuForEvent: o_event] );
63 - (void)keyDown:(NSEvent *)o_event
67 if( [[o_event characters] length] )
69 key = [[o_event characters] characterAtIndex: 0];
74 case NSDeleteCharacter:
75 case NSDeleteFunctionKey:
76 case NSDeleteCharFunctionKey:
77 case NSBackspaceCharacter:
78 [[self delegate] deleteItem:self];
81 case NSEnterCharacter:
82 case NSCarriageReturnCharacter:
83 [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist]
88 [super keyDown: o_event];
95 /*****************************************************************************
96 * VLCPlaylist implementation
97 *****************************************************************************/
98 @implementation VLCPlaylist
105 o_outline_dict = [[NSMutableDictionary alloc] init];
106 o_nodes_array = [[NSMutableArray alloc] init];
107 o_items_array = [[NSMutableArray alloc] init];
117 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
119 vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE,
123 i_current_view = VIEW_CATEGORY;
124 playlist_ViewUpdate( p_playlist, i_current_view );
126 [o_outline_view setTarget: self];
127 [o_outline_view setDelegate: self];
128 [o_outline_view setDataSource: self];
130 [o_outline_view setDoubleAction: @selector(playItem:)];
132 [o_outline_view registerForDraggedTypes:
133 [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
134 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
136 /* We need to check whether _defaultTableHeaderSortImage exists, since it
137 belongs to an Apple hidden private API, and then can "disapear" at any time*/
139 if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderSortImage)] )
141 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
145 o_ascendingSortingImage = nil;
148 if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)] )
150 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
154 o_descendingSortingImage = nil;
157 o_tc_sortColumn = nil;
159 for( i_index = 0; i_index < p_list->i_count; i_index++ )
162 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
164 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
166 /* create the menu entries used in the playlist menu */
167 o_lmi = [[o_mi_services submenu] addItemWithTitle:
168 [NSString stringWithUTF8String:
169 p_parser->psz_longname ? p_parser->psz_longname :
170 ( p_parser->psz_shortname ? p_parser->psz_shortname:
171 p_parser->psz_object_name)]
172 action: @selector(servicesChange:)
174 [o_lmi setTarget: self];
175 [o_lmi setRepresentedObject:
176 [NSString stringWithCString: p_parser->psz_object_name]];
177 if( playlist_IsServicesDiscoveryLoaded( p_playlist,
178 p_parser->psz_object_name ) )
179 [o_lmi setState: NSOnState];
181 /* create the menu entries for the main menu */
182 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
183 [NSString stringWithUTF8String:
184 p_parser->psz_longname ? p_parser->psz_longname :
185 ( p_parser->psz_shortname ? p_parser->psz_shortname:
186 p_parser->psz_object_name)]
187 action: @selector(servicesChange:)
189 [o_lmi setTarget: self];
190 [o_lmi setRepresentedObject:
191 [NSString stringWithCString: p_parser->psz_object_name]];
192 if( playlist_IsServicesDiscoveryLoaded( p_playlist,
193 p_parser->psz_object_name ) )
194 [o_lmi setState: NSOnState];
197 vlc_list_release( p_list );
198 vlc_object_release( p_playlist );
200 /* Change the simple textfield into a searchField if we can... */
202 if( MACOS_VERSION >= 10.3 )
204 NSView *o_parentview = [o_status_field superview];
205 NSSearchField *o_better_search_field = [[NSSearchField alloc]initWithFrame:[o_search_field frame]];
206 [o_better_search_field setRecentsAutosaveName:@"VLC media player search"];
207 [o_better_search_field setDelegate:self];
208 [[NSNotificationCenter defaultCenter] addObserver: self
209 selector: @selector(searchfieldChanged:)
210 name: NSControlTextDidChangeNotification
211 object: o_better_search_field];
213 [o_better_search_field setTarget:self];
214 [o_better_search_field setAction:@selector(searchItem:)];
216 [o_better_search_field setAutoresizingMask:NSViewMinXMargin];
217 [o_parentview addSubview:o_better_search_field];
218 [o_search_field setHidden:YES];
222 //[self playlistUpdated];
225 - (void)searchfieldChanged:(NSNotification *)o_notification
227 [o_search_field setStringValue:[[o_notification object] stringValue]];
232 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
233 [o_mi_play setTitle: _NS("Play")];
234 [o_mi_delete setTitle: _NS("Delete")];
235 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
236 [o_mi_selectall setTitle: _NS("Select All")];
237 [o_mi_info setTitle: _NS("Properties")];
238 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
239 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
240 [o_mi_services setTitle: _NS("Services discovery")];
241 [[o_tc_name headerCell] setStringValue:_NS("Name")];
242 [[o_tc_author headerCell] setStringValue:_NS("Author")];
243 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
244 [o_status_field setStringValue: [NSString stringWithFormat:
245 _NS("no items in playlist")]];
247 [o_random_ckb setTitle: _NS("Random")];
249 [o_search_button setTitle: _NS("Search")];
251 [o_search_field setToolTip: _NS("Search in Playlist")];
252 [[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
253 [[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
254 [[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
257 - (NSOutlineView *)outlineView
259 return o_outline_view;
262 - (void)playlistUpdated
266 /* Clear indications of any existing column sorting*/
267 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
269 [o_outline_view setIndicatorImage:nil inTableColumn:
270 [[o_outline_view tableColumns] objectAtIndex:i]];
273 [o_outline_view setHighlightedTableColumn:nil];
274 o_tc_sortColumn = nil;
275 // TODO Find a way to keep the dict size to a minimum
276 //[o_outline_dict removeAllObjects];
277 [o_outline_view reloadData];
280 - (void)playModeUpdated
282 playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
284 vlc_value_t val, val2;
286 if( p_playlist == NULL )
291 var_Get( p_playlist, "loop", &val2 );
292 var_Get( p_playlist, "repeat", &val );
293 if( val.b_bool == VLC_TRUE )
295 [o_loop_popup selectItemAtIndex: 1];
297 else if( val2.b_bool == VLC_TRUE )
299 [o_loop_popup selectItemAtIndex: 2];
303 [o_loop_popup selectItemAtIndex: 0];
306 var_Get( p_playlist, "random", &val );
307 [o_random_ckb setState: val.b_bool];
309 vlc_object_release( p_playlist );
312 - (playlist_item_t *)parentOfItem:(playlist_item_t *)p_item
315 for( i = 0 ; i < p_item->i_parents; i++ )
317 if( p_item->pp_parents[i]->i_view == i_current_view )
319 return p_item->pp_parents[i]->p_parent;
325 - (void)updateRowSelection
331 playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
333 playlist_item_t *p_item, *p_temp_item;
334 NSMutableArray *o_array = [NSMutableArray array];
336 if( p_playlist == NULL )
339 p_item = p_playlist->status.p_item;
342 vlc_object_release(p_playlist);
346 p_temp_item = p_item;
347 while( p_temp_item->i_parents > 0 )
349 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
351 p_temp_item = [self parentOfItem: p_temp_item];
352 /*for (i = 0 ; i < p_temp_item->i_parents ; i++)
354 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
356 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
362 for (j = 0 ; j < [o_array count] - 1 ; j++)
365 if( ( o_item = [o_outline_dict objectForKey:
366 [NSString stringWithFormat: @"%p",
367 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
368 [o_outline_view expandItem: o_item];
372 i_row = [o_outline_view rowForItem:[o_outline_dict
373 objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
375 [o_outline_view selectRow: i_row byExtendingSelection: NO];
376 [o_outline_view scrollRowToVisible: i_row];
378 vlc_object_release(p_playlist);
381 - (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node
383 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
385 playlist_item_t *p_temp_item = p_item;
387 if( p_playlist == NULL )
392 if( p_node == p_item )
394 vlc_object_release(p_playlist);
398 if( p_node->i_children < 1)
400 vlc_object_release(p_playlist);
407 vlc_mutex_lock( &p_playlist->object_lock );
409 // Let's check if we can do without that
412 /* Since outlineView: willDisplayCell:... may call this function with
413 p_items that don't exist anymore, first check if the item is still
414 in the playlist. Any cleaner solution welcomed. */
417 if( p_playlist->pp_all_items[i] == p_item ) break;
418 else if ( i == p_playlist->i_all_size - 1 )
420 vlc_object_release( p_playlist );
421 vlc_mutex_unlock( &p_playlist->object_lock );
426 while( p_temp_item->i_parents > 0 )
428 p_temp_item = [self parentOfItem: p_temp_item];
429 if( p_temp_item == p_node )
431 vlc_mutex_unlock( &p_playlist->object_lock );
432 vlc_object_release( p_playlist );
436 /* for( i = 0; i < p_temp_item->i_parents ; i++ )
438 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
440 if( p_temp_item->pp_parents[i]->p_parent == p_node )
442 vlc_mutex_unlock( &p_playlist->object_lock );
443 vlc_object_release( p_playlist );
448 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
454 vlc_mutex_unlock( &p_playlist->object_lock );
457 vlc_object_release( p_playlist );
461 /* This method is usefull for instance to remove the selected children of an
462 already selected node, for instance */
463 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
466 for( i = 0 ; i < [o_items count] ; i++ )
468 for ( j = 0 ; j < [o_nodes count] ; j++ )
470 if( o_items == o_nodes)
472 if( j == i ) continue;
474 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
475 inNode: [[o_nodes objectAtIndex:j] pointerValue]] )
477 [o_nodes removeObjectAtIndex:i];
478 /* We need to execute the next iteration with the same index
479 since the current item has been deleted */
488 - (BOOL)isValueItem: (id)o_item inNode: (id)o_node
491 int i_total = [[o_outline_view dataSource] outlineView:o_outline_view
492 numberOfChildrenOfItem: o_node];
493 for( i = 0 ; i < i_total ; i++ )
495 id o_temp_item = [[o_outline_view dataSource] outlineView:
496 o_outline_view child:i ofItem: o_node];
497 if( [[o_outline_view dataSource] outlineView:o_outline_view
498 numberOfChildrenOfItem: o_temp_item] > 0 )
500 if( [self isValueItem: o_item inNode: o_temp_item] == YES )
503 else if( [o_temp_item isEqual: o_item] )
511 - (IBAction)savePlaylist:(id)sender
513 intf_thread_t * p_intf = VLCIntf;
514 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
517 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
518 NSString * o_name = [NSString stringWithFormat: @"%@.m3u", _NS("Untitled")];
519 [o_save_panel setTitle: _NS("Save Playlist")];
520 [o_save_panel setPrompt: _NS("Save")];
522 if( [o_save_panel runModalForDirectory: nil
523 file: o_name] == NSOKButton )
525 playlist_Export( p_playlist, [[o_save_panel filename] fileSystemRepresentation], "export-m3u" );
530 /* When called retrieves the selected outlineview row and plays that node or item */
531 - (IBAction)playItem:(id)sender
533 intf_thread_t * p_intf = VLCIntf;
534 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
537 if( p_playlist != NULL )
539 playlist_item_t *p_item;
540 playlist_item_t *p_node = NULL;
543 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
547 if( p_item->i_children == -1 )
549 p_node = [self parentOfItem: p_item];
551 /* for( i = 0 ; i < p_item->i_parents ; i++ )
553 if( p_item->pp_parents[i]->i_view == i_current_view )
555 p_node = p_item->pp_parents[i]->p_parent;
562 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
564 p_item = p_node->pp_children[0];
571 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, i_current_view, p_node, p_item );
573 vlc_object_release( p_playlist );
577 - (IBAction)servicesChange:(id)sender
579 NSMenuItem *o_mi = (NSMenuItem *)sender;
580 NSString *o_string = [o_mi representedObject];
581 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
583 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string cString] ) )
584 playlist_ServicesDiscoveryAdd( p_playlist, [o_string cString] );
586 playlist_ServicesDiscoveryRemove( p_playlist, [o_string cString] );
588 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
589 [o_string cString] ) ? YES : NO];
591 i_current_view = VIEW_CATEGORY;
592 playlist_ViewUpdate( p_playlist, i_current_view );
593 vlc_object_release( p_playlist );
594 [self playlistUpdated];
598 - (IBAction)selectAll:(id)sender
600 [o_outline_view selectAll: nil];
603 - (IBAction)deleteItem:(id)sender
605 int i, i_count, i_row;
606 NSMutableArray *o_to_delete;
609 playlist_t * p_playlist;
610 intf_thread_t * p_intf = VLCIntf;
612 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
615 if ( p_playlist == NULL )
619 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
620 i_count = [o_to_delete count];
622 for( i = 0; i < i_count; i++ )
624 o_number = [o_to_delete lastObject];
625 i_row = [o_number intValue];
626 id o_item = [o_outline_view itemAtRow: i_row];
627 playlist_item_t *p_item = [o_item pointerValue];
628 [o_to_delete removeObject: o_number];
629 [o_outline_view deselectRow: i_row];
631 if( [[o_outline_view dataSource] outlineView:o_outline_view
632 numberOfChildrenOfItem: o_item] > 0 )
633 //is a node and not an item
635 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
636 [self isItem: p_playlist->status.p_item inNode:
637 ((playlist_item_t *)[o_item pointerValue])] == YES )
639 // if current item is in selected node and is playing then stop playlist
640 playlist_Stop( p_playlist );
642 vlc_mutex_lock( &p_playlist->object_lock );
643 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
644 vlc_mutex_unlock( &p_playlist->object_lock );
648 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
649 p_playlist->status.p_item == [[o_outline_view itemAtRow: i_row] pointerValue] )
651 playlist_Stop( p_playlist );
653 vlc_mutex_lock( &p_playlist->object_lock );
654 playlist_Delete( p_playlist, p_item->input.i_id );
655 vlc_mutex_unlock( &p_playlist->object_lock );
658 [self playlistUpdated];
659 vlc_object_release( p_playlist );
662 - (IBAction)sortNodeByName:(id)sender
664 [self sortNode: SORT_TITLE];
667 - (IBAction)sortNodeByAuthor:(id)sender
669 [self sortNode: SORT_AUTHOR];
672 - (void)sortNode:(int)i_mode
674 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
676 playlist_item_t * p_item;
678 if (p_playlist == NULL)
683 if( [o_outline_view selectedRow] > -1 )
685 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
689 /*If no item is selected, sort the whole playlist*/
691 playlist_view_t * p_view = playlist_ViewFind( p_playlist, i_current_view );
692 p_item = p_view->p_root;
695 if( p_item->i_children > -1 ) // the item is a node
697 vlc_mutex_lock( &p_playlist->object_lock );
698 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
699 vlc_mutex_unlock( &p_playlist->object_lock );
705 for( i = 0 ; i < p_item->i_parents ; i++ )
707 if( p_item->pp_parents[i]->i_view == i_current_view )
709 vlc_mutex_lock( &p_playlist->object_lock );
710 playlist_RecursiveNodeSort( p_playlist,
711 p_item->pp_parents[i]->p_parent, i_mode, ORDER_NORMAL );
712 vlc_mutex_unlock( &p_playlist->object_lock );
717 vlc_object_release( p_playlist );
718 [self playlistUpdated];
721 - (playlist_item_t *)createItem:(NSDictionary *)o_one_item
723 intf_thread_t * p_intf = VLCIntf;
724 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
727 if( p_playlist == NULL )
731 playlist_item_t *p_item;
733 BOOL b_rem = FALSE, b_dir = FALSE;
734 NSString *o_uri, *o_name;
739 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
740 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
741 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
743 /* Find the name for a disc entry ( i know, can you believe the trouble?) */
744 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
746 int i_count, i_index;
747 struct statfs *mounts = NULL;
749 i_count = getmntinfo (&mounts, MNT_NOWAIT);
750 /* getmntinfo returns a pointer to static data. Do not free. */
751 for( i_index = 0 ; i_index < i_count; i_index++ )
753 NSMutableString *o_temp, *o_temp2;
754 o_temp = [NSMutableString stringWithString: o_uri];
755 o_temp2 = [NSMutableString stringWithCString: mounts[i_index].f_mntfromname];
756 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:NULL range:NSMakeRange(0, [o_temp length]) ];
757 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:NULL range:NSMakeRange(0, [o_temp2 length]) ];
758 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:NULL range:NSMakeRange(0, [o_temp2 length]) ];
760 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
762 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithCString:mounts[i_index].f_mntonname]];
766 /* If no name, then make a guess */
767 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
769 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
770 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
771 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
773 /* All of this is to make sure CD's play when you D&D them on VLC */
774 /* Converts mountpoint to a /dev file */
777 NSMutableString *o_temp;
779 buf = (struct statfs *) malloc (sizeof(struct statfs));
780 statfs( [o_uri fileSystemRepresentation], buf );
781 psz_dev = strdup(buf->f_mntfromname);
782 o_temp = [NSMutableString stringWithCString: psz_dev ];
783 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:NULL range:NSMakeRange(0, [o_temp length]) ];
784 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:NULL range:NSMakeRange(0, [o_temp length]) ];
785 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:NULL range:NSMakeRange(0, [o_temp length]) ];
789 p_item = playlist_ItemNew( p_intf, [o_uri fileSystemRepresentation], [o_name UTF8String] );
795 for( i = 0; i < (int)[o_options count]; i++ )
797 playlist_ItemAddOption( p_item, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
801 /* Recent documents menu */
802 o_true_file = [NSURL fileURLWithPath: o_uri];
803 if( o_true_file != nil )
805 [[NSDocumentController sharedDocumentController]
806 noteNewRecentDocumentURL: o_true_file];
809 vlc_object_release( p_playlist );
813 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
816 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
818 if( p_playlist == NULL )
823 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
825 playlist_item_t *p_item;
826 NSDictionary *o_one_item;
829 o_one_item = [o_array objectAtIndex: i_item];
830 p_item = [self createItem: o_one_item];
837 playlist_AddItem( p_playlist, p_item, PLAYLIST_APPEND, i_position == -1 ? PLAYLIST_END : i_position + i_item );
839 if( i_item == 0 && !b_enqueue )
841 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
844 vlc_object_release( p_playlist );
847 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position inView:(int)i_view enqueue:(BOOL)b_enqueue
850 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
852 if( p_playlist == NULL )
857 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
859 playlist_item_t *p_item;
860 NSDictionary *o_one_item;
863 o_one_item = [o_array objectAtIndex: i_item];
864 p_item = [self createItem: o_one_item];
871 playlist_NodeAddItem( p_playlist, p_item, i_view, p_node, PLAYLIST_APPEND, i_position + i_item );
873 if( i_item == 0 && !b_enqueue )
875 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
878 vlc_object_release( p_playlist );
882 - (IBAction)handlePopUp:(id)sender
885 intf_thread_t * p_intf = VLCIntf;
886 vlc_value_t val1,val2;
887 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
889 if( p_playlist == NULL )
894 switch( [o_loop_popup indexOfSelectedItem] )
899 var_Set( p_playlist, "loop", val1 );
901 var_Set( p_playlist, "repeat", val1 );
902 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
907 var_Set( p_playlist, "repeat", val1 );
909 var_Set( p_playlist, "loop", val1 );
910 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
914 var_Get( p_playlist, "repeat", &val1 );
915 var_Get( p_playlist, "loop", &val2 );
916 if( val1.b_bool || val2.b_bool )
919 var_Set( p_playlist, "repeat", val1 );
920 var_Set( p_playlist, "loop", val1 );
921 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
925 vlc_object_release( p_playlist );
926 [self playlistUpdated];
929 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
931 playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
933 playlist_item_t *p_selected_item;
934 int i_current, i_selected_row;
939 i_selected_row = [o_outline_view selectedRow];
940 if (i_selected_row < 0)
943 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
944 i_selected_row] pointerValue];
946 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
949 NSString *o_current_name, *o_current_author;
951 vlc_mutex_lock( &p_playlist->object_lock );
952 o_current_name = [NSString stringWithUTF8String:
953 p_item->pp_children[i_current]->input.psz_name];
954 psz_temp = vlc_input_item_GetInfo( &p_item->input ,
955 _("Meta-information"),_("Artist") );
956 o_current_author = [NSString stringWithUTF8String: psz_temp];
958 vlc_mutex_unlock( &p_playlist->object_lock );
960 if( p_selected_item == p_item->pp_children[i_current] &&
961 b_selected_item_met == NO )
963 b_selected_item_met = YES;
965 else if( p_selected_item == p_item->pp_children[i_current] &&
966 b_selected_item_met == YES )
968 vlc_object_release( p_playlist );
971 else if( b_selected_item_met == YES &&
972 ( [o_current_name rangeOfString:[o_search_field
973 stringValue] options:NSCaseInsensitiveSearch ].length ||
974 [o_current_author rangeOfString:[o_search_field
975 stringValue] options:NSCaseInsensitiveSearch ].length ) )
977 vlc_object_release( p_playlist );
978 /*Adds the parent items in the result array as well, so that we can
980 return [NSMutableArray arrayWithObject: [NSValue
981 valueWithPointer: p_item->pp_children[i_current]]];
983 if( p_item->pp_children[i_current]->i_children > 0 )
985 id o_result = [self subSearchItem:
986 p_item->pp_children[i_current]];
987 if( o_result != NULL )
989 vlc_object_release( p_playlist );
990 [o_result insertObject: [NSValue valueWithPointer:
991 p_item->pp_children[i_current]] atIndex:0];
996 vlc_object_release( p_playlist );
1000 - (IBAction)searchItem:(id)sender
1002 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1004 playlist_view_t * p_view;
1010 b_selected_item_met = NO;
1012 if( p_playlist == NULL )
1014 p_view = playlist_ViewFind( p_playlist, i_current_view );
1018 /*First, only search after the selected item:*
1019 *(b_selected_item_met = NO) */
1020 o_result = [self subSearchItem:p_view->p_root];
1021 if( o_result == NULL )
1023 /* If the first search failed, search again from the beginning */
1024 o_result = [self subSearchItem:p_view->p_root];
1026 if( o_result != NULL )
1029 if( [[o_result objectAtIndex: 0] pointerValue] ==
1030 p_playlist->p_general )
1035 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1037 [o_outline_view expandItem: [o_outline_dict objectForKey:
1038 [NSString stringWithFormat: @"%p",
1039 [[o_result objectAtIndex: i] pointerValue]]]];
1041 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1042 [NSString stringWithFormat: @"%p",
1043 [[o_result objectAtIndex: [o_result count] - 1 ]
1048 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1049 [o_outline_view scrollRowToVisible: i_row];
1052 vlc_object_release( p_playlist );
1055 - (IBAction)recursiveExpandNode:(id)sender
1058 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1059 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1061 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1062 isItemExpandable: o_item] )
1064 for( i = 0 ; i < p_item->i_parents ; i++ )
1066 if( p_item->pp_parents[i]->i_view == i_current_view )
1068 o_item = [o_outline_dict objectForKey: [NSString
1069 stringWithFormat: @"%p", p_item->pp_parents[i]->p_parent]];
1075 /* We need to collapse the node first, since OSX refuses to recursively
1076 expand an already expanded node, even if children nodes are collapsed. */
1077 [o_outline_view collapseItem: o_item collapseChildren: YES];
1078 [o_outline_view expandItem: o_item expandChildren: YES];
1081 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1085 vlc_bool_t b_item_sel;
1087 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1089 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
1090 [o_outline_view selectedRow] != -1 );
1091 b_rows = [o_outline_view numberOfRows] != 0;
1093 [o_mi_play setEnabled: b_item_sel];
1094 [o_mi_delete setEnabled: b_item_sel];
1095 [o_mi_selectall setEnabled: b_rows];
1096 [o_mi_info setEnabled: b_item_sel];
1097 [o_mi_recursive_expand setEnabled: b_item_sel];
1098 [o_mi_sort_name setEnabled: b_item_sel];
1099 [o_mi_sort_author setEnabled: b_item_sel];
1101 return( o_ctx_menu );
1104 - (playlist_item_t *)selectedPlaylistItem
1106 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
1110 - (void)outlineView: (NSTableView*)o_tv
1111 didClickTableColumn:(NSTableColumn *)o_tc
1113 int i_mode = 0, i_type;
1114 intf_thread_t *p_intf = VLCIntf;
1115 playlist_view_t *p_view;
1117 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1119 if( p_playlist == NULL )
1124 /* Check whether the selected table column header corresponds to a
1125 sortable table column*/
1126 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1128 vlc_object_release( p_playlist );
1132 p_view = playlist_ViewFind( p_playlist, i_current_view );
1134 if( o_tc_sortColumn == o_tc )
1136 b_isSortDescending = !b_isSortDescending;
1140 b_isSortDescending = VLC_FALSE;
1143 if( o_tc == o_tc_name )
1145 i_mode = SORT_TITLE;
1147 else if( o_tc == o_tc_author )
1149 i_mode = SORT_AUTHOR;
1152 if( b_isSortDescending )
1154 i_type = ORDER_REVERSE;
1158 i_type = ORDER_NORMAL;
1161 vlc_mutex_lock( &p_playlist->object_lock );
1162 playlist_RecursiveNodeSort( p_playlist, p_view->p_root, i_mode, i_type );
1163 vlc_mutex_unlock( &p_playlist->object_lock );
1165 vlc_object_release( p_playlist );
1166 [self playlistUpdated];
1168 o_tc_sortColumn = o_tc;
1169 [o_outline_view setHighlightedTableColumn:o_tc];
1171 if( b_isSortDescending )
1173 [o_outline_view setIndicatorImage:o_descendingSortingImage
1174 inTableColumn:o_tc];
1178 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1179 inTableColumn:o_tc];
1184 - (void)outlineView:(NSOutlineView *)outlineView
1185 willDisplayCell:(id)cell
1186 forTableColumn:(NSTableColumn *)tableColumn
1189 playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1194 if( !p_playlist ) return;
1196 o_playing_item = [o_outline_dict objectForKey:
1197 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1199 if( [self isValueItem: o_playing_item inNode: item] ||
1200 [o_playing_item isEqual: item] )
1202 [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1206 [cell setFont: [NSFont systemFontOfSize: 0]];
1208 vlc_object_release( p_playlist );
1213 @implementation VLCPlaylist (NSOutlineViewDataSource)
1215 /* return the number of children for Obj-C pointer item */ /* DONE */
1216 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
1219 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1221 if( p_playlist == NULL || outlineView != o_outline_view )
1227 playlist_view_t *p_view;
1228 p_view = playlist_ViewFind( p_playlist, i_current_view );
1229 if( p_view && p_view->p_root )
1231 i_return = p_view->p_root->i_children;
1232 if( i_current_view == VIEW_CATEGORY )
1234 i_return--; /* remove the GENERAL item from the list */
1235 i_return += p_playlist->p_general->i_children; /* add the items of the general node */
1241 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1243 i_return = p_item->i_children;
1245 vlc_object_release( p_playlist );
1253 /* return the child at index for the Obj-C pointer item */ /* DONE */
1254 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1256 playlist_item_t *p_return = NULL;
1257 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1261 if( p_playlist == NULL )
1267 playlist_view_t *p_view;
1268 p_view = playlist_ViewFind( p_playlist, i_current_view );
1269 if( p_view && p_view->p_root ) p_return = p_view->p_root->pp_children[index];
1271 if( i_current_view == VIEW_CATEGORY )
1273 if( p_playlist->p_general->i_children && index >= 0 && index < p_playlist->p_general->i_children )
1275 p_return = p_playlist->p_general->pp_children[index];
1277 else if( p_view && p_view->p_root && index >= 0 && index - p_playlist->p_general->i_children < p_view->p_root->i_children )
1279 p_return = p_view->p_root->pp_children[index - p_playlist->p_general->i_children + 1];
1286 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1287 if( p_item && index < p_item->i_children && index >= 0 )
1288 p_return = p_item->pp_children[index];
1291 if( p_playlist->i_size >= 2 )
1293 [o_status_field setStringValue: [NSString stringWithFormat:
1294 _NS("%i items in playlist"), p_playlist->i_size]];
1298 if( p_playlist->i_size == 0 )
1300 [o_status_field setStringValue: [NSString stringWithFormat:
1301 _NS("no items in playlist"), p_playlist->i_size]];
1305 [o_status_field setStringValue: [NSString stringWithFormat:
1306 _NS("1 item in playlist"), p_playlist->i_size]];
1310 vlc_object_release( p_playlist );
1312 o_value = [[NSValue valueWithPointer: p_return] retain];
1314 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p", p_return]];
1318 /* is the item expandable */
1319 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
1322 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1324 if( p_playlist == NULL )
1330 playlist_view_t *p_view;
1331 p_view = playlist_ViewFind( p_playlist, i_current_view );
1332 if( p_view && p_view->p_root ) i_return = p_view->p_root->i_children;
1334 if( i_current_view == VIEW_CATEGORY )
1337 i_return += p_playlist->p_general->i_children;
1342 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1344 i_return = p_item->i_children;
1346 vlc_object_release( p_playlist );
1354 /* retrieve the string values for the cells */
1355 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
1358 intf_thread_t *p_intf = VLCIntf;
1359 playlist_t *p_playlist;
1360 playlist_item_t *p_item;
1362 if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
1364 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1366 if( p_playlist == NULL )
1371 p_item = (playlist_item_t *)[item pointerValue];
1373 if( p_item == NULL )
1375 vlc_object_release( p_playlist );
1379 if( [[o_tc identifier] isEqualToString:@"1"] )
1381 o_value = [NSString stringWithUTF8String:
1382 p_item->input.psz_name];
1383 if( o_value == NULL )
1384 o_value = [NSString stringWithCString:
1385 p_item->input.psz_name];
1387 else if( [[o_tc identifier] isEqualToString:@"2"] )
1390 psz_temp = vlc_input_item_GetInfo( &p_item->input ,_("Meta-information"),_("Artist") );
1392 if( psz_temp == NULL )
1396 o_value = [NSString stringWithUTF8String: psz_temp];
1397 if( o_value == NULL )
1399 o_value = [NSString stringWithCString: psz_temp];
1404 else if( [[o_tc identifier] isEqualToString:@"3"] )
1406 char psz_duration[MSTRTIME_MAX_SIZE];
1407 mtime_t dur = p_item->input.i_duration;
1410 secstotimestr( psz_duration, dur/1000000 );
1411 o_value = [NSString stringWithUTF8String: psz_duration];
1415 o_value = @"-:--:--";
1418 vlc_object_release( p_playlist );
1423 /* Required for drag & drop and reordering */
1424 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1427 playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1430 /* First remove the items that were moved during the last drag & drop
1432 [o_items_array removeAllObjects];
1433 [o_nodes_array removeAllObjects];
1435 if( !p_playlist ) return NO;
1437 for( i = 0 ; i < [items count] ; i++ )
1439 id o_item = [items objectAtIndex: i];
1441 /* Refuse to move items that are not in the General Node
1442 (Service Discovery) */
1443 if( ![self isItem: [o_item pointerValue] inNode:
1444 p_playlist->p_general] )
1446 vlc_object_release(p_playlist);
1449 /* Fill the items and nodes to move in 2 different arrays */
1450 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1451 [o_nodes_array addObject: o_item];
1453 [o_items_array addObject: o_item];
1456 /* Now we need to check if there are selected items that are in already
1457 selected nodes. In that case, we only want to move the nodes */
1458 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1459 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1462 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1464 for ( j = 0 ; j < [o_nodes_array count] ; j++ )
1466 if( j == i ) continue;
1467 if( [self isItem: [[o_nodes_array objectAtIndex:i] pointerValue]
1468 inNode: [[o_nodes_array objectAtIndex:j] pointerValue]] )
1470 [o_nodes_array removeObjectAtIndex:i];
1471 /* We need to execute the next iteration with the same index
1472 since the current item has been deleted */
1479 for( i = 0 ; i < [o_items_array count] ; i++ )
1481 for ( j = 0 ; j < [o_nodes_array count] ; j++ )
1483 if( [self isItem: [[o_items_array objectAtIndex:i] pointerValue]
1484 inNode: [[o_nodes_array objectAtIndex:j] pointerValue]] )
1486 [o_items_array removeObjectAtIndex:i];
1493 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1494 a Drop operation comçing from the playlist.
1495 We need to add NSFilenamesPboardType otherwise the outlineview refuses
1498 [pboard declareTypes: [NSArray arrayWithObjects:
1499 @"VLCPlaylistItemPboardType",NSFilenamesPboardType, nil] owner: self];
1500 [pboard setPropertyList:[NSArray array]
1501 forType:NSFilenamesPboardType];
1503 vlc_object_release(p_playlist);
1507 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1509 playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1511 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1513 if( !p_playlist ) return NSDragOperationNone;
1515 /* We refuse to drop an item in anything else than a child of the General
1516 Node. We still accept items that would be root nodes of the outlineview
1517 however, to allow drop in an empty playlist.*/
1518 if( !([self isItem: [item pointerValue] inNode: p_playlist->p_general] ||
1521 vlc_object_release(p_playlist);
1522 return NSDragOperationNone;
1525 /* Drop from the Playlist */
1526 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1529 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1531 /* We refuse to Drop in a child of an item we are moving */
1532 if( [self isItem: [item pointerValue] inNode:
1533 [[o_nodes_array objectAtIndex: i] pointerValue]] )
1535 vlc_object_release(p_playlist);
1536 return NSDragOperationNone;
1539 vlc_object_release(p_playlist);
1540 return NSDragOperationMove;
1543 /* Drop from the Finder */
1544 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1546 vlc_object_release(p_playlist);
1547 return NSDragOperationGeneric;
1549 vlc_object_release(p_playlist);
1550 return NSDragOperationNone;
1553 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1555 playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1557 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1559 if( !p_playlist ) return NO;
1561 /* Drag & Drop inside the playlist */
1562 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1566 playlist_item_t *p_new_parent, *p_item = NULL;
1567 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1569 /* If the item is to be dropped as root item of the outline, make it a
1570 child of the General node.
1571 Else, choose the proposed parent as parent. */
1573 p_new_parent = p_playlist->p_general;
1575 p_new_parent = [item pointerValue];
1577 /* If the proposed parent is not a node, then use the parent node of
1579 if( p_new_parent->i_children <= 0 )
1582 playlist_item_t *p_temp_item = p_new_parent;
1583 p_new_parent = [self parentOfItem: p_new_parent];
1586 vlc_object_release(p_playlist);
1589 /* Calculate the position of the dropped item in this new parent:
1590 following the first proposed parent. */
1591 for( j = 0; j < p_new_parent->i_children; j++ )
1593 if( p_new_parent->pp_children[j] == p_temp_item )
1598 else if( j == p_new_parent->i_children - 1 )
1603 for( i = 0; i < [o_all_items count]; i++ )
1605 playlist_item_t *p_old_parent = NULL;
1606 int i_old_index = 0;
1608 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1609 p_old_parent = [self parentOfItem: p_item];
1612 /* We may need the old index later */
1613 if( p_new_parent == p_old_parent )
1616 for( j = 0; j < p_old_parent->i_children; j++ )
1618 if( p_old_parent->pp_children[j] == p_item )
1627 /* If we move the playing item in a different node or we move the
1628 node containing the playing item in a different node, then stop
1629 playback, or the playlist refuses to detach the item. */
1630 /* if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
1631 (( p_item == p_playlist->status.p_item &&
1632 p_new_parent != p_old_parent) ||
1633 ( p_item->i_children > 0 &&
1634 [self isItem: p_playlist->status.p_item inNode:p_item] == YES))
1636 playlist_Stop( p_playlist );
1638 vlc_mutex_lock( &p_playlist->object_lock );
1639 // Acually detach the item from the old position
1640 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1642 playlist_NodeRemoveParent( p_playlist, p_item, p_old_parent ) ==
1646 /* Calculate the new index */
1649 /* If we move the item in the same node, we need to take into
1650 account that one item will be deleted */
1651 else if((p_new_parent == p_old_parent &&
1652 i_old_index < index + (int)i)
1653 || p_new_parent == p_playlist->p_general || index == 0 )
1654 i_new_index = index + i;
1656 i_new_index = index + i + 1;
1657 // Reattach the item to the new position
1658 playlist_NodeInsert( p_playlist, i_current_view, p_item,
1659 p_new_parent, i_new_index );
1661 vlc_mutex_unlock( &p_playlist->object_lock );
1663 [self playlistUpdated];
1664 i_row = [o_outline_view rowForItem:[o_outline_dict
1665 objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
1669 i_row = [o_outline_view rowForItem:[o_outline_dict
1670 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1673 [o_outline_view deselectAll: self];
1674 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1675 [o_outline_view scrollRowToVisible: i_row];
1677 vlc_object_release(p_playlist);
1681 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1684 playlist_item_t *p_node = [item pointerValue];
1686 NSArray *o_array = [NSArray array];
1687 NSArray *o_values = [[o_pasteboard propertyListForType:
1688 NSFilenamesPboardType]
1689 sortedArrayUsingSelector:
1690 @selector(caseInsensitiveCompare:)];
1692 for( i = 0; i < (int)[o_values count]; i++)
1694 NSDictionary *o_dic;
1695 o_dic = [NSDictionary dictionaryWithObject:[o_values
1696 objectAtIndex:i] forKey:@"ITEM_URL"];
1697 o_array = [o_array arrayByAddingObject: o_dic];
1702 [self appendArray: o_array atPos: index enqueue: YES];
1704 else if( p_node->i_children == -1 )
1707 playlist_item_t *p_real_node = NULL;
1709 for( i_counter = 0 ; i_counter < p_node->i_parents ; i_counter++ )
1711 if( p_node->pp_parents[i_counter]->i_view == i_current_view )
1713 p_real_node = p_node->pp_parents[i_counter]->p_parent;
1716 if( i_counter == p_node->i_parents )
1718 vlc_object_release(p_playlist);
1722 [self appendNodeArray: o_array inNode: p_real_node
1723 atPos: index inView: i_current_view enqueue: YES];
1727 [self appendNodeArray: o_array inNode: p_node
1728 atPos: index inView: i_current_view enqueue: YES];
1730 vlc_object_release( p_playlist );
1733 vlc_object_release( p_playlist );
1737 /* Delegate method of NSWindow */
1738 /*- (void)windowWillClose:(NSNotification *)aNotification
1740 [o_btn_playlist setState: NSOffState];