Simple example project?
Posted: Wed Oct 10, 2007 2:17 am
Is there a simple example out there on how to use growl? I'm not getting anywhere with the current docs.
Code: Select all
#import <Cocoa/Cocoa.h>
#import <Growl-WithInstaller/Growl.h>
@interface GrowlController: NSObject<GrowlApplicationBridgeDelegate>
{
}
@end
Code: Select all
#import "GrowlController.h"
#define SampleNotificationName @"The HelloGrowl Sample Notification"
#define GROWL_NOTIFICATION_DEFAULT @"NotificationDefault;
@implementation GrowlController
- (void) awakeFromNib {
[GrowlApplicationBridge setGrowlDelegate:self];
//[GrowlApplicationBridge reregisterGrowlNotifications];
//NSDictionary *prefsDict = [[NSDictionary alloc] initWithContentsOfFile:GROWL_PREFS_PATH];
//[growlLoggingButton setState:[[prefsDict valueForKey:@"GrowlLoggingEnabled"] intValue]];
}
- (NSString *)applicationNameForGrowl {
return @"BeepHammer";
}
- (NSDictionary *) registrationDictionaryForGrowl
{
NSArray *notifications = [NSArray arrayWithObjects:
SampleNotificationName,
nil];
NSDictionary *regDict = [NSDictionary dictionaryWithObjectsAndKeys:
@"Weather", GROWL_APP_NAME,
notifications, GROWL_NOTIFICATIONS_ALL,
notifications, GROWL_NOTIFICATIONS_DEFAULT,
nil];
return regDict;
}
- (void) sendMessage {
[GrowlApplicationBridge notifyWithTitle:"Title"
description:"Description"
notificationName:SampleNotificationName];
}
@end
Code: Select all
#import <Cocoa/Cocoa.h>
#import "GrowlController.h"
int main(int argc, char *argv[])
{
GrowlController *cont = [[GrowlController alloc] init];
[cont sendMessage];
return NSApplicationMain(argc, (const char **) argv);
}