mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 13:07:02 +00:00
Fixed: delegate of the notificationCenter is in AppController
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
@class XcodeCapp;
|
||||
|
||||
@interface AppController : NSObject <NSApplicationDelegate, NSMenuDelegate, NSUserNotificationCenterDelegate>
|
||||
@interface AppController : NSObject <NSApplicationDelegate, NSMenuDelegate>
|
||||
|
||||
@property (strong) IBOutlet NSMenu *statusMenu;
|
||||
@property (unsafe_unretained) IBOutlet NSMenuItem *menuItemHistory;
|
||||
|
||||
@@ -112,9 +112,6 @@ AppController *SharedAppControllerInstance = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
|
||||
center.delegate = self;
|
||||
|
||||
// If we were opened from the command line, self.pathToOpenAtLaunch will be set.
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
@@ -530,12 +527,4 @@ AppController *SharedAppControllerInstance = nil;
|
||||
self.menuItemHistory.enabled = [projectHistory count] > 0;
|
||||
}
|
||||
|
||||
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
|
||||
{
|
||||
if ([[self.xcc errorList] count])
|
||||
[self.xcc openErrorsPanel:self];
|
||||
|
||||
[center removeDeliveredNotification:notification];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1713,53 +1713,8 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
return index != NSNotFound;
|
||||
}
|
||||
|
||||
#pragma mark - User notifications
|
||||
|
||||
- (NSString *)applicationNameForGrowl
|
||||
{
|
||||
return @"XcodeCapp";
|
||||
}
|
||||
|
||||
- (void)notifyUserWithTitle:(NSString *)aTitle message:(NSString *)aMessage
|
||||
{
|
||||
if ([NSUserNotificationCenter class])
|
||||
{
|
||||
NSUserNotification *note = [NSUserNotification new];
|
||||
note.title = aTitle;
|
||||
note.informativeText = aMessage;
|
||||
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:note];
|
||||
}
|
||||
else
|
||||
{
|
||||
[GrowlApplicationBridge notifyWithTitle:aTitle
|
||||
description:aMessage
|
||||
notificationName:GROWL_NOTIFICATIONS_DEFAULT
|
||||
iconData:nil
|
||||
priority:0
|
||||
isSticky:NO
|
||||
clickContext:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)wantUserNotificationWithInfo:(NSDictionary *)info
|
||||
{
|
||||
[self performSelectorOnMainThread:@selector(notifyUserWithInfo:) withObject:info waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void)notifyUserWithInfo:(NSDictionary *)info
|
||||
{
|
||||
if ([info[@"projectId"] intValue] != self.projectId)
|
||||
return;
|
||||
|
||||
[self notifyUserWithTitle:info[@"title"] message:info[@"message"]];
|
||||
}
|
||||
|
||||
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
|
||||
{
|
||||
// Notification Center may decide not to show a notification. We always want them to show.
|
||||
return YES;
|
||||
}
|
||||
#pragma mark - capp_lint
|
||||
|
||||
- (IBAction)checkProjectWithCappLint:(id)aSender
|
||||
{
|
||||
@@ -1830,6 +1785,63 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - User notifications
|
||||
|
||||
- (NSString *)applicationNameForGrowl
|
||||
{
|
||||
return @"XcodeCapp";
|
||||
}
|
||||
|
||||
- (void)notifyUserWithTitle:(NSString *)aTitle message:(NSString *)aMessage
|
||||
{
|
||||
if ([NSUserNotificationCenter class])
|
||||
{
|
||||
NSUserNotification *note = [NSUserNotification new];
|
||||
note.title = aTitle;
|
||||
note.informativeText = aMessage;
|
||||
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:note];
|
||||
}
|
||||
else
|
||||
{
|
||||
[GrowlApplicationBridge notifyWithTitle:aTitle
|
||||
description:aMessage
|
||||
notificationName:GROWL_NOTIFICATIONS_DEFAULT
|
||||
iconData:nil
|
||||
priority:0
|
||||
isSticky:NO
|
||||
clickContext:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)wantUserNotificationWithInfo:(NSDictionary *)info
|
||||
{
|
||||
[self performSelectorOnMainThread:@selector(notifyUserWithInfo:) withObject:info waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void)notifyUserWithInfo:(NSDictionary *)info
|
||||
{
|
||||
if ([info[@"projectId"] intValue] != self.projectId)
|
||||
return;
|
||||
|
||||
[self notifyUserWithTitle:info[@"title"] message:info[@"message"]];
|
||||
}
|
||||
|
||||
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
|
||||
{
|
||||
// Notification Center may decide not to show a notification. We always want them to show.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
|
||||
{
|
||||
if ([self.errorList count])
|
||||
[self openErrorsPanel:self];
|
||||
|
||||
[center removeDeliveredNotification:notification];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user