+/* This method is usefull for instance to remove the selected children of an
+ already selected node */
+- (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
+{
+ playlist_t * p_playlist = pl_Yield( VLCIntf );
+
+ NSSavePanel *o_save_panel = [NSSavePanel savePanel];
+ NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
+
+ //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
+ [o_save_panel setTitle: _NS("Save Playlist")];
+ [o_save_panel setPrompt: _NS("Save")];
+ [o_save_panel setAccessoryView: o_save_accessory_view];
+
+ if( [o_save_panel runModalForDirectory: nil
+ file: o_name] == NSOKButton )
+ {
+ NSString *o_filename = [o_save_panel filename];
+
+ if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
+ {
+ NSString * o_real_filename;
+ NSRange range;
+ range.location = [o_filename length] - [@".xspf" length];
+ range.length = [@".xspf" length];
+
+ if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
+ range: range] != NSOrderedSame )
+ {
+ o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
+ }
+ else
+ {
+ o_real_filename = o_filename;
+ }
+ playlist_Export( p_playlist,
+ [o_real_filename fileSystemRepresentation],
+ p_playlist->p_local_category, "export-xspf" );
+ }
+ else
+ {
+ NSString * o_real_filename;
+ NSRange range;
+ range.location = [o_filename length] - [@".m3u" length];
+ range.length = [@".m3u" length];
+
+ if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
+ range: range] != NSOrderedSame )
+ {
+ o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
+ }
+ else
+ {
+ o_real_filename = o_filename;
+ }
+ playlist_Export( p_playlist,
+ [o_real_filename fileSystemRepresentation],
+ p_playlist->p_local_category, "export-m3u" );
+ }
+ }
+ vlc_object_release( p_playlist );
+}