2 // GrowlSpeechDisplay.m
5 // Created by Ingmar Stein on 15.11.04.
6 // Copyright 2004-2006 The Growl Project. All rights reserved.
9 #import "GrowlSpeechDisplay.h"
10 #import "GrowlSpeechPrefs.h"
11 #import "GrowlSpeechDefines.h"
12 #import "GrowlPathUtilities.h"
13 #import "GrowlDefinesInternal.h"
14 #import "GrowlApplicationNotification.h"
15 #include "CFDictionaryAdditions.h"
17 @implementation GrowlSpeechDisplay
20 [preferencePane release];
24 - (NSPreferencePane *) preferencePane {
26 preferencePane = [[GrowlSpeechPrefs alloc] initWithBundle:[NSBundle bundleWithIdentifier:@"com.growl.Speech"]];
27 return preferencePane;
30 - (void) displayNotification:(GrowlApplicationNotification *)notification {
31 NSString *voice = nil;
32 READ_GROWL_PREF_VALUE(GrowlSpeechVoicePref, GrowlSpeechPrefDomain, NSString *, &voice);
34 CFMakeCollectable(voice);
37 voice = [NSSpeechSynthesizer defaultVoice];
40 NSString *desc = [notification notificationDescription];
42 NSSpeechSynthesizer *syn = [[NSSpeechSynthesizer alloc] initWithVoice:voice];
43 [syn startSpeakingString:desc];
45 NSDictionary *noteDict = [notification dictionaryRepresentation];
46 if (getBooleanForKey(noteDict, GROWL_SCREENSHOT_MODE)) {
47 NSString *path = [[[GrowlPathUtilities screenshotsDirectory] stringByAppendingPathComponent:[GrowlPathUtilities nextScreenshotName]] stringByAppendingPathExtension:@"aiff"];
48 NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
49 [syn startSpeakingString:desc toURL:url];
55 id clickContext = getObjectForKey(noteDict, GROWL_NOTIFICATION_CLICK_CONTEXT);
57 NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
58 getObjectForKey(noteDict, @"ClickHandlerEnabled"), @"ClickHandlerEnabled",
59 clickContext, GROWL_KEY_CLICKED_CONTEXT,
60 getObjectForKey(noteDict, GROWL_APP_PID), GROWL_APP_PID,
62 [[NSNotificationCenter defaultCenter] postNotificationName:GROWL_NOTIFICATION_TIMED_OUT
63 object:[notification applicationName]
69 - (BOOL)requiresPositioning {