//
//	File:		ICeCoffEEController.m
//
//	Contains:	ICeCoffEE APE preference pane controller
//
//	Copyright:	Copyright (c) 2003, Nicholas Riley
//			All Rights Reserved.
//
//	Author(s):	Nicholas Riley (Sun Jan 19 2003)
//
// ===========================================================================

#import <ApplicationEnhancer/ApplicationEnhancer.h>
#import "ICeCoffEEController.h"

// Just a handy macro for localized strings from our bundle; unused in this project.
#define NSLocalizedString_(key, comment) [[self bundle] localizedStringForKey:(key) value:@"" table:nil]

@implementation ICeCoffEEController

// This method should return an id of a class that implements the protocol
// required by APE Manager.

+ (id)prefPaneHandlerForAPE:(NSBundle*)apeBundle andBundle:(NSBundle*)prefPaneBundle
{
    return [[self alloc] initWithAPE:apeBundle andBundle:prefPaneBundle];
}

// Init the instance of our class
- (id)initWithAPE:(NSBundle*)apeBundle andBundle:(NSBundle*)prefPaneBundle
{
    [self setBundle:prefPaneBundle];			// save our bundle for future use
    
    [NSBundle loadNibNamed:@"APE Manager plugin" owner:self];	// load our nib file; it will call our awakeFromNib method
    
    return self;
}

// This method is called when the preference pane is about to be shown.
- (void)willLoad
{
    // we do nothing here
}

// This method is called when the preference pane will be dismissed.
- (void)willUnload
{
    // we do nothing here, as well
}

// This method should return an NSView to be loaded into APE Manager preference
// area.
- (NSView*)mainView
{
    return [window contentView];			// we return our window's contentView
}

// This method is called once our nib file is loaded (we load it in the init method)
- (void)awakeFromNib
{  
    prefs = [[CFPreferencesWrapper_ICeCoffEE preferencesWithApplication:@"net.sabi.ICeCoffEE"] retain];
                                                        // load the preferences for our APE module 

    // do other inits here
}

- (void)setBundle:(NSBundle *)aBundle;
{
    [aBundle retain];
    [_bundle release];
    _bundle = aBundle;
}

- (NSBundle *)bundle;
{
    [_bundle autorelease];
    return [_bundle retain];
}
@end
