mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Depend on NSTask and NSBundle
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4081 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f77ae12819
commit
fa35a55ba7
3 changed files with 26 additions and 74 deletions
|
@ -1,3 +1,10 @@
|
|||
Wed Apr 14 15:04:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSPasteboard.m: Remove 'system()' and use NSTask to launch
|
||||
gpbs if necessary instead.
|
||||
* Source/NSWorkspace.m: Removed a load of obsolete code - depend on
|
||||
NSBundle and NSTask to do the right thing.
|
||||
|
||||
Fri Apr 9 16:08:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSStringDrawing.m: Further hacking of the string drawing stuff
|
||||
|
|
|
@ -46,11 +46,11 @@
|
|||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSMethodSignature.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSTask.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
|
||||
#define stringify_it(X) #X
|
||||
#define prog_path(X,Y) \
|
||||
stringify_it(X) "/Tools/" GNUSTEP_TARGET_DIR "/" LIBRARY_COMBO Y
|
||||
#define prog_path(X) stringify_it(X) "/Tools/gpbs"
|
||||
|
||||
@interface NSPasteboard (Private)
|
||||
+ (id<PasteboardServer>) _pbs;
|
||||
|
@ -127,15 +127,17 @@ static id<PasteboardServer> the_server = nil;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSRunLoop *loop = [NSRunLoop currentRunLoop];
|
||||
NSDate *next;
|
||||
static NSString *cmd = nil;
|
||||
|
||||
system(prog_path(GNUSTEP_INSTALL_PREFIX, "/gpbs &"));
|
||||
if (cmd == nil)
|
||||
cmd = [NSString stringWithCString:
|
||||
prog_path(GNUSTEP_INSTALL_PREFIX)];
|
||||
[NSTask launchedTaskWithLaunchPath: cmd arguments: nil];
|
||||
[NSTimer scheduledTimerWithTimeInterval: 5.0
|
||||
invocation: nil
|
||||
repeats: NO];
|
||||
next = [NSDate dateWithTimeIntervalSinceNow: 5.0];
|
||||
[loop runUntilDate: next];
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:
|
||||
[NSDate dateWithTimeIntervalSinceNow: 5.0]];
|
||||
recursion = YES;
|
||||
[self _pbs];
|
||||
recursion = NO;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSPanel.h>
|
||||
#include <AppKit/GSServicesManager.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
|
@ -47,11 +48,6 @@
|
|||
|
||||
static NSDictionary *applications = nil;
|
||||
|
||||
@interface NSWorkspace (GNUstep)
|
||||
- (NSTask*) launchProgram: (NSString *)prog
|
||||
atPath: (NSString *)path;
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSWorkspace
|
||||
|
||||
|
@ -393,8 +389,10 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
|
|||
* 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];
|
||||
path = [[NSString alloc] initWithFormat: @"%s/make_services",
|
||||
mkpath(GNUSTEP_INSTALL_PREFIX)];
|
||||
task = [NSTask launchedTaskWithLaunchPath: path
|
||||
arguments: nil];
|
||||
if (task != nil)
|
||||
[task waitUntilExit];
|
||||
|
||||
|
@ -426,10 +424,9 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
|
|||
showIcon: (BOOL)showIcon
|
||||
autolaunch: (BOOL)autolaunch
|
||||
{
|
||||
NSFileManager *mgr;
|
||||
NSString *path;
|
||||
NSString *file;
|
||||
NSDictionary *info;
|
||||
NSBundle *bundle;
|
||||
|
||||
if (appName == nil)
|
||||
return NO;
|
||||
|
@ -459,19 +456,8 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
|
|||
* 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"];
|
||||
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;
|
||||
}
|
||||
file = [info objectForKey: @"NSExecutable"];
|
||||
bundle = [NSBundle bundleWithPath: path];
|
||||
file = [[bundle infoDictionary] objectForKey: @"NSExecutable"];
|
||||
if (file != nil)
|
||||
{
|
||||
NSString *exepath;
|
||||
|
@ -487,7 +473,8 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
|
|||
}
|
||||
}
|
||||
|
||||
if ([self launchProgram: appName atPath: path] == nil)
|
||||
path = [path stringByAppendingPathComponent: appName];
|
||||
if ([NSTask launchedTaskWithLaunchPath: path arguments: nil] == nil)
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
@ -559,47 +546,3 @@ inFileViewerRootedAtPath: (NSString *)rootFullpath
|
|||
|
||||
@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