diff --git a/Mac/OSX/PythonLauncher/MyAppDelegate.h b/Mac/OSX/PythonLauncher/MyAppDelegate.h index c65175a7aec..097b54177c8 100644 --- a/Mac/OSX/PythonLauncher/MyAppDelegate.h +++ b/Mac/OSX/PythonLauncher/MyAppDelegate.h @@ -11,4 +11,5 @@ - (IBAction)showPreferences:(id)sender; - (BOOL)shouldShowUI; - (BOOL)shouldTerminate; +- (void)testFileTypeBinding; @end diff --git a/Mac/OSX/PythonLauncher/MyAppDelegate.m b/Mac/OSX/PythonLauncher/MyAppDelegate.m index cb9797249db..a5ba7510784 100644 --- a/Mac/OSX/PythonLauncher/MyAppDelegate.m +++ b/Mac/OSX/PythonLauncher/MyAppDelegate.m @@ -1,6 +1,7 @@ #import "MyAppDelegate.h" #import "PreferencesWindowController.h" #import +#import @implementation MyAppDelegate @@ -19,6 +20,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { + // Test that the file mappings are correct + [self testFileTypeBinding]; // If we were opened because of a file drag or doubleclick // we've set initial_action_done in shouldShowUI // Otherwise we open a preferences dialog. @@ -50,4 +53,44 @@ return NO; } +- (void)testFileTypeBinding +{ + NSURL *ourUrl; + OSStatus err; + FSRef appRef; + NSURL *appUrl; + static NSString *extensions[] = { @"py", @"pyw", @"pyc", NULL}; + NSString **ext_p; + int i; + + if ([[NSUserDefaults standardUserDefaults] boolForKey: @"SkipFileBindingTest"]) + return; + ourUrl = [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]]; + for( ext_p = extensions; *ext_p; ext_p++ ) { + err = LSGetApplicationForInfo( + kLSUnknownType, + kLSUnknownCreator, + (CFStringRef)*ext_p, + kLSRolesViewer, + &appRef, + (CFURLRef *)&appUrl); + if (err || ![appUrl isEqual: ourUrl] ) { + i = NSRunAlertPanel(@"File type binding", + @"PythonLauncher is not the default application for all " \ + @"Python script types. You should fix this with the " \ + @"Finder's \"Get Info\" command.\n\n" \ + @"See \"Changing the application that opens a file\" in " \ + @"Mac Help for details.", + @"OK", + @"Don't show this warning again", + NULL); + if ( i == 0 ) { // Don't show again + [[NSUserDefaults standardUserDefaults] + setObject:@"YES" forKey:@"SkipFileBindingTest"]; + } + return; + } + } +} + @end diff --git a/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj b/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj index 5b4a06c87c5..107ce3dd4f2 100755 --- a/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj +++ b/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj @@ -317,24 +317,6 @@ English CFBundleDocumentTypes - - CFBundleTypeExtensions - - ???? - - CFBundleTypeIconFile - - CFBundleTypeName - DocumentType - CFBundleTypeOSTypes - - ???? - - CFBundleTypeRole - Editor - NSDocumentClass - MyDocument - CFBundleTypeExtensions