diff --git a/Objektiv/AppDelegate.m b/Objektiv/AppDelegate.m index daec791..70959b0 100644 --- a/Objektiv/AppDelegate.m +++ b/Objektiv/AppDelegate.m @@ -253,23 +253,6 @@ - (void) showNotification:(NSString *)browserIdentifier [center deliverNotification:notification]; } -- (void)getUrl:(NSAppleEventDescriptor *)event -withReplyEvent:(NSAppleEventDescriptor *)replyEvent -{ - // Get the URL - NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] - stringValue]; - NSArray *urls = [NSArray arrayWithObject:[NSURL URLWithString:urlStr]]; - - int options = NSWorkspaceLaunchAsync; - - [[NSWorkspace sharedWorkspace] openURLs: urls - withAppBundleIdentifier: [[Browsers sharedInstance] defaultBrowserIdentifier] - options: options - additionalEventParamDescriptor: nil - launchIdentifiers: nil]; -} - - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification { return YES; @@ -300,4 +283,33 @@ -(void)displayAreWeDefaultMsg } } +#pragma mark - File Handlers + +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + [self openWithBrowser:[NSString stringWithFormat:kLocalFileUri, filename]]; + return YES; +} + +- (void)getUrl:(NSAppleEventDescriptor *)event +withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + [self openWithBrowser:[[event paramDescriptorForKeyword:keyDirectObject] + stringValue]]; +} + +- (void)openWithBrowser:(NSString*)location +{ + + NSArray *urls = [NSArray arrayWithObject:[NSURL URLWithString:location]]; + + int options = NSWorkspaceLaunchAsync; + + [[NSWorkspace sharedWorkspace] openURLs: urls + withAppBundleIdentifier: [[Browsers sharedInstance] defaultBrowserIdentifier] + options: options + additionalEventParamDescriptor: nil + launchIdentifiers: nil]; +} + @end diff --git a/Objektiv/Constants.h b/Objektiv/Constants.h index f01592a..32725de 100644 --- a/Objektiv/Constants.h +++ b/Objektiv/Constants.h @@ -26,6 +26,8 @@ #define NotificationTitle NSLocalizedString(@"%@ selected", @"Title of the notification") #define NotificationText NSLocalizedString(@"You selected %@ as your default browser using %@.", @"Notification text") +#define kLocalFileUri @"file://locahost%@" + #define StatusBarIconSize 16 // Via https://gist.github.com/1057420 diff --git a/Objektiv/Objektiv-Info.plist b/Objektiv/Objektiv-Info.plist index 0ae1c2b..11e561f 100644 --- a/Objektiv/Objektiv-Info.plist +++ b/Objektiv/Objektiv-Info.plist @@ -4,6 +4,19 @@ CFBundleDevelopmentRegion en + CFBundleDocumentTypes + + + CFBundleTypeName + TEXT + LSHandlerRank + Alternate + LSItemContentTypes + + public.text + + + CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile @@ -17,7 +30,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.6.2 + 0.6.3 CFBundleSignature ???? CFBundleURLTypes