Browse files

Merge pull request #9 from henrikbrixandersen/master

Add support for NSUserNotification.subtitle
  • Loading branch information...
2 parents dc92907 + 282f4ab commit bc33b6d97864abc60122b7b37e7f47e51a846f14 @alloy alloy committed Aug 1, 2012
Showing with 14 additions and 0 deletions.
  1. +8 −0 README.markdown
  2. +6 −0 Terminal Notifier/AppDelegate.m
View
8 README.markdown
@@ -67,6 +67,14 @@ The title of the notification. This defaults to ‘Terminal’.
-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+
+`-subtitle VALUE`
+
+The subtitle of the notification.
+
+-------------------------------------------------------------------------------
+
`-group ID`
Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
View
6 Terminal Notifier/AppDelegate.m
@@ -30,6 +30,7 @@ - (void)printHelpBanner;
" Optional:\n" \
"\n" \
" -title VALUE The notification title. Defaults to ‘Terminal’.\n" \
+ " -subtitle VALUE The notification subtitle.\n" \
" -group ID A string which identifies the group the notifications belong to.\n" \
" Old notifications with the same ID will be removed.\n" \
" -activate ID The bundle identifier of the application to activate when the user clicks the notification.\n" \
@@ -50,6 +51,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
} else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSString *subtitle = defaults[@"subtitle"];
NSString *message = defaults[@"message"];
NSString *remove = defaults[@"remove"];
if (message == nil && remove == nil) {
@@ -70,13 +72,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
if (defaults[@"open"]) options[@"open"] = defaults[@"open"];
[self deliverNotificationWithTitle:defaults[@"title"] ?: @"Terminal"
+ subtitle:subtitle
message:message
options:options];
}
}
}
- (void)deliverNotificationWithTitle:(NSString *)title
+ subtitle:(NSString *)subtitle
message:(NSString *)message
options:(NSDictionary *)options;
{
@@ -85,6 +89,7 @@ - (void)deliverNotificationWithTitle:(NSString *)title
NSUserNotification *userNotification = [NSUserNotification new];
userNotification.title = title;
+ userNotification.subtitle = subtitle;
userNotification.informativeText = message;
userNotification.userInfo = options;
@@ -118,6 +123,7 @@ - (void)userActivatedNotification:(NSUserNotification *)userNotification;
NSLog(@"User activated notification:");
NSLog(@" group ID: %@", groupID);
NSLog(@" title: %@", userNotification.title);
+ NSLog(@" subtitle: %@", userNotification.subtitle);
NSLog(@" message: %@", userNotification.informativeText);
NSLog(@"bundle ID: %@", bundleID);
NSLog(@" command: %@", command);

0 comments on commit bc33b6d

Please sign in to comment.