Skip to content

Commit

Permalink
add Notification Center as a handler for user notifications
Browse files Browse the repository at this point in the history
close #867
  • Loading branch information
skurfer committed Sep 21, 2012
1 parent d50ba41 commit 1d72069
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Quicksilver/Code-App/QSHelpersPrefPane.m
Expand Up @@ -61,6 +61,10 @@ - (NSMenu *)menuForTable:(NSString *)table includeDefault:(BOOL)includeDefault {
NSString *path, *title;
NSMenuItem *item = nil;
for(NSString *key in mediators) {
// drop10.7: ugly hack - when Notification Center becomes the default, remove this check
if ([key isEqualToString:@"com.apple.NotificationCenter"] && ![NSApplication isMountainLion]) {
continue;
}
path = [workspace absolutePathForAppBundleWithIdentifier:key];
NSString *class = [mediators objectForKey:key];
NSBundle *bundle = [QSReg bundleForClassName:class];
Expand Down
12 changes: 12 additions & 0 deletions Quicksilver/Code-App/QSNotificationCenterNotifier.h
@@ -0,0 +1,12 @@
//
// QSNotificationCenterNotifier.h
// Quicksilver
//
// Created by Rob McBroom on 2012/09/20.
//
// Display notifications using Notification Center introduced with 10.8
//

@interface QSNotificationCenterNotifier : NSObject <QSNotifier>

@end
28 changes: 28 additions & 0 deletions Quicksilver/Code-App/QSNotificationCenterNotifier.m
@@ -0,0 +1,28 @@
//
// QSNotificationCenterNotifier.m
// Quicksilver
//
// Created by Rob McBroom on 2012/09/20.
//
//

#import "QSNotificationCenterNotifier.h"

@implementation QSNotificationCenterNotifier

- (void)displayNotificationWithAttributes:(NSDictionary *)attributes
{
NSString *title = [attributes objectForKey:QSNotifierTitle];
NSString *subtitle = [attributes objectForKey:QSNotifierText];
NSString *details = [[attributes objectForKey:QSNotifierDetails] string];

NSUserNotification *message = [[NSUserNotification alloc] init];
[message setTitle:title];
[message setSubtitle:subtitle];
[message setInformativeText:details];

[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:message];
[message release];
}

@end
1 change: 1 addition & 0 deletions Quicksilver/Localized/en.lproj/Localizable.strings
Expand Up @@ -13,6 +13,7 @@
"QSApplicationPrefPane" = "Application";
"QSCatalogController" = "Catalog";
"QSSilverNotifier" = "Quicksilver (Built-in)";
"QSNotificationCenterNotifier" = "Notification Center";
"QSDefaultStringRanker" = "Default (Built-in)";

// QSController.m Alerts
Expand Down
2 changes: 2 additions & 0 deletions Quicksilver/PropertyLists/QSRegistration.plist
Expand Up @@ -152,6 +152,8 @@
<string>QSConsoleNotifier</string>
<key>com.blacktree.Quicksilver</key>
<string>QSSilverNotifier</string>
<key>com.apple.NotificationCenter</key>
<string>QSNotificationCenterNotifier</string>
</dict>
<key>QSObjectHandlers</key>
<dict>
Expand Down
8 changes: 8 additions & 0 deletions Quicksilver/Quicksilver.xcodeproj/project.pbxproj
Expand Up @@ -375,6 +375,8 @@
CDE8ADBC15824E3E0099CC83 /* NDKeyboardLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE8ADBA15824E3E0099CC83 /* NDKeyboardLayout.m */; };
D413172F15DEE5D90021479B /* LaunchAtLoginController.h in Headers */ = {isa = PBXBuildFile; fileRef = D413172C15DEE5D90021479B /* LaunchAtLoginController.h */; };
D413173015DEE5D90021479B /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = D413172D15DEE5D90021479B /* LaunchAtLoginController.m */; };
D46A0E1D160B934300DE11D5 /* QSNotificationCenterNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = D46A0E1B160B934200DE11D5 /* QSNotificationCenterNotifier.h */; };
D46A0E1E160B934300DE11D5 /* QSNotificationCenterNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = D46A0E1C160B934300DE11D5 /* QSNotificationCenterNotifier.m */; };
D493990D1350078E00B908C6 /* QSDownloads.h in Headers */ = {isa = PBXBuildFile; fileRef = D49399091350078E00B908C6 /* QSDownloads.h */; };
D493990E1350078E00B908C6 /* QSDownloads.m in Sources */ = {isa = PBXBuildFile; fileRef = D493990A1350078E00B908C6 /* QSDownloads.m */; };
D4A43887137CCF0300F15F7F /* QSURLExtractor.py in Resources */ = {isa = PBXBuildFile; fileRef = D4A4383B137CCCF500F15F7F /* QSURLExtractor.py */; };
Expand Down Expand Up @@ -1408,6 +1410,8 @@
CDE8ADBA15824E3E0099CC83 /* NDKeyboardLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NDKeyboardLayout.m; sourceTree = "<group>"; };
D413172C15DEE5D90021479B /* LaunchAtLoginController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LaunchAtLoginController.h; sourceTree = "<group>"; };
D413172D15DEE5D90021479B /* LaunchAtLoginController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LaunchAtLoginController.m; sourceTree = "<group>"; };
D46A0E1B160B934200DE11D5 /* QSNotificationCenterNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSNotificationCenterNotifier.h; sourceTree = "<group>"; };
D46A0E1C160B934300DE11D5 /* QSNotificationCenterNotifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSNotificationCenterNotifier.m; sourceTree = "<group>"; };
D49399091350078E00B908C6 /* QSDownloads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSDownloads.h; sourceTree = "<group>"; };
D493990A1350078E00B908C6 /* QSDownloads.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSDownloads.m; sourceTree = "<group>"; };
D4A4383B137CCCF500F15F7F /* QSURLExtractor.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = QSURLExtractor.py; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2456,6 +2460,8 @@
7F60F12707FA134600922645 /* QSMainPreferencePanes.m */,
92E946170D04CCEF0013377F /* QSModifierKeyEvents.h */,
92E946180D04CCEF0013377F /* QSModifierKeyEvents.m */,
D46A0E1B160B934200DE11D5 /* QSNotificationCenterNotifier.h */,
D46A0E1C160B934300DE11D5 /* QSNotificationCenterNotifier.m */,
E18001F007B2BBB900010DB0 /* QSPlugInsPrefPane.h */,
E18001F107B2BBB900010DB0 /* QSPlugInsPrefPane.m */,
7FF63FF207CC0DF500A5EE4A /* QSPreferencesController.h */,
Expand Down Expand Up @@ -2941,6 +2947,7 @@
92E946190D04CCEF0013377F /* QSModifierKeyEvents.h in Headers */,
4D00307613116304009040B7 /* Quicksilver.h in Headers */,
CDDB44E71518C78F00800B66 /* QSCrashReporterWindowController.h in Headers */,
D46A0E1D160B934300DE11D5 /* QSNotificationCenterNotifier.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -4055,6 +4062,7 @@
7F4E4B390A3CD83D0070336A /* QSMainMenuPrefPane.m in Sources */,
92E9461A0D04CCEF0013377F /* QSModifierKeyEvents.m in Sources */,
CDDB44E81518C78F00800B66 /* QSCrashReporterWindowController.m in Sources */,
D46A0E1E160B934300DE11D5 /* QSNotificationCenterNotifier.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 1d72069

Please sign in to comment.