mirror of https://github.com/python/cpython.git
At startup, test that PythonLauncher is the default application for files
of type .py, .pyw and .pyc. If not, post a warning.
This commit is contained in:
parent
94d09f84be
commit
c30d7c37ee
|
@ -11,4 +11,5 @@
|
||||||
- (IBAction)showPreferences:(id)sender;
|
- (IBAction)showPreferences:(id)sender;
|
||||||
- (BOOL)shouldShowUI;
|
- (BOOL)shouldShowUI;
|
||||||
- (BOOL)shouldTerminate;
|
- (BOOL)shouldTerminate;
|
||||||
|
- (void)testFileTypeBinding;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#import "MyAppDelegate.h"
|
#import "MyAppDelegate.h"
|
||||||
#import "PreferencesWindowController.h"
|
#import "PreferencesWindowController.h"
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
|
#import <ApplicationServices/ApplicationServices.h>
|
||||||
|
|
||||||
@implementation MyAppDelegate
|
@implementation MyAppDelegate
|
||||||
|
|
||||||
|
@ -19,6 +20,8 @@
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
|
// Test that the file mappings are correct
|
||||||
|
[self testFileTypeBinding];
|
||||||
// If we were opened because of a file drag or doubleclick
|
// If we were opened because of a file drag or doubleclick
|
||||||
// we've set initial_action_done in shouldShowUI
|
// we've set initial_action_done in shouldShowUI
|
||||||
// Otherwise we open a preferences dialog.
|
// Otherwise we open a preferences dialog.
|
||||||
|
@ -50,4 +53,44 @@
|
||||||
return NO;
|
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
|
@end
|
||||||
|
|
|
@ -317,24 +317,6 @@
|
||||||
<string>English</string>
|
<string>English</string>
|
||||||
<key>CFBundleDocumentTypes</key>
|
<key>CFBundleDocumentTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<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>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
|
|
Loading…
Reference in New Issue