//
//  TestApp3AppDelegate.m
//  TestApp3
//
//  Created by itexmac2 on 27/05/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TestApp3AppDelegate.h"
#import <PreferencePanes/PreferencePanes.h>

@interface NSHelpManager(TeXDist)
- (void)openHelpAnchor:(NSString *)anchor inBook:(NSString *)book;
@end

@implementation TestApp3AppDelegate


@synthesize preferencePane;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSString * BIPIP = [NSBundle mainBundle].builtInPlugInsPath;
    NSString * prefPanePath = [BIPIP stringByAppendingPathComponent:TEXDIST_PREFPANE_NAME];
    NSLog(@"prefPanePath:%@",prefPanePath);
    NSBundle * B = [NSBundle bundleWithPath:prefPanePath];
    NSLog(@"B:%@",B);
    NSAssert([B load],@"MISSED");
    Class PFClass = B.principalClass;
    self.preferencePane = [[[PFClass alloc] initWithBundle:B] autorelease];
    NSView * MV = [self.preferencePane loadMainView];
    window.contentView = MV;
    [self.preferencePane didSelect];
}

- (IBAction)reset:(id)irrelevant;
{
    [self.preferencePane didUnselect];
    [self.preferencePane didSelect];
}
- (IBAction)showHelp:(id)irrelevant;
{
    NSHelpManager * SHM = [NSHelpManager sharedHelpManager];
    if ([SHM respondsToSelector:@selector(openHelpAnchor:inBook:)]) {
        NSLog(@"Searching 'access' in help book %@",TeXDist_HELP_BOOK_ID);
        [SHM openHelpAnchor:@"access" inBook:TeXDist_HELP_BOOK_ID];
    }
    return;
}
@end
