/*****************************************************************************
* playlist.m: MacOS X interface module
*****************************************************************************
-* Copyright (C) 2002-2005 VideoLAN
+* Copyright (C) 2002-2005 VideoLAN (Centrale Réseaux) and its contributors
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
- * Derk-Jan Hartman <hartman at videolan dot org>
+ * Derk-Jan Hartman <hartman at videola/n dot org>
* Benjamin Pracht <bigben at videolab dot org>
*
* This program is free software; you can redistribute it and/or modify
[[self delegate] deleteItem:self];
break;
+ case NSEnterCharacter:
+ case NSCarriageReturnCharacter:
+ [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist]
+ playItem:self];
+ break;
+
default:
[super keyDown: o_event];
break;
if ( self != nil )
{
o_outline_dict = [[NSMutableDictionary alloc] init];
+ o_nodes_array = [[NSMutableArray alloc] init];
+ o_items_array = [[NSMutableArray alloc] init];
+
+
//i_moveRow = -1;
}
return self;
vlc_list_release( p_list );
vlc_object_release( p_playlist );
+ /* Change the simple textfield into a searchField if we can... */
+#if 0
+ if( MACOS_VERSION >= 10.3 )
+ {
+ NSView *o_parentview = [o_status_field superview];
+ NSSearchField *o_better_search_field = [[NSSearchField alloc]initWithFrame:[o_search_field frame]];
+ [o_better_search_field setRecentsAutosaveName:@"VLC media player search"];
+ [o_better_search_field setDelegate:self];
+ [[NSNotificationCenter defaultCenter] addObserver: self
+ selector: @selector(searchfieldChanged:)
+ name: NSControlTextDidChangeNotification
+ object: o_better_search_field];
+
+ [o_better_search_field setTarget:self];
+ [o_better_search_field setAction:@selector(searchItem:)];
+
+ [o_better_search_field setAutoresizingMask:NSViewMinXMargin];
+ [o_parentview addSubview:o_better_search_field];
+ [o_search_field setHidden:YES];
+ }
+#endif
[self initStrings];
//[self playlistUpdated];
}
+- (void)searchfieldChanged:(NSNotification *)o_notification
+{
+ [o_search_field setStringValue:[[o_notification object] stringValue]];
+}
+
- (void)initStrings
{
[o_mi_save_playlist setTitle: _NS("Save Playlist...")];
[o_mi_play setTitle: _NS("Play")];
[o_mi_delete setTitle: _NS("Delete")];
+ [o_mi_recursive_expand setTitle: _NS("Expand Node")];
[o_mi_selectall setTitle: _NS("Select All")];
[o_mi_info setTitle: _NS("Properties")];
[o_mi_sort_name setTitle: _NS("Sort Node by Name")];
#if 0
[o_search_button setTitle: _NS("Search")];
#endif
+ [o_search_field setToolTip: _NS("Search in Playlist")];
[[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
[[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
[[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
vlc_object_release( p_playlist );
}
+- (playlist_item_t *)parentOfItem:(playlist_item_t *)p_item
+{
+ int i;
+ for( i = 0 ; i < p_item->i_parents; i++ )
+ {
+ if( p_item->pp_parents[i]->i_view == i_current_view )
+ {
+ return p_item->pp_parents[i]->p_parent;
+ }
+ }
+ return NULL;
+}
+
- (void)updateRowSelection
{
- int i,i_row;
+// int i;
+ int i_row;
unsigned int j;
playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
return;
p_item = p_playlist->status.p_item;
- if( p_item == NULL ) return;
+ if( p_item == NULL )
+ {
+ vlc_object_release(p_playlist);
+ return;
+ }
p_temp_item = p_item;
while( p_temp_item->i_parents > 0 )
{
[o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
- for (i = 0 ; i < p_temp_item->i_parents ; i++)
+
+ p_temp_item = [self parentOfItem: p_temp_item];
+ /*for (i = 0 ; i < p_temp_item->i_parents ; i++)
{
if( p_temp_item->pp_parents[i]->i_view == i_current_view )
{
p_temp_item = p_temp_item->pp_parents[i]->p_parent;
break;
}
- }
+ }*/
}
for (j = 0 ; j < [o_array count] - 1 ; j++)
{
- [o_outline_view expandItem: [o_outline_dict objectForKey:
+ id o_item;
+ if( ( o_item = [o_outline_dict objectForKey:
[NSString stringWithFormat: @"%p",
- [[o_array objectAtIndex:j] pointerValue]]]];
+ [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
+ [o_outline_view expandItem: o_item];
}
vlc_object_release(p_playlist);
}
+/* Check if p_item is a child of p_node recursively. We need to check the item existence first since OSX sometimes tries to redraw items that have been
+ deleted. We don't do it when not required since this verification takes
+ quite a long time on big playlists (yes, pretty hacky). */
+- (BOOL)isItem: (playlist_item_t *)p_item
+ inNode: (playlist_item_t *)p_node
+ checkItemExistence:(BOOL)b_check
-- (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node
{
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
return NO;
}
+ if( p_node == p_item )
+ {
+ vlc_object_release(p_playlist);
+ return YES;
+ }
+
+ if( p_node->i_children < 1)
+ {
+ vlc_object_release(p_playlist);
+ return NO;
+ }
+
if ( p_temp_item )
{
+ int i;
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( b_check )
+ {
+ /* Since outlineView: willDisplayCell:... may call this function with
+ p_items that don't exist anymore, first check if the item is still
+ in the playlist. Any cleaner solution welcomed. */
+ for( i = 0; i < p_playlist->i_all_size; i++ )
+ {
+ if( p_playlist->pp_all_items[i] == p_item ) break;
+ else if ( i == p_playlist->i_all_size - 1 )
+ {
+ vlc_object_release( p_playlist );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ return NO;
+ }
+ }
+ }
+
while( p_temp_item->i_parents > 0 )
{
- int i;
- for( i = 0; i < p_temp_item->i_parents ; i++ )
+ p_temp_item = [self parentOfItem: p_temp_item];
+ if( p_temp_item == p_node )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return YES;
+ }
+
+/* for( i = 0; i < p_temp_item->i_parents ; i++ )
{
if( p_temp_item->pp_parents[i]->i_view == i_current_view )
{
if( p_temp_item->pp_parents[i]->p_parent == p_node )
{
+ vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
return YES;
}
break;
}
}
- }
+ }*/
}
+ vlc_mutex_unlock( &p_playlist->object_lock );
}
vlc_object_release( p_playlist );
return NO;
}
+/* This method is usefull for instance to remove the selected children of an
+ already selected node, for instance */
+- (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
+{
+ unsigned int i, j;
+ for( i = 0 ; i < [o_items count] ; i++ )
+ {
+ for ( j = 0 ; j < [o_nodes count] ; j++ )
+ {
+ if( o_items == o_nodes)
+ {
+ if( j == i ) continue;
+ }
+ if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
+ inNode: [[o_nodes objectAtIndex:j] pointerValue]
+ checkItemExistence: NO] )
+ {
+ [o_items removeObjectAtIndex:i];
+ /* We need to execute the next iteration with the same index
+ since the current item has been deleted */
+ i--;
+ break;
+ }
+ }
+ }
+
+}
+
+- (IBAction)savePlaylist:(id)sender
+{
+ intf_thread_t * p_intf = VLCIntf;
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+
+ NSSavePanel *o_save_panel = [NSSavePanel savePanel];
+ NSString * o_name = [NSString stringWithFormat: @"%@.m3u", _NS("Untitled")];
+ [o_save_panel setTitle: _NS("Save Playlist")];
+ [o_save_panel setPrompt: _NS("Save")];
+
+ if( [o_save_panel runModalForDirectory: nil
+ file: o_name] == NSOKButton )
+ {
+ playlist_Export( p_playlist, [[o_save_panel filename] fileSystemRepresentation], "export-m3u" );
+ }
+}
+
/* When called retrieves the selected outlineview row and plays that node or item */
- (IBAction)playItem:(id)sender
{
playlist_item_t *p_item;
playlist_item_t *p_node = NULL;
- int i;
+// int i;
p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
{
if( p_item->i_children == -1 )
{
- for( i = 0 ; i < p_item->i_parents ; i++ )
+ p_node = [self parentOfItem: p_item];
+
+/* for( i = 0 ; i < p_item->i_parents ; i++ )
{
if( p_item->pp_parents[i]->i_view == i_current_view )
{
p_node = p_item->pp_parents[i]->p_parent;
}
- }
+ }*/
}
else
{
for( i = 0; i < i_count; i++ )
{
- playlist_item_t * p_item;
o_number = [o_to_delete lastObject];
i_row = [o_number intValue];
-
+ id o_item = [o_outline_view itemAtRow: i_row];
+ playlist_item_t *p_item = [o_item pointerValue];
[o_to_delete removeObject: o_number];
[o_outline_view deselectRow: i_row];
- p_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_row] pointerValue];
-
- if( p_item->i_children > -1 ) //is a node and not an item
+ if( [[o_outline_view dataSource] outlineView:o_outline_view
+ numberOfChildrenOfItem: o_item] > 0 )
+ //is a node and not an item
{
if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
- [self isItem: p_playlist->status.p_item inNode: p_item] == YES )
+ [self isItem: p_playlist->status.p_item inNode:
+ ((playlist_item_t *)[o_item pointerValue])
+ checkItemExistence: NO] == YES )
{
// if current item is in selected node and is playing then stop playlist
playlist_Stop( p_playlist );
}
+ vlc_mutex_lock( &p_playlist->object_lock );
playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
+ vlc_mutex_unlock( &p_playlist->object_lock );
}
else
{
{
playlist_Stop( p_playlist );
}
- playlist_LockDelete( p_playlist, p_item->input.i_id );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ playlist_Delete( p_playlist, p_item->input.i_id );
+ vlc_mutex_unlock( &p_playlist->object_lock );
}
}
[self playlistUpdated];
o_current_name = [NSString stringWithUTF8String:
p_item->pp_children[i_current]->input.psz_name];
psz_temp = vlc_input_item_GetInfo( &p_item->input ,
- _("Meta-information"),_("Artist") );
+ _("Meta-information"),_("Artist") );
o_current_author = [NSString stringWithUTF8String: psz_temp];
free( psz_temp);
vlc_mutex_unlock( &p_playlist->object_lock );
if( p_playlist == NULL )
return;
-
p_view = playlist_ViewFind( p_playlist, i_current_view );
if( p_view )
}
if( o_result != NULL )
{
- for( i = 0 ; i < [o_result count] - 1 ; i++ )
+ int i_start;
+ if( [[o_result objectAtIndex: 0] pointerValue] ==
+ p_playlist->p_general )
+ i_start = 1;
+ else
+ i_start = 0;
+
+ for( i = i_start ; i < [o_result count] - 1 ; i++ )
{
[o_outline_view expandItem: [o_outline_dict objectForKey:
[NSString stringWithFormat: @"%p",
vlc_object_release( p_playlist );
}
+- (IBAction)recursiveExpandNode:(id)sender
+{
+ int i;
+ id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
+ playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
+
+ if( ![[o_outline_view dataSource] outlineView: o_outline_view
+ isItemExpandable: o_item] )
+ {
+ for( i = 0 ; i < p_item->i_parents ; i++ )
+ {
+ if( p_item->pp_parents[i]->i_view == i_current_view )
+ {
+ o_item = [o_outline_dict objectForKey: [NSString
+ stringWithFormat: @"%p", p_item->pp_parents[i]->p_parent]];
+ break;
+ }
+ }
+ }
+
+ /* We need to collapse the node first, since OSX refuses to recursively
+ expand an already expanded node, even if children nodes are collapsed. */
+ [o_outline_view collapseItem: o_item collapseChildren: YES];
+ [o_outline_view expandItem: o_item expandChildren: YES];
+}
+
- (NSMenu *)menuForEvent:(NSEvent *)o_event
{
NSPoint pt;
[o_mi_delete setEnabled: b_item_sel];
[o_mi_selectall setEnabled: b_rows];
[o_mi_info setEnabled: b_item_sel];
+ [o_mi_recursive_expand setEnabled: b_item_sel];
+ [o_mi_sort_name setEnabled: b_item_sel];
+ [o_mi_sort_author setEnabled: b_item_sel];
return( o_ctx_menu );
}
{
return;
}
-
+
/* Check whether the selected table column header corresponds to a
sortable table column*/
if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
{
playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
- playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
+
+ id o_playing_item;
if( !p_playlist ) return;
- if( ( p_item == p_playlist->status.p_item ) ||
- ( p_item->i_children != 0 &&
- [self isItem: p_playlist->status.p_item inNode: p_item] ) )
+ o_playing_item = [o_outline_dict objectForKey:
+ [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
+
+ if( [self isItem: [o_playing_item pointerValue] inNode:
+ [item pointerValue] checkItemExistence: YES]
+ || [o_playing_item isEqual: item] )
{
[cell setFont: [NSFont boldSystemFontOfSize: 0]];
}
playlist_view_t *p_view;
p_view = playlist_ViewFind( p_playlist, i_current_view );
if( p_view && p_view->p_root )
+ {
i_return = p_view->p_root->i_children;
+ if( i_current_view == VIEW_CATEGORY )
+ {
+ i_return--; /* remove the GENERAL item from the list */
+ i_return += p_playlist->p_general->i_children; /* add the items of the general node */
+ }
+ }
}
else
{
/* root object */
playlist_view_t *p_view;
p_view = playlist_ViewFind( p_playlist, i_current_view );
- if( p_view && index < p_view->p_root->i_children && index >= 0 )
- p_return = p_view->p_root->pp_children[index];
+ if( p_view && p_view->p_root ) p_return = p_view->p_root->pp_children[index];
+
+ if( i_current_view == VIEW_CATEGORY )
+ {
+ if( p_playlist->p_general->i_children && index >= 0 && index < p_playlist->p_general->i_children )
+ {
+ p_return = p_playlist->p_general->pp_children[index];
+ }
+ else if( p_view && p_view->p_root && index >= 0 && index - p_playlist->p_general->i_children < p_view->p_root->i_children )
+ {
+ p_return = p_view->p_root->pp_children[index - p_playlist->p_general->i_children + 1];
+
+ }
+ }
}
else
{
/* root object */
playlist_view_t *p_view;
p_view = playlist_ViewFind( p_playlist, i_current_view );
- if( p_view && p_view->p_root )
- i_return = p_view->p_root->i_children;
+ if( p_view && p_view->p_root ) i_return = p_view->p_root->i_children;
+
+ if( i_current_view == VIEW_CATEGORY )
+ {
+ i_return--;
+ i_return += p_playlist->p_general->i_children;
+ }
}
else
{
/* Required for drag & drop and reordering */
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
{
-/* unsigned int i;
+ unsigned int i,j;
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+
+ /* First remove the items that were moved during the last drag & drop
+ operation */
+ [o_items_array removeAllObjects];
+ [o_nodes_array removeAllObjects];
+
+ if( !p_playlist ) return NO;
for( i = 0 ; i < [items count] ; i++ )
{
- if( [outlineView levelForItem: [items objectAtIndex: i]] == 0 )
+ id o_item = [items objectAtIndex: i];
+
+ /* Refuse to move items that are not in the General Node
+ (Service Discovery) */
+ if( ![self isItem: [o_item pointerValue] inNode:
+ p_playlist->p_general checkItemExistence: NO])
{
+ vlc_object_release(p_playlist);
return NO;
}
- }*/
- return NO;
+ /* Fill the items and nodes to move in 2 different arrays */
+ if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
+ [o_nodes_array addObject: o_item];
+ else
+ [o_items_array addObject: o_item];
+ }
+
+ /* Now we need to check if there are selected items that are in already
+ selected nodes. In that case, we only want to move the nodes */
+ [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
+ [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
+
+#if 0
+ for( i = 0 ; i < [o_nodes_array count] ; i++ )
+ {
+ for ( j = 0 ; j < [o_nodes_array count] ; j++ )
+ {
+ if( j == i ) continue;
+ if( [self isItem: [[o_nodes_array objectAtIndex:i] pointerValue]
+ inNode: [[o_nodes_array objectAtIndex:j] pointerValue]] )
+ {
+ [o_nodes_array removeObjectAtIndex:i];
+ /* We need to execute the next iteration with the same index
+ since the current item has been deleted */
+ i--;
+ break;
+ }
+ }
+ }
+
+ for( i = 0 ; i < [o_items_array count] ; i++ )
+ {
+ for ( j = 0 ; j < [o_nodes_array count] ; j++ )
+ {
+ if( [self isItem: [[o_items_array objectAtIndex:i] pointerValue]
+ inNode: [[o_nodes_array objectAtIndex:j] pointerValue]] )
+ {
+ [o_items_array removeObjectAtIndex:i];
+ i--;
+ break;
+ }
+ }
+ }
+#endif
+ /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
+ a Drop operation comçing from the playlist.
+ We need to add NSFilenamesPboardType otherwise the outlineview refuses
+ to the drop. */
+
+ [pboard declareTypes: [NSArray arrayWithObjects:
+ @"VLCPlaylistItemPboardType",NSFilenamesPboardType, nil] owner: self];
+ [pboard setPropertyList:[NSArray array]
+ forType:NSFilenamesPboardType];
+
+ vlc_object_release(p_playlist);
+ return YES;
}
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
{
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
NSPasteboard *o_pasteboard = [info draggingPasteboard];
- if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
+ if( !p_playlist ) return NSDragOperationNone;
+
+ /* We refuse to drop an item in anything else than a child of the General
+ Node. We still accept items that would be root nodes of the outlineview
+ however, to allow drop in an empty playlist.*/
+ if( !([self isItem: [item pointerValue] inNode: p_playlist->p_general
+ checkItemExistence: NO] || item == nil) )
{
+ vlc_object_release(p_playlist);
+ return NSDragOperationNone;
+ }
+
+ /* Drop from the Playlist */
+ if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
+ {
+ unsigned int i;
+ for( i = 0 ; i < [o_nodes_array count] ; i++ )
+ {
+ /* We refuse to Drop in a child of an item we are moving */
+ if( [self isItem: [item pointerValue] inNode:
+ [[o_nodes_array objectAtIndex: i] pointerValue]
+ checkItemExistence: NO] )
+ {
+ vlc_object_release(p_playlist);
+ return NSDragOperationNone;
+ }
+ }
+ vlc_object_release(p_playlist);
+ return NSDragOperationMove;
+ }
+
+ /* Drop from the Finder */
+ else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
+ {
+ vlc_object_release(p_playlist);
return NSDragOperationGeneric;
}
+ vlc_object_release(p_playlist);
return NSDragOperationNone;
}
if( !p_playlist ) return NO;
- if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
+ /* Drag & Drop inside the playlist */
+ if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
+ {
+ int i_row;
+ unsigned int i;
+ playlist_item_t *p_new_parent, *p_item = NULL;
+ NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
+ o_items_array];
+ /* If the item is to be dropped as root item of the outline, make it a
+ child of the General node.
+ Else, choose the proposed parent as parent. */
+ if( item == nil )
+ p_new_parent = p_playlist->p_general;
+ else
+ p_new_parent = [item pointerValue];
+
+ /* If the proposed parent is not a node, then use the parent node of
+ this item. */
+ if( p_new_parent->i_children <= 0 )
+ {
+ int j;
+ playlist_item_t *p_temp_item = p_new_parent;
+ p_new_parent = [self parentOfItem: p_new_parent];
+ if( !p_new_parent )
+ {
+ vlc_object_release(p_playlist);
+ return NO;
+ }
+ /* Calculate the position of the dropped item in this new parent:
+ following the first proposed parent. */
+ for( j = 0; j < p_new_parent->i_children; j++ )
+ {
+ if( p_new_parent->pp_children[j] == p_temp_item )
+ {
+ index = j;
+ break;
+ }
+ else if( j == p_new_parent->i_children - 1 )
+ index = -1;
+ }
+ }
+
+ for( i = 0; i < [o_all_items count]; i++ )
+ {
+ playlist_item_t *p_old_parent = NULL;
+ int i_old_index = 0;
+
+ p_item = [[o_all_items objectAtIndex:i] pointerValue];
+ p_old_parent = [self parentOfItem: p_item];
+ if( !p_old_parent )
+ continue;
+ /* We may need the old index later */
+ if( p_new_parent == p_old_parent )
+ {
+ int j;
+ for( j = 0; j < p_old_parent->i_children; j++ )
+ {
+ if( p_old_parent->pp_children[j] == p_item )
+ {
+ i_old_index = j;
+ break;
+ }
+ }
+ }
+
+
+ /* If we move the playing item in a different node or we move the
+ node containing the playing item in a different node, then stop
+ playback, or the playlist refuses to detach the item. */
+/* if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
+ (( p_item == p_playlist->status.p_item &&
+ p_new_parent != p_old_parent) ||
+ ( p_item->i_children > 0 &&
+ [self isItem: p_playlist->status.p_item inNode:p_item] == YES))
+ {
+ playlist_Stop( p_playlist );
+ }*/
+ vlc_mutex_lock( &p_playlist->object_lock );
+ // Acually detach the item from the old position
+ if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
+ VLC_SUCCESS &&
+ playlist_NodeRemoveParent( p_playlist, p_item, p_old_parent ) ==
+ VLC_SUCCESS )
+ {
+ int i_new_index;
+ /* Calculate the new index */
+ if( index == -1 )
+ i_new_index = -1;
+ /* If we move the item in the same node, we need to take into
+ account that one item will be deleted */
+ else if((p_new_parent == p_old_parent &&
+ i_old_index < index + (int)i)
+ || p_new_parent == p_playlist->p_general || index == 0 )
+ i_new_index = index + i;
+ else
+ i_new_index = index + i + 1;
+ // Reattach the item to the new position
+ playlist_NodeInsert( p_playlist, i_current_view, p_item,
+ p_new_parent, i_new_index );
+ }
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ }
+ [self playlistUpdated];
+ i_row = [o_outline_view rowForItem:[o_outline_dict
+ objectForKey:[NSString stringWithFormat: @"%p",
+ [[o_all_items objectAtIndex: 0] pointerValue]]]];
+
+ if( i_row == -1 )
+ {
+ i_row = [o_outline_view rowForItem:[o_outline_dict
+ objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
+ }
+
+ [o_outline_view deselectAll: self];
+ [o_outline_view selectRow: i_row byExtendingSelection: NO];
+ [o_outline_view scrollRowToVisible: i_row];
+
+ vlc_object_release(p_playlist);
+ return YES;
+ }
+
+ else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
{
int i;
playlist_item_t *p_node = [item pointerValue];
}
if( i_counter == p_node->i_parents )
{
+ vlc_object_release(p_playlist);
return NO;
}
}