diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-06-20 14:36:58 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-06-20 14:36:58 (GMT) |
commit | c30d7c37ee1a2344fe866c95ce557a8a32f403f3 (patch) | |
tree | 14ce11df0980175ccd63a3b6002d023786044706 /Mac | |
parent | 94d09f84be3be999739a61de5c49547ca82fe964 (diff) | |
download | cpython-c30d7c37ee1a2344fe866c95ce557a8a32f403f3.zip cpython-c30d7c37ee1a2344fe866c95ce557a8a32f403f3.tar.gz cpython-c30d7c37ee1a2344fe866c95ce557a8a32f403f3.tar.bz2 |
At startup, test that PythonLauncher is the default application for files
of type .py, .pyw and .pyc. If not, post a warning.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/OSX/PythonLauncher/MyAppDelegate.h | 1 | ||||
-rw-r--r-- | Mac/OSX/PythonLauncher/MyAppDelegate.m | 43 | ||||
-rwxr-xr-x | Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj | 18 |
3 files changed, 44 insertions, 18 deletions
diff --git a/Mac/OSX/PythonLauncher/MyAppDelegate.h b/Mac/OSX/PythonLauncher/MyAppDelegate.h index c65175a..097b541 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 cb97972..a5ba751 100644 --- a/Mac/OSX/PythonLauncher/MyAppDelegate.m +++ b/Mac/OSX/PythonLauncher/MyAppDelegate.m @@ -1,6 +1,7 @@ #import "MyAppDelegate.h" #import "PreferencesWindowController.h" #import <Carbon/Carbon.h> +#import <ApplicationServices/ApplicationServices.h> @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 5b4a06c..107ce3d 100755 --- a/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj +++ b/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj @@ -320,24 +320,6 @@ <dict> <key>CFBundleTypeExtensions</key> <array> - <string>????</string> - </array> - <key>CFBundleTypeIconFile</key> - <string></string> - <key>CFBundleTypeName</key> - <string>DocumentType</string> - <key>CFBundleTypeOSTypes</key> - <array> - <string>????</string> - </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>NSDocumentClass</key> - <string>MyDocument</string> - </dict> - <dict> - <key>CFBundleTypeExtensions</key> - <array> <string>py</string> </array> <key>CFBundleTypeIconFile</key> |