+- (void)tableView:(NSTableView *)o_tv
+ willDisplayCell:(id)o_cell
+ forTableColumn:(NSTableColumn *)o_tc
+ row:(int)o_rows
+{
+ intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if ((p_playlist->i_groups) > 1 )
+ {
+ [o_cell setDrawsBackground: VLC_TRUE];
+ switch ( p_playlist->pp_items[o_rows]->i_group % 8 )
+ {
+ case 1:
+ /*white*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0]];
+ break;
+
+ case 2:
+ /*red*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:0.76471 alpha:1.0]];
+ break;
+
+ case 3:
+ /*dark blue*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:0.76471 green:0.76471 blue:1.0 alpha:1.0]];
+ break;
+
+ case 4:
+ /*orange*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:0.89804 blue:0.76471 alpha:1.0]];
+ break;
+
+ case 5:
+ /*purple*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:1.0 alpha:1.0]];
+ break;
+
+ case 6:
+ /*green*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:0.76471 alpha:1.0]];
+ break;
+
+ case 7:
+ /*light blue*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:1.0 alpha:1.0]];
+ break;
+
+ case 0:
+ /*yellow*/
+ [o_cell setBackgroundColor: [NSColor colorWithDeviceRed:1.0 green:1.0 blue:0.76471 alpha:1.0]];
+ break;
+ }
+
+ }
+vlc_object_release( p_playlist );
+}
+
+- (BOOL)tableView:(NSTableView *)o_tv
+ writeRows:(NSArray*)o_rows
+ toPasteboard:(NSPasteboard*)o_pasteboard
+{
+ int i_rows = [o_rows count];
+ NSArray *o_filenames = [NSArray array];
+
+ [o_pasteboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:self];
+ [o_pasteboard setPropertyList:o_filenames forType:NSFilenamesPboardType];
+ if ( i_rows == 1 )
+ {
+ i_moveRow = [[o_rows objectAtIndex:0]intValue];
+ return YES;
+ }
+ return NO;
+}
+
+- (NSDragOperation)tableView:(NSTableView*)o_tv
+ validateDrop:(id <NSDraggingInfo>)o_info
+ proposedRow:(int)i_row
+ proposedDropOperation:(NSTableViewDropOperation)o_operation
+{
+ if ( o_operation == NSTableViewDropAbove )
+ {
+ if ( i_moveRow >= 0 )
+ {
+ if ( i_row != i_moveRow )
+ {
+ return NSDragOperationMove;
+ }
+ /* what if in the previous run, the row wasn't actually moved?
+ then we can't drop new files on this location */
+ return NSDragOperationNone;
+ }
+ return NSDragOperationGeneric;
+ }
+ return NSDragOperationNone;
+}
+
+- (BOOL)tableView:(NSTableView*)o_tv
+ acceptDrop:(id <NSDraggingInfo>)o_info
+ row:(int)i_proposed_row
+ dropOperation:(NSTableViewDropOperation)o_operation
+{
+ if ( i_moveRow >= 0 )
+ {
+ if (i_moveRow != -1 && i_proposed_row != -1)
+ {
+ intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+
+ if( p_playlist == NULL )
+ {
+ i_moveRow = -1;
+ return NO;
+ }
+
+ playlist_Move( p_playlist, i_moveRow, i_proposed_row );
+
+ vlc_object_release( p_playlist );
+ }
+ [self playlistUpdated];
+ i_moveRow = -1;
+ return YES;
+ }
+ else
+ {
+ NSPasteboard * o_pasteboard;
+ o_pasteboard = [o_info draggingPasteboard];
+
+ if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
+ {
+ int i;
+ NSArray *o_array = [NSArray array];
+ NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType]
+ sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
+
+ for( i = 0; i < (int)[o_values count]; i++)
+ {
+ NSDictionary *o_dic;
+ o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
+ o_array = [o_array arrayByAddingObject: o_dic];
+ }
+ [self appendArray: o_array atPos: i_proposed_row enqueue:YES];
+ return YES;
+ }
+ return NO;
+ }
+ [self updateRowSelection];
+}
+
+/* Delegate method of NSWindow */
+- (void)windowWillClose:(NSNotification *)aNotification
+{
+ [o_btn_playlist setState: NSOffState];
+}
+