1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2004 VideoLAN
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Derk-Jan Hartman <hartman at videolan dot org>
9 * Benjamin Pracht <bigben at videolab dot org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include <stdlib.h> /* malloc(), free() */
30 #include <sys/param.h> /* for MAXPATHLEN */
33 #include <sys/mount.h>
41 /*****************************************************************************
42 * VLCPlaylistView implementation
43 *****************************************************************************/
44 @implementation VLCPlaylistView
46 - (NSMenu *)menuForEvent:(NSEvent *)o_event
48 return( [[self delegate] menuForEvent: o_event] );
51 - (void)keyDown:(NSEvent *)o_event
55 NSMutableArray *o_to_delete;
58 playlist_t * p_playlist;
59 intf_thread_t * p_intf = [NSApp getIntf];
61 if( [[o_event characters] length] )
63 key = [[o_event characters] characterAtIndex: 0];
66 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
69 if ( p_playlist == NULL )
76 case NSDeleteCharacter:
77 case NSDeleteFunctionKey:
78 case NSDeleteCharFunctionKey:
79 case NSBackspaceCharacter:
80 o_to_delete = [NSMutableArray arrayWithArray:[[self selectedRowEnumerator] allObjects]];
81 c = [o_to_delete count];
83 for( i = 0; i < c; i++ ) {
84 o_number = [o_to_delete lastObject];
85 i_row = [o_number intValue];
87 if( p_playlist->i_index == i_row && p_playlist->i_status )
89 playlist_Stop( p_playlist );
91 [o_to_delete removeObject: o_number];
92 [self deselectRow: i_row];
93 playlist_Delete( p_playlist, i_row );
99 [super keyDown: o_event];
103 if( p_playlist != NULL )
105 vlc_object_release( p_playlist );
112 /*****************************************************************************
113 * VLCPlaylist implementation
114 *****************************************************************************/
115 @implementation VLCPlaylist
129 [o_table_view setTarget: self];
130 [o_table_view setDelegate: self];
131 [o_table_view setDataSource: self];
133 [o_table_view setDoubleAction: @selector(playItem:)];
135 [o_table_view registerForDraggedTypes:
136 [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
137 [o_table_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
138 [o_window setExcludedFromWindowsMenu: TRUE];
139 [o_info_window setExcludedFromWindowsMenu: TRUE];
140 /* We need to check whether _defaultTableHeaderSortImage exists, since it
141 belongs to an Apple hidden private API, and then can "disapear" at any time*/
143 if( [[NSTableView class] respondsToSelector:@selector(_defaultTableHeaderSortImage)] )
145 o_ascendingSortingImage = [[NSTableView class] _defaultTableHeaderSortImage];
149 o_ascendingSortingImage = nil;
152 if( [[NSTableView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)] )
154 o_descendingSortingImage = [[NSTableView class] _defaultTableHeaderReverseSortImage];
158 o_descendingSortingImage = nil;
162 [self playlistUpdated];
167 [o_window setTitle: _NS("Playlist")];
168 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
169 [o_mi_play setTitle: _NS("Play")];
170 [o_mi_delete setTitle: _NS("Delete")];
171 [o_mi_selectall setTitle: _NS("Select All")];
172 [o_mi_info setTitle: _NS("Proprieties")];
173 [[o_tc_name headerCell] setStringValue:_NS("Name")];
174 [[o_tc_author headerCell] setStringValue:_NS("Author")];
175 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
176 [o_random_ckb setTitle: _NS("Random")];
177 [o_search_button setTitle: _NS("Search")];
178 [o_btn_playlist setToolTip: _NS("Playlist")];
179 [[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
180 [[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
181 [[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
183 [o_info_window setTitle: _NS("Proprieties")];
184 [o_uri_lbl setStringValue: _NS("URI")];
185 [o_title_lbl setStringValue: _NS("Title")];
186 [o_author_lbl setStringValue: _NS("Author")];
187 [o_btn_info_ok setTitle: _NS("OK")];
188 [o_btn_info_cancel setTitle: _NS("Cancel")];
191 - (void) tableView:(NSTableView*)o_tv
192 didClickTableColumn:(NSTableColumn *)o_tc
194 intf_thread_t * p_intf = [NSApp getIntf];
195 playlist_t *p_playlist =
196 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
199 int max = [[o_table_view tableColumns] count];
202 if( p_playlist == NULL )
207 if( o_tc_sortColumn == o_tc )
209 b_isSortDescending = !b_isSortDescending;
211 else if( o_tc == o_tc_name || o_tc == o_tc_author ||
214 b_isSortDescending = VLC_FALSE;
215 [o_table_view setHighlightedTableColumn:o_tc];
216 o_tc_sortColumn = o_tc;
217 for( i=0 ; i<max ; i++ )
219 [o_table_view setIndicatorImage:nil inTableColumn:[[o_table_view tableColumns] objectAtIndex:i]];
223 if( o_tc_id == o_tc && !b_isSortDescending )
225 playlist_SortID( p_playlist , ORDER_NORMAL );
226 [o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
228 else if( o_tc_name == o_tc && !b_isSortDescending )
230 playlist_SortTitle( p_playlist , ORDER_NORMAL );
231 [o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
233 else if( o_tc_author == o_tc && !b_isSortDescending )
235 playlist_SortAuthor( p_playlist , ORDER_NORMAL );
236 [o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
238 else if( o_tc_id == o_tc && b_isSortDescending )
240 playlist_SortID( p_playlist , ORDER_REVERSE );
241 [o_table_view setIndicatorImage:o_ascendingSortingImage inTableColumn:o_tc];
243 else if( o_tc_name == o_tc && b_isSortDescending )
245 playlist_SortTitle( p_playlist , ORDER_REVERSE );
246 [o_table_view setIndicatorImage:o_descendingSortingImage inTableColumn:o_tc];
248 else if( o_tc_author == o_tc && b_isSortDescending )
250 playlist_SortAuthor( p_playlist , ORDER_REVERSE );
251 [o_table_view setIndicatorImage:o_descendingSortingImage inTableColumn:o_tc];
253 vlc_object_release( p_playlist );
254 [self playlistUpdated];
258 - (BOOL)tableView:(NSTableView *)o_tv
259 shouldEditTableColumn:(NSTableColumn *)o_tc
265 - (NSMenu *)menuForEvent:(NSEvent *)o_event
269 vlc_bool_t b_item_sel;
271 pt = [o_table_view convertPoint: [o_event locationInWindow]
273 b_item_sel = ( [o_table_view rowAtPoint: pt] != -1 &&
274 [o_table_view selectedRow] != -1 );
275 b_rows = [o_table_view numberOfRows] != 0;
277 [o_mi_play setEnabled: b_item_sel];
278 [o_mi_delete setEnabled: b_item_sel];
279 [o_mi_selectall setEnabled: b_rows];
280 [o_mi_info setEnabled: b_item_sel];
282 return( o_ctx_menu );
285 - (IBAction)toggleWindow:(id)sender
287 if( [o_window isVisible] )
289 [o_window orderOut:sender];
290 [o_btn_playlist setState:NSOffState];
294 [o_window makeKeyAndOrderFront:sender];
295 [o_btn_playlist setState:NSOnState];
299 - (IBAction)savePlaylist:(id)sender
301 intf_thread_t * p_intf = [NSApp getIntf];
302 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
305 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
306 NSString * o_name = [NSString stringWithFormat: @"%@.m3u", _NS("Untitled")];
307 [o_save_panel setTitle: _NS("Save Playlist")];
308 [o_save_panel setPrompt: _NS("Save")];
310 if( [o_save_panel runModalForDirectory: nil
311 file: o_name] == NSOKButton )
313 playlist_Export( p_playlist, [[o_save_panel filename] fileSystemRepresentation], "export-m3u" );
318 - (IBAction)playItem:(id)sender
320 intf_thread_t * p_intf = [NSApp getIntf];
321 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
324 if( p_playlist != NULL )
326 playlist_Goto( p_playlist, [o_table_view selectedRow] );
327 vlc_object_release( p_playlist );
331 - (IBAction)deleteItems:(id)sender
334 NSMutableArray *o_to_delete;
337 intf_thread_t * p_intf = [NSApp getIntf];
338 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
341 if( p_playlist == NULL )
346 o_to_delete = [NSMutableArray arrayWithArray:[[o_table_view selectedRowEnumerator] allObjects]];
347 c = (int)[o_to_delete count];
349 for( i = 0; i < c; i++ ) {
350 o_number = [o_to_delete lastObject];
351 i_row = [o_number intValue];
353 if( p_playlist->i_index == i_row && p_playlist->i_status )
355 playlist_Stop( p_playlist );
357 [o_to_delete removeObject: o_number];
358 [o_table_view deselectRow: i_row];
359 playlist_Delete( p_playlist, i_row );
362 vlc_object_release( p_playlist );
364 /* this is actually duplicity, because the intf.m manage also updates the view
365 * when the playlist changes. we do this on purpose, because else there is a
366 * delay of .5 sec or so when we delete an item */
367 [self playlistUpdated];
368 [self updateRowSelection];
371 - (IBAction)selectAll:(id)sender
373 [o_table_view selectAll: nil];
377 - (IBAction)searchItem:(id)sender
380 NSString *o_current_name;
381 NSString *o_current_author;
383 intf_thread_t * p_intf = [NSApp getIntf];
384 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
387 if( p_playlist == NULL )
391 if( [o_table_view numberOfRows] < 1 )
396 if( [o_table_view selectedRow] == [o_table_view numberOfRows]-1 )
402 i_current = [o_table_view selectedRow];
409 vlc_mutex_lock( &p_playlist->object_lock );
410 o_current_name = [NSString stringWithUTF8String:
411 p_playlist->pp_items[i_current]->psz_name];
412 o_current_author = [NSString stringWithUTF8String:
413 playlist_GetInfo(p_playlist, i_current ,_("General"),_("Author") )];
414 vlc_mutex_unlock( &p_playlist->object_lock );
417 if( [o_current_name rangeOfString:[o_search_keyword stringValue] options:NSCaseInsensitiveSearch ].length ||
418 [o_current_author rangeOfString:[o_search_keyword stringValue] options:NSCaseInsensitiveSearch ].length )
420 [o_table_view selectRow: i_current byExtendingSelection: NO];
421 [o_table_view scrollRowToVisible: i_current];
424 if( i_current == [o_table_view numberOfRows] - 1 )
429 while (i_current != [o_table_view selectedRow]);
430 vlc_object_release( p_playlist );
434 - (IBAction)handlePopUp:(id)sender
437 intf_thread_t * p_intf = [NSApp getIntf];
438 vlc_value_t val1,val2;
439 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
441 if( p_playlist == NULL )
446 switch ([o_loop_popup indexOfSelectedItem])
451 var_Set( p_playlist, "loop", val1 );
453 var_Set( p_playlist, "repeat", val1 );
454 vout_OSDMessage( p_intf, _( "Repeat One" ) );
459 var_Set( p_playlist, "repeat", val1 );
461 var_Set( p_playlist, "loop", val1 );
462 vout_OSDMessage( p_intf, _( "Repeat All" ) );
466 var_Get( p_playlist, "repeat", &val1 );
467 var_Get( p_playlist, "loop", &val2 );
468 if (val1.b_bool || val2.b_bool)
471 var_Set( p_playlist, "repeat", val1 );
472 var_Set( p_playlist, "loop", val1 );
473 vout_OSDMessage( p_intf, _( "Repeat Off" ) );
477 vlc_object_release( p_playlist );
478 [self playlistUpdated];
482 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
485 intf_thread_t * p_intf = [NSApp getIntf];
486 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
489 if( p_playlist == NULL )
494 for ( i_item = 0; i_item < (int)[o_array count]; i_item++ )
497 NSDictionary *o_one_item;
498 int j, i_total_options = 0, i_new_id = -1;
499 int i_mode = PLAYLIST_INSERT;
500 BOOL b_rem = FALSE, b_dir = FALSE;
501 NSString *o_uri, *o_name;
504 char **ppsz_options = NULL;
507 o_one_item = [o_array objectAtIndex: i_item];
508 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
509 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
510 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
512 /* If no name, then make a guess */
513 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
515 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
516 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
517 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
519 /* All of this is to make sure CD's play when you D&D them on VLC */
520 /* Converts mountpoint to a /dev file */
523 buf = (struct statfs *) malloc (sizeof(struct statfs));
524 statfs( [o_uri fileSystemRepresentation], buf );
525 psz_dev = strdup(buf->f_mntfromname);
526 o_uri = [NSString stringWithCString: psz_dev ];
529 if( o_options && [o_options count] > 0 )
531 /* Count the input options */
532 i_total_options = [o_options count];
534 /* Allocate ppsz_options */
535 for( j = 0; j < i_total_options; j++ )
538 ppsz_options = (char **)malloc( sizeof(char *) * i_total_options );
540 ppsz_options[j] = strdup([[o_options objectAtIndex:j] UTF8String]);
545 i_new_id = playlist_AddExt( p_playlist, [o_uri fileSystemRepresentation],
546 [o_name UTF8String], i_mode,
547 i_position == -1 ? PLAYLIST_END : i_position + i_item,
548 0, (ppsz_options != NULL ) ? (const char **)ppsz_options : 0, i_total_options );
551 for( j = 0; j < i_total_options; j++ )
552 free( ppsz_options[j] );
553 if( ppsz_options ) free( ppsz_options ); */
555 /* Recent documents menu */
556 o_true_file = [NSURL fileURLWithPath: o_uri];
557 if( o_true_file != nil )
559 [[NSDocumentController sharedDocumentController]
560 noteNewRecentDocumentURL: o_true_file];
563 if( i_item == 0 && !b_enqueue )
565 playlist_Goto( p_playlist, playlist_GetPositionById( p_playlist, i_new_id ) );
566 playlist_Play( p_playlist );
570 vlc_object_release( p_playlist );
573 - (void)playlistUpdated
575 vlc_value_t val1, val2;
576 intf_thread_t * p_intf = [NSApp getIntf];
577 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
579 if( p_playlist != NULL )
581 var_Get( p_playlist, "random", &val1 );
582 [o_random_ckb setState: val1.b_bool];
584 var_Get( p_playlist, "repeat", &val1 );
585 var_Get( p_playlist, "loop", &val2 );
588 [o_loop_popup selectItemAtIndex:1];
592 [o_loop_popup selectItemAtIndex:2];
596 [o_loop_popup selectItemAtIndex:0];
598 vlc_object_release( p_playlist );
600 [o_table_view reloadData];
603 - (void)updateRowSelection
607 intf_thread_t * p_intf = [NSApp getIntf];
608 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
611 if( p_playlist == NULL )
616 i_row = p_playlist->i_index;
617 vlc_object_release( p_playlist );
619 [o_table_view selectRow: i_row byExtendingSelection: NO];
620 [o_table_view scrollRowToVisible: i_row];
625 - (IBAction)togglePlaylistInfoPanel:(id)sender
627 intf_thread_t * p_intf = [NSApp getIntf];
628 playlist_t * p_playlist;
629 if( [o_info_window isVisible] )
631 [o_info_window orderOut: sender];
635 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
640 int i_item = [o_table_view selectedRow];
641 [o_uri_txt setStringValue:[NSString stringWithUTF8String: p_playlist->pp_items[i_item]->psz_uri]];
642 [o_title_txt setStringValue:[NSString stringWithUTF8String: p_playlist->pp_items[i_item]->psz_name]];
643 [o_author_txt setStringValue:[NSString stringWithUTF8String: playlist_GetInfo(p_playlist, i_item ,_("General"),_("Author") )]];
644 vlc_object_release ( p_playlist );
646 [o_info_window makeKeyAndOrderFront: sender];
650 - (IBAction)infoCancel:(id)sender
652 [self togglePlaylistInfoPanel:self];
655 - (IBAction)infoOk:(id)sender
657 int i_item = [o_table_view selectedRow];
658 intf_thread_t * p_intf = [NSApp getIntf];
659 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
663 vlc_mutex_lock(&p_playlist->pp_items[i_item]->lock);
665 p_playlist->pp_items[i_item]->psz_uri = strdup([[o_uri_txt stringValue] cString]);
666 p_playlist->pp_items[i_item]->psz_name = strdup([[o_title_txt stringValue] cString]);
667 playlist_ItemAddInfo(p_playlist->pp_items[i_item],_("General"),_("Author"), [[o_author_txt stringValue] cString]);
669 vlc_mutex_unlock(&p_playlist->pp_items[i_item]->lock);
670 vlc_object_release ( p_playlist );
672 [self togglePlaylistInfoPanel:self];
673 [self playlistUpdated];
679 @implementation VLCPlaylist (NSTableDataSource)
681 - (int)numberOfRowsInTableView:(NSTableView *)o_tv
684 intf_thread_t * p_intf = [NSApp getIntf];
685 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
688 if( p_playlist != NULL )
690 vlc_mutex_lock( &p_playlist->object_lock );
691 i_count = p_playlist->i_size;
692 vlc_mutex_unlock( &p_playlist->object_lock );
693 vlc_object_release( p_playlist );
695 [o_status_field setStringValue: [NSString stringWithFormat:_NS("%i items in playlist"), i_count]];
699 - (id)tableView:(NSTableView *)o_tv
700 objectValueForTableColumn:(NSTableColumn *)o_tc
704 intf_thread_t * p_intf = [NSApp getIntf];
705 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
708 if( p_playlist == NULL )
713 if( [[o_tc identifier] isEqualToString:@"0"] )
715 o_value = [NSString stringWithFormat:@"%i", i_row + 1];
717 else if( [[o_tc identifier] isEqualToString:@"1"] )
719 vlc_mutex_lock( &p_playlist->object_lock );
720 o_value = [NSString stringWithUTF8String:
721 p_playlist->pp_items[i_row]->psz_name];
722 vlc_mutex_unlock( &p_playlist->object_lock );
724 else if( [[o_tc identifier] isEqualToString:@"2"] )
726 vlc_mutex_lock( &p_playlist->object_lock );
727 o_value = [NSString stringWithUTF8String:
728 playlist_GetInfo(p_playlist, i_row ,_("General"),_("Author") )];
729 vlc_mutex_unlock( &p_playlist->object_lock );
731 else if( [[o_tc identifier] isEqualToString:@"3"] )
733 char psz_duration[MSTRTIME_MAX_SIZE];
734 mtime_t dur = p_playlist->pp_items[i_row]->i_duration;
737 secstotimestr( psz_duration, dur/1000000 );
738 o_value = [NSString stringWithUTF8String: psz_duration];
742 o_value = @"-:--:--";
746 vlc_object_release( p_playlist );
751 - (void)tableView:(NSTableView *)o_tv
752 willDisplayCell:(id)o_cell
753 forTableColumn:(NSTableColumn *)o_tc
756 intf_thread_t * p_intf = [NSApp getIntf];
757 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
759 if ((p_playlist->i_groups) > 1 )
761 [o_cell setDrawsBackground: VLC_TRUE];
762 switch ( p_playlist->pp_items[o_rows]->i_group % 8 )
766 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0]];
771 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:0.76471 alpha:1.0]];
776 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:0.76471 green:0.76471 blue:1.0 alpha:1.0]];
781 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:0.89804 blue:0.76471 alpha:1.0]];
786 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:1.0 alpha:1.0]];
791 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:0.76471 alpha:1.0]];
796 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:1.0 alpha:1.0]];
801 [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:1.0 blue:0.76471 alpha:1.0]];
806 vlc_object_release( p_playlist );
809 - (BOOL)tableView:(NSTableView *)o_tv
810 writeRows:(NSArray*)o_rows
811 toPasteboard:(NSPasteboard*)o_pasteboard
813 int i_rows = [o_rows count];
814 NSArray *o_filenames = [NSArray array];
816 [o_pasteboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:self];
817 [o_pasteboard setPropertyList:o_filenames forType:NSFilenamesPboardType];
820 i_moveRow = [[o_rows objectAtIndex:0]intValue];
826 - (NSDragOperation)tableView:(NSTableView*)o_tv
827 validateDrop:(id <NSDraggingInfo>)o_info
828 proposedRow:(int)i_row
829 proposedDropOperation:(NSTableViewDropOperation)o_operation
831 if ( o_operation == NSTableViewDropAbove )
833 if ( i_moveRow >= 0 )
835 if ( i_row != i_moveRow )
837 return NSDragOperationMove;
839 /* what if in the previous run, the row wasn't actually moved?
840 then we can't drop new files on this location */
841 return NSDragOperationNone;
843 return NSDragOperationGeneric;
845 return NSDragOperationNone;
848 - (BOOL)tableView:(NSTableView*)o_tv
849 acceptDrop:(id <NSDraggingInfo>)o_info
850 row:(int)i_proposed_row
851 dropOperation:(NSTableViewDropOperation)o_operation
853 if ( i_moveRow >= 0 )
855 if (i_moveRow != -1 && i_proposed_row != -1)
857 intf_thread_t * p_intf = [NSApp getIntf];
858 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
861 if( p_playlist == NULL )
867 playlist_Move( p_playlist, i_moveRow, i_proposed_row );
869 vlc_object_release( p_playlist );
871 [self playlistUpdated];
877 NSPasteboard * o_pasteboard;
878 o_pasteboard = [o_info draggingPasteboard];
880 if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
883 NSArray *o_array = [NSArray array];
884 NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType]
885 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
887 for( i = 0; i < (int)[o_values count]; i++)
890 o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
891 o_array = [o_array arrayByAddingObject: o_dic];
893 [self appendArray: o_array atPos: i_proposed_row enqueue:YES];
898 [self updateRowSelection];
901 /* Delegate method of NSWindow */
902 - (void)windowWillClose:(NSNotification *)aNotification
904 [o_btn_playlist setState: NSOffState];