mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 12:00:52 +00:00
Run make_services if necessary
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3234 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
087bd3a593
commit
b4d60228d8
2 changed files with 88 additions and 27 deletions
|
@ -38,10 +38,20 @@
|
|||
# Flags dealing with compiling and linking
|
||||
#
|
||||
|
||||
# GNUSTEP_INSTALL_PREFIX must be defined here and not in config.h because
|
||||
# the installing person may set it on the `make' command line.
|
||||
GNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT)
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
GNUSTEP_INSTALL_LIBDIR=$(GNUSTEP_LIBRARIES_ROOT)
|
||||
ADDITIONAL_CPPFLAGS = -DGNUSTEP_INSTALL_LIBDIR=\"$(GNUSTEP_INSTALL_LIBDIR)\" \
|
||||
${DPS_DEFINE}
|
||||
${DPS_DEFINE} \
|
||||
-DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_INSTALL_PREFIX) \
|
||||
-DGNUSTEP_TARGET_DIR=\"$(GNUSTEP_TARGET_DIR)\" \
|
||||
-DGNUSTEP_TARGET_CPU=\"$(GNUSTEP_TARGET_CPU)\" \
|
||||
-DGNUSTEP_TARGET_OS=\"$(GNUSTEP_TARGET_OS)\" \
|
||||
-DLIBRARY_COMBO=\"$(LIBRARY_COMBO)\"
|
||||
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS = -g -Wall
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include "../Tools/PasteboardServer.h"
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSData.h>
|
||||
|
@ -38,10 +39,15 @@
|
|||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSPortNameServer.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSSerialization.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
#define stringify_it(X) #X
|
||||
#define prog_path(X,Y) \
|
||||
stringify_it(X) "/Tools/" GNUSTEP_TARGET_DIR "/" LIBRARY_COMBO Y
|
||||
|
||||
@interface NSPasteboard (Private)
|
||||
+ (id<PasteboardServer>) _pbs;
|
||||
+ (NSPasteboard*) _pasteboardWithTarget: (id<PasteboardObject>)aTarget
|
||||
|
@ -84,30 +90,47 @@ static id<PasteboardServer> the_server = nil;
|
|||
|
||||
+ (id<PasteboardServer>) _pbs
|
||||
{
|
||||
if (the_server == nil) {
|
||||
NSString* host;
|
||||
if (the_server == nil)
|
||||
{
|
||||
NSString* host;
|
||||
|
||||
host = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
|
||||
if (host == nil) {
|
||||
host = [[NSProcessInfo processInfo] hostName];
|
||||
}
|
||||
the_server = (id<PasteboardServer>)[NSConnection
|
||||
rootProxyForConnectionWithRegisteredName: PBSNAME
|
||||
host: host];
|
||||
if ([(id)the_server retain]) {
|
||||
NSConnection* conn = [(id)the_server connectionForProxy];
|
||||
host = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
|
||||
if (host == nil)
|
||||
{
|
||||
host = [[NSProcessInfo processInfo] hostName];
|
||||
}
|
||||
the_server = (id<PasteboardServer>)[NSConnection
|
||||
rootProxyForConnectionWithRegisteredName: PBSNAME
|
||||
host: host];
|
||||
if ([(id)the_server retain])
|
||||
{
|
||||
NSConnection* conn = [(id)the_server connectionForProxy];
|
||||
|
||||
[NSNotificationCenter
|
||||
addObserver: self
|
||||
selector: @selector(_lostServer:)
|
||||
name: NSConnectionDidDieNotification
|
||||
object: conn];
|
||||
[NSNotificationCenter addObserver: self
|
||||
selector: @selector(_lostServer:)
|
||||
name: NSConnectionDidDieNotification
|
||||
object: conn];
|
||||
}
|
||||
else
|
||||
{
|
||||
static BOOL recursion = NO;
|
||||
|
||||
if (recursion)
|
||||
{
|
||||
NSLog(@"Unable to contact pasteboard server - "
|
||||
@"please ensure that gpbs is running.\n");
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
system(prog_path(GNUSTEP_INSTALL_PREFIX, "/gpbs &"));
|
||||
sleep(5);
|
||||
recursion = YES;
|
||||
[self _pbs];
|
||||
recursion = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
NSLog(@"Unable to contact pasteboard server - "
|
||||
@"please ensure that gpbs is running.\n");
|
||||
}
|
||||
}
|
||||
return the_server;
|
||||
}
|
||||
|
||||
|
@ -132,7 +155,7 @@ static id<PasteboardServer> the_server = nil;
|
|||
* If this is the case, our proxy for the object on the server will be
|
||||
* out of date, so we swap it for the newly created one.
|
||||
*/
|
||||
if (p->target != aTarget) {
|
||||
if (p->target != (id)aTarget) {
|
||||
[p->target autorelease];
|
||||
p->target = [(id)aTarget retain];
|
||||
}
|
||||
|
@ -660,17 +683,20 @@ provideDataForType:(NSString *)type
|
|||
static NSString* contentsPrefix = @"NSTypedFileContentsPboardType:";
|
||||
static NSString* namePrefix = @"NSTypedFilenamesPboardType:";
|
||||
|
||||
NSString *NSCreateFileContentsPboardType(NSString *fileType)
|
||||
NSString*
|
||||
NSCreateFileContentsPboardType(NSString *fileType)
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@%@", contentsPrefix, fileType];
|
||||
}
|
||||
|
||||
NSString *NSCreateFilenamePboardType(NSString *filename)
|
||||
NSString*
|
||||
NSCreateFilenamePboardType(NSString *filename)
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@%@", namePrefix, filename];
|
||||
}
|
||||
|
||||
NSString *NSGetFileType(NSString *pboardType)
|
||||
NSString*
|
||||
NSGetFileType(NSString *pboardType)
|
||||
{
|
||||
if ([pboardType hasPrefix: contentsPrefix]) {
|
||||
return [pboardType substringFromIndex: [contentsPrefix length]];
|
||||
|
@ -681,7 +707,8 @@ NSString *NSGetFileType(NSString *pboardType)
|
|||
return nil;
|
||||
}
|
||||
|
||||
NSArray *NSGetFileTypes(NSArray *pboardTypes)
|
||||
NSArray*
|
||||
NSGetFileTypes(NSArray *pboardTypes)
|
||||
{
|
||||
NSMutableArray *a = [NSMutableArray arrayWithCapacity: [pboardTypes count]];
|
||||
unsigned int i;
|
||||
|
@ -699,5 +726,29 @@ NSArray *NSGetFileTypes(NSArray *pboardTypes)
|
|||
return nil;
|
||||
}
|
||||
|
||||
void
|
||||
NSUpdateDynamicServices()
|
||||
{
|
||||
system(prog_path(GNUSTEP_INSTALL_PREFIX, "/make_services"));
|
||||
}
|
||||
|
||||
|
||||
static NSConnection *listener = nil;
|
||||
|
||||
void
|
||||
NSRegisterServicesProvider(id provider, NSString *name)
|
||||
{
|
||||
if (listener)
|
||||
{
|
||||
/*
|
||||
* Ensure there is no previous listener and nothing else using
|
||||
* the given port name.
|
||||
*/
|
||||
[[NSPortNameServer defaultPortNameServer] removePortForName: name];
|
||||
[listener release];
|
||||
}
|
||||
listener = [NSConnection newRegisteringAtName: name
|
||||
withRootObject: provider];
|
||||
[listener retain];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue