forked from psychs/tinygrowl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.m
More file actions
64 lines (49 loc) · 1.48 KB
/
Test.m
File metadata and controls
64 lines (49 loc) · 1.48 KB
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
#import "TinyGrowlClient.h"
#import <Foundation/Foundation.h>
#include <unistd.h>
@interface MyDelegate : NSObject {
TinyGrowlClient *growl;
NSTimer *timer;
}
@end
@implementation MyDelegate
- (void) applicationDidFinishLaunching:(NSNotification *)notification
{
NSLog(@"registering app");
[growl release];
growl = [TinyGrowlClient new];
[growl setDelegate: self];
[growl setAppName:@"TinyGrowlClientTest"];
[growl setAllNotifications: [NSArray arrayWithObjects: @"notifications", nil]];
[growl registerApplication];
timer = [NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(tryPost:)
userInfo:nil
repeats:YES];
}
- (void) tryPost:(id)obj
{
NSLog(@"posting notification..");
[growl notifyWithType:@"notifications" title:@"title" description:@"description" clickContext:@"someContext"];
}
- (void) tinyGrowlClient:(TinyGrowlClient*)growl didClick:(id)context {
NSLog(@"didClick");
}
- (void) tinyGrowlClient:(TinyGrowlClient*)growl didTimeOut:(id)context {
NSLog(@"didTimeOut");
}
- (void) tinyGrowlClient:(TinyGrowlClient*)growl didChangeRunning:(bool)running {
if (running) NSLog(@"growl started again");
else NSLog(@"growl quit");
}
@end;
int main() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
TinyGrowlClient *growl = [TinyGrowlClient new];
MyDelegate *d = [MyDelegate new];
[NSApp setDelegate:[d autorelease]];
[NSApp run];
[pool drain];
}