-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQSGrowlNotifier.m
75 lines (63 loc) · 2.11 KB
/
QSGrowlNotifier.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// QSGrowlNotifier.m
// QSGrowlNotifier
//
// Created by Nicholas Jitkoff on 7/12/04.
// Copyright __MyCompanyName__ 2004. All rights reserved.
//
#import <QSCore/QSNotifyMediator.h>
#import "QSGrowlNotifier.h"
#import <Growl/GrowlApplicationBridge.h>
#define QSGrowlNotification @"Quicksilver Notification"
#define QSiTunesNotification @"iTunes Notification"
Class GAB;
@implementation QSGrowlNotifier
+ (void) initialize {
[super initialize];
NSBundle *plugin = [NSBundle bundleForClass:self];
NSString *path = [[plugin privateFrameworksPath] stringByAppendingPathComponent:@"Growl.framework"];
NSBundle *bundle = [NSBundle bundleWithPath:path];
if (path && [bundle load]) {
GAB = NSClassFromString(@"GrowlApplicationBridge");
} else {
GAB = nil;
}
}
- (id) init {
if (self = [super init]) {
[GAB setGrowlDelegate:self];
}
return self;
}
- (NSDictionary *) registrationDictionaryForGrowl {
NSArray *notifications = [NSArray arrayWithObjects:QSGrowlNotification, QSiTunesNotification, nil];
return [NSDictionary dictionaryWithObjectsAndKeys:
notifications, GROWL_NOTIFICATIONS_ALL,
notifications, GROWL_NOTIFICATIONS_DEFAULT,
nil];
}
- (NSString *) applicationNameForGrowl {
return @"Quicksilver";
}
- (void) displayNotificationWithAttributes:(NSDictionary *)attributes {
NSString *type = QSGrowlNotification;
if ([[attributes objectForKey:QSNotifierType] isEqualToString:@"QSiTunesTrackChangeNotification"]) {
type = QSiTunesNotification;
}
NSString *text = [attributes objectForKey:QSNotifierText];
if (!text)
text = @"";
NSAttributedString *details = [attributes objectForKey:QSNotifierDetails];
if (details) {
text = [text stringByAppendingFormat:@"\n%@", [details string]];
}
[GAB notifyWithTitle:[attributes objectForKey:QSNotifierTitle]
description:text
notificationName:type
iconData:[[attributes objectForKey:QSNotifierIcon] TIFFRepresentation]
priority:0
isSticky:NO
clickContext:nil
identifier:(type == QSiTunesNotification ? QSiTunesNotification : nil)];
}
@end