1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSWorkspace.m
|
|
|
|
|
|
|
|
Description...
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
1998-11-23 21:39:58 +00:00
|
|
|
Implementation: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: 1998
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSWorkspace.h>
|
1999-01-07 15:52:42 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
#include <AppKit/NSPanel.h>
|
|
|
|
#include <AppKit/GSServicesManager.h>
|
1998-11-23 21:39:58 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
|
|
|
#include <Foundation/NSLock.h>
|
1999-01-07 15:52:42 +00:00
|
|
|
#include <Foundation/NSPathUtilities.h>
|
1998-11-23 21:39:58 +00:00
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
#include <Foundation/NSTask.h>
|
|
|
|
#include <Foundation/NSException.h>
|
1998-11-25 19:51:25 +00:00
|
|
|
#include <Foundation/NSProcessInfo.h>
|
1999-04-08 20:42:46 +00:00
|
|
|
#include <Foundation/NSFileManager.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-23 21:39:58 +00:00
|
|
|
#define stringify_it(X) #X
|
1999-04-08 20:42:46 +00:00
|
|
|
#define mkpath(X) stringify_it(X) "/Tools"
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
static NSDictionary *applications = nil;
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
@interface NSWorkspace (GNUstep)
|
|
|
|
- (NSTask*) launchProgram: (NSString *)prog
|
|
|
|
atPath: (NSString *)path;
|
|
|
|
@end
|
|
|
|
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
@implementation NSWorkspace
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
static NSWorkspace *sharedWorkspace = nil;
|
1998-11-23 21:39:58 +00:00
|
|
|
static NSNotificationCenter *workspaceCenter = nil;
|
1999-04-08 20:42:46 +00:00
|
|
|
static BOOL userDefaultsChanged = NO;
|
1998-11-23 21:39:58 +00:00
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
static NSString *appListName = @".GNUstepAppList";
|
|
|
|
static NSString *appListPath = nil;
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
static NSString* gnustep_target_dir =
|
|
|
|
#ifdef GNUSTEP_TARGET_DIR
|
|
|
|
@GNUSTEP_TARGET_DIR;
|
|
|
|
#else
|
|
|
|
nil;
|
|
|
|
#endif
|
|
|
|
static NSString* gnustep_target_cpu =
|
|
|
|
#ifdef GNUSTEP_TARGET_CPU
|
|
|
|
@GNUSTEP_TARGET_CPU;
|
|
|
|
#else
|
|
|
|
nil;
|
|
|
|
#endif
|
|
|
|
static NSString* gnustep_target_os =
|
|
|
|
#ifdef GNUSTEP_TARGET_OS
|
|
|
|
@GNUSTEP_TARGET_OS;
|
|
|
|
#else
|
|
|
|
nil;
|
|
|
|
#endif
|
|
|
|
static NSString* library_combo =
|
|
|
|
#ifdef LIBRARY_COMBO
|
|
|
|
@LIBRARY_COMBO;
|
|
|
|
#else
|
|
|
|
nil;
|
|
|
|
#endif
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
if (self == [NSWorkspace class])
|
|
|
|
{
|
1998-11-23 21:39:58 +00:00
|
|
|
static BOOL beenHere;
|
|
|
|
NSDictionary *env;
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Initial version
|
1999-04-08 20:42:46 +00:00
|
|
|
[self setVersion: 1];
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
[gnustep_global_lock lock];
|
|
|
|
if (beenHere == YES)
|
|
|
|
{
|
|
|
|
[gnustep_global_lock unlock];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
beenHere = YES;
|
|
|
|
|
|
|
|
workspaceCenter = [NSNotificationCenter new];
|
|
|
|
env = [[NSProcessInfo processInfo] environment];
|
|
|
|
if (env)
|
|
|
|
{
|
|
|
|
NSString *str;
|
1999-01-07 15:52:42 +00:00
|
|
|
NSData *data;
|
|
|
|
NSDictionary *newApps;
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
str = [env objectForKey: @"GNUSTEP_USER_ROOT"];
|
|
|
|
if (str == nil)
|
1998-12-06 19:51:44 +00:00
|
|
|
str = [NSString stringWithFormat: @"%@/GNUstep",
|
1998-12-01 20:54:23 +00:00
|
|
|
NSHomeDirectory()];
|
1998-12-06 19:51:44 +00:00
|
|
|
str = [str stringByAppendingPathComponent: @"Services"];
|
1998-12-01 20:54:23 +00:00
|
|
|
str = [str stringByAppendingPathComponent: appListName];
|
|
|
|
appListPath = [str retain];
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_DIR"]) != nil)
|
|
|
|
gnustep_target_dir = [str retain];
|
|
|
|
else if ((str = [env objectForKey: @"GNUSTEP_HOST_DIR"]) != nil)
|
|
|
|
gnustep_target_dir = [str retain];
|
|
|
|
|
|
|
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_CPU"]) != nil)
|
|
|
|
gnustep_target_cpu = [str retain];
|
|
|
|
else if ((str = [env objectForKey: @"GNUSTEP_HOST_CPU"]) != nil)
|
|
|
|
gnustep_target_cpu = [str retain];
|
|
|
|
|
|
|
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_OS"]) != nil)
|
|
|
|
gnustep_target_os = [str retain];
|
|
|
|
else if ((str = [env objectForKey: @"GNUSTEP_HOST_OS"]) != nil)
|
|
|
|
gnustep_target_os = [str retain];
|
|
|
|
|
|
|
|
if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil)
|
|
|
|
library_combo = [str retain];
|
|
|
|
|
1999-01-07 15:52:42 +00:00
|
|
|
data = [NSData dataWithContentsOfFile: appListPath];
|
|
|
|
if (data)
|
|
|
|
newApps = [NSDeserializer deserializePropertyListFromData: data
|
|
|
|
mutableContainers: NO];
|
|
|
|
applications = [newApps retain];
|
1998-11-23 21:39:58 +00:00
|
|
|
[gnustep_global_lock unlock];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-23 21:39:58 +00:00
|
|
|
+ (id) allocWithZone: (NSZone*)zone
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"You may not allocate a workspace directly"];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Creating a Workspace
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
+ (NSWorkspace *) sharedWorkspace
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-23 21:39:58 +00:00
|
|
|
if (sharedWorkspace == nil)
|
|
|
|
{
|
|
|
|
[gnustep_global_lock lock];
|
|
|
|
if (sharedWorkspace == nil)
|
|
|
|
{
|
|
|
|
sharedWorkspace =
|
|
|
|
(NSWorkspace*)NSAllocateObject(self, 0, NSDefaultMallocZone());
|
1999-01-07 15:52:42 +00:00
|
|
|
|
1998-11-23 21:39:58 +00:00
|
|
|
}
|
|
|
|
[gnustep_global_lock unlock];
|
|
|
|
}
|
|
|
|
return sharedWorkspace;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
1998-11-23 21:39:58 +00:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"Attempt to call dealloc for shared worksapace"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"Attempt to call init for shared worksapace"];
|
|
|
|
return nil;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Opening Files
|
|
|
|
//
|
1999-01-07 15:52:42 +00:00
|
|
|
- (BOOL) openFile: (NSString *)fullPath
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-01-07 15:52:42 +00:00
|
|
|
NSString *ext = [fullPath pathExtension];
|
|
|
|
NSDictionary *map;
|
|
|
|
NSArray *apps;
|
|
|
|
NSString *appName;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the applications cache (generated by the make_services tool)
|
|
|
|
* and lookup the special entry that contains a dictionary of all
|
|
|
|
* file extensions recognised by GNUstep applications. Then find
|
|
|
|
* the array of applications that can handle our file.
|
|
|
|
*/
|
|
|
|
if (applications == nil)
|
|
|
|
[self findApplications];
|
|
|
|
map = [applications objectForKey: @"GSExtensionsMap"];
|
|
|
|
apps = [map objectForKey: ext];
|
|
|
|
if (apps == nil || [apps count] == 0)
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(nil,
|
1999-04-08 20:42:46 +00:00
|
|
|
[NSString stringWithFormat:
|
1999-01-07 15:52:42 +00:00
|
|
|
@"No known applications for file extension '%@'", ext],
|
|
|
|
@"Continue", nil, nil);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME - need a mechanism for determining default application */
|
|
|
|
appName = [apps objectAtIndex: 0];
|
|
|
|
|
|
|
|
return [self openFile: fullPath withApplication: appName];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) openFile: (NSString *)fullPath
|
|
|
|
fromImage: (NSImage *)anImage
|
|
|
|
at: (NSPoint)point
|
|
|
|
inView: (NSView *)aView
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-01-07 15:52:42 +00:00
|
|
|
/* FIXME - should do animation here */
|
|
|
|
return [self openFile: fullPath];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) openFile: (NSString *)fullPath
|
|
|
|
withApplication: (NSString *)appName
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-01-07 15:52:42 +00:00
|
|
|
return [self openFile: fullPath withApplication: appName andDeactivate: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) openFile: (NSString *)fullPath
|
|
|
|
withApplication: (NSString *)appName
|
|
|
|
andDeactivate: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-01-07 15:52:42 +00:00
|
|
|
NSString *port = [appName stringByDeletingPathExtension];
|
|
|
|
NSDate *finish = [NSDate dateWithTimeIntervalSinceNow: 30.0];
|
|
|
|
id app;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to connect to the application - launches if necessary.
|
|
|
|
*/
|
|
|
|
app = GSContactApplication(appName, port, finish);
|
|
|
|
if (app == nil)
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(nil,
|
1999-04-08 20:42:46 +00:00
|
|
|
[NSString stringWithFormat:
|
1999-01-07 15:52:42 +00:00
|
|
|
@"Failed to contact '%@' to open file", port],
|
|
|
|
@"Continue", nil, nil);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
if (flag == NO)
|
|
|
|
[app application: nil openFileWithoutUI: fullPath];
|
|
|
|
else
|
|
|
|
[app application: nil openFile: fullPath];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(nil,
|
1999-04-08 20:42:46 +00:00
|
|
|
[NSString stringWithFormat:
|
1999-01-07 15:52:42 +00:00
|
|
|
@"Failed to contact '%@' to open file", port],
|
|
|
|
@"Continue", nil, nil);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
if (flag)
|
|
|
|
[[NSApplication sharedApplication] deactivate];
|
|
|
|
|
1999-01-07 15:52:42 +00:00
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) openTempFile: (NSString *)appName
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Manipulating Files
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) performFileOperation: (NSString *)operation
|
|
|
|
source: (NSString *)source
|
|
|
|
destination: (NSString *)destination
|
|
|
|
files: (NSArray *)files
|
|
|
|
tag: (int *)tag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) selectFile: (NSString *)fullPath
|
|
|
|
inFileViewerRootedAtPath: (NSString *)rootFullpath
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Requesting Information about Files
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSString *) fullPathForApplication: (NSString *)appName
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-23 21:39:58 +00:00
|
|
|
NSString *last = [appName lastPathComponent];
|
|
|
|
|
|
|
|
if (applications == nil)
|
1998-12-01 20:54:23 +00:00
|
|
|
[self findApplications];
|
1998-11-23 21:39:58 +00:00
|
|
|
|
|
|
|
if ([appName isEqual: last])
|
|
|
|
{
|
|
|
|
NSString *ext = [appName pathExtension];
|
|
|
|
|
|
|
|
if (ext == nil)
|
|
|
|
{
|
|
|
|
appName = [appName stringByAppendingPathExtension: @"app"];
|
|
|
|
}
|
|
|
|
return [applications objectForKey: appName];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) getFileSystemInfoForPath: (NSString *)fullPath
|
|
|
|
isRemovable: (BOOL *)removableFlag
|
|
|
|
isWritable: (BOOL *)writableFlag
|
|
|
|
isUnmountable: (BOOL *)unmountableFlag
|
|
|
|
description: (NSString **)description
|
|
|
|
type: (NSString **)fileSystemType
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) getInfoForFile: (NSString *)fullPath
|
|
|
|
application: (NSString **)appName
|
|
|
|
type: (NSString **)type
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSImage *) iconForFile: (NSString *)fullPath
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSImage *) iconForFiles: (NSArray *)pathArray
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSImage *) iconForFileType: (NSString *)fileType
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Tracking Changes to the File System
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) fileSystemChanged
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (void) noteFileSystemChanged
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Updating Registered Services and File Types
|
|
|
|
//
|
1999-01-07 15:52:42 +00:00
|
|
|
- (void) findApplications
|
1998-11-23 21:39:58 +00:00
|
|
|
{
|
1999-04-08 20:42:46 +00:00
|
|
|
static NSString *path = nil;
|
|
|
|
NSData *data;
|
|
|
|
NSDictionary *newApps;
|
|
|
|
NSTask *task;
|
1998-11-23 21:39:58 +00:00
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
/*
|
|
|
|
* Try to locate and run an executable copy of 'make_services'
|
|
|
|
*/
|
|
|
|
if (path == nil)
|
|
|
|
path = [[NSString alloc] initWithCString: mkpath(GNUSTEP_INSTALL_PREFIX)];
|
|
|
|
task = [self launchProgram: @"make_services" atPath: path];
|
|
|
|
if (task != nil)
|
|
|
|
[task waitUntilExit];
|
1998-11-23 21:39:58 +00:00
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
data = [NSData dataWithContentsOfFile: appListPath];
|
1998-12-01 14:41:53 +00:00
|
|
|
if (data)
|
1998-12-01 20:54:23 +00:00
|
|
|
newApps = [NSDeserializer deserializePropertyListFromData: data
|
|
|
|
mutableContainers: NO];
|
1998-12-01 14:41:53 +00:00
|
|
|
else
|
1998-12-01 20:54:23 +00:00
|
|
|
newApps = [NSDictionary dictionary];
|
1998-12-01 14:41:53 +00:00
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
ASSIGN(applications, newApps);
|
1998-11-23 21:39:58 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Launching and Manipulating Applications
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (void) hideOtherApplications
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) launchApplication: (NSString *)appName
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-23 21:39:58 +00:00
|
|
|
return [self launchApplication: appName
|
|
|
|
showIcon: YES
|
|
|
|
autolaunch: NO];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) launchApplication: (NSString *)appName
|
|
|
|
showIcon: (BOOL)showIcon
|
|
|
|
autolaunch: (BOOL)autolaunch
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-13 21:57:32 +00:00
|
|
|
NSFileManager *mgr;
|
1998-11-23 21:39:58 +00:00
|
|
|
NSString *path;
|
|
|
|
NSString *file;
|
|
|
|
NSDictionary *info;
|
|
|
|
|
|
|
|
if (appName == nil)
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
path = appName;
|
|
|
|
appName = [path lastPathComponent];
|
|
|
|
if ([appName isEqual: path])
|
|
|
|
{
|
|
|
|
path = [self fullPathForApplication: appName];
|
|
|
|
appName = [[path lastPathComponent] stringByDeletingPathExtension];
|
|
|
|
}
|
|
|
|
else if ([appName pathExtension] == nil)
|
|
|
|
{
|
|
|
|
path = [path stringByAppendingPathExtension: @"app"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
appName = [[path lastPathComponent] stringByDeletingPathExtension];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path == nil)
|
|
|
|
return NO;
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
/*
|
|
|
|
* See if the 'Info-gnustep.plist' specifies the location of the
|
|
|
|
* executable - if it does, replace our app name with the specified
|
|
|
|
* value. If the executable name is an absolute path name, we also
|
|
|
|
* replace the path with that specified.
|
|
|
|
*/
|
1998-11-23 21:39:58 +00:00
|
|
|
file = [path stringByAppendingPathComponent: @"Resources/Info-gnustep.plist"];
|
1999-04-13 21:57:32 +00:00
|
|
|
mgr = [NSFileManager defaultManager];
|
|
|
|
if ([mgr isReadableFileAtPath: file])
|
|
|
|
info = [NSDictionary dictionaryWithContentsOfFile: file];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file = [path stringByAppendingPathComponent: @"Resources/Info.plist"];
|
|
|
|
if ([mgr isReadableFileAtPath: file])
|
|
|
|
info = [NSDictionary dictionaryWithContentsOfFile: file];
|
|
|
|
else
|
|
|
|
info = nil;
|
|
|
|
}
|
1998-11-23 21:39:58 +00:00
|
|
|
file = [info objectForKey: @"NSExecutable"];
|
1999-04-08 20:42:46 +00:00
|
|
|
if (file != nil)
|
1998-11-23 21:39:58 +00:00
|
|
|
{
|
1999-04-13 21:57:32 +00:00
|
|
|
NSString *exepath;
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
appName = [file lastPathComponent];
|
1999-04-13 21:57:32 +00:00
|
|
|
exepath = [file stringByDeletingLastPathComponent];
|
|
|
|
if ([exepath isEqualToString: @""] == NO)
|
1999-04-08 20:42:46 +00:00
|
|
|
{
|
1999-04-13 21:57:32 +00:00
|
|
|
if ([file isAbsolutePath] == YES)
|
|
|
|
path = exepath;
|
|
|
|
else
|
|
|
|
path = [path stringByAppendingPathComponent: exepath];
|
1999-04-08 20:42:46 +00:00
|
|
|
}
|
1998-11-23 21:39:58 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
if ([self launchProgram: appName atPath: path] == nil)
|
|
|
|
return NO;
|
1998-11-23 21:39:58 +00:00
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Unmounting a Device
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) unmountAndEjectDeviceAtPath: (NSString *)path
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Tracking Status Changes for Devices
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (void) checkForRemovableMedia
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSArray *) mountNewRemovableMedia
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSArray *) mountedRemovableMedia
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Notification Center
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (NSNotificationCenter *) notificationCenter
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-23 21:39:58 +00:00
|
|
|
return workspaceCenter;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Tracking Changes to the User Defaults Database
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (void) noteUserDefaultsChanged
|
1998-11-23 21:39:58 +00:00
|
|
|
{
|
|
|
|
userDefaultsChanged = YES;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
- (BOOL) userDefaultsChanged
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-23 21:39:58 +00:00
|
|
|
BOOL hasChanged = userDefaultsChanged;
|
|
|
|
userDefaultsChanged = NO;
|
|
|
|
return hasChanged;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Animating an Image
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (void) slideImage: (NSImage *)image
|
|
|
|
from: (NSPoint)fromPoint
|
|
|
|
to: (NSPoint)toPoint
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Requesting Additional Time before Power Off or Logout
|
|
|
|
//
|
1999-04-08 20:42:46 +00:00
|
|
|
- (int) extendPowerOffBy: (int)requested
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
1999-04-08 20:42:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@implementation NSWorkspace (GNUstep)
|
|
|
|
/*
|
|
|
|
* Attempt to start a program. First look in machine/os/libs directory,
|
|
|
|
* then in machine/os directory, then at top level.
|
|
|
|
*/
|
|
|
|
- (NSTask*) launchProgram: (NSString *)prog
|
|
|
|
atPath: (NSString *)path
|
|
|
|
{
|
|
|
|
NSArray *args;
|
|
|
|
NSTask *task;
|
|
|
|
NSString *path0;
|
|
|
|
NSString *path1;
|
|
|
|
NSString *path2;
|
|
|
|
NSFileManager *mgr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to locate the actual executable file and start it running.
|
|
|
|
*/
|
|
|
|
path2 = [path stringByAppendingPathComponent: prog];
|
|
|
|
path = [path stringByAppendingPathComponent: gnustep_target_dir];
|
|
|
|
path1 = [path stringByAppendingPathComponent: prog];
|
|
|
|
path = [path stringByAppendingPathComponent: library_combo];
|
|
|
|
path0 = [path stringByAppendingPathComponent: prog];
|
|
|
|
|
|
|
|
mgr = [NSFileManager defaultManager];
|
|
|
|
if ([mgr isExecutableFileAtPath: path0])
|
|
|
|
path = path0;
|
|
|
|
else if ([mgr isExecutableFileAtPath: path1])
|
|
|
|
path = path1;
|
|
|
|
else if ([mgr isExecutableFileAtPath: path2])
|
|
|
|
path = path2;
|
|
|
|
else
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
args = [NSArray arrayWithObjects: nil];
|
|
|
|
task = [NSTask launchedTaskWithLaunchPath: path
|
|
|
|
arguments: args];
|
|
|
|
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|