Mercurial > projects > dstep
annotate dstep/foundation/NSDistributedNotificationCenter.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 7ff919f595d5 |
children | b9de51448c6b |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSDistributedNotificationCenter; | |
8 | |
9 import dstep.foundation.NSDictionary; | |
10 import dstep.foundation.NSNotification; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
11 import dstep.foundation.NSObjCRuntime; |
14 | 12 import dstep.foundation.NSString; |
13 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
14 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
15 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
16 |
14 | 17 |
18 import bindings = dstep.foundation.NSDistributedNotificationCenter_bindings; | |
19 | |
20 alias NSUInteger NSNotificationSuspensionBehavior; | |
21 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
22 private NSString NSLocalNotificationCenterType_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
23 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
24 NSString NSLocalNotificationCenterType () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
25 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
26 if (NSLocalNotificationCenterType_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
27 return NSLocalNotificationCenterType_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
28 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
29 return NSLocalNotificationCenterType_ = new NSString(bindings.NSLocalNotificationCenterType); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
30 } |
14 | 31 |
32 enum | |
33 { | |
34 NSNotificationSuspensionBehaviorDrop = 1, | |
35 NSNotificationSuspensionBehaviorCoalesce = 2, | |
36 NSNotificationSuspensionBehaviorHold = 3, | |
37 NSNotificationSuspensionBehaviorDeliverImmediately = 4 | |
38 } | |
39 | |
40 enum | |
41 { | |
42 NSNotificationDeliverImmediately = (1 << 0), | |
43 NSNotificationPostToAllSessions = (1 << 1) | |
44 } | |
45 | |
46 class NSDistributedNotificationCenter : NSNotificationCenter | |
47 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
50 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
53 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
54 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
55 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
56 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
57 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
58 } |
14 | 59 |
60 static NSDistributedNotificationCenter notificationCenterForType (NSString notificationCenterType) | |
61 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
62 return invokeObjcSuperClass!(NSDistributedNotificationCenter, "notificationCenterForType:", NSString)(notificationCenterType); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 } |
14 | 64 |
65 static Object defaultCenter () | |
66 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
67 return invokeObjcSuperClass!(Object, "defaultCenter"); |
14 | 68 } |
69 | |
70 void addObserver (Object observer, SEL selector, NSString name, NSString object, uint suspensionBehavior) | |
71 { | |
72 return invokeObjcSelf!(void, "addObserver:selector:name:object:suspensionBehavior:", Object, SEL, NSString, NSString, uint)(observer, selector, name, object, suspensionBehavior); | |
73 } | |
74 | |
75 void postNotificationName (NSString name, NSString object, NSDictionary userInfo, bool deliverImmediately) | |
76 { | |
77 return invokeObjcSelf!(void, "postNotificationName:object:userInfo:deliverImmediately:", NSString, NSString, NSDictionary, bool)(name, object, userInfo, deliverImmediately); | |
78 } | |
79 | |
80 void postNotificationName (NSString name, NSString object, NSDictionary userInfo, NSUInteger options) | |
81 { | |
82 return invokeObjcSelf!(void, "postNotificationName:object:userInfo:options:", NSString, NSString, NSDictionary, NSUInteger)(name, object, userInfo, options); | |
83 } | |
84 | |
85 void setSuspended (bool suspended) | |
86 { | |
87 return invokeObjcSelf!(void, "setSuspended:", bool)(suspended); | |
88 } | |
89 | |
90 bool suspended () | |
91 { | |
92 return invokeObjcSelf!(bool, "suspended"); | |
93 } | |
94 | |
95 void addObserver (Object observer, SEL aSelector, NSString aName, NSString anObject) | |
96 { | |
97 return invokeObjcSelf!(void, "addObserver:selector:name:object:", Object, SEL, NSString, NSString)(observer, aSelector, aName, anObject); | |
98 } | |
99 | |
100 void postNotificationName (NSString aName, NSString anObject) | |
101 { | |
102 return invokeObjcSelf!(void, "postNotificationName:object:", NSString, NSString)(aName, anObject); | |
103 } | |
104 | |
105 void postNotificationName (NSString aName, NSString anObject, NSDictionary aUserInfo) | |
106 { | |
107 return invokeObjcSelf!(void, "postNotificationName:object:userInfo:", NSString, NSString, NSDictionary)(aName, anObject, aUserInfo); | |
108 } | |
109 | |
110 void removeObserver (Object observer, NSString aName, NSString anObject) | |
111 { | |
112 return invokeObjcSelf!(void, "removeObserver:name:object:", Object, NSString, NSString)(observer, aName, anObject); | |
113 } | |
114 } | |
115 |