Make -doService: handle nil return/send types correctly. Fix calls to NSRunAlertPanel().

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@13803 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2002-06-08 18:11:17 +00:00
parent bf66abaffb
commit 5003acb480
2 changed files with 21 additions and 13 deletions

View file

@ -1,3 +1,10 @@
2002-06-08 Alexander Malmberg <alexander@malmberg.org>
* Source/GSServicesProvider.m (-doService:): Only try to
write/read selection if the send/return type isn't nil.
Fix calls to NSRunAlertPanel() so they don't do printf()
expansion on the message twice.
Thu Jun 6 08:29:42 2002 Nicola Pero <n.pero@mi.flashnet.it> Thu Jun 6 08:29:42 2002 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSScroller.m ([NSScroller -setFrame:]): Do not add * Source/NSScroller.m ([NSScroller -setFrame:]): Do not add

View file

@ -455,8 +455,6 @@ static NSString *disabledName = @".GNUstepDisabled";
NSWindow *resp = [[_application keyWindow] firstResponder]; NSWindow *resp = [[_application keyWindow] firstResponder];
id obj = nil; id obj = nil;
NSLog(@"doService: called");
for (i = 0; i <= es; i++) for (i = 0; i <= es; i++)
{ {
NSString *sendType; NSString *sendType;
@ -476,8 +474,9 @@ static NSString *disabledName = @".GNUstepDisabled";
NSPasteboard *pb; NSPasteboard *pb;
pb = [NSPasteboard pasteboardWithUniqueName]; pb = [NSPasteboard pasteboardWithUniqueName];
if ([obj writeSelectionToPasteboard: pb if (sendType
types: sendTypes] == NO) && [obj writeSelectionToPasteboard: pb
types: sendTypes] == NO)
{ {
NSRunAlertPanel(nil, NSRunAlertPanel(nil,
@"object failed to write to pasteboard", @"object failed to write to pasteboard",
@ -485,7 +484,8 @@ static NSString *disabledName = @".GNUstepDisabled";
} }
else if (NSPerformService(title, pb) == YES) else if (NSPerformService(title, pb) == YES)
{ {
if ([obj readSelectionFromPasteboard: pb] == NO) if (returnType
&& [obj readSelectionFromPasteboard: pb] == NO)
{ {
NSRunAlertPanel(nil, NSRunAlertPanel(nil,
@"object failed to read from pasteboard", @"object failed to read from pasteboard",
@ -1259,8 +1259,9 @@ NSPerformService(NSString *serviceItem, NSPasteboard *pboard)
if (service == nil) if (service == nil)
{ {
NSRunAlertPanel(nil, NSRunAlertPanel(nil,
[NSString stringWithFormat: @"No service matching '%@'", serviceItem], @"No service matching '%@'",
@"Continue", nil, nil); @"Continue", nil, nil,
serviceItem);
return NO; /* No matching service. */ return NO; /* No matching service. */
} }
@ -1288,9 +1289,9 @@ NSPerformService(NSString *serviceItem, NSPasteboard *pboard)
if (provider == nil) if (provider == nil)
{ {
NSRunAlertPanel(nil, NSRunAlertPanel(nil,
[NSString stringWithFormat: @"Failed to contact service provider for '%@'",
@"Failed to contact service provider for '%@'", serviceItem], @"Continue", nil, nil,
@"Continue", nil, nil); serviceItem);
return NO; return NO;
} }
@ -1327,9 +1328,9 @@ NSPerformService(NSString *serviceItem, NSPasteboard *pboard)
if (error != nil) if (error != nil)
{ {
NSRunAlertPanel(nil, NSRunAlertPanel(nil,
[NSString stringWithFormat: @"Failed to contact service provider for '%@': %@",
@"Failed to contact service provider for '%@'", serviceItem], @"Continue", nil, nil,
@"Continue", nil, nil); serviceItem, error);
return NO; return NO;
} }