From b52b96da8d4ff46d59d12734441db09de6744adf Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Wed, 21 May 2003 22:08:17 +0000 Subject: [PATCH] Basic implemention of [activeApplication] and [launchedApplications]. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16765 72102866-910b-0410-8b05-ffd578937521 --- Source/NSWorkspace.m | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Source/NSWorkspace.m b/Source/NSWorkspace.m index 7c8b3f740..13cbb4f7b 100644 --- a/Source/NSWorkspace.m +++ b/Source/NSWorkspace.m @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -1119,6 +1120,34 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath return YES; } +- (NSDictionary*) activeApplication +{ + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; + + return [NSDictionary dictionaryWithObjectsAndKeys: + [processInfo processName], @"NSApplicationName", + [[NSBundle mainBundle] bundlePath], @"NSApplicationPath", + [NSNumber numberWithInt: [processInfo processIdentifier]], + @"NSApplicationProcessIdentifier", + nil]; +} + +- (NSArray*) launchedApplications +{ + NSDictionary *dict; + NSString *app; + NSMutableArray *apps = [NSMutableArray array]; + NSEnumerator *enumerator = [_launched keyEnumerator]; + + while ((app = [enumerator nextObject]) != nil) + { + dict = [NSDictionary dictionaryWithObject: app forKey: @"NSApplicationName"]; + [apps addObject: dict]; + } + + return apps; +} + /* * Unmounting a Device */ @@ -1911,9 +1940,11 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath * App being launched, send * NSWorkspaceWillLaunchApplicationNotification */ - userinfo = [NSDictionary dictionaryWithObject: - [[appName lastPathComponent] stringByDeletingPathExtension] - forKey: @"NSApplicationName"]; + userinfo = [NSDictionary dictionaryWithObjectsAndKeys: + [[appName lastPathComponent] stringByDeletingPathExtension], + @"NSApplicationName", + appName, @"NSApplicationPath", + nil]; [_workspaceCenter postNotificationName: NSWorkspaceWillLaunchApplicationNotification object: self