//
//  TestApp2AppDelegate.m
//  TestApp2
//
//  Created by itexmac2 on 06/05/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TestApp2AppDelegate.h"
#import "TeXDistController.h"
#import "TeXDistCommon.h"
#import "TeXDistAuthentication.h"
#import "TeXDistributionUtils.h"

@implementation TestApp2AppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSLog(@"%@",NSLocalizedStringFromTableInBundle(@"texbin", nil, [NSBundle bundleForClass:[TeXDistArchitecture class]], @"None"));
}
- (NSUInteger)countOfDistributions;
{
	return [TeXDistController sharedController].distributions.count;
}
- (id)objectInDistributionsAtIndex:(NSUInteger)index;
{
	return [[TeXDistController sharedController].distributions objectAtIndex:index];
}
- (IBAction)showHelp:(id)irrelevant;
{
}
- (IBAction)reset:(id)irrelevant;
{
	NSLog(@"**** [TeXDistPrefPane didSelect]: There must be an active distribution... Checking");
	[self willChangeValueForKey:@"distributions"];
    NSError * ROR;
	if (NOT [[TeXDistController sharedController] resetAndReturnError:&ROR]) {
        [[TeXDistController sharedController] reportError:ROR];
    }
	[self didChangeValueForKey:@"distributions"];
	if (NOT self.countOfDistributions) {
		NSRunAlertPanel(IL8N(@"NO TEX DISTRIBUTION AVAILABLE"), IL8N(@"PLEASE INSTALL A TEX DISTRIBUTION"), nil,nil,nil);
    }
	[[TeXDistAuthentication sharedInstance] invalidateCredentials];
    return;
}
@end
