implemented Notification Center

This commit is contained in:
Jeena Paradies 2012-11-10 01:17:52 +01:00
parent d8683ed9d5
commit 9bcba0beae
4 changed files with 48 additions and 4 deletions

View file

@ -14,7 +14,7 @@
#import "AccessToken.h"
@interface Controller : NSObject {
@interface Controller : NSObject <NSUserNotificationCenterDelegate> {
IBOutlet WebView *timelineView;
IBOutlet NSWindow *timelineViewWindow;
IBOutlet WebView *mentionsView;
@ -52,6 +52,8 @@
- (NSString *)pluginURL;
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void)unreadMentions:(NSInteger)count;
- (void)notificateUserAboutMention:(NSString *)text fromName:(NSString *)name withPostId:(NSString *)postId andEntity:(NSString *)entity;
- (void)openURL:(NSString *)url;
- (void)setString:(NSString *)string forKey:(NSString *)aKey;

View file

@ -23,6 +23,7 @@
- (void)awakeFromNib {
[self initHotKeys];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
@ -257,6 +258,24 @@
}
}
- (void)notificateUserAboutMention:(NSString *)text fromName:(NSString *)name withPostId:(NSString *)postId andEntity:(NSString *)entity {
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = @"Tent Mention";
notification.subtitle = [NSString stringWithFormat:@"Mentioned by %@", name];
notification.informativeText = text;
notification.hasActionButton = YES;
notification.actionButtonTitle = @"Show";
notification.soundName = NSUserNotificationDefaultSoundName;
notification.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
entity, @"entity",
postId, @"postId", nil];
NSLog(@"%@", notification);
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
- (void)openURL:(NSString *)url {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
@ -326,6 +345,13 @@
conversationViewWindow.title = @"Test";
}
// Notifications
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
[self showConversationForPostId:[notification.userInfo objectForKey:@"postId"] andEntity:[notification.userInfo objectForKey:@"entity"]];
}
/* CARBON */
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData)