mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-20 14:36:36 +00:00
merge in themes branch to keep in sync
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23705 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c8e6566831
commit
c033d17a2d
13 changed files with 1446 additions and 372 deletions
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
@ -36,13 +37,14 @@
|
|||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSWorkspace.h"
|
||||
#include "AppKit/NSHelpManager.h"
|
||||
#include "AppKit/NSHelpPanel.h"
|
||||
#include "AppKit/NSGraphics.h"
|
||||
|
||||
#include "GNUstepGUI/GSHelpManagerPanel.h"
|
||||
|
||||
@implementation NSBundle (NSHelpManager)
|
||||
|
||||
- (NSString *)pathForHelpResource:(NSString *)fileName
|
||||
- (NSString *) pathForHelpResource: (NSString *)fileName
|
||||
{
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
|
@ -59,6 +61,7 @@
|
|||
while ((language = [enumerator nextObject]))
|
||||
{
|
||||
NSString *langDir = [NSString stringWithFormat: @"%@.lproj", language];
|
||||
|
||||
[array addObject: [primary stringByAppendingPathComponent: langDir]];
|
||||
}
|
||||
|
||||
|
@ -71,6 +74,7 @@
|
|||
while ((language = [enumerator nextObject]))
|
||||
{
|
||||
NSString *langDir = [NSString stringWithFormat: @"%@.lproj", language];
|
||||
|
||||
[array addObject: [primary stringByAppendingPathComponent: langDir]];
|
||||
}
|
||||
|
||||
|
@ -107,7 +111,7 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (NSAttributedString *)contextHelpForKey:(NSString *)key
|
||||
- (NSAttributedString *) contextHelpForKey: (NSString *)key
|
||||
{
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSString *dictPath = [self pathForResource: @"Help" ofType: @"plist"];
|
||||
|
@ -127,8 +131,8 @@
|
|||
if (helpFile)
|
||||
{
|
||||
NSData *data = [helpFile objectForKey: @"NSHelpRTFContents"];
|
||||
return ((data != nil) ? [NSUnarchiver unarchiveObjectWithData: data] :
|
||||
nil) ;
|
||||
return ((data != nil) ? [NSUnarchiver unarchiveObjectWithData: data]
|
||||
: nil);
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -137,8 +141,10 @@
|
|||
|
||||
if (helpFile)
|
||||
{
|
||||
NSString *helpstr = [[NSAttributedString alloc] initWithPath: helpFile
|
||||
documentAttributes: NULL];
|
||||
NSString *helpstr;
|
||||
|
||||
helpstr = [[NSAttributedString alloc] initWithPath: helpFile
|
||||
documentAttributes: NULL];
|
||||
return TEST_AUTORELEASE (helpstr);
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +171,7 @@
|
|||
// "appname.rtfd" or "appname.rtf"
|
||||
}
|
||||
|
||||
if (help)
|
||||
if (help != nil)
|
||||
{
|
||||
NSString *file = nil;
|
||||
|
||||
|
@ -180,13 +186,64 @@
|
|||
[help stringByAppendingPathExtension: @"rtf"]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file = [mb pathForHelpResource: help];
|
||||
}
|
||||
|
||||
if (file)
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openFile: file];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file != nil)
|
||||
{
|
||||
if ([[NSWorkspace sharedWorkspace] openFile: file] == YES)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSHelpPanel *panel = [NSHelpPanel sharedHelpPanel];
|
||||
NSString *ext = [file pathExtension];
|
||||
NSTextView *tv;
|
||||
id object;
|
||||
|
||||
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 = [[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);
|
||||
}
|
||||
|
||||
if (object != nil)
|
||||
{
|
||||
[[tv textStorage] setAttributedString: object];
|
||||
[tv sizeToFit];
|
||||
}
|
||||
[tv setNeedsDisplay: YES];
|
||||
[panel makeKeyAndOrderFront: self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSBeep();
|
||||
}
|
||||
|
@ -207,7 +264,7 @@ static BOOL _gnu_contextHelpActive = NO;
|
|||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (NSHelpManager*)sharedHelpManager
|
||||
+ (NSHelpManager*) sharedHelpManager
|
||||
{
|
||||
if (!_gnu_sharedHelpManager)
|
||||
{
|
||||
|
@ -217,12 +274,12 @@ static BOOL _gnu_contextHelpActive = NO;
|
|||
return _gnu_sharedHelpManager;
|
||||
}
|
||||
|
||||
+ (BOOL)isContextHelpModeActive
|
||||
+ (BOOL) isContextHelpModeActive
|
||||
{
|
||||
return _gnu_contextHelpActive;
|
||||
}
|
||||
|
||||
+ (void)setContextHelpModeActive: (BOOL) flag
|
||||
+ (void) setContextHelpModeActive: (BOOL) flag
|
||||
{
|
||||
_gnu_contextHelpActive = flag;
|
||||
if (flag)
|
||||
|
@ -287,7 +344,7 @@ static BOOL _gnu_contextHelpActive = NO;
|
|||
NSMapRemove(contextHelpTopics, object);
|
||||
}
|
||||
|
||||
- (void)setContextHelp:(NSAttributedString *)help forObject:(id)object
|
||||
- (void) setContextHelp: (NSAttributedString *)help forObject: (id)object
|
||||
{
|
||||
NSMapInsert(contextHelpTopics, object, help);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue