diff --git a/ChangeLog b/ChangeLog
index 7ee4ca957..a33a46c10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-29 Richard Frith-Macdonald
+
+ * Source/NSHelpManager.m: Allow the GSHelpViewer user default to
+ control how application help is displayed.
+ * Documentation/GuiUser/DefaultsSummary.gsdoc: Document the new
+ user default.
+
2008-12-28 Fred Kiefer
* Source/NSWindow.m: Remove left over traces of toolbar handling.
diff --git a/Documentation/GuiUser/DefaultsSummary.gsdoc b/Documentation/GuiUser/DefaultsSummary.gsdoc
index 42fbe47ec..edf7ca6e3 100644
--- a/Documentation/GuiUser/DefaultsSummary.gsdoc
+++ b/Documentation/GuiUser/DefaultsSummary.gsdoc
@@ -100,6 +100,18 @@
begin with a dot ('.') are not shown in the NSSavePanel or
NSOpenPanel.
+ GSHelpViewer
+
+
+ A string which can be used to specify the name of the application
+ to be used to view application help.
If this is not specified
+ (or is an empty string) the 'best' available viewer is used (an
+ application whose Info.plist says that it can view files of the
+ appropriate type ... usually rtp or rtfd files).
+ If this is set to NSHelpPanel
or if no application can
+ be used to view the help file, the help is displayed by the
+ shared help panel object built in to the application.
+
GSInsertControlKeystrokes
diff --git a/Source/NSHelpManager.m b/Source/NSHelpManager.m
index b6f74e850..11cabe4fe 100644
--- a/Source/NSHelpManager.m
+++ b/Source/NSHelpManager.m
@@ -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"])
{