Add GSHelpViewer user default

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27447 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2008-12-29 08:22:38 +00:00
parent 6c0a0ef0cb
commit 06ff2b01a8
3 changed files with 49 additions and 15 deletions

View file

@ -166,22 +166,21 @@
- (void) showHelp: (id)sender
{
NSBundle *mb = [NSBundle mainBundle];
NSDictionary *info = [mb infoDictionary];
NSString *help;
help = [info objectForKey: @"GSHelpContentsFile"];
NSBundle *mb = [NSBundle mainBundle];
NSDictionary *info = [mb infoDictionary];
NSString *help = [info objectForKey: @"GSHelpContentsFile"];
if (help == nil)
{
/* If there's no specification, we look for a files named
* "appname.rtfd" or "appname.rtf"
*/
help = [info objectForKey: @"NSExecutable"];
// If there's no specification, we look for a files named
// "appname.rtfd" or "appname.rtf"
}
if (help != nil)
{
NSString *file = nil;
NSString *file;
if ([[help pathExtension] length] == 0)
{
@ -201,21 +200,37 @@
if (file != nil)
{
if ([[NSWorkspace sharedWorkspace] openFile: file] == YES)
BOOL result = NO;
NSString *ext = [file pathExtension];
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSString *viewer;
viewer = [[NSUserDefaults standardUserDefaults]
stringForKey: @"GSHelpViewer"];
if ([viewer isEqual: @"NSHelpPanel"] == NO)
{
return;
if ([viewer length] == 0)
{
viewer = [ws getBestAppInRole: @"Viewer" forExtension: ext];
}
if (viewer != nil)
{
result = [[NSWorkspace sharedWorkspace] openFile: file
withApplication: viewer];
}
}
else
if (result == NO)
{
NSHelpPanel *panel = [NSHelpPanel sharedHelpPanel];
NSString *ext = [file pathExtension];
NSHelpPanel *panel;
NSTextView *tv;
id object;
panel = [NSHelpPanel sharedHelpPanel];
tv = [(NSScrollView*)[panel contentView] documentView];
if (ext == nil
|| [ext isEqualToString: @""]
|| [ext isEqualToString: @""]
|| [ext isEqualToString: @"txt"]
|| [ext isEqualToString: @"text"])
{