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:
Richard Frith-MacDonald 2008-12-29 08:22:38 +00:00
parent 0568f0a0c5
commit 30d220530a
3 changed files with 49 additions and 15 deletions

View file

@ -1,3 +1,10 @@
2008-12-29 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <FredKiefer@gmx.de>
* Source/NSWindow.m: Remove left over traces of toolbar handling.

View file

@ -100,6 +100,18 @@
begin with a dot ('.') are not shown in the NSSavePanel or
NSOpenPanel.
</p>
<term>GSHelpViewer</term>
<desc>
<p>
A string which can be used to specify the name of the application
to be used to view application help.<br /> 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).<br />
If this is set to <code>NSHelpPanel</code> 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.
</p>
</desc>
<term>GSInsertControlKeystrokes</term>
<desc>

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"])
{