#import <Foundation/NSString.h>

#import <IconKit/IKSuitcase.h>

#import "IKSuitcaseInspector.h"

@implementation IKSuitcaseInspector: IBInspector
{
    id look;
    id classToHold;
}

#define NAME				0
#define ICON				1
#define OPENICON			2


- init
{
    [super init];
    [NSBundle loadNibNamed:@"IKSuitcaseInspector" owner:self];
    return self;
}

- updateLook: sender
{
	NSString
		* name = [[look cellWithTag:NAME] stringValue],
		* icon = [[look cellWithTag:ICON] stringValue],
		* openIcon = [[look cellWithTag:OPENICON] stringValue];
	
    [(IKSuitcase *) [self object]  setName:name];
    [[self object]  setImage: icon ? [NSImage imageNamed:(NSString *)icon] : nil];
    [[self object]  setAcceptingDragImage: openIcon ? [NSImage imageNamed:(NSString *)openIcon] : nil];

    [self  ok: sender];

    return self;
}


- updateClassToHold: sender
{
    [[self object]  setClassToHold: [classToHold stringValue]];
    [self  ok: sender];

    return self;
}


/* ========================================================================== */


/*

The ok: method does nothing.  The revert method needs to initialize itself from the current selection.

*/


- (void)ok:(id)sender
{
	[self  touch: self];
	[super  ok: sender];
}


- (void)revert:(id)sender
{
    NSString 	*s = [[self object] classToHold];
    NSString 	*n = [(IKSuitcase *)[self object] name];
    NSString    *icon = [[(IKSuitcase *)[self object] image] name],
        * openIcon = [[(IKSuitcase *)[self object]  acceptingDragImage] name];
	
    [[look cellWithTag:NAME]  setStringValue: n ? n : @""];
    [[look cellWithTag:ICON] setStringValue:icon ? icon : @""];
    [[look cellWithTag:OPENICON] setStringValue:openIcon ? openIcon : @""];

    [classToHold  setStringValue: s ? s : @""];

    [super revert: sender];
}


- (BOOL) wantsButtons
{
    return NO;
}


@end
