Restrict to sane number of types, with sane defaults

This commit is contained in:
Matthias Neeracher 2011-08-14 22:37:23 +02:00
parent d24a3e783d
commit 514fffddbd

View File

@ -139,10 +139,21 @@
[exportMovie writeToFile:[url path] withAttributes:attributes]; [exportMovie writeToFile:[url path] withAttributes:attributes];
} }
#define kMAAudioTypes @"m4a", @"aiff", @"aif", @"wav", @"caf", @"mp3"
#define kMAVideoTypes @"mov", @"mp4"
- (IBAction)exportMedia:(id)sender - (IBAction)exportMedia:(id)sender
{ {
NSSavePanel * savePanel = [NSSavePanel savePanel]; QTMovie * currentMovie = [self currentMovie];
[savePanel setAllowedFileTypes:[QTMovie movieFileTypes:QTIncludeCommonTypes]]; 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 beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result) {
[savePanel orderOut:self]; [savePanel orderOut:self];
if (result == NSFileHandlingPanelOKButton) if (result == NSFileHandlingPanelOKButton)