Fixup to behave like MacOS-X on duplicate launch.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22134 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-12-04 08:55:21 +00:00
parent bd69452e95
commit beb8fdb1fe

View file

@ -1048,28 +1048,27 @@ static NSString *disabledName = @".GNUstepDisabled";
if (registered == NO) if (registered == NO)
{ {
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSString *def = [defs objectForKey: @"NSUseRunningCopy"]; if ([defs boolForKey: @"NSUseRunningCopy"] == YES)
int result; {
id app;
if (def != nil) /*
{ * Try to activate the other app and terminate self.
if ([def boolValue] == YES) */
app = [NSConnection rootProxyForConnectionWithRegisteredName: appName
host: @""];
NS_DURING
{ {
result = NSAlertOtherReturn; [app activateIgnoringOtherApps: YES];
} }
else NS_HANDLER
{ {
result = NSAlertAlternateReturn; /* maybe it terminated. */
} }
NS_ENDHANDLER
registered = NO;
} }
else else
{
result = NSRunAlertPanel(appName,
@"Application may already be running with this name",
@"Continue", @"Abort", @"Rename");
}
if (result == NSAlertOtherReturn)
{ {
unsigned count = 0; unsigned count = 0;
@ -1093,64 +1092,10 @@ static NSString *disabledName = @".GNUstepDisabled";
} }
NS_ENDHANDLER NS_ENDHANDLER
} }
}
if (result == NSAlertDefaultReturn)
{
id app;
/*
* Try to terminate the other app and run using normal name.
*/
app = [NSConnection rootProxyForConnectionWithRegisteredName: appName
host: @""];
NS_DURING
{
[app terminate: nil];
}
NS_HANDLER
{
/* maybe it terminated. */
}
NS_ENDHANDLER
NS_DURING
{
NSRegisterServicesProvider(self, appName);
registered = YES;
}
NS_HANDLER
{
registered = NO;
}
NS_ENDHANDLER
}
if (result == NSAlertAlternateReturn)
{
id app;
/*
* Try to activate the other app and terminate self.
*/
app = [NSConnection rootProxyForConnectionWithRegisteredName: appName
host: @""];
NS_DURING
{
[app activateIgnoringOtherApps: YES];
}
NS_HANDLER
{
/* maybe it terminated. */
}
NS_ENDHANDLER
registered = NO;
}
if (result == NSAlertDefaultReturn || result == NSAlertOtherReturn)
{
if (registered == NO) if (registered == NO)
{ {
int result;
/* /*
* Something is seriously wrong - we can't talk to the * Something is seriously wrong - we can't talk to the
* nameserver, so all interaction with the workspace manager * nameserver, so all interaction with the workspace manager