From 4f9d846b9c8dcc597c0cc1881c0a20cd8631e975 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Tue, 12 Oct 1999 14:33:55 +0000 Subject: [PATCH] Added priovate notifcation center class git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4991 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++ Source/NSWorkspace.m | 77 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f616629a5..6431154ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 12 1999 Richard Frith-Macdonald + + * Source/NSWorkspace.m: Added private notification center class to + handle notifications to be passed between applications. + Sat Oct 9 1999 Nicola Pero * Source/NSButton.m ([-keyDown:]): Perform a click if diff --git a/Source/NSWorkspace.m b/Source/NSWorkspace.m index 8a7a97797..0af2cfe39 100644 --- a/Source/NSWorkspace.m +++ b/Source/NSWorkspace.m @@ -44,11 +44,86 @@ #include #include #include +#include #include #define stringify_it(X) #X #define mkpath(X) stringify_it(X) "/Tools" +static NSString *GSWorkspaceNotification = @"GSWorkspaceNotification"; + +@interface _GSWorkspaceCenter: NSNotificationCenter +{ + NSDistributedNotificationCenter *remote; +} +- (void) _handleRemoteNotification: (NSNotification*)aNotification; +@end + +@implementation _GSWorkspaceCenter + +- (void) dealloc +{ + [remote removeObserver: self name: nil object: GSWorkspaceNotification]; + RELEASE(remote); + [super dealloc]; +} + +- (id) init +{ + self = [super init]; + if (self != nil) + { + remote = RETAIN([NSDistributedNotificationCenter defaultCenter]); + [remote addObserver: self + selector: @selector(_handleRemoteNotification:) + name: nil + object: GSWorkspaceNotification]; + } + return self; +} + +/* + * Post notification both locally and remotely. + */ +- (void) postNotification: (NSNotification*)aNotification +{ + NSNotification *rem; + + rem = [NSNotification notificationWithName: [aNotification name] + object: GSWorkspaceNotification + userInfo: [aNotification userInfo]]; + [remote postNotification: rem]; + [super postNotification: aNotification]; +} + +- (void) postNotificationName: (NSString*)name + object: (id)object +{ + [self postNotification: [NSNotification notificationWithName: name + object: object]]; +} + +- (void) postNotificationName: (NSString*)name + object: (id)object + userInfo: (NSDictionary*)info +{ + [self postNotification: [NSNotification notificationWithName: name + object: object + userInfo: info]]; +} + +/* + * Forward a notification from a remote application to observers in this + * application. + */ +- (void) _handleRemoteNotification: (NSNotification*)aNotification +{ + [super postNotification: aNotification]; +} + +@end + + @implementation NSWorkspace @@ -92,7 +167,7 @@ static NSString *_rootPath = @"/"; beenHere = YES; - workspaceCenter = [NSNotificationCenter new]; + workspaceCenter = [_GSWorkspaceCenter new]; iconMap = [NSMutableDictionary new]; /*