mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 20:50:44 +00:00
Tidied launching
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4049 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cbbfd93df2
commit
f8510ac5ec
4 changed files with 268 additions and 116 deletions
|
@ -57,7 +57,6 @@
|
|||
}
|
||||
+ (GSServicesManager*) newWithApplication: (NSApplication*)app;
|
||||
+ (GSServicesManager*) manager;
|
||||
- (void) checkServices;
|
||||
- (void) doService: (NSCell*)item;
|
||||
- (BOOL) hasRegisteredTypes: (NSDictionary*)service;
|
||||
- (NSString*) item2title: (NSCell*)item;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSSerialization.h>
|
||||
#include <Foundation/NSPortNameServer.h>
|
||||
#include <Foundation/NSTask.h>
|
||||
|
||||
#include <base/fast.x>
|
||||
|
||||
|
@ -57,20 +58,16 @@
|
|||
|
||||
#include <AppKit/GSServicesManager.h>
|
||||
|
||||
#define stringify_it(X) #X
|
||||
#define prog_path(X,Y) \
|
||||
stringify_it(X) "/Tools/" GNUSTEP_TARGET_DIR "/" LIBRARY_COMBO
|
||||
|
||||
/*
|
||||
* The GNUListener class is for talking to other applications.
|
||||
* The GSListener class is for talking to other applications.
|
||||
* It is a proxy with some dangerous methods implemented in a
|
||||
* harmless manner to reduce the chances of a malicious app
|
||||
* messing with us. This is responsible for forwarding service
|
||||
* requests and other communications with the outside world.
|
||||
*/
|
||||
@interface GNUListener : NSObject
|
||||
@interface GSListener : NSObject
|
||||
+ (id) connectionBecameInvalid: (NSNotification*)notification;
|
||||
+ (GNUListener*) listener;
|
||||
+ (GSListener*) listener;
|
||||
+ (id) servicesProvider;
|
||||
+ (void) setServicesProvider: (id)anObject;
|
||||
- (Class) class;
|
||||
|
@ -78,10 +75,20 @@
|
|||
- (void) release;
|
||||
- (id) retain;
|
||||
- (id) self;
|
||||
- (BOOL) application: (NSApplication*)theApp
|
||||
openFile: (NSString*)file;
|
||||
- (BOOL) application: (NSApplication*)theApp
|
||||
openFileWithoutUI: (NSString*)file;
|
||||
- (BOOL) application: (NSApplication*)theApp
|
||||
openTempFile: (NSString*)file;
|
||||
- (void) performService: (NSString*)name
|
||||
withPasteboard: (NSPasteboard*)pb
|
||||
userData: (NSString*)ud
|
||||
error: (NSString**)e;
|
||||
@end
|
||||
|
||||
static NSConnection *listenerConnection = nil;
|
||||
static GNUListener *listener = nil;
|
||||
static GSListener *listener = nil;
|
||||
static id servicesProvider = nil;
|
||||
|
||||
void
|
||||
|
@ -94,7 +101,7 @@ NSUnregisterServicesProvider(NSString *name)
|
|||
* the given port name.
|
||||
*/
|
||||
[[NSPortNameServer defaultPortNameServer] removePortForName: name];
|
||||
[NSNotificationCenter removeObserver: [GNUListener class]
|
||||
[NSNotificationCenter removeObserver: [GSListener class]
|
||||
name: NSConnectionDidDieNotification
|
||||
object: listenerConnection];
|
||||
[listenerConnection release];
|
||||
|
@ -113,7 +120,7 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
* the given port name.
|
||||
*/
|
||||
[[NSPortNameServer defaultPortNameServer] removePortForName: name];
|
||||
[NSNotificationCenter removeObserver: [GNUListener class]
|
||||
[NSNotificationCenter removeObserver: [GSListener class]
|
||||
name: NSConnectionDidDieNotification
|
||||
object: listenerConnection];
|
||||
[listenerConnection release];
|
||||
|
@ -122,12 +129,12 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
if (name && provider)
|
||||
{
|
||||
listenerConnection = [NSConnection newRegisteringAtName: name
|
||||
withRootObject: [GNUListener listener]];
|
||||
withRootObject: [GSListener listener]];
|
||||
if (listenerConnection)
|
||||
{
|
||||
[listenerConnection retain];
|
||||
[NotificationDispatcher
|
||||
addObserver: [GNUListener class]
|
||||
addObserver: [GSListener class]
|
||||
selector: @selector(connectionBecameInvalid:)
|
||||
name: NSConnectionDidDieNotification
|
||||
object: listenerConnection];
|
||||
|
@ -140,12 +147,12 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
}
|
||||
|
||||
/*
|
||||
* The GNUListener class exists as a proxy to forward messages to
|
||||
* The GSListener class exists as a proxy to forward messages to
|
||||
* service provider objects. It implements very few methods and
|
||||
* those that it does implement are generally designed to defeat
|
||||
* any attack by a malicious program.
|
||||
*/
|
||||
@implementation GNUListener
|
||||
@implementation GSListener
|
||||
|
||||
+ (id) connectionBecameInvalid: (NSNotification*)notification
|
||||
{
|
||||
|
@ -160,7 +167,7 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (GNUListener*) listener
|
||||
+ (GSListener*) listener
|
||||
{
|
||||
if (listener == nil)
|
||||
{
|
||||
|
@ -219,6 +226,63 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) application: (NSApplication*)theApp
|
||||
openFile: (NSString*)file
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
|
||||
return [app application: theApp openFile: file];
|
||||
}
|
||||
|
||||
- (BOOL) application: (NSApplication*)theApp
|
||||
openFileWithoutUI: (NSString*)file
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
|
||||
return [app application: theApp openFileWithoutUI: file];
|
||||
}
|
||||
|
||||
- (BOOL) application: (NSApplication*)theApp
|
||||
openTempFile: (NSString*)file
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
|
||||
return [app application: theApp openTempFile: file];
|
||||
}
|
||||
|
||||
- (void) performService: (NSString*)name
|
||||
withPasteboard: (NSPasteboard*)pb
|
||||
userData: (NSString*)ud
|
||||
error: (NSString**)e
|
||||
{
|
||||
id obj = servicesProvider;
|
||||
SEL msgSel = NSSelectorFromString(name);
|
||||
IMP msgImp;
|
||||
|
||||
if (obj != nil && [obj respondsToSelector: msgSel])
|
||||
{
|
||||
msgImp = [obj methodForSelector: msgSel];
|
||||
if (msgImp != 0)
|
||||
{
|
||||
(*msgImp)(obj, msgSel, pb, ud, e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
obj = [[NSApplication sharedApplication] delegate];
|
||||
if (obj != nil && [obj respondsToSelector: msgSel])
|
||||
{
|
||||
msgImp = [obj methodForSelector: msgSel];
|
||||
if (msgImp != 0)
|
||||
{
|
||||
(*msgImp)(obj, msgSel, pb, ud, e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
*e = @"No object available to provide service";
|
||||
}
|
||||
|
||||
- (void) release
|
||||
{
|
||||
}
|
||||
|
@ -232,7 +296,7 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
{
|
||||
return self;
|
||||
}
|
||||
@end /* GNUListener */
|
||||
@end /* GSListener */
|
||||
|
||||
|
||||
|
||||
|
@ -302,13 +366,6 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
return manager;
|
||||
}
|
||||
|
||||
- (void) checkServices
|
||||
{
|
||||
system(prog_path(GNUSTEP_INSTALL_PREFIX, "/make_services"));
|
||||
|
||||
[self loadServices];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSString *appName;
|
||||
|
@ -860,7 +917,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
|
||||
- (id) servicesProvider
|
||||
{
|
||||
return [GNUListener servicesProvider];
|
||||
return [GSListener servicesProvider];
|
||||
}
|
||||
|
||||
- (void) setServicesMenu: (NSMenu*)aMenu
|
||||
|
@ -871,7 +928,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
|
||||
- (void) setServicesProvider: (id)anObject
|
||||
{
|
||||
[GNUListener setServicesProvider: anObject];
|
||||
[GSListener setServicesProvider: anObject];
|
||||
}
|
||||
|
||||
- (int) setShowsServicesMenuItem: (NSString*)item to: (BOOL)enable
|
||||
|
@ -1195,7 +1252,12 @@ NSPerformService(NSString *serviceItem, NSPasteboard *pboard)
|
|||
msgImp = get_imp(fastClass(provider), msgSel);
|
||||
NS_DURING
|
||||
{
|
||||
(*msgImp)(provider, msgSel, pboard, userData, &error);
|
||||
[provider performService: selName
|
||||
withPasteboard: pboard
|
||||
userData: userData
|
||||
error: &error];
|
||||
|
||||
// (*msgImp)(provider, msgSel, pboard, userData, &error);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
|
|
|
@ -50,6 +50,34 @@
|
|||
#include <AppKit/NSCursor.h>
|
||||
|
||||
|
||||
@interface GSWindowView : NSView
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GSWindowView
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
NSColor *c = [[self window] backgroundColor];
|
||||
|
||||
[c set];
|
||||
NSRectFill(rect);
|
||||
}
|
||||
|
||||
- (Class) classForCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([self class] == [GSWindowView class])
|
||||
return [super class];
|
||||
return [self class];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
|
@ -71,11 +99,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
+ (NSView *) _windowViewWithFrame: (NSRect)frameRect // create the view at
|
||||
{ // the root of window's
|
||||
return nil; // view heirarchy.
|
||||
} // (backend)
|
||||
|
||||
+ (void) removeFrameUsingName: (NSString *)name
|
||||
{ // Saving and restoring
|
||||
} // the window's frame
|
||||
|
@ -208,13 +231,14 @@
|
|||
{
|
||||
NSView *wv;
|
||||
|
||||
if (!aView) // contentview can't be nil
|
||||
// contentview can't be nil
|
||||
if (!aView)
|
||||
aView = [[[NSView alloc] initWithFrame: frame] autorelease];
|
||||
// If window view has not
|
||||
// been created, create it
|
||||
|
||||
// If window view has not been created, create it
|
||||
if ((!content_view) || ([content_view superview] == nil))
|
||||
{
|
||||
wv = [NSWindow _windowViewWithFrame: frame];
|
||||
wv = [[GSWindowView allocWithZone: [self zone]] initWithFrame: frame];
|
||||
[wv viewWillMoveToWindow: self];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -40,22 +40,27 @@
|
|||
#include <Foundation/NSTask.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
|
||||
#define stringify_it(X) #X
|
||||
#define prog_path(X,Y) \
|
||||
stringify_it(X) "/Tools/" GNUSTEP_TARGET_DIR "/" LIBRARY_COMBO
|
||||
#define mkpath(X) stringify_it(X) "/Tools"
|
||||
|
||||
static NSDictionary *applications = nil;
|
||||
|
||||
@interface NSWorkspace (GNUstep)
|
||||
- (NSTask*) launchProgram: (NSString *)prog
|
||||
atPath: (NSString *)path;
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSWorkspace
|
||||
|
||||
static NSWorkspace *sharedWorkspace = nil;
|
||||
static NSWorkspace *sharedWorkspace = nil;
|
||||
static NSNotificationCenter *workspaceCenter = nil;
|
||||
static BOOL userDefaultsChanged = NO;
|
||||
static BOOL userDefaultsChanged = NO;
|
||||
|
||||
static NSString *appListName = @".GNUstepAppList";
|
||||
static NSString *appListPath = nil;
|
||||
static NSString *appListName = @".GNUstepAppList";
|
||||
static NSString *appListPath = nil;
|
||||
|
||||
static NSString* gnustep_target_dir =
|
||||
#ifdef GNUSTEP_TARGET_DIR
|
||||
|
@ -85,7 +90,7 @@ static NSString* library_combo =
|
|||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSWorkspace class])
|
||||
{
|
||||
|
@ -93,7 +98,7 @@ static NSString* library_combo =
|
|||
NSDictionary *env;
|
||||
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
[self setVersion: 1];
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
if (beenHere == YES)
|
||||
|
@ -158,7 +163,7 @@ static NSString* library_combo =
|
|||
//
|
||||
// Creating a Workspace
|
||||
//
|
||||
+ (NSWorkspace *)sharedWorkspace
|
||||
+ (NSWorkspace *) sharedWorkspace
|
||||
{
|
||||
if (sharedWorkspace == nil)
|
||||
{
|
||||
|
@ -213,7 +218,7 @@ static NSString* library_combo =
|
|||
if (apps == nil || [apps count] == 0)
|
||||
{
|
||||
NSRunAlertPanel(nil,
|
||||
[NSString stringWithFormat:
|
||||
[NSString stringWithFormat:
|
||||
@"No known applications for file extension '%@'", ext],
|
||||
@"Continue", nil, nil);
|
||||
return NO;
|
||||
|
@ -225,31 +230,29 @@ static NSString* library_combo =
|
|||
return [self openFile: fullPath withApplication: appName];
|
||||
}
|
||||
|
||||
- (BOOL)openFile:(NSString *)fullPath
|
||||
fromImage:(NSImage *)anImage
|
||||
at:(NSPoint)point
|
||||
inView:(NSView *)aView
|
||||
- (BOOL) openFile: (NSString *)fullPath
|
||||
fromImage: (NSImage *)anImage
|
||||
at: (NSPoint)point
|
||||
inView: (NSView *)aView
|
||||
{
|
||||
/* FIXME - should do animation here */
|
||||
return [self openFile: fullPath];
|
||||
}
|
||||
|
||||
- (BOOL)openFile:(NSString *)fullPath
|
||||
withApplication:(NSString *)appName
|
||||
- (BOOL) openFile: (NSString *)fullPath
|
||||
withApplication: (NSString *)appName
|
||||
{
|
||||
return [self openFile: fullPath withApplication: appName andDeactivate: YES];
|
||||
}
|
||||
|
||||
- (BOOL)openFile:(NSString *)fullPath
|
||||
withApplication:(NSString *)appName
|
||||
andDeactivate:(BOOL)flag
|
||||
- (BOOL) openFile: (NSString *)fullPath
|
||||
withApplication: (NSString *)appName
|
||||
andDeactivate: (BOOL)flag
|
||||
{
|
||||
NSString *port = [appName stringByDeletingPathExtension];
|
||||
NSDate *finish = [NSDate dateWithTimeIntervalSinceNow: 30.0];
|
||||
id app;
|
||||
|
||||
/* FIXME - should probably deactivate self here. */
|
||||
|
||||
/*
|
||||
* Try to connect to the application - launches if necessary.
|
||||
*/
|
||||
|
@ -257,7 +260,7 @@ static NSString* library_combo =
|
|||
if (app == nil)
|
||||
{
|
||||
NSRunAlertPanel(nil,
|
||||
[NSString stringWithFormat:
|
||||
[NSString stringWithFormat:
|
||||
@"Failed to contact '%@' to open file", port],
|
||||
@"Continue", nil, nil);
|
||||
return NO;
|
||||
|
@ -273,17 +276,20 @@ static NSString* library_combo =
|
|||
NS_HANDLER
|
||||
{
|
||||
NSRunAlertPanel(nil,
|
||||
[NSString stringWithFormat:
|
||||
[NSString stringWithFormat:
|
||||
@"Failed to contact '%@' to open file", port],
|
||||
@"Continue", nil, nil);
|
||||
return NO;
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
if (flag)
|
||||
[[NSApplication sharedApplication] deactivate];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)openTempFile:(NSString *)fullPath
|
||||
- (BOOL) openTempFile: (NSString *)appName
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
@ -291,17 +297,17 @@ static NSString* library_combo =
|
|||
//
|
||||
// Manipulating Files
|
||||
//
|
||||
- (BOOL)performFileOperation:(NSString *)operation
|
||||
source:(NSString *)source
|
||||
destination:(NSString *)destination
|
||||
files:(NSArray *)files
|
||||
tag:(int *)tag
|
||||
- (BOOL) performFileOperation: (NSString *)operation
|
||||
source: (NSString *)source
|
||||
destination: (NSString *)destination
|
||||
files: (NSArray *)files
|
||||
tag: (int *)tag
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)selectFile:(NSString *)fullPath
|
||||
inFileViewerRootedAtPath:(NSString *)rootFullpath
|
||||
- (BOOL) selectFile: (NSString *)fullPath
|
||||
inFileViewerRootedAtPath: (NSString *)rootFullpath
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
@ -309,7 +315,7 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Requesting Information about Files
|
||||
//
|
||||
- (NSString *)fullPathForApplication:(NSString *)appName
|
||||
- (NSString *) fullPathForApplication: (NSString *)appName
|
||||
{
|
||||
NSString *last = [appName lastPathComponent];
|
||||
|
||||
|
@ -329,34 +335,34 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)getFileSystemInfoForPath:(NSString *)fullPath
|
||||
isRemovable:(BOOL *)removableFlag
|
||||
isWritable:(BOOL *)writableFlag
|
||||
isUnmountable:(BOOL *)unmountableFlag
|
||||
description:(NSString **)description
|
||||
type:(NSString **)fileSystemType
|
||||
- (BOOL) getFileSystemInfoForPath: (NSString *)fullPath
|
||||
isRemovable: (BOOL *)removableFlag
|
||||
isWritable: (BOOL *)writableFlag
|
||||
isUnmountable: (BOOL *)unmountableFlag
|
||||
description: (NSString **)description
|
||||
type: (NSString **)fileSystemType
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)getInfoForFile:(NSString *)fullPath
|
||||
application:(NSString **)appName
|
||||
type:(NSString **)type
|
||||
- (BOOL) getInfoForFile: (NSString *)fullPath
|
||||
application: (NSString **)appName
|
||||
type: (NSString **)type
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSImage *)iconForFile:(NSString *)fullPath
|
||||
- (NSImage *) iconForFile: (NSString *)fullPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSImage *)iconForFiles:(NSArray *)pathArray
|
||||
- (NSImage *) iconForFiles: (NSArray *)pathArray
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSImage *)iconForFileType:(NSString *)fileType
|
||||
- (NSImage *) iconForFileType: (NSString *)fileType
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
@ -364,23 +370,33 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Tracking Changes to the File System
|
||||
//
|
||||
- (BOOL)fileSystemChanged
|
||||
- (BOOL) fileSystemChanged
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)noteFileSystemChanged
|
||||
{}
|
||||
- (void) noteFileSystemChanged
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Updating Registered Services and File Types
|
||||
//
|
||||
- (void) findApplications
|
||||
{
|
||||
NSData *data;
|
||||
NSDictionary *newApps;
|
||||
static NSString *path = nil;
|
||||
NSData *data;
|
||||
NSDictionary *newApps;
|
||||
NSTask *task;
|
||||
|
||||
system(prog_path(GNUSTEP_INSTALL_PREFIX, "/make_services"));
|
||||
/*
|
||||
* 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];
|
||||
|
||||
data = [NSData dataWithContentsOfFile: appListPath];
|
||||
if (data)
|
||||
|
@ -395,22 +411,21 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Launching and Manipulating Applications
|
||||
//
|
||||
- (void)hideOtherApplications
|
||||
{}
|
||||
- (void) hideOtherApplications
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)launchApplication:(NSString *)appName
|
||||
- (BOOL) launchApplication: (NSString *)appName
|
||||
{
|
||||
return [self launchApplication: appName
|
||||
showIcon: YES
|
||||
autolaunch: NO];
|
||||
}
|
||||
|
||||
- (BOOL)launchApplication:(NSString *)appName
|
||||
showIcon:(BOOL)showIcon
|
||||
autolaunch:(BOOL)autolaunch
|
||||
- (BOOL) launchApplication: (NSString *)appName
|
||||
showIcon: (BOOL)showIcon
|
||||
autolaunch: (BOOL)autolaunch
|
||||
{
|
||||
NSArray *args;
|
||||
NSTask *task;
|
||||
NSString *path;
|
||||
NSString *file;
|
||||
NSDictionary *info;
|
||||
|
@ -437,28 +452,33 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
if (path == nil)
|
||||
return NO;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
file = [path stringByAppendingPathComponent: @"Resources/Info-gnustep.plist"];
|
||||
info = [NSDictionary dictionaryWithContentsOfFile: file];
|
||||
file = [info objectForKey: @"NSExecutable"];
|
||||
if (file == nil)
|
||||
if (file != nil)
|
||||
{
|
||||
file = appName;
|
||||
appName = [file lastPathComponent];
|
||||
if ([file isAbsolutePath] == YES)
|
||||
{
|
||||
path = [file stringByDeletingLastPathComponent];
|
||||
}
|
||||
}
|
||||
path = [path stringByAppendingPathComponent: gnustep_target_dir];
|
||||
path = [path stringByAppendingPathComponent: library_combo];
|
||||
path = [path stringByAppendingPathComponent: appName];
|
||||
|
||||
args = [NSArray arrayWithObjects: nil];
|
||||
task = [NSTask launchedTaskWithLaunchPath: path
|
||||
arguments: args];
|
||||
|
||||
if ([self launchProgram: appName atPath: path] == nil)
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
//
|
||||
// Unmounting a Device
|
||||
//
|
||||
- (BOOL)unmountAndEjectDeviceAtPath:(NSString *)path
|
||||
- (BOOL) unmountAndEjectDeviceAtPath: (NSString *)path
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
@ -466,15 +486,16 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Tracking Status Changes for Devices
|
||||
//
|
||||
- (void)checkForRemovableMedia
|
||||
{}
|
||||
- (void) checkForRemovableMedia
|
||||
{
|
||||
}
|
||||
|
||||
- (NSArray *)mountNewRemovableMedia
|
||||
- (NSArray *) mountNewRemovableMedia
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)mountedRemovableMedia
|
||||
- (NSArray *) mountedRemovableMedia
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
@ -482,7 +503,7 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Notification Center
|
||||
//
|
||||
- (NSNotificationCenter *)notificationCenter
|
||||
- (NSNotificationCenter *) notificationCenter
|
||||
{
|
||||
return workspaceCenter;
|
||||
}
|
||||
|
@ -490,12 +511,12 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Tracking Changes to the User Defaults Database
|
||||
//
|
||||
- (void)noteUserDefaultsChanged
|
||||
- (void) noteUserDefaultsChanged
|
||||
{
|
||||
userDefaultsChanged = YES;
|
||||
}
|
||||
|
||||
- (BOOL)userDefaultsChanged
|
||||
- (BOOL) userDefaultsChanged
|
||||
{
|
||||
BOOL hasChanged = userDefaultsChanged;
|
||||
userDefaultsChanged = NO;
|
||||
|
@ -505,17 +526,63 @@ inFileViewerRootedAtPath:(NSString *)rootFullpath
|
|||
//
|
||||
// Animating an Image
|
||||
//
|
||||
- (void)slideImage:(NSImage *)image
|
||||
from:(NSPoint)fromPoint
|
||||
to:(NSPoint)toPoint
|
||||
{}
|
||||
- (void) slideImage: (NSImage *)image
|
||||
from: (NSPoint)fromPoint
|
||||
to: (NSPoint)toPoint
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Requesting Additional Time before Power Off or Logout
|
||||
//
|
||||
- (int)extendPowerOffBy:(int)requested
|
||||
- (int) extendPowerOffBy: (int)requested
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@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
|
||||
|
||||
|
|
Loading…
Reference in a new issue