mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 19:01:15 +00:00
improve handling of external viewer success or failure, return early in case of success
This commit is contained in:
parent
62a162ed99
commit
60aca74336
1 changed files with 41 additions and 38 deletions
|
@ -221,54 +221,57 @@
|
|||
{
|
||||
result = [[NSWorkspace sharedWorkspace] openFile: file
|
||||
withApplication: viewer];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == NO)
|
||||
{
|
||||
NSHelpPanel *panel;
|
||||
NSTextView *tv;
|
||||
id object = nil;
|
||||
// external viewer succeeded
|
||||
if (result)
|
||||
return;
|
||||
|
||||
panel = [NSHelpPanel sharedHelpPanel];
|
||||
tv = [(NSScrollView*)[panel contentView] documentView];
|
||||
if (ext == nil
|
||||
// fallback to internal viewer
|
||||
{
|
||||
NSHelpPanel *panel;
|
||||
NSTextView *tv;
|
||||
id object = nil;
|
||||
|
||||
panel = [NSHelpPanel sharedHelpPanel];
|
||||
tv = [(NSScrollView*)[panel contentView] documentView];
|
||||
if (ext == nil
|
||||
|| [ext isEqualToString: @""]
|
||||
|| [ext isEqualToString: @"txt"]
|
||||
|| [ext isEqualToString: @"text"])
|
||||
{
|
||||
object = [NSString stringWithContentsOfFile: file];
|
||||
}
|
||||
else if ([ext isEqualToString: @"rtf"])
|
||||
{
|
||||
NSData *data = [NSData dataWithContentsOfFile: file];
|
||||
{
|
||||
object = [NSString stringWithContentsOfFile: file];
|
||||
}
|
||||
else if ([ext isEqualToString: @"rtf"])
|
||||
{
|
||||
NSData *data = [NSData dataWithContentsOfFile: file];
|
||||
|
||||
object = [[NSAttributedString alloc] initWithRTF: data
|
||||
documentAttributes: 0];
|
||||
AUTORELEASE (object);
|
||||
}
|
||||
else if ([ext isEqualToString: @"rtfd"])
|
||||
{
|
||||
NSFileWrapper *wrapper;
|
||||
object = [[NSAttributedString alloc] initWithRTF: data
|
||||
documentAttributes: 0];
|
||||
AUTORELEASE (object);
|
||||
}
|
||||
else if ([ext isEqualToString: @"rtfd"])
|
||||
{
|
||||
NSFileWrapper *wrapper;
|
||||
|
||||
wrapper = [[NSFileWrapper alloc] initWithPath: file];
|
||||
AUTORELEASE (wrapper);
|
||||
object = [[NSAttributedString alloc]
|
||||
initWithRTFDFileWrapper: wrapper
|
||||
documentAttributes: 0];
|
||||
AUTORELEASE (object);
|
||||
}
|
||||
wrapper = [[NSFileWrapper alloc] initWithPath: file];
|
||||
AUTORELEASE (wrapper);
|
||||
object = [[NSAttributedString alloc]
|
||||
initWithRTFDFileWrapper: wrapper
|
||||
documentAttributes: 0];
|
||||
AUTORELEASE (object);
|
||||
}
|
||||
|
||||
if (object != nil)
|
||||
{
|
||||
[[tv textStorage] setAttributedString: object];
|
||||
[tv sizeToFit];
|
||||
}
|
||||
[tv setNeedsDisplay: YES];
|
||||
[panel makeKeyAndOrderFront: self];
|
||||
return;
|
||||
}
|
||||
if (object != nil)
|
||||
{
|
||||
[[tv textStorage] setAttributedString: object];
|
||||
[tv sizeToFit];
|
||||
}
|
||||
[tv setNeedsDisplay: YES];
|
||||
[panel makeKeyAndOrderFront: self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue