From 514fffddbdafce7525fde08155f2d283b4dbf99e Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sun, 14 Aug 2011 22:37:23 +0200 Subject: [PATCH] Restrict to sane number of types, with sane defaults --- Medianno/MADocWindow.mm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index ce166e8..f839c56 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -139,10 +139,21 @@ [exportMovie writeToFile:[url path] withAttributes:attributes]; } +#define kMAAudioTypes @"m4a", @"aiff", @"aif", @"wav", @"caf", @"mp3" +#define kMAVideoTypes @"mov", @"mp4" + - (IBAction)exportMedia:(id)sender { - NSSavePanel * savePanel = [NSSavePanel savePanel]; - [savePanel setAllowedFileTypes:[QTMovie movieFileTypes:QTIncludeCommonTypes]]; + QTMovie * currentMovie = [self currentMovie]; + NSSavePanel * savePanel = [NSSavePanel savePanel]; + NSDictionary *attrs = [currentMovie movieAttributes]; + BOOL hasVideo = [[attrs objectForKey:QTMovieHasVideoAttribute] boolValue]; + BOOL hasAudio = !hasVideo || [[attrs objectForKey:QTMovieHasAudioAttribute] boolValue]; + [savePanel setAllowedFileTypes:(hasVideo + ? (hasAudio + ? [NSArray arrayWithObjects: kMAVideoTypes, kMAAudioTypes, nil] + : [NSArray arrayWithObjects: kMAVideoTypes, nil]) + : [NSArray arrayWithObjects: kMAAudioTypes, nil])]; [savePanel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result) { [savePanel orderOut:self]; if (result == NSFileHandlingPanelOKButton)