mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 00:21:00 +00:00
2004-11-09 18:55 Alexander Malmberg <alexander@malmberg.org>
* Source/NSPasteboard.m (+_pbs): Give gpbs a --GSStartupNotification argument. Listen for the notification and connect immediately if it arrives. Clarify the user message. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20325 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ee1cfbe06c
commit
e30825e76a
2 changed files with 52 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-11-09 18:55 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Source/NSPasteboard.m (+_pbs): Give gpbs a --GSStartupNotification
|
||||||
|
argument. Listen for the notification and connect immediately if it
|
||||||
|
arrives. Clarify the user message.
|
||||||
|
|
||||||
2004-11-08 Quentin Mathe <qmathe@club-internet.fr>
|
2004-11-08 Quentin Mathe <qmathe@club-internet.fr>
|
||||||
|
|
||||||
* Source/NSButtonCell.m (-setImage:): Added overriden NSCell method in
|
* Source/NSButtonCell.m (-setImage:): Added overriden NSCell method in
|
||||||
|
|
|
@ -529,6 +529,7 @@
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSConnection.h>
|
#include <Foundation/NSConnection.h>
|
||||||
#include <Foundation/NSDistantObject.h>
|
#include <Foundation/NSDistantObject.h>
|
||||||
|
#include <Foundation/NSDistributedNotificationCenter.h>
|
||||||
#include <Foundation/NSMapTable.h>
|
#include <Foundation/NSMapTable.h>
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
@ -1963,7 +1964,6 @@ static NSMapTable *mimeMap = NULL;
|
||||||
{
|
{
|
||||||
static BOOL recursion = NO;
|
static BOOL recursion = NO;
|
||||||
static NSString *cmd = nil;
|
static NSString *cmd = nil;
|
||||||
static NSArray *args = nil;
|
|
||||||
|
|
||||||
if (cmd == nil && recursion ==NO)
|
if (cmd == nil && recursion ==NO)
|
||||||
{
|
{
|
||||||
|
@ -1985,23 +1985,61 @@ static NSMapTable *mimeMap = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NSDistributedNotificationCenter *nc;
|
||||||
|
NSMutableArray *startIndicator;
|
||||||
|
NSArray *args = nil;
|
||||||
|
NSDate *timeoutDate;
|
||||||
|
|
||||||
NSLog(@"\nI couldn't contact the pasteboard server for %@ -\n"
|
NSLog(@"\nI couldn't contact the pasteboard server for %@ -\n"
|
||||||
@"so I'm attempting to to start one - which will take a few seconds.\n"
|
@"so I'm attempting to start one - which might take a few seconds.\n"
|
||||||
@"Trying to launch gpbs from %@ or a machine/operating-system subdirectory.\n"
|
@"Trying to launch gpbs from %@ or a machine/operating-system subdirectory.\n"
|
||||||
@"It is recommended that you start the pasteboard server (gpbs) when\n"
|
@"It is recommended that you start the pasteboard server (gpbs) when\n"
|
||||||
@"your windowing system is started up.\n", description,
|
@"your windowing system is started up.\n", description,
|
||||||
[cmd stringByDeletingLastPathComponent]);
|
[cmd stringByDeletingLastPathComponent]);
|
||||||
|
|
||||||
if ([host length] > 0)
|
if ([host length] > 0)
|
||||||
{
|
{
|
||||||
args = [[NSArray alloc] initWithObjects:
|
args = [[NSArray alloc] initWithObjects:
|
||||||
@"-NSHost", host, nil];
|
@"-NSHost", host,
|
||||||
|
@"-GSStartupNotification",@"GSStartup-GPBS", nil];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args = [[NSArray alloc] initWithObjects:
|
||||||
|
@"-GSStartupNotification",@"GSStartup-GPBS", nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Trick: To avoid having to use global variables or new methods
|
||||||
|
to track whether the notification has been received or not, we
|
||||||
|
use a mutable array as an indicator. When the notification is
|
||||||
|
received, the array is emptied, so we just check the count.
|
||||||
|
*/
|
||||||
|
startIndicator = [[NSMutableArray alloc] initWithObjects:
|
||||||
|
AUTORELEASE([[NSObject alloc] init]), nil];
|
||||||
|
|
||||||
|
nc = [NSDistributedNotificationCenter defaultCenter];
|
||||||
|
[nc addObserver: startIndicator
|
||||||
|
selector: @selector(removeAllObjects)
|
||||||
|
name: @"GSStartup-GPBS"
|
||||||
|
object: nil];
|
||||||
|
|
||||||
[NSTask launchedTaskWithLaunchPath: cmd arguments: args];
|
[NSTask launchedTaskWithLaunchPath: cmd arguments: args];
|
||||||
[NSTimer scheduledTimerWithTimeInterval: 5.0
|
RELEASE(args);
|
||||||
invocation: nil
|
|
||||||
repeats: NO];
|
timeoutDate = [NSDate dateWithTimeIntervalSinceNow: 5.0];
|
||||||
[[NSRunLoop currentRunLoop] runUntilDate:
|
|
||||||
[NSDate dateWithTimeIntervalSinceNow: 5.0]];
|
while ([startIndicator count]
|
||||||
|
&& [timeoutDate timeIntervalSinceNow] > 0.0)
|
||||||
|
{
|
||||||
|
[[NSRunLoop currentRunLoop]
|
||||||
|
runMode: NSDefaultRunLoopMode
|
||||||
|
beforeDate: timeoutDate];
|
||||||
|
}
|
||||||
|
|
||||||
|
[nc removeObserver: startIndicator];
|
||||||
|
DESTROY(startIndicator);
|
||||||
|
|
||||||
recursion = YES;
|
recursion = YES;
|
||||||
[self _pbs];
|
[self _pbs];
|
||||||
recursion = NO;
|
recursion = NO;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue