+ playlist_ItemAddOption( p_item, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
+ }
+ }
+
+ /* Recent documents menu */
+ o_true_file = [NSURL fileURLWithPath: o_uri];
+ if( o_true_file != nil )
+ {
+ [[NSDocumentController sharedDocumentController]
+ noteNewRecentDocumentURL: o_true_file];
+ }
+
+ vlc_object_release( p_playlist );
+ return p_item;
+}
+
+- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
+{
+ int i_item;
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
+ {
+ playlist_item_t *p_item;
+ NSDictionary *o_one_item;
+
+ /* Get the item */
+ o_one_item = [o_array objectAtIndex: i_item];
+ p_item = [self createItem: o_one_item];
+ if( !p_item )
+ {
+ continue;
+ }
+
+ /* Add the item */
+ playlist_AddItem( p_playlist, p_item, PLAYLIST_APPEND, i_position == -1 ? PLAYLIST_END : i_position + i_item );
+
+ if( i_item == 0 && !b_enqueue )
+ {
+ playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
+ }
+ }
+ vlc_object_release( p_playlist );
+}
+
+- (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position inView:(int)i_view enqueue:(BOOL)b_enqueue
+{
+ int i_item;
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
+ {
+ playlist_item_t *p_item;
+ NSDictionary *o_one_item;
+
+ /* Get the item */
+ o_one_item = [o_array objectAtIndex: i_item];
+ p_item = [self createItem: o_one_item];
+ if( !p_item )
+ {
+ continue;
+ }
+
+ /* Add the item */
+ playlist_NodeAddItem( p_playlist, p_item, i_view, p_node, PLAYLIST_APPEND, i_position + i_item );
+
+ if( i_item == 0 && !b_enqueue )
+ {
+ playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
+ }
+ }
+ vlc_object_release( p_playlist );
+
+}
+
+- (IBAction)handlePopUp:(id)sender
+
+{
+ intf_thread_t * p_intf = VLCIntf;
+ vlc_value_t val1,val2;
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ switch( [o_loop_popup indexOfSelectedItem] )
+ {
+ case 1:
+
+ val1.b_bool = 0;
+ var_Set( p_playlist, "loop", val1 );
+ val1.b_bool = 1;
+ var_Set( p_playlist, "repeat", val1 );
+ vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
+ break;
+
+ case 2:
+ val1.b_bool = 0;
+ var_Set( p_playlist, "repeat", val1 );
+ val1.b_bool = 1;
+ var_Set( p_playlist, "loop", val1 );
+ vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
+ break;
+
+ default:
+ var_Get( p_playlist, "repeat", &val1 );
+ var_Get( p_playlist, "loop", &val2 );
+ if( val1.b_bool || val2.b_bool )
+ {
+ val1.b_bool = 0;
+ var_Set( p_playlist, "repeat", val1 );
+ var_Set( p_playlist, "loop", val1 );
+ vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
+ }
+ break;
+ }
+ vlc_object_release( p_playlist );
+ [self playlistUpdated];
+}
+
+- (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
+{
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ playlist_item_t *p_selected_item;
+ int i_current, i_selected_row;
+
+ if( !p_playlist )
+ return NULL;
+
+ i_selected_row = [o_outline_view selectedRow];
+ if (i_selected_row < 0)
+ i_selected_row = 0;
+
+ p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
+ i_selected_row] pointerValue];
+
+ for( i_current = 0; i_current < p_item->i_children ; i_current++ )
+ {
+ char *psz_temp;
+ NSString *o_current_name, *o_current_author;
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+ 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") );
+ o_current_author = [NSString stringWithUTF8String: psz_temp];
+ free( psz_temp);
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ if( p_selected_item == p_item->pp_children[i_current] &&
+ b_selected_item_met == NO )
+ {
+ b_selected_item_met = YES;
+ }
+ else if( p_selected_item == p_item->pp_children[i_current] &&
+ b_selected_item_met == YES )
+ {
+ vlc_object_release( p_playlist );
+ return NULL;
+ }
+ else if( b_selected_item_met == YES &&
+ ( [o_current_name rangeOfString:[o_search_field
+ stringValue] options:NSCaseInsensitiveSearch ].length ||
+ [o_current_author rangeOfString:[o_search_field
+ stringValue] options:NSCaseInsensitiveSearch ].length ) )
+ {
+ vlc_object_release( p_playlist );
+ /*Adds the parent items in the result array as well, so that we can
+ expand the tree*/
+ return [NSMutableArray arrayWithObject: [NSValue
+ valueWithPointer: p_item->pp_children[i_current]]];
+ }
+ if( p_item->pp_children[i_current]->i_children > 0 )
+ {
+ id o_result = [self subSearchItem:
+ p_item->pp_children[i_current]];
+ if( o_result != NULL )
+ {
+ vlc_object_release( p_playlist );
+ [o_result insertObject: [NSValue valueWithPointer:
+ p_item->pp_children[i_current]] atIndex:0];
+ return o_result;