+- (void)playModeUpdated
+{
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ vlc_value_t val, val2;
+
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ var_Get( p_playlist, "loop", &val2 );
+ var_Get( p_playlist, "repeat", &val );
+ if( val.b_bool == VLC_TRUE )
+ {
+ [o_loop_popup selectItemAtIndex: 1];
+ }
+ else if( val2.b_bool == VLC_TRUE )
+ {
+ [o_loop_popup selectItemAtIndex: 2];
+ }
+ else
+ {
+ [o_loop_popup selectItemAtIndex: 0];
+ }
+
+ var_Get( p_playlist, "random", &val );
+ [o_random_ckb setState: val.b_bool];
+
+ vlc_object_release( p_playlist );
+}
+
+- (void)updateRowSelection
+{
+ int i,i_row;
+ unsigned int j;
+
+ playlist_t *p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ playlist_item_t *p_item, *p_temp_item;
+ NSMutableArray *o_array = [NSMutableArray array];
+
+ if( p_playlist == NULL )
+ return;
+
+ p_item = p_playlist->status.p_item;
+ if( p_item == NULL ) 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++)
+ {
+ 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++)
+ {
+ id o_item;
+ if( ( o_item = [o_outline_dict objectForKey:
+ [NSString stringWithFormat: @"%p",
+ [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
+ [o_outline_view expandItem: o_item];
+
+ }
+
+ i_row = [o_outline_view rowForItem:[o_outline_dict
+ objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
+
+ [o_outline_view selectRow: i_row byExtendingSelection: NO];
+ [o_outline_view scrollRowToVisible: i_row];
+
+ vlc_object_release(p_playlist);
+}
+
+
+- (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 );
+ playlist_item_t *p_temp_item = p_item;
+
+ if( p_playlist == NULL )
+ {
+ return NO;
+ }
+
+ if ( p_temp_item )
+ {
+ vlc_mutex_lock( &p_playlist->object_lock );
+ while( p_temp_item->i_parents > 0 )
+ {
+ int i;
+ 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_object_release( p_playlist );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ return YES;
+ }
+ else
+ {
+ p_temp_item = p_temp_item->pp_parents[i]->p_parent;
+ break;
+ }
+ }
+ }
+ }
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ }
+
+ vlc_object_release( p_playlist );
+ return NO;
+}
+
+- (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 */