mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 08:21:00 +00:00
Implement user default to select behavior with multiple copies of app
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22133 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
76d8b6f824
commit
edc873246a
2 changed files with 52 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2005-12-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSServicesManager.m: Implement use of NSUseRunningCopy
|
||||||
|
|
||||||
2005-11-29 Fabien VALLON <fabien@sonappart.net>
|
2005-11-29 Fabien VALLON <fabien@sonappart.net>
|
||||||
|
|
||||||
* Source/NSCachedImageRep.m : Improved documentation
|
* Source/NSCachedImageRep.m : Improved documentation
|
||||||
|
|
|
@ -324,6 +324,12 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
||||||
{
|
{
|
||||||
id delegate = [[NSApplication sharedApplication] delegate];
|
id delegate = [[NSApplication sharedApplication] delegate];
|
||||||
|
|
||||||
|
if ([selName isEqualToString: @"activateIgnoringOtherApps:"])
|
||||||
|
{
|
||||||
|
[anInvocation invokeWithTarget: NSApp];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ([selName hasPrefix: @"application:"] == YES)
|
if ([selName hasPrefix: @"application:"] == YES)
|
||||||
{
|
{
|
||||||
if ([delegate respondsToSelector: aSel] == YES)
|
if ([delegate respondsToSelector: aSel] == YES)
|
||||||
|
@ -1041,9 +1047,27 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
|
|
||||||
if (registered == NO)
|
if (registered == NO)
|
||||||
{
|
{
|
||||||
int result = NSRunAlertPanel(appName,
|
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
NSString *def = [defs objectForKey: @"NSUseRunningCopy"];
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (def != nil)
|
||||||
|
{
|
||||||
|
if ([def boolValue] == YES)
|
||||||
|
{
|
||||||
|
result = NSAlertOtherReturn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = NSAlertAlternateReturn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = NSRunAlertPanel(appName,
|
||||||
@"Application may already be running with this name",
|
@"Application may already be running with this name",
|
||||||
@"Continue", @"Abort", @"Rename");
|
@"Continue", @"Abort", @"Rename");
|
||||||
|
}
|
||||||
|
|
||||||
if (result == NSAlertOtherReturn)
|
if (result == NSAlertOtherReturn)
|
||||||
{
|
{
|
||||||
|
@ -1102,6 +1126,27 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
NS_ENDHANDLER
|
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 (result == NSAlertDefaultReturn || result == NSAlertOtherReturn)
|
||||||
{
|
{
|
||||||
if (registered == NO)
|
if (registered == NO)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue