forked from subtleGradient/callback-mac
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Growl.h | ||
// callback-mac | ||
// | ||
// Created by Alex MacCaw on 06/01/2012. | ||
// Copyright (c) 2012 Nitobi Software Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <Growl/Growl.h> | ||
|
||
#define APP_GROWL_NOTIFICATION @"Growl Notification" | ||
|
||
@interface GrowlNotifier : NSObject <GrowlApplicationBridgeDelegate> { | ||
|
||
} | ||
|
||
- (void) notify:(NSDictionary*)message; | ||
- (NSString *)applicationNameForGrowl; | ||
- (NSImage *)applicationIconForGrowl; | ||
- (NSDictionary *)registrationDictionaryForGrowl; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Growl.m | ||
// callback-mac | ||
// | ||
// Created by Alex MacCaw on 06/01/2012. | ||
// Copyright (c) 2012 Nitobi Software Inc. All rights reserved. | ||
// | ||
|
||
#import "GrowlNotifier.h" | ||
|
||
@implementation GrowlNotifier | ||
|
||
- (id) init { | ||
if (self = [super init]) { | ||
NSBundle *myBundle = [NSBundle bundleForClass:[self class]]; | ||
NSString *growlPath = [[myBundle privateFrameworksPath] | ||
stringByAppendingPathComponent:@"Growl.framework"]; | ||
NSBundle *growlBundle = [NSBundle bundleWithPath:growlPath]; | ||
if (growlBundle && [growlBundle load]) { | ||
// Register ourselves as a Growl delegate | ||
[GrowlApplicationBridge setGrowlDelegate:self]; | ||
} else { | ||
NSLog(@"Could not load Growl.framework"); | ||
} | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void) notify:(NSDictionary *)message { | ||
[GrowlApplicationBridge notifyWithTitle:[message valueForKey:@"title"] | ||
description:[message valueForKey:@"content"] | ||
notificationName:APP_GROWL_NOTIFICATION | ||
iconData:nil | ||
priority:0 | ||
isSticky:false | ||
clickContext:nil]; | ||
} | ||
|
||
- (NSString *)applicationNameForGrowl { | ||
return @"Callback"; | ||
} | ||
|
||
- (NSImage *)applicationIconForGrowl { | ||
return [NSImage imageNamed:@"NSApplicationIcon"]; | ||
} | ||
|
||
- (NSDictionary *)registrationDictionaryForGrowl { | ||
NSArray *allowedNotifications = [NSArray arrayWithObject:APP_GROWL_NOTIFICATION]; | ||
NSArray *defaultNotifications = [NSArray arrayWithObject:APP_GROWL_NOTIFICATION]; | ||
|
||
NSDictionary *ticket = [NSDictionary dictionaryWithObjectsAndKeys: | ||
allowedNotifications, GROWL_NOTIFICATIONS_ALL, | ||
defaultNotifications, GROWL_NOTIFICATIONS_DEFAULT, | ||
nil]; | ||
|
||
return ticket; | ||
} | ||
|
||
#pragma mark WebScripting Protocol | ||
|
||
/* checks whether a selector is acceptable to be called from JavaScript */ | ||
+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector | ||
{ | ||
if (selector == @selector(notify:)) | ||
return NO; | ||
|
||
return YES; | ||
} | ||
|
||
/* helper function so we don't have to have underscores and stuff in js to refer to the right method */ | ||
+ (NSString*) webScriptNameForSelector:(SEL)selector | ||
{ | ||
id result = nil; | ||
|
||
if (selector == @selector(notify:)) { | ||
result = @"notify"; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
// right now exclude all properties (eg keys) | ||
+ (BOOL) isKeyExcludedFromWebScript:(const char*)name | ||
{ | ||
return YES; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Versions/Current/Growl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Versions/Current/Headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Versions/Current/Resources |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <Growl/GrowlDefines.h> | ||
|
||
#ifdef __OBJC__ | ||
# include <Growl/GrowlApplicationBridge.h> | ||
#endif |
Oops, something went wrong.