|
boredzo@2402
|
1 |
//
|
|
boredzo@2402
|
2 |
// GrowlSpeechDisplay.m
|
|
boredzo@2402
|
3 |
// Display Plugins
|
|
boredzo@2402
|
4 |
//
|
|
boredzo@2402
|
5 |
// Created by Ingmar Stein on 15.11.04.
|
|
ingmarstein@3040
|
6 |
// Copyright 2004-2006 The Growl Project. All rights reserved.
|
|
boredzo@2402
|
7 |
//
|
|
boredzo@2402
|
8 |
|
|
boredzo@2402
|
9 |
#import "GrowlSpeechDisplay.h"
|
|
boredzo@2402
|
10 |
#import "GrowlSpeechPrefs.h"
|
|
boredzo@2402
|
11 |
#import "GrowlSpeechDefines.h"
|
|
ingmarstein@2470
|
12 |
#import "GrowlPathUtilities.h"
|
|
boredzo@2402
|
13 |
#import "GrowlDefinesInternal.h"
|
|
ingmarstein@2695
|
14 |
#import "GrowlApplicationNotification.h"
|
|
ingmarstein@2641
|
15 |
#include "CFDictionaryAdditions.h"
|
|
boredzo@2402
|
16 |
|
|
boredzo@2402
|
17 |
@implementation GrowlSpeechDisplay
|
|
boredzo@2756
|
18 |
|
|
boredzo@2402
|
19 |
- (void) dealloc {
|
|
ofri@2716
|
20 |
[preferencePane release];
|
|
boredzo@2402
|
21 |
[super dealloc];
|
|
boredzo@2402
|
22 |
}
|
|
boredzo@2402
|
23 |
|
|
boredzo@2402
|
24 |
- (NSPreferencePane *) preferencePane {
|
|
ofri@2716
|
25 |
if (!preferencePane)
|
|
ofri@2716
|
26 |
preferencePane = [[GrowlSpeechPrefs alloc] initWithBundle:[NSBundle bundleWithIdentifier:@"com.growl.Speech"]];
|
|
ofri@2716
|
27 |
return preferencePane;
|
|
boredzo@2402
|
28 |
}
|
|
boredzo@2402
|
29 |
|
|
ingmarstein@2695
|
30 |
- (void) displayNotification:(GrowlApplicationNotification *)notification {
|
|
boredzo@2402
|
31 |
NSString *voice = nil;
|
|
boredzo@2402
|
32 |
READ_GROWL_PREF_VALUE(GrowlSpeechVoicePref, GrowlSpeechPrefDomain, NSString *, &voice);
|
|
Rudy@4259
|
33 |
if (voice) {
|
|
Rudy@4259
|
34 |
CFMakeCollectable(voice);
|
|
boredzo@2402
|
35 |
[voice autorelease];
|
|
Rudy@4259
|
36 |
} else {
|
|
boredzo@2402
|
37 |
voice = [NSSpeechSynthesizer defaultVoice];
|
|
Rudy@4259
|
38 |
}
|
|
Rudy@4259
|
39 |
|
|
evands@2922
|
40 |
NSString *desc = [notification notificationDescription];
|
|
boredzo@2402
|
41 |
|
|
boredzo@2402
|
42 |
NSSpeechSynthesizer *syn = [[NSSpeechSynthesizer alloc] initWithVoice:voice];
|
|
boredzo@2402
|
43 |
[syn startSpeakingString:desc];
|
|
boredzo@2402
|
44 |
|
|
ingmarstein@2700
|
45 |
NSDictionary *noteDict = [notification dictionaryRepresentation];
|
|
ingmarstein@2641
|
46 |
if (getBooleanForKey(noteDict, GROWL_SCREENSHOT_MODE)) {
|
|
boredzo@2677
|
47 |
NSString *path = [[[GrowlPathUtilities screenshotsDirectory] stringByAppendingPathComponent:[GrowlPathUtilities nextScreenshotName]] stringByAppendingPathExtension:@"aiff"];
|
|
boredzo@2402
|
48 |
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
|
|
boredzo@2402
|
49 |
[syn startSpeakingString:desc toURL:url];
|
|
boredzo@2402
|
50 |
[url release];
|
|
boredzo@2402
|
51 |
}
|
|
boredzo@2402
|
52 |
|
|
boredzo@2402
|
53 |
[syn autorelease];
|
|
boredzo@2402
|
54 |
|
|
ingmarstein@2641
|
55 |
id clickContext = getObjectForKey(noteDict, GROWL_NOTIFICATION_CLICK_CONTEXT);
|
|
boredzo@2402
|
56 |
if (clickContext) {
|
|
boredzo@2402
|
57 |
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
ingmarstein@2641
|
58 |
getObjectForKey(noteDict, @"ClickHandlerEnabled"), @"ClickHandlerEnabled",
|
|
ingmarstein@2641
|
59 |
clickContext, GROWL_KEY_CLICKED_CONTEXT,
|
|
ingmarstein@2641
|
60 |
getObjectForKey(noteDict, GROWL_APP_PID), GROWL_APP_PID,
|
|
boredzo@2402
|
61 |
nil];
|
|
boredzo@2402
|
62 |
[[NSNotificationCenter defaultCenter] postNotificationName:GROWL_NOTIFICATION_TIMED_OUT
|
|
ingmarstein@2699
|
63 |
object:[notification applicationName]
|
|
boredzo@2402
|
64 |
userInfo:userInfo];
|
|
boredzo@2402
|
65 |
[userInfo release];
|
|
boredzo@2402
|
66 |
}
|
|
boredzo@2402
|
67 |
}
|
|
bgannin@3280
|
68 |
|
|
bgannin@3280
|
69 |
- (BOOL)requiresPositioning {
|
|
bgannin@3280
|
70 |
return NO;
|
|
bgannin@3280
|
71 |
}
|
|
bgannin@3280
|
72 |
|
|
boredzo@2402
|
73 |
@end
|