]> git.sesse.net Git - vlc/blob - modules/gui/macosx/playlist.m
db9ce190a38c9689c846510178844694e87fa6d8
[vlc] / modules / gui / macosx / playlist.m
1 /*****************************************************************************
2  * playlist.m: MacOS X interface module
3  *****************************************************************************
4 * Copyright (C) 2002-2005 VideoLAN
5  * $Id$
6  *
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>
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 /* TODO
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
34  */
35
36
37 /*****************************************************************************
38  * Preamble
39  *****************************************************************************/
40 #include <stdlib.h>                                      /* malloc(), free() */
41 #include <sys/param.h>                                    /* for MAXPATHLEN */
42 #include <string.h>
43 #include <math.h>
44 #include <sys/mount.h>
45 #include <vlc_keys.h>
46
47 #include "intf.h"
48 #include "playlist.h"
49 #include "controls.h"
50 #include "osd.h"
51 #include "misc.h"
52
53 /*****************************************************************************
54  * VLCPlaylistView implementation 
55  *****************************************************************************/
56 @implementation VLCPlaylistView
57
58 - (NSMenu *)menuForEvent:(NSEvent *)o_event
59 {
60     return( [[self delegate] menuForEvent: o_event] );
61 }
62
63 - (void)keyDown:(NSEvent *)o_event
64 {
65     unichar key = 0;
66
67     if( [[o_event characters] length] )
68     {
69         key = [[o_event characters] characterAtIndex: 0];
70     }
71
72     switch( key )
73     {
74         case NSDeleteCharacter:
75         case NSDeleteFunctionKey:
76         case NSDeleteCharFunctionKey:
77         case NSBackspaceCharacter:
78             [[self delegate] deleteItem:self];
79             break;
80
81         case NSEnterCharacter:
82         case NSCarriageReturnCharacter:
83             [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist]
84                                                             playItem:self];
85             break;
86
87         default:
88             [super keyDown: o_event];
89             break;
90     }
91 }
92
93 @end
94
95 /*****************************************************************************
96  * VLCPlaylist implementation 
97  *****************************************************************************/
98 @implementation VLCPlaylist
99
100 - (id)init
101 {
102     self = [super init];
103     if ( self != nil )
104     {
105         o_outline_dict = [[NSMutableDictionary alloc] init];
106         //i_moveRow = -1;
107     }
108     return self;
109 }
110
111 - (void)awakeFromNib
112 {
113     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
114                                           FIND_ANYWHERE );
115     vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE,
116                                         FIND_ANYWHERE );
117
118     int i_index;
119     i_current_view = VIEW_CATEGORY;
120     playlist_ViewUpdate( p_playlist, i_current_view );
121
122     [o_outline_view setTarget: self];
123     [o_outline_view setDelegate: self];
124     [o_outline_view setDataSource: self];
125
126     [o_outline_view setDoubleAction: @selector(playItem:)];
127
128     [o_outline_view registerForDraggedTypes:
129         [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
130     [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
131
132 /* We need to check whether _defaultTableHeaderSortImage exists, since it 
133 belongs to an Apple hidden private API, and then can "disapear" at any time*/
134
135     if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderSortImage)] )
136     {
137         o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
138     }
139     else
140     {
141         o_ascendingSortingImage = nil;
142     }
143
144     if( [[NSOutlineView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)] )
145     {
146         o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
147     }
148     else
149     {
150         o_descendingSortingImage = nil;
151     }
152
153     o_tc_sortColumn = nil;
154
155     for( i_index = 0; i_index < p_list->i_count; i_index++ )
156     {
157         NSMenuItem * o_lmi;
158         module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
159
160         if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
161         {
162             /* create the menu entries used in the playlist menu */
163             o_lmi = [[o_mi_services submenu] addItemWithTitle:
164                      [NSString stringWithUTF8String:
165                      p_parser->psz_longname ? p_parser->psz_longname :
166                      ( p_parser->psz_shortname ? p_parser->psz_shortname:
167                      p_parser->psz_object_name)]
168                                              action: @selector(servicesChange:)
169                                              keyEquivalent: @""];
170             [o_lmi setTarget: self];
171             [o_lmi setRepresentedObject:
172                    [NSString stringWithCString: p_parser->psz_object_name]];
173             if( playlist_IsServicesDiscoveryLoaded( p_playlist,
174                     p_parser->psz_object_name ) )
175                 [o_lmi setState: NSOnState];
176                 
177             /* create the menu entries for the main menu */
178             o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
179                      [NSString stringWithUTF8String:
180                      p_parser->psz_longname ? p_parser->psz_longname :
181                      ( p_parser->psz_shortname ? p_parser->psz_shortname:
182                      p_parser->psz_object_name)]
183                                              action: @selector(servicesChange:)
184                                              keyEquivalent: @""];
185             [o_lmi setTarget: self];
186             [o_lmi setRepresentedObject:
187                    [NSString stringWithCString: p_parser->psz_object_name]];
188             if( playlist_IsServicesDiscoveryLoaded( p_playlist,
189                     p_parser->psz_object_name ) )
190                 [o_lmi setState: NSOnState];
191         }
192     }
193     vlc_list_release( p_list );
194     vlc_object_release( p_playlist );
195
196     /* Change the simple textfield into a searchField if we can... */
197 #if 0
198     if( MACOS_VERSION >= 10.3 )
199     {
200         NSView *o_parentview = [o_status_field superview];
201         NSSearchField *o_better_search_field = [[NSSearchField alloc]initWithFrame:[o_search_field frame]];
202         [o_better_search_field setRecentsAutosaveName:@"VLC media player search"];
203         [o_better_search_field setDelegate:self];
204         [[NSNotificationCenter defaultCenter] addObserver: self
205             selector: @selector(searchfieldChanged:)
206             name: NSControlTextDidChangeNotification
207             object: o_better_search_field];
208
209         [o_better_search_field setTarget:self];
210         [o_better_search_field setAction:@selector(searchItem:)];
211
212         [o_better_search_field setAutoresizingMask:NSViewMinXMargin];
213         [o_parentview addSubview:o_better_search_field];
214         [o_search_field setHidden:YES];
215     }
216 #endif
217     [self initStrings];
218     //[self playlistUpdated];
219 }
220
221 - (void)searchfieldChanged:(NSNotification *)o_notification
222 {
223     [o_search_field setStringValue:[[o_notification object] stringValue]];
224 }
225
226 - (void)initStrings
227 {
228     [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
229     [o_mi_play setTitle: _NS("Play")];
230     [o_mi_delete setTitle: _NS("Delete")];
231     [o_mi_selectall setTitle: _NS("Select All")];
232     [o_mi_info setTitle: _NS("Properties")];
233     [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
234     [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
235     [o_mi_services setTitle: _NS("Services discovery")];
236     [[o_tc_name headerCell] setStringValue:_NS("Name")];
237     [[o_tc_author headerCell] setStringValue:_NS("Author")];
238     [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
239     [o_status_field setStringValue: [NSString stringWithFormat:
240                         _NS("no items in playlist")]];
241
242     [o_random_ckb setTitle: _NS("Random")];
243 #if 0
244     [o_search_button setTitle: _NS("Search")];
245 #endif
246     [o_search_field setToolTip: _NS("Search in Playlist")];
247     [[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
248     [[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
249     [[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
250 }
251
252 - (NSOutlineView *)outlineView
253 {
254     return o_outline_view;
255 }
256
257 - (void)playlistUpdated
258 {
259     unsigned int i;
260
261     /* Clear indications of any existing column sorting*/
262     for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
263     {
264         [o_outline_view setIndicatorImage:nil inTableColumn:
265                             [[o_outline_view tableColumns] objectAtIndex:i]];
266     }
267
268     [o_outline_view setHighlightedTableColumn:nil];
269     o_tc_sortColumn = nil;
270     // TODO Find a way to keep the dict size to a minimum
271     //[o_outline_dict removeAllObjects];
272     [o_outline_view reloadData];
273 }
274
275 - (void)playModeUpdated
276 {
277     playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
278                                           FIND_ANYWHERE );
279     vlc_value_t val, val2;
280
281     if( p_playlist == NULL )
282     {
283         return;
284     }
285
286     var_Get( p_playlist, "loop", &val2 );
287     var_Get( p_playlist, "repeat", &val );
288     if( val.b_bool == VLC_TRUE )
289     {
290         [o_loop_popup selectItemAtIndex: 1];
291    }
292     else if( val2.b_bool == VLC_TRUE )
293     {
294         [o_loop_popup selectItemAtIndex: 2];
295     }
296     else
297     {
298         [o_loop_popup selectItemAtIndex: 0];
299     }
300
301     var_Get( p_playlist, "random", &val );
302     [o_random_ckb setState: val.b_bool];
303
304     vlc_object_release( p_playlist );
305 }
306
307 - (void)updateRowSelection
308 {
309     int i,i_row;
310     unsigned int j;
311
312     playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
313                                           FIND_ANYWHERE );
314     playlist_item_t *p_item, *p_temp_item;
315     NSMutableArray *o_array = [NSMutableArray array];
316
317     if( p_playlist == NULL )
318         return;
319
320     p_item = p_playlist->status.p_item;
321     if( p_item == NULL ) return;
322
323     p_temp_item = p_item;
324     while( p_temp_item->i_parents > 0 )
325     {
326         [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
327         for (i = 0 ; i < p_temp_item->i_parents ; i++)
328         {
329             if( p_temp_item->pp_parents[i]->i_view == i_current_view )
330             {
331                 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
332                 break;
333             }
334         }
335     }
336
337     for (j = 0 ; j < [o_array count] - 1 ; j++)
338     {
339         id o_item;
340         if( ( o_item = [o_outline_dict objectForKey:
341                             [NSString stringWithFormat: @"%p",
342                             [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
343             [o_outline_view expandItem: o_item];
344
345     }
346
347     i_row = [o_outline_view rowForItem:[o_outline_dict
348             objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
349
350     [o_outline_view selectRow: i_row byExtendingSelection: NO];
351     [o_outline_view scrollRowToVisible: i_row];
352
353     vlc_object_release(p_playlist);
354 }
355
356
357 - (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node
358 {
359     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
360                                           FIND_ANYWHERE );
361     playlist_item_t *p_temp_item = p_item;
362
363     if( p_playlist == NULL )
364     {
365         return NO;
366     }
367
368     if ( p_temp_item )
369     {
370         vlc_mutex_lock( &p_playlist->object_lock );
371         while( p_temp_item->i_parents > 0 )
372         {
373             int i;
374             for( i = 0; i < p_temp_item->i_parents ; i++ )
375             {
376                 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
377                 {
378                     if( p_temp_item->pp_parents[i]->p_parent == p_node )
379                     {
380                         vlc_object_release( p_playlist );
381                         vlc_mutex_unlock( &p_playlist->object_lock );
382                         return YES;
383                     }
384                     else
385                     {
386                         p_temp_item = p_temp_item->pp_parents[i]->p_parent;
387                         break;
388                     }
389                 }
390             }
391         }
392         vlc_mutex_unlock( &p_playlist->object_lock );
393     }
394
395     vlc_object_release( p_playlist );
396     return NO;
397 }
398
399 - (IBAction)savePlaylist:(id)sender
400 {
401     intf_thread_t * p_intf = VLCIntf;
402     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
403                                                        FIND_ANYWHERE );
404
405     NSSavePanel *o_save_panel = [NSSavePanel savePanel];
406     NSString * o_name = [NSString stringWithFormat: @"%@.m3u", _NS("Untitled")];
407     [o_save_panel setTitle: _NS("Save Playlist")];
408     [o_save_panel setPrompt: _NS("Save")];
409
410     if( [o_save_panel runModalForDirectory: nil
411             file: o_name] == NSOKButton )
412     {
413         playlist_Export( p_playlist, [[o_save_panel filename] fileSystemRepresentation], "export-m3u" );
414     }
415 }
416
417
418 /* When called retrieves the selected outlineview row and plays that node or item */
419 - (IBAction)playItem:(id)sender
420 {
421     intf_thread_t * p_intf = VLCIntf;
422     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
423                                                        FIND_ANYWHERE );
424
425     if( p_playlist != NULL )
426     {
427         playlist_item_t *p_item;
428         playlist_item_t *p_node = NULL;
429         int i;
430
431         p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
432
433         if( p_item )
434         {
435             if( p_item->i_children == -1 )
436             {
437                 for( i = 0 ; i < p_item->i_parents ; i++ )
438                 {
439                     if( p_item->pp_parents[i]->i_view == i_current_view )
440                     {
441                         p_node = p_item->pp_parents[i]->p_parent;
442                     }
443                 }
444             }
445             else
446             {
447                 p_node = p_item;
448                 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
449                 {
450                     p_item = p_node->pp_children[0];
451                 }
452                 else
453                 {
454                     p_item = NULL;
455                 }
456             }
457             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, i_current_view, p_node, p_item );
458         }
459         vlc_object_release( p_playlist );
460     }
461 }
462
463 - (IBAction)servicesChange:(id)sender
464 {
465     NSMenuItem *o_mi = (NSMenuItem *)sender;
466     NSString *o_string = [o_mi representedObject];
467     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
468                                           FIND_ANYWHERE );
469     if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string cString] ) )
470         playlist_ServicesDiscoveryAdd( p_playlist, [o_string cString] );
471     else
472         playlist_ServicesDiscoveryRemove( p_playlist, [o_string cString] );
473
474     [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
475                                           [o_string cString] ) ? YES : NO];
476
477     i_current_view = VIEW_CATEGORY;
478     playlist_ViewUpdate( p_playlist, i_current_view );
479     vlc_object_release( p_playlist );
480     [self playlistUpdated];
481     return;
482 }
483
484 - (IBAction)selectAll:(id)sender
485 {
486     [o_outline_view selectAll: nil];
487 }
488
489 - (IBAction)deleteItem:(id)sender
490 {
491     int i, i_count, i_row;
492     NSMutableArray *o_to_delete;
493     NSNumber *o_number;
494
495     playlist_t * p_playlist;
496     intf_thread_t * p_intf = VLCIntf;
497
498     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
499                                           FIND_ANYWHERE );
500
501     if ( p_playlist == NULL )
502     {
503         return;
504     }
505     o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
506     i_count = [o_to_delete count];
507
508     for( i = 0; i < i_count; i++ )
509     {
510         playlist_item_t * p_item;
511         o_number = [o_to_delete lastObject];
512         i_row = [o_number intValue];
513
514         [o_to_delete removeObject: o_number];
515         [o_outline_view deselectRow: i_row];
516
517         p_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_row] pointerValue];
518
519         if( p_item->i_children > -1 ) //is a node and not an item
520         {
521             if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
522                 [self isItem: p_playlist->status.p_item inNode: p_item] == YES )
523             {
524                 // if current item is in selected node and is playing then stop playlist
525                 playlist_Stop( p_playlist );
526             }
527             playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
528         }
529         else
530         {
531             if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
532                 p_playlist->status.p_item == [[o_outline_view itemAtRow: i_row] pointerValue] )
533             {
534                 playlist_Stop( p_playlist );
535             }
536             playlist_LockDelete( p_playlist, p_item->input.i_id );
537         }
538     }
539     [self playlistUpdated];
540     vlc_object_release( p_playlist );
541 }
542
543 - (IBAction)sortNodeByName:(id)sender
544 {
545     [self sortNode: SORT_TITLE];
546 }
547
548 - (IBAction)sortNodeByAuthor:(id)sender
549 {
550     [self sortNode: SORT_AUTHOR];
551 }
552
553 - (void)sortNode:(int)i_mode
554 {
555     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
556                                           FIND_ANYWHERE );
557     playlist_item_t * p_item;
558
559     if (p_playlist == NULL)
560     {
561         return;
562     }
563
564     if( [o_outline_view selectedRow] > -1 )
565     {
566         p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
567                                                                 pointerValue];
568     }
569     else
570     /*If no item is selected, sort the whole playlist*/
571     {
572         playlist_view_t * p_view = playlist_ViewFind( p_playlist, i_current_view );
573         p_item = p_view->p_root;
574     }
575
576     if( p_item->i_children > -1 ) // the item is a node
577     {
578         vlc_mutex_lock( &p_playlist->object_lock );
579         playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
580         vlc_mutex_unlock( &p_playlist->object_lock );
581     }
582     else
583     {
584         int i;
585
586         for( i = 0 ; i < p_item->i_parents ; i++ )
587         {
588             if( p_item->pp_parents[i]->i_view == i_current_view )
589             {
590                 vlc_mutex_lock( &p_playlist->object_lock );
591                 playlist_RecursiveNodeSort( p_playlist,
592                         p_item->pp_parents[i]->p_parent, i_mode, ORDER_NORMAL );
593                 vlc_mutex_unlock( &p_playlist->object_lock );
594                 break;
595             }
596         }
597     }
598     vlc_object_release( p_playlist );
599     [self playlistUpdated];
600 }
601
602 - (playlist_item_t *)createItem:(NSDictionary *)o_one_item
603 {
604     intf_thread_t * p_intf = VLCIntf;
605     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
606                                                        FIND_ANYWHERE );
607
608     if( p_playlist == NULL )
609     {
610         return NULL;
611     }
612     playlist_item_t *p_item;
613     int i;
614     BOOL b_rem = FALSE, b_dir = FALSE;
615     NSString *o_uri, *o_name;
616     NSArray *o_options;
617     NSURL *o_true_file;
618
619     /* Get the item */
620     o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
621     o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
622     o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
623
624     /* Find the name for a disc entry ( i know, can you believe the trouble?) */
625     if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
626     {
627         int i_count, i_index;
628         struct statfs *mounts = NULL;
629
630         i_count = getmntinfo (&mounts, MNT_NOWAIT);
631         /* getmntinfo returns a pointer to static data. Do not free. */
632         for( i_index = 0 ; i_index < i_count; i_index++ )
633         {
634             NSMutableString *o_temp, *o_temp2;
635             o_temp = [NSMutableString stringWithString: o_uri];
636             o_temp2 = [NSMutableString stringWithCString: mounts[i_index].f_mntfromname];
637             [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:NULL range:NSMakeRange(0, [o_temp length]) ];
638             [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:NULL range:NSMakeRange(0, [o_temp2 length]) ];
639             [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:NULL range:NSMakeRange(0, [o_temp2 length]) ];
640
641             if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
642             {
643                 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithCString:mounts[i_index].f_mntonname]];
644             }
645         }
646     }
647     /* If no name, then make a guess */
648     if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
649
650     if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
651         [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
652                 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem   )
653     {
654         /* All of this is to make sure CD's play when you D&D them on VLC */
655         /* Converts mountpoint to a /dev file */
656         struct statfs *buf;
657         char *psz_dev;
658         NSMutableString *o_temp;
659
660         buf = (struct statfs *) malloc (sizeof(struct statfs));
661         statfs( [o_uri fileSystemRepresentation], buf );
662         psz_dev = strdup(buf->f_mntfromname);
663         o_temp = [NSMutableString stringWithCString: psz_dev ];
664         [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:NULL range:NSMakeRange(0, [o_temp length]) ];
665         [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:NULL range:NSMakeRange(0, [o_temp length]) ];
666         [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:NULL range:NSMakeRange(0, [o_temp length]) ];
667         o_uri = o_temp;
668     }
669
670     p_item = playlist_ItemNew( p_intf, [o_uri fileSystemRepresentation], [o_name UTF8String] );
671     if( !p_item )
672        return NULL;
673
674     if( o_options )
675     {
676         for( i = 0; i < (int)[o_options count]; i++ )
677         {
678             playlist_ItemAddOption( p_item, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
679         }
680     }
681
682     /* Recent documents menu */
683     o_true_file = [NSURL fileURLWithPath: o_uri];
684     if( o_true_file != nil )
685     {
686         [[NSDocumentController sharedDocumentController]
687             noteNewRecentDocumentURL: o_true_file];
688     }
689
690     vlc_object_release( p_playlist );
691     return p_item;
692 }
693
694 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
695 {
696     int i_item;
697     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
698                                             FIND_ANYWHERE );
699     if( p_playlist == NULL )
700     {
701         return;
702     }
703
704     for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
705     {
706         playlist_item_t *p_item;
707         NSDictionary *o_one_item;
708
709         /* Get the item */
710         o_one_item = [o_array objectAtIndex: i_item];
711         p_item = [self createItem: o_one_item];
712         if( !p_item )
713         {
714             continue;
715         }
716
717         /* Add the item */
718         playlist_AddItem( p_playlist, p_item, PLAYLIST_APPEND, i_position == -1 ? PLAYLIST_END : i_position + i_item );
719
720         if( i_item == 0 && !b_enqueue )
721         {
722             playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
723         }
724     }
725     vlc_object_release( p_playlist );
726 }
727
728 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position inView:(int)i_view enqueue:(BOOL)b_enqueue
729 {
730     int i_item;
731     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
732                                             FIND_ANYWHERE );
733     if( p_playlist == NULL )
734     {
735         return;
736     }
737
738     for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
739     {
740         playlist_item_t *p_item;
741         NSDictionary *o_one_item;
742
743         /* Get the item */
744         o_one_item = [o_array objectAtIndex: i_item];
745         p_item = [self createItem: o_one_item];
746         if( !p_item )
747         {
748             continue;
749         }
750
751         /* Add the item */
752         playlist_NodeAddItem( p_playlist, p_item, i_view, p_node, PLAYLIST_APPEND, i_position + i_item );
753
754         if( i_item == 0 && !b_enqueue )
755         {
756             playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
757         }
758     }
759     vlc_object_release( p_playlist );
760
761 }
762
763 - (IBAction)handlePopUp:(id)sender
764
765 {
766     intf_thread_t * p_intf = VLCIntf;
767     vlc_value_t val1,val2;
768     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
769                                             FIND_ANYWHERE );
770     if( p_playlist == NULL )
771     {
772         return;
773     }
774
775     switch( [o_loop_popup indexOfSelectedItem] )
776     {
777         case 1:
778
779              val1.b_bool = 0;
780              var_Set( p_playlist, "loop", val1 );
781              val1.b_bool = 1;
782              var_Set( p_playlist, "repeat", val1 );
783              vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
784         break;
785
786         case 2:
787              val1.b_bool = 0;
788              var_Set( p_playlist, "repeat", val1 );
789              val1.b_bool = 1;
790              var_Set( p_playlist, "loop", val1 );
791              vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
792         break;
793
794         default:
795              var_Get( p_playlist, "repeat", &val1 );
796              var_Get( p_playlist, "loop", &val2 );
797              if( val1.b_bool || val2.b_bool )
798              {
799                   val1.b_bool = 0;
800                   var_Set( p_playlist, "repeat", val1 );
801                   var_Set( p_playlist, "loop", val1 );
802                   vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
803              }
804          break;
805      }
806      vlc_object_release( p_playlist );
807      [self playlistUpdated];
808 }
809
810 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
811 {
812     playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
813                                                        FIND_ANYWHERE );
814     playlist_item_t *p_selected_item;
815     int i_current, i_selected_row;
816
817     if( !p_playlist )
818         return NULL;
819
820     i_selected_row = [o_outline_view selectedRow];
821     if (i_selected_row < 0)
822         i_selected_row = 0;
823
824     p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
825                                             i_selected_row] pointerValue];
826
827     for( i_current = 0; i_current < p_item->i_children ; i_current++ )
828     {
829         char *psz_temp;
830         NSString *o_current_name, *o_current_author;
831
832         vlc_mutex_lock( &p_playlist->object_lock );
833         o_current_name = [NSString stringWithUTF8String:
834             p_item->pp_children[i_current]->input.psz_name];
835         psz_temp = vlc_input_item_GetInfo( &p_item->input ,
836                                    _("Meta-information"),_("Artist") );
837         o_current_author = [NSString stringWithUTF8String: psz_temp];
838         free( psz_temp);
839         vlc_mutex_unlock( &p_playlist->object_lock );
840
841         if( p_selected_item == p_item->pp_children[i_current] &&
842                     b_selected_item_met == NO )
843         {
844             b_selected_item_met = YES;
845         }
846         else if( p_selected_item == p_item->pp_children[i_current] &&
847                     b_selected_item_met == YES )
848         {
849             vlc_object_release( p_playlist );
850             return NULL;
851         }
852         else if( b_selected_item_met == YES &&
853                     ( [o_current_name rangeOfString:[o_search_field
854                         stringValue] options:NSCaseInsensitiveSearch ].length ||
855                       [o_current_author rangeOfString:[o_search_field
856                         stringValue] options:NSCaseInsensitiveSearch ].length ) )
857         {
858             vlc_object_release( p_playlist );
859             /*Adds the parent items in the result array as well, so that we can
860             expand the tree*/
861             return [NSMutableArray arrayWithObject: [NSValue
862                             valueWithPointer: p_item->pp_children[i_current]]];
863         }
864         if( p_item->pp_children[i_current]->i_children > 0 )
865         {
866             id o_result = [self subSearchItem:
867                                             p_item->pp_children[i_current]];
868             if( o_result != NULL )
869             {
870                 vlc_object_release( p_playlist );
871                 [o_result insertObject: [NSValue valueWithPointer:
872                                 p_item->pp_children[i_current]] atIndex:0];
873                 return o_result;
874             }
875         }
876     }
877     vlc_object_release( p_playlist );
878     return NULL;
879 }
880
881 - (IBAction)searchItem:(id)sender
882 {
883     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
884                                                        FIND_ANYWHERE );
885     playlist_view_t * p_view;
886     id o_result;
887
888     unsigned int i;
889     int i_row = -1;
890
891     b_selected_item_met = NO;
892
893     if( p_playlist == NULL )
894         return;
895     p_view = playlist_ViewFind( p_playlist, i_current_view );
896
897     if( p_view )
898     {
899         /*First, only search after the selected item:*
900          *(b_selected_item_met = NO)                 */
901         o_result = [self subSearchItem:p_view->p_root];
902         if( o_result == NULL )
903         {
904             /* If the first search failed, search again from the beginning */
905             o_result = [self subSearchItem:p_view->p_root];
906         }
907         if( o_result != NULL )
908         {
909             for( i = 0 ; i < [o_result count] - 1 ; i++ )
910             {
911                 [o_outline_view expandItem: [o_outline_dict objectForKey:
912                             [NSString stringWithFormat: @"%p",
913                             [[o_result objectAtIndex: i] pointerValue]]]];
914             }
915             i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
916                             [NSString stringWithFormat: @"%p",
917                             [[o_result objectAtIndex: [o_result count] - 1 ]
918                             pointerValue]]]];
919         }
920         if( i_row > -1 )
921         {
922             [o_outline_view selectRow:i_row byExtendingSelection: NO];
923             [o_outline_view scrollRowToVisible: i_row];
924         }
925     }
926     vlc_object_release( p_playlist );
927 }
928
929 - (NSMenu *)menuForEvent:(NSEvent *)o_event
930 {
931     NSPoint pt;
932     vlc_bool_t b_rows;
933     vlc_bool_t b_item_sel;
934
935     pt = [o_outline_view convertPoint: [o_event locationInWindow]
936                                                  fromView: nil];
937     b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
938                    [o_outline_view selectedRow] != -1 );
939     b_rows = [o_outline_view numberOfRows] != 0;
940
941     [o_mi_play setEnabled: b_item_sel];
942     [o_mi_delete setEnabled: b_item_sel];
943     [o_mi_selectall setEnabled: b_rows];
944     [o_mi_info setEnabled: b_item_sel];
945
946     return( o_ctx_menu );
947 }
948
949 - (playlist_item_t *)selectedPlaylistItem
950 {
951     return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
952                                                                 pointerValue];
953 }
954
955 - (void)outlineView: (NSTableView*)o_tv
956                   didClickTableColumn:(NSTableColumn *)o_tc
957 {
958     int i_mode = 0, i_type;
959     intf_thread_t *p_intf = VLCIntf;
960     playlist_view_t *p_view;
961
962     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
963                                        FIND_ANYWHERE );
964     if( p_playlist == NULL )
965     {
966         return;
967     }
968     
969     /* Check whether the selected table column header corresponds to a
970        sortable table column*/
971     if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
972     {
973         vlc_object_release( p_playlist );
974         return;
975     }
976
977     p_view = playlist_ViewFind( p_playlist, i_current_view );
978
979     if( o_tc_sortColumn == o_tc )
980     {
981         b_isSortDescending = !b_isSortDescending;
982     }
983     else
984     {
985         b_isSortDescending = VLC_FALSE;
986     }
987
988     if( o_tc == o_tc_name )
989     {
990         i_mode = SORT_TITLE;
991     }
992     else if( o_tc == o_tc_author )
993     {
994         i_mode = SORT_AUTHOR;
995     }
996
997     if( b_isSortDescending )
998     {
999         i_type = ORDER_REVERSE;
1000     }
1001     else
1002     {
1003         i_type = ORDER_NORMAL;
1004     }
1005
1006     vlc_mutex_lock( &p_playlist->object_lock );
1007     playlist_RecursiveNodeSort( p_playlist, p_view->p_root, i_mode, i_type );
1008     vlc_mutex_unlock( &p_playlist->object_lock );
1009
1010     vlc_object_release( p_playlist );
1011     [self playlistUpdated];
1012
1013     o_tc_sortColumn = o_tc;
1014     [o_outline_view setHighlightedTableColumn:o_tc];
1015
1016     if( b_isSortDescending )
1017     {
1018         [o_outline_view setIndicatorImage:o_descendingSortingImage
1019                                                         inTableColumn:o_tc];
1020     }
1021     else
1022     {
1023         [o_outline_view setIndicatorImage:o_ascendingSortingImage
1024                                                         inTableColumn:o_tc];
1025     }
1026 }
1027
1028
1029 - (void)outlineView:(NSOutlineView *)outlineView
1030                                 willDisplayCell:(id)cell
1031                                 forTableColumn:(NSTableColumn *)tableColumn
1032                                 item:(id)item
1033 {
1034     playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1035                                           FIND_ANYWHERE );
1036     playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1037
1038     if( !p_playlist ) return;
1039
1040     if( ( p_item == p_playlist->status.p_item ) ||
1041             ( p_item->i_children != 0 &&
1042             [self isItem: p_playlist->status.p_item inNode: p_item] ) )
1043     {
1044         [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1045     }
1046     else
1047     {
1048         [cell setFont: [NSFont systemFontOfSize: 0]];
1049     }
1050     vlc_object_release( p_playlist );
1051 }
1052
1053 @end
1054
1055 @implementation VLCPlaylist (NSOutlineViewDataSource)
1056
1057 /* return the number of children for Obj-C pointer item */ /* DONE */
1058 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
1059 {
1060     int i_return = 0;
1061     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1062                                                        FIND_ANYWHERE );
1063     if( p_playlist == NULL || outlineView != o_outline_view )
1064         return 0;
1065
1066     if( item == nil )
1067     {
1068         /* root object */
1069         playlist_view_t *p_view;
1070         p_view = playlist_ViewFind( p_playlist, i_current_view );
1071         if( p_view && p_view->p_root )
1072         {
1073             i_return = p_view->p_root->i_children;
1074             if( i_current_view == VIEW_CATEGORY )
1075             {
1076                 i_return--; /* remove the GENERAL item from the list */
1077                 i_return += p_playlist->p_general->i_children; /* add the items of the general node */
1078             }
1079         }
1080     }
1081     else
1082     {
1083         playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1084         if( p_item )
1085             i_return = p_item->i_children;
1086     }
1087     vlc_object_release( p_playlist );
1088     
1089     if( i_return <= 0 )
1090         i_return = 0;
1091     
1092     return i_return;
1093 }
1094
1095 /* return the child at index for the Obj-C pointer item */ /* DONE */
1096 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1097 {
1098     playlist_item_t *p_return = NULL;
1099     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1100                                                        FIND_ANYWHERE );
1101     NSValue *o_value;
1102
1103     if( p_playlist == NULL )
1104         return nil;
1105
1106     if( item == nil )
1107     {
1108         /* root object */
1109         playlist_view_t *p_view;
1110         p_view = playlist_ViewFind( p_playlist, i_current_view );
1111         if( p_view && p_view->p_root ) p_return = p_view->p_root->pp_children[index];
1112         
1113         if( i_current_view == VIEW_CATEGORY )
1114         {
1115             if( p_playlist->p_general->i_children && index >= 0 && index < p_playlist->p_general->i_children )
1116             {
1117                 p_return = p_playlist->p_general->pp_children[index];
1118             }
1119             else if( p_view && p_view->p_root && index >= 0 && index - p_playlist->p_general->i_children < p_view->p_root->i_children )
1120             {
1121                 p_return = p_view->p_root->pp_children[index - p_playlist->p_general->i_children + 1];
1122                 
1123             }
1124         }
1125     }
1126     else
1127     {
1128         playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1129         if( p_item && index < p_item->i_children && index >= 0 )
1130             p_return = p_item->pp_children[index];
1131     }
1132     
1133     if( p_playlist->i_size >= 2 )
1134     {
1135         [o_status_field setStringValue: [NSString stringWithFormat:
1136                     _NS("%i items in playlist"), p_playlist->i_size]];
1137     }
1138     else
1139     {
1140         if( p_playlist->i_size == 0 )
1141         {
1142             [o_status_field setStringValue: [NSString stringWithFormat:
1143                     _NS("no items in playlist"), p_playlist->i_size]];
1144         }
1145         else
1146         {
1147             [o_status_field setStringValue: [NSString stringWithFormat:
1148                     _NS("1 item in playlist"), p_playlist->i_size]];
1149         }
1150     }
1151
1152     vlc_object_release( p_playlist );
1153
1154     o_value = [[NSValue valueWithPointer: p_return] retain];
1155
1156     [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p", p_return]];
1157     return o_value;
1158 }
1159
1160 /* is the item expandable */
1161 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
1162 {
1163     int i_return = 0;
1164     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1165                                                        FIND_ANYWHERE );
1166     if( p_playlist == NULL )
1167         return NO;
1168
1169     if( item == nil )
1170     {
1171         /* root object */
1172         playlist_view_t *p_view;
1173         p_view = playlist_ViewFind( p_playlist, i_current_view );
1174         if( p_view && p_view->p_root ) i_return = p_view->p_root->i_children;
1175         
1176         if( i_current_view == VIEW_CATEGORY )
1177         {
1178             i_return--;
1179             i_return += p_playlist->p_general->i_children;
1180         }
1181     }
1182     else
1183     {
1184         playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
1185         if( p_item )
1186             i_return = p_item->i_children;
1187     }
1188     vlc_object_release( p_playlist );
1189
1190     if( i_return <= 0 )
1191         return NO;
1192     else
1193         return YES;
1194 }
1195
1196 /* retrieve the string values for the cells */
1197 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
1198 {
1199     id o_value = nil;
1200     intf_thread_t *p_intf = VLCIntf;
1201     playlist_t *p_playlist;
1202     playlist_item_t *p_item;
1203     
1204     if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
1205     
1206     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1207                                                FIND_ANYWHERE );
1208     if( p_playlist == NULL )
1209     {
1210         return( @"error" );
1211     }
1212
1213     p_item = (playlist_item_t *)[item pointerValue];
1214
1215     if( p_item == NULL )
1216     {
1217         vlc_object_release( p_playlist );
1218         return( @"error");
1219     }
1220
1221     if( [[o_tc identifier] isEqualToString:@"1"] )
1222     {
1223         o_value = [NSString stringWithUTF8String:
1224             p_item->input.psz_name];
1225         if( o_value == NULL )
1226             o_value = [NSString stringWithCString:
1227                 p_item->input.psz_name];
1228     }
1229     else if( [[o_tc identifier] isEqualToString:@"2"] )
1230     {
1231         char *psz_temp;
1232         psz_temp = vlc_input_item_GetInfo( &p_item->input ,_("Meta-information"),_("Artist") );
1233
1234         if( psz_temp == NULL )
1235             o_value = @"";
1236         else
1237         {
1238             o_value = [NSString stringWithUTF8String: psz_temp];
1239             if( o_value == NULL )
1240             {
1241                 o_value = [NSString stringWithCString: psz_temp];
1242             }
1243             free( psz_temp );
1244         }
1245     }
1246     else if( [[o_tc identifier] isEqualToString:@"3"] )
1247     {
1248         char psz_duration[MSTRTIME_MAX_SIZE];
1249         mtime_t dur = p_item->input.i_duration;
1250         if( dur != -1 )
1251         {
1252             secstotimestr( psz_duration, dur/1000000 );
1253             o_value = [NSString stringWithUTF8String: psz_duration];
1254         }
1255         else
1256         {
1257             o_value = @"-:--:--";
1258         }
1259     }
1260     vlc_object_release( p_playlist );
1261
1262     return( o_value );
1263 }
1264
1265 /* Required for drag & drop and reordering */
1266 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1267 {
1268 /*    unsigned int i;
1269
1270     for( i = 0 ; i < [items count] ; i++ )
1271     {
1272         if( [outlineView levelForItem: [items objectAtIndex: i]] == 0 )
1273         {
1274             return NO;
1275         }
1276     }*/
1277     return NO;
1278 }
1279
1280 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1281 {
1282     NSPasteboard *o_pasteboard = [info draggingPasteboard];
1283
1284     if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1285     {
1286         return NSDragOperationGeneric;
1287     }
1288     return NSDragOperationNone;
1289 }
1290
1291 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1292 {
1293     playlist_t * p_playlist =  vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
1294                                                        FIND_ANYWHERE );
1295     NSPasteboard *o_pasteboard = [info draggingPasteboard];
1296
1297     if( !p_playlist ) return NO;
1298
1299     if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1300     {
1301         int i;
1302         playlist_item_t *p_node = [item pointerValue];
1303
1304         NSArray *o_array = [NSArray array];
1305         NSArray *o_values = [[o_pasteboard propertyListForType:
1306                                         NSFilenamesPboardType]
1307                                 sortedArrayUsingSelector:
1308                                         @selector(caseInsensitiveCompare:)];
1309
1310         for( i = 0; i < (int)[o_values count]; i++)
1311         {
1312             NSDictionary *o_dic;
1313             o_dic = [NSDictionary dictionaryWithObject:[o_values
1314                         objectAtIndex:i] forKey:@"ITEM_URL"];
1315             o_array = [o_array arrayByAddingObject: o_dic];
1316         }
1317
1318         if ( item == nil )
1319         {
1320             [self appendArray: o_array atPos: index enqueue: YES];
1321         }
1322         else if( p_node->i_children == -1 )
1323         {
1324             int i_counter;
1325             playlist_item_t *p_real_node = NULL;
1326
1327             for( i_counter = 0 ; i_counter < p_node->i_parents ; i_counter++ )
1328             {
1329                 if( p_node->pp_parents[i_counter]->i_view == i_current_view )
1330                 {
1331                     p_real_node = p_node->pp_parents[i_counter]->p_parent;
1332                     break;
1333                 }
1334                 if( i_counter == p_node->i_parents )
1335                 {
1336                     return NO;
1337                 }
1338             }
1339             [self appendNodeArray: o_array inNode: p_real_node
1340                 atPos: index inView: i_current_view enqueue: YES];
1341         }
1342         else
1343         {
1344             [self appendNodeArray: o_array inNode: p_node
1345                 atPos: index inView: i_current_view enqueue: YES];
1346         }
1347         vlc_object_release( p_playlist );
1348         return YES;
1349     }
1350     vlc_object_release( p_playlist );
1351     return NO;
1352 }
1353
1354 /* Delegate method of NSWindow */
1355 /*- (void)windowWillClose:(NSNotification *)aNotification
1356 {
1357     [o_btn_playlist setState: NSOffState];
1358 }
1359 */
1360 @end
1361
1362