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_interaction.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 intf_thread_t *p_intf = VLCIntf;
246 playlist_item_t *p_item;
248 if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
250 p_item = (playlist_item_t *)[item pointerValue];
255 //NSLog( @"values for %p", p_item );
257 if( [[o_tc identifier] isEqualToString:@"1"] )
259 /* sanity check to prevent the NSString class from crashing */
260 if( p_item->input.psz_name != NULL )
262 o_value = [NSString stringWithUTF8String:
263 p_item->input.psz_name];
264 if( o_value == NULL )
265 o_value = [NSString stringWithCString:
266 p_item->input.psz_name];
269 else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
270 p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
272 o_value = [NSString stringWithUTF8String:
273 p_item->p_input->p_meta->psz_artist];
274 if( o_value == NULL )
275 o_value = [NSString stringWithCString:
276 p_item->p_input->p_meta->psz_artist];
278 else if( [[o_tc identifier] isEqualToString:@"3"] )
280 char psz_duration[MSTRTIME_MAX_SIZE];
281 mtime_t dur = p_item->p_input->i_duration;
284 secstotimestr( psz_duration, dur/1000000 );
285 o_value = [NSString stringWithUTF8String: psz_duration];
289 o_value = @"-:--:--";
298 /*****************************************************************************
299 * VLCPlaylistWizard implementation
300 *****************************************************************************/
301 @implementation VLCPlaylistWizard
303 - (IBAction)reloadOutlineView
305 /* Only reload the outlineview if the wizard window is open since this can
306 be quite long on big playlists */
307 if( [[o_outline_view window] isVisible] )
309 [o_outline_view reloadData];
315 /*****************************************************************************
316 * extension to NSOutlineView's interface to fix compilation warnings
317 * and let us access these 2 functions properly
318 * this uses a private Apple-API, but works fine on all current OSX releases
319 * keep checking for compatiblity with future releases though
320 *****************************************************************************/
322 @interface NSOutlineView (UndocumentedSortImages)
323 + (NSImage *)_defaultTableHeaderSortImage;
324 + (NSImage *)_defaultTableHeaderReverseSortImage;
328 /*****************************************************************************
329 * VLCPlaylist implementation
330 *****************************************************************************/
331 @implementation VLCPlaylist
338 o_nodes_array = [[NSMutableArray alloc] init];
339 o_items_array = [[NSMutableArray alloc] init];
346 playlist_t * p_playlist = pl_Yield( VLCIntf );
347 vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE,
352 [super awakeFromNib];
354 [o_outline_view setDoubleAction: @selector(playItem:)];
356 [o_outline_view registerForDraggedTypes:
357 [NSArray arrayWithObjects: NSFilenamesPboardType,
358 @"VLCPlaylistItemPboardType", nil]];
359 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
361 /* this uses private Apple API which works fine until 10.4,
362 * but keep checking in the future!
363 * These methods are being added artificially to NSOutlineView's interface above */
364 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
365 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
367 o_tc_sortColumn = nil;
369 for( i_index = 0; i_index < p_list->i_count; i_index++ )
371 vlc_bool_t b_enabled;
374 module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object ;
376 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
378 /* Check for submodules */
380 while( p_parser->pp_shortcuts[++i] != NULL ); i--;
382 /* Check whether to enable these menuitems */
383 objectname = i>=0 ? p_parser->pp_shortcuts[i] : p_parser->psz_object_name;
384 b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, objectname );
386 /* Create the menu entries used in the playlist menu */
387 o_lmi = [[o_mi_services submenu] addItemWithTitle:
388 [NSString stringWithUTF8String:
389 p_parser->psz_longname ? p_parser->psz_longname :
390 ( p_parser->psz_shortname ? p_parser->psz_shortname:
392 action: @selector(servicesChange:)
394 [o_lmi setTarget: self];
395 [o_lmi setRepresentedObject: [NSString stringWithCString: objectname]];
396 if( b_enabled ) [o_lmi setState: NSOnState];
398 /* Create the menu entries for the main menu */
399 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
400 [NSString stringWithUTF8String:
401 p_parser->psz_longname ? p_parser->psz_longname :
402 ( p_parser->psz_shortname ? p_parser->psz_shortname:
404 action: @selector(servicesChange:)
406 [o_lmi setTarget: self];
407 [o_lmi setRepresentedObject: [NSString stringWithCString:objectname]];
408 if( b_enabled ) [o_lmi setState: NSOnState];
411 vlc_list_release( p_list );
412 vlc_object_release( p_playlist );
414 //[self playlistUpdated];
417 - (void)searchfieldChanged:(NSNotification *)o_notification
419 [o_search_field setStringValue:[[o_notification object] stringValue]];
426 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
427 [o_mi_play setTitle: _NS("Play")];
428 [o_mi_delete setTitle: _NS("Delete")];
429 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
430 [o_mi_selectall setTitle: _NS("Select All")];
431 [o_mi_info setTitle: _NS("Information")];
432 [o_mi_preparse setTitle: _NS("Get Stream Information")];
433 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
434 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
435 [o_mi_services setTitle: _NS("Services discovery")];
436 [o_status_field setStringValue: [NSString stringWithFormat:
437 _NS("No items in the playlist")]];
440 [o_search_button setTitle: _NS("Search")];
442 [o_search_field setToolTip: _NS("Search in Playlist")];
443 [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];
445 [o_save_accessory_text setStringValue: _NS("File Format:")];
446 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
447 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
450 - (void)playlistUpdated
454 /* Clear indications of any existing column sorting */
455 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
457 [o_outline_view setIndicatorImage:nil inTableColumn:
458 [[o_outline_view tableColumns] objectAtIndex:i]];
461 [o_outline_view setHighlightedTableColumn:nil];
462 o_tc_sortColumn = nil;
463 // TODO Find a way to keep the dict size to a minimum
464 //[o_outline_dict removeAllObjects];
465 [o_outline_view reloadData];
466 [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];
467 [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];
469 playlist_t *p_playlist = pl_Yield( VLCIntf );
471 if( playlist_CurrentSize( p_playlist ) >= 2 )
473 [o_status_field setStringValue: [NSString stringWithFormat:
474 _NS("%i items in the playlist"),
475 playlist_CurrentSize( p_playlist )]];
479 if( playlist_IsEmpty( p_playlist ) )
481 [o_status_field setStringValue: _NS("No items in the playlist")];
485 [o_status_field setStringValue: _NS("1 item in the playlist")];
488 vlc_object_release( p_playlist );
491 - (void)playModeUpdated
493 playlist_t *p_playlist = pl_Yield( VLCIntf );
494 vlc_value_t val, val2;
496 var_Get( p_playlist, "loop", &val2 );
497 var_Get( p_playlist, "repeat", &val );
498 if( val.b_bool == VLC_TRUE )
500 [[[VLCMain sharedInstance] getControls] repeatOne];
502 else if( val2.b_bool == VLC_TRUE )
504 [[[VLCMain sharedInstance] getControls] repeatAll];
508 [[[VLCMain sharedInstance] getControls] repeatOff];
511 [[[VLCMain sharedInstance] getControls] shuffle];
513 vlc_object_release( p_playlist );
516 - (void)updateRowSelection
521 playlist_t *p_playlist = pl_Yield( VLCIntf );
522 playlist_item_t *p_item, *p_temp_item;
523 NSMutableArray *o_array = [NSMutableArray array];
525 p_item = p_playlist->status.p_item;
528 vlc_object_release(p_playlist);
532 p_temp_item = p_item;
533 while( p_temp_item->p_parent )
535 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
536 p_temp_item = p_temp_item->p_parent;
537 /*for (i = 0 ; i < p_temp_item->i_parents ; i++)
539 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
541 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
547 for( j = 0; j < [o_array count] - 1; j++ )
550 if( ( o_item = [o_outline_dict objectForKey:
551 [NSString stringWithFormat: @"%p",
552 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
554 [o_outline_view expandItem: o_item];
559 i_row = [o_outline_view rowForItem:[o_outline_dict
560 objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
562 [o_outline_view selectRow: i_row byExtendingSelection: NO];
563 [o_outline_view scrollRowToVisible: i_row];
565 vlc_object_release( p_playlist );
567 /* update our info-panel to reflect the new item */
568 [[[VLCMain sharedInstance] getInfo] updatePanel];
571 /* Check if p_item is a child of p_node recursively. We need to check the item
572 existence first since OSX sometimes tries to redraw items that have been
573 deleted. We don't do it when not required since this verification takes
574 quite a long time on big playlists (yes, pretty hacky). */
575 - (BOOL)isItem: (playlist_item_t *)p_item
576 inNode: (playlist_item_t *)p_node
577 checkItemExistence:(BOOL)b_check
580 playlist_t * p_playlist = pl_Yield( VLCIntf );
581 playlist_item_t *p_temp_item = p_item;
583 if( p_node == p_item )
585 vlc_object_release(p_playlist);
589 if( p_node->i_children < 1)
591 vlc_object_release(p_playlist);
598 vlc_mutex_lock( &p_playlist->object_lock );
602 /* Since outlineView: willDisplayCell:... may call this function with
603 p_items that don't exist anymore, first check if the item is still
604 in the playlist. Any cleaner solution welcomed. */
605 for( i = 0; i < p_playlist->all_items.i_size; i++ )
607 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
608 else if ( i == p_playlist->all_items.i_size - 1 )
610 vlc_object_release( p_playlist );
611 vlc_mutex_unlock( &p_playlist->object_lock );
619 p_temp_item = p_temp_item->p_parent;
620 if( p_temp_item == p_node )
622 vlc_mutex_unlock( &p_playlist->object_lock );
623 vlc_object_release( p_playlist );
627 vlc_mutex_unlock( &p_playlist->object_lock );
630 vlc_object_release( p_playlist );
634 /* This method is usefull for instance to remove the selected children of an
635 already selected node */
636 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
639 for( i = 0 ; i < [o_items count] ; i++ )
641 for ( j = 0 ; j < [o_nodes count] ; j++ )
643 if( o_items == o_nodes)
645 if( j == i ) continue;
647 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
648 inNode: [[o_nodes objectAtIndex:j] pointerValue]
649 checkItemExistence: NO] )
651 [o_items removeObjectAtIndex:i];
652 /* We need to execute the next iteration with the same index
653 since the current item has been deleted */
662 - (IBAction)savePlaylist:(id)sender
664 intf_thread_t * p_intf = VLCIntf;
665 playlist_t * p_playlist = pl_Yield( p_intf );
667 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
668 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
670 //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
671 [o_save_panel setTitle: _NS("Save Playlist")];
672 [o_save_panel setPrompt: _NS("Save")];
673 [o_save_panel setAccessoryView: o_save_accessory_view];
675 if( [o_save_panel runModalForDirectory: nil
676 file: o_name] == NSOKButton )
678 NSString *o_filename = [o_save_panel filename];
680 if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
682 NSString * o_real_filename;
684 range.location = [o_filename length] - [@".xspf" length];
685 range.length = [@".xspf" length];
687 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
688 range: range] != NSOrderedSame )
690 o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
694 o_real_filename = o_filename;
696 playlist_Export( p_playlist,
697 [o_real_filename fileSystemRepresentation],
698 p_playlist->p_local_category, "export-xspf" );
702 NSString * o_real_filename;
704 range.location = [o_filename length] - [@".m3u" length];
705 range.length = [@".m3u" length];
707 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
708 range: range] != NSOrderedSame )
710 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
714 o_real_filename = o_filename;
716 playlist_Export( p_playlist,
717 [o_real_filename fileSystemRepresentation],
718 p_playlist->p_local_category, "export-m3u" );
721 vlc_object_release( p_playlist );
724 /* When called retrieves the selected outlineview row and plays that node or item */
725 - (IBAction)playItem:(id)sender
727 intf_thread_t * p_intf = VLCIntf;
728 playlist_t * p_playlist = pl_Yield( p_intf );
730 playlist_item_t *p_item;
731 playlist_item_t *p_node = NULL;
733 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
737 if( p_item->i_children == -1 )
739 p_node = p_item->p_parent;
745 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
747 p_item = p_node->pp_children[0];
754 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_node, p_item );
756 vlc_object_release( p_playlist );
759 /* When called retrieves the selected outlineview row and plays that node or item */
760 - (IBAction)preparseItem:(id)sender
763 NSMutableArray *o_to_preparse;
764 intf_thread_t * p_intf = VLCIntf;
765 playlist_t * p_playlist = pl_Yield( p_intf );
767 o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
768 i_count = [o_to_preparse count];
772 playlist_item_t *p_item = NULL;
774 for( i = 0; i < i_count; i++ )
776 o_number = [o_to_preparse lastObject];
777 i_row = [o_number intValue];
778 p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
779 [o_to_preparse removeObject: o_number];
780 [o_outline_view deselectRow: i_row];
784 if( p_item->i_children == -1 )
786 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
790 msg_Dbg( p_intf, "preparse of nodes not yet implemented" );
794 vlc_object_release( p_playlist );
795 [self playlistUpdated];
798 - (IBAction)servicesChange:(id)sender
800 NSMenuItem *o_mi = (NSMenuItem *)sender;
801 NSString *o_string = [o_mi representedObject];
802 playlist_t * p_playlist = pl_Yield( VLCIntf );
803 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string cString] ) )
804 playlist_ServicesDiscoveryAdd( p_playlist, [o_string cString] );
806 playlist_ServicesDiscoveryRemove( p_playlist, [o_string cString] );
808 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
809 [o_string cString] ) ? YES : NO];
811 vlc_object_release( p_playlist );
812 [self playlistUpdated];
816 - (IBAction)selectAll:(id)sender
818 [o_outline_view selectAll: nil];
821 - (IBAction)deleteItem:(id)sender
823 int i, i_count, i_row;
824 NSMutableArray *o_to_delete;
827 playlist_t * p_playlist;
828 intf_thread_t * p_intf = VLCIntf;
830 p_playlist = pl_Yield( p_intf );
832 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
833 i_count = [o_to_delete count];
835 for( i = 0; i < i_count; i++ )
837 o_number = [o_to_delete lastObject];
838 i_row = [o_number intValue];
839 id o_item = [o_outline_view itemAtRow: i_row];
840 playlist_item_t *p_item = [o_item pointerValue];
841 [o_to_delete removeObject: o_number];
842 [o_outline_view deselectRow: i_row];
844 if( [[o_outline_view dataSource] outlineView:o_outline_view
845 numberOfChildrenOfItem: o_item] > 0 )
846 //is a node and not an item
848 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
849 [self isItem: p_playlist->status.p_item inNode:
850 ((playlist_item_t *)[o_item pointerValue])
851 checkItemExistence: NO] == YES )
853 // if current item is in selected node and is playing then stop playlist
854 playlist_Stop( p_playlist );
856 vlc_mutex_lock( &p_playlist->object_lock );
857 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
858 vlc_mutex_unlock( &p_playlist->object_lock );
862 playlist_LockDelete( p_playlist, p_item->i_id );
865 [self playlistUpdated];
866 vlc_object_release( p_playlist );
869 - (IBAction)sortNodeByName:(id)sender
871 [self sortNode: SORT_TITLE];
874 - (IBAction)sortNodeByAuthor:(id)sender
876 [self sortNode: SORT_ARTIST];
879 - (void)sortNode:(int)i_mode
881 playlist_t * p_playlist = pl_Yield( VLCIntf );
882 playlist_item_t * p_item;
884 if( [o_outline_view selectedRow] > -1 )
886 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
890 /*If no item is selected, sort the whole playlist*/
892 p_item = p_playlist->p_root_category;
895 if( p_item->i_children > -1 ) // the item is a node
897 vlc_mutex_lock( &p_playlist->object_lock );
898 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
899 vlc_mutex_unlock( &p_playlist->object_lock );
903 vlc_mutex_lock( &p_playlist->object_lock );
904 playlist_RecursiveNodeSort( p_playlist,
905 p_item->p_parent, i_mode, ORDER_NORMAL );
906 vlc_mutex_unlock( &p_playlist->object_lock );
908 vlc_object_release( p_playlist );
909 [self playlistUpdated];
912 - (input_item_t *)createItem:(NSDictionary *)o_one_item
914 intf_thread_t * p_intf = VLCIntf;
915 playlist_t * p_playlist = pl_Yield( p_intf );
917 input_item_t *p_input;
919 BOOL b_rem = FALSE, b_dir = FALSE;
920 NSString *o_uri, *o_name;
925 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
926 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
927 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
929 /* Find the name for a disc entry ( i know, can you believe the trouble?) */
930 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
932 int i_count, i_index;
933 struct statfs *mounts = NULL;
935 i_count = getmntinfo (&mounts, MNT_NOWAIT);
936 /* getmntinfo returns a pointer to static data. Do not free. */
937 for( i_index = 0 ; i_index < i_count; i_index++ )
939 NSMutableString *o_temp, *o_temp2;
940 o_temp = [NSMutableString stringWithString: o_uri];
941 o_temp2 = [NSMutableString stringWithCString: mounts[i_index].f_mntfromname];
942 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:nil range:NSMakeRange(0, [o_temp length]) ];
943 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
944 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
946 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
948 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithCString:mounts[i_index].f_mntonname]];
952 /* If no name, then make a guess */
953 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
955 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
956 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
957 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
959 /* All of this is to make sure CD's play when you D&D them on VLC */
960 /* Converts mountpoint to a /dev file */
963 NSMutableString *o_temp;
965 buf = (struct statfs *) malloc (sizeof(struct statfs));
966 statfs( [o_uri fileSystemRepresentation], buf );
967 psz_dev = strdup(buf->f_mntfromname);
968 o_temp = [NSMutableString stringWithCString: psz_dev ];
969 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:nil range:NSMakeRange(0, [o_temp length]) ];
970 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
971 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
975 p_input = input_ItemNew( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
981 for( i = 0; i < (int)[o_options count]; i++ )
983 input_ItemAddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
987 /* Recent documents menu */
988 o_true_file = [NSURL fileURLWithPath: o_uri];
989 if( o_true_file != nil )
991 [[NSDocumentController sharedDocumentController]
992 noteNewRecentDocumentURL: o_true_file];
995 vlc_object_release( p_playlist );
999 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
1002 playlist_t * p_playlist = pl_Yield( VLCIntf );
1004 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1006 input_item_t *p_input;
1007 NSDictionary *o_one_item;
1010 o_one_item = [o_array objectAtIndex: i_item];
1011 p_input = [self createItem: o_one_item];
1018 playlist_PlaylistAddInput( p_playlist, p_input, PLAYLIST_INSERT,
1019 i_position == -1 ? PLAYLIST_END : i_position + i_item );
1021 if( i_item == 0 && !b_enqueue )
1023 playlist_item_t *p_item;
1024 p_item = playlist_ItemGetByInput( p_playlist, p_input );
1025 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
1029 playlist_item_t *p_item;
1030 p_item = playlist_ItemGetByInput( p_playlist, p_input );
1031 playlist_Control( p_playlist, PLAYLIST_PREPARSE, p_item );
1034 [self playlistUpdated];
1035 vlc_object_release( p_playlist );
1038 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1041 playlist_t * p_playlist = pl_Yield( VLCIntf );
1043 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1045 input_item_t *p_input;
1046 NSDictionary *o_one_item;
1049 o_one_item = [o_array objectAtIndex: i_item];
1050 p_input = [self createItem: o_one_item];
1057 playlist_NodeAddInput( p_playlist, p_input, p_node,
1060 PLAYLIST_END : i_position + i_item );
1063 if( i_item == 0 && !b_enqueue )
1065 playlist_item_t *p_item;
1066 p_item = playlist_ItemGetByInput( p_playlist, p_input );
1067 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
1071 playlist_item_t *p_item;
1072 p_item = playlist_ItemGetByInput( p_playlist, p_input );
1073 playlist_Control( p_playlist, PLAYLIST_PREPARSE, p_item );
1076 [self playlistUpdated];
1077 vlc_object_release( p_playlist );
1080 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1082 playlist_t *p_playlist = pl_Yield( VLCIntf );
1083 playlist_item_t *p_selected_item;
1084 int i_current, i_selected_row;
1086 i_selected_row = [o_outline_view selectedRow];
1087 if (i_selected_row < 0)
1090 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
1091 i_selected_row] pointerValue];
1093 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
1096 NSString *o_current_name, *o_current_author;
1098 vlc_mutex_lock( &p_playlist->object_lock );
1099 o_current_name = [NSString stringWithUTF8String:
1100 p_item->pp_children[i_current]->p_input->psz_name];
1101 psz_temp = input_ItemGetInfo( p_item->p_input ,
1102 _("Meta-information"),_("Artist") );
1103 o_current_author = [NSString stringWithUTF8String: psz_temp];
1105 vlc_mutex_unlock( &p_playlist->object_lock );
1107 if( p_selected_item == p_item->pp_children[i_current] &&
1108 b_selected_item_met == NO )
1110 b_selected_item_met = YES;
1112 else if( p_selected_item == p_item->pp_children[i_current] &&
1113 b_selected_item_met == YES )
1115 vlc_object_release( p_playlist );
1118 else if( b_selected_item_met == YES &&
1119 ( [o_current_name rangeOfString:[o_search_field
1120 stringValue] options:NSCaseInsensitiveSearch ].length ||
1121 [o_current_author rangeOfString:[o_search_field
1122 stringValue] options:NSCaseInsensitiveSearch ].length ) )
1124 vlc_object_release( p_playlist );
1125 /*Adds the parent items in the result array as well, so that we can
1127 return [NSMutableArray arrayWithObject: [NSValue
1128 valueWithPointer: p_item->pp_children[i_current]]];
1130 if( p_item->pp_children[i_current]->i_children > 0 )
1132 id o_result = [self subSearchItem:
1133 p_item->pp_children[i_current]];
1134 if( o_result != NULL )
1136 vlc_object_release( p_playlist );
1137 [o_result insertObject: [NSValue valueWithPointer:
1138 p_item->pp_children[i_current]] atIndex:0];
1143 vlc_object_release( p_playlist );
1147 - (IBAction)searchItem:(id)sender
1149 playlist_t * p_playlist = pl_Yield( VLCIntf );
1155 b_selected_item_met = NO;
1157 /*First, only search after the selected item:*
1158 *(b_selected_item_met = NO) */
1159 o_result = [self subSearchItem:p_playlist->p_root_category];
1160 if( o_result == NULL )
1162 /* If the first search failed, search again from the beginning */
1163 o_result = [self subSearchItem:p_playlist->p_root_category];
1165 if( o_result != NULL )
1168 if( [[o_result objectAtIndex: 0] pointerValue] ==
1169 p_playlist->p_local_category )
1174 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1176 [o_outline_view expandItem: [o_outline_dict objectForKey:
1177 [NSString stringWithFormat: @"%p",
1178 [[o_result objectAtIndex: i] pointerValue]]]];
1180 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1181 [NSString stringWithFormat: @"%p",
1182 [[o_result objectAtIndex: [o_result count] - 1 ]
1187 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1188 [o_outline_view scrollRowToVisible: i_row];
1190 vlc_object_release( p_playlist );
1193 - (IBAction)recursiveExpandNode:(id)sender
1195 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1196 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1198 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1199 isItemExpandable: o_item] )
1201 o_item = [o_outline_dict objectForKey: [NSString
1202 stringWithFormat: @"%p", p_item->p_parent]];
1205 /* We need to collapse the node first, since OSX refuses to recursively
1206 expand an already expanded node, even if children nodes are collapsed. */
1207 [o_outline_view collapseItem: o_item collapseChildren: YES];
1208 [o_outline_view expandItem: o_item expandChildren: YES];
1211 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1215 vlc_bool_t b_item_sel;
1217 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1219 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
1220 [o_outline_view selectedRow] != -1 );
1221 b_rows = [o_outline_view numberOfRows] != 0;
1223 [o_mi_play setEnabled: b_item_sel];
1224 [o_mi_delete setEnabled: b_item_sel];
1225 [o_mi_selectall setEnabled: b_rows];
1226 [o_mi_info setEnabled: b_item_sel];
1227 [o_mi_preparse setEnabled: b_item_sel];
1228 [o_mi_recursive_expand setEnabled: b_item_sel];
1229 [o_mi_sort_name setEnabled: b_item_sel];
1230 [o_mi_sort_author setEnabled: b_item_sel];
1232 return( o_ctx_menu );
1235 - (void)outlineView: (NSTableView*)o_tv
1236 didClickTableColumn:(NSTableColumn *)o_tc
1238 int i_mode = 0, i_type;
1239 intf_thread_t *p_intf = VLCIntf;
1241 playlist_t *p_playlist = pl_Yield( p_intf );
1243 /* Check whether the selected table column header corresponds to a
1244 sortable table column*/
1245 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1247 vlc_object_release( p_playlist );
1251 if( o_tc_sortColumn == o_tc )
1253 b_isSortDescending = !b_isSortDescending;
1257 b_isSortDescending = VLC_FALSE;
1260 if( o_tc == o_tc_name )
1262 i_mode = SORT_TITLE;
1264 else if( o_tc == o_tc_author )
1266 i_mode = SORT_ARTIST;
1269 if( b_isSortDescending )
1271 i_type = ORDER_REVERSE;
1275 i_type = ORDER_NORMAL;
1278 vlc_mutex_lock( &p_playlist->object_lock );
1279 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1280 vlc_mutex_unlock( &p_playlist->object_lock );
1282 vlc_object_release( p_playlist );
1283 [self playlistUpdated];
1285 o_tc_sortColumn = o_tc;
1286 [o_outline_view setHighlightedTableColumn:o_tc];
1288 if( b_isSortDescending )
1290 [o_outline_view setIndicatorImage:o_descendingSortingImage
1291 inTableColumn:o_tc];
1295 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1296 inTableColumn:o_tc];
1301 - (void)outlineView:(NSOutlineView *)outlineView
1302 willDisplayCell:(id)cell
1303 forTableColumn:(NSTableColumn *)tableColumn
1306 playlist_t *p_playlist = pl_Yield( VLCIntf );
1310 o_playing_item = [o_outline_dict objectForKey:
1311 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1313 if( [self isItem: [o_playing_item pointerValue] inNode:
1314 [item pointerValue] checkItemExistence: YES]
1315 || [o_playing_item isEqual: item] )
1317 [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1321 [cell setFont: [NSFont systemFontOfSize: 0]];
1323 vlc_object_release( p_playlist );
1326 - (IBAction)addNode:(id)sender
1328 /* we have to create a new thread here because otherwise we would block the
1329 * interface since the interaction-stuff and this code would run in the same
1331 [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
1332 toTarget: self withObject:nil];
1333 [self playlistUpdated];
1336 - (void)addNodeThreadedly
1338 NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
1340 /* simply adds a new node to the end of the playlist */
1341 playlist_t * p_playlist = pl_Yield( VLCIntf );
1342 vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
1345 char *psz_name = NULL;
1346 playlist_item_t * p_item;
1347 ret_v = intf_UserStringInput( p_playlist, _("New Node"),
1348 _("Please enter a name for the new node."), &psz_name );
1349 if( psz_name != NULL && psz_name != "" )
1350 p_item = playlist_NodeCreate( p_playlist, psz_name,
1351 p_playlist->p_local_category );
1353 p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
1354 p_playlist->p_local_category );
1357 msg_Warn( VLCIntf, "node creation failed" );
1359 vlc_object_release( p_playlist );
1365 @implementation VLCPlaylist (NSOutlineViewDataSource)
1367 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1369 id o_value = [super outlineView: outlineView child: index ofItem: item];
1370 playlist_t *p_playlist = pl_Yield( VLCIntf );
1372 if( playlist_CurrentSize( p_playlist ) >= 2 )
1374 [o_status_field setStringValue: [NSString stringWithFormat:
1375 _NS("%i items in the playlist"),
1376 playlist_CurrentSize( p_playlist )]];
1380 if( playlist_IsEmpty( p_playlist ) )
1382 [o_status_field setStringValue: _NS("No items in the playlist")];
1386 [o_status_field setStringValue: _NS("1 item in the playlist")];
1389 vlc_object_release( p_playlist );
1391 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
1392 [o_value pointerValue]]];
1393 msg_Dbg( VLCIntf, "adding item %p", [o_value pointerValue] );
1398 /* Required for drag & drop and reordering */
1399 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1402 playlist_t *p_playlist = pl_Yield( VLCIntf );
1404 /* First remove the items that were moved during the last drag & drop
1406 [o_items_array removeAllObjects];
1407 [o_nodes_array removeAllObjects];
1409 for( i = 0 ; i < [items count] ; i++ )
1411 id o_item = [items objectAtIndex: i];
1413 /* Refuse to move items that are not in the General Node
1414 (Service Discovery) */
1415 if( ![self isItem: [o_item pointerValue] inNode:
1416 p_playlist->p_local_category checkItemExistence: NO])
1418 vlc_object_release(p_playlist);
1421 /* Fill the items and nodes to move in 2 different arrays */
1422 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1423 [o_nodes_array addObject: o_item];
1425 [o_items_array addObject: o_item];
1428 /* Now we need to check if there are selected items that are in already
1429 selected nodes. In that case, we only want to move the nodes */
1430 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1431 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1433 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1434 a Drop operation coming from the playlist. */
1436 [pboard declareTypes: [NSArray arrayWithObjects:
1437 @"VLCPlaylistItemPboardType", nil] owner: self];
1438 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1440 vlc_object_release(p_playlist);
1444 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1446 playlist_t *p_playlist = pl_Yield( VLCIntf );
1447 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1449 if( !p_playlist ) return NSDragOperationNone;
1451 /* Dropping ON items is not allowed if item is not a node */
1454 if( index == NSOutlineViewDropOnItemIndex &&
1455 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1457 vlc_object_release( p_playlist );
1458 return NSDragOperationNone;
1462 /* We refuse to drop an item in anything else than a child of the General
1463 Node. We still accept items that would be root nodes of the outlineview
1464 however, to allow drop in an empty playlist. */
1465 if( !([self isItem: [item pointerValue] inNode: p_playlist->p_local_category
1466 checkItemExistence: NO] || item == nil) )
1468 vlc_object_release( p_playlist );
1469 return NSDragOperationNone;
1472 /* Drop from the Playlist */
1473 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1476 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1478 /* We refuse to Drop in a child of an item we are moving */
1479 if( [self isItem: [item pointerValue] inNode:
1480 [[o_nodes_array objectAtIndex: i] pointerValue]
1481 checkItemExistence: NO] )
1483 vlc_object_release( p_playlist );
1484 return NSDragOperationNone;
1487 vlc_object_release( p_playlist );
1488 return NSDragOperationMove;
1491 /* Drop from the Finder */
1492 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1494 vlc_object_release( p_playlist );
1495 return NSDragOperationGeneric;
1497 vlc_object_release( p_playlist );
1498 return NSDragOperationNone;
1501 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1503 playlist_t * p_playlist = pl_Yield( VLCIntf );
1504 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1506 /* Drag & Drop inside the playlist */
1507 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1509 int i_row, i_removed_from_node = 0;
1511 playlist_item_t *p_new_parent, *p_item = NULL;
1512 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1514 /* If the item is to be dropped as root item of the outline, make it a
1515 child of the General node.
1516 Else, choose the proposed parent as parent. */
1517 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1518 else p_new_parent = [item pointerValue];
1520 /* Make sure the proposed parent is a node.
1521 (This should never be true) */
1522 if( p_new_parent->i_children < 0 )
1524 vlc_object_release( p_playlist );
1528 for( i = 0; i < [o_all_items count]; i++ )
1530 playlist_item_t *p_old_parent = NULL;
1531 int i_old_index = 0;
1533 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1534 p_old_parent = p_item->p_parent;
1537 /* We may need the old index later */
1538 if( p_new_parent == p_old_parent )
1541 for( j = 0; j < p_old_parent->i_children; j++ )
1543 if( p_old_parent->pp_children[j] == p_item )
1551 vlc_mutex_lock( &p_playlist->object_lock );
1552 // Acually detach the item from the old position
1553 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1557 /* Calculate the new index */
1560 /* If we move the item in the same node, we need to take into
1561 account that one item will be deleted */
1564 if ((p_new_parent == p_old_parent &&
1565 i_old_index < index + (int)i) )
1567 i_removed_from_node++;
1569 i_new_index = index + i - i_removed_from_node;
1571 // Reattach the item to the new position
1572 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1574 vlc_mutex_unlock( &p_playlist->object_lock );
1576 [self playlistUpdated];
1577 i_row = [o_outline_view rowForItem:[o_outline_dict
1578 objectForKey:[NSString stringWithFormat: @"%p",
1579 [[o_all_items objectAtIndex: 0] pointerValue]]]];
1583 i_row = [o_outline_view rowForItem:[o_outline_dict
1584 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1587 [o_outline_view deselectAll: self];
1588 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1589 [o_outline_view scrollRowToVisible: i_row];
1591 vlc_object_release( p_playlist );
1595 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1598 playlist_item_t *p_node = [item pointerValue];
1600 NSArray *o_array = [NSArray array];
1601 NSArray *o_values = [[o_pasteboard propertyListForType:
1602 NSFilenamesPboardType]
1603 sortedArrayUsingSelector:
1604 @selector(caseInsensitiveCompare:)];
1606 for( i = 0; i < (int)[o_values count]; i++)
1608 NSDictionary *o_dic;
1609 o_dic = [NSDictionary dictionaryWithObject:[o_values
1610 objectAtIndex:i] forKey:@"ITEM_URL"];
1611 o_array = [o_array arrayByAddingObject: o_dic];
1616 [self appendArray: o_array atPos: index enqueue: YES];
1618 /* This should never occur */
1619 else if( p_node->i_children == -1 )
1621 vlc_object_release( p_playlist );
1626 [self appendNodeArray: o_array inNode: p_node
1627 atPos: index enqueue: YES];
1629 vlc_object_release( p_playlist );
1632 vlc_object_release( p_playlist );
1636 /* Delegate method of NSWindow */
1637 /*- (void)windowWillClose:(NSNotification *)aNotification
1639 [o_btn_playlist setState: NSOffState];