MACOSX: Improve opening files from the Help menu
Now in addition to rtf extension and no extension, it also looks for the html and md extensions. Also unless the extension is RTF or HTML, which are widely recognized, it explicitely indicate that the file should be open with TextEdit. This fixes bug #10938, with opening the README and NEWS file from the Help menu failing when the bundle was compiled without using pandoc and thus the only files available are the markdown ones. Support for the html extension is to prepare for a future change to have a nicer README than the plain text one.
This commit is contained in:
parent
a663930dd0
commit
66ef22d555
1 changed files with 13 additions and 2 deletions
|
@ -61,12 +61,23 @@ typedef unsigned long NSUInteger;
|
|||
|
||||
static void openFromBundle(NSString *file) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:file ofType:@"rtf"];
|
||||
if (!path) {
|
||||
path = [[NSBundle mainBundle] pathForResource:file ofType:@"html"];
|
||||
if (!path) {
|
||||
path = [[NSBundle mainBundle] pathForResource:file ofType:@""];
|
||||
if (!path)
|
||||
path = [[NSBundle mainBundle] pathForResource:file ofType:@"md"];
|
||||
}
|
||||
}
|
||||
|
||||
if (path) {
|
||||
// RTF and HTML files are widely recognized and we can rely on the default
|
||||
// file association working for those. For the other ones this might not be
|
||||
// the case so we explicitely indicate they should be open with TextEdit.
|
||||
if ([path hasSuffix:@".html"] || [path hasSuffix:@".rtf"])
|
||||
[[NSWorkspace sharedWorkspace] openFile:path];
|
||||
else
|
||||
[[NSWorkspace sharedWorkspace] openFile:path withApplication:@"TextEdit"];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue