
#import <IconKit/IKFolder.h>

#import "IKFolderInspector.h"

@implementation IKFolderInspector: IBInspector
{
    id look;
    id options;
    id browserOptions;
}



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

#define DRAGGABLE			0
#define DRAGACCEPTING		1
#define EDITABLE			2

#define HIDDEN				0
#define LEAF				1


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


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


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

    return self;
}


- updateOptions: sender
{
    [[self object]  setEditable: [[sender cellWithTag:EDITABLE]  state]];
    [[self object]  setDraggable: [[sender cellWithTag:DRAGGABLE]  state]];
    [[self object]  setDragAccepting: [[sender cellWithTag:DRAGACCEPTING] state]];

    [self  ok: sender];

    return self;
}


- updateBrowserOptions: sender
{
    [[self object]  setHidden: [[sender cellWithTag:HIDDEN]  state]];
    [[self object]  setLeaf: [[sender cellWithTag:LEAF]  state]];
    [self  ok: sender];

    return self;
}


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


- (void)revert:(id)sender
{
    NSString 	*name = [(IKFolder *)[self object] name];

    NSString	*icon = [[(IKFolder *)[self object] image] name],
        *openIcon = [[(IKFolder *)[self object]  acceptingDragImage] name];
	
    [[look cellWithTag:NAME]  setStringValue: name ? name : @""];
    [[look cellWithTag:ICON] setStringValue:icon ? icon : @""];
    [[look cellWithTag:OPENICON] setStringValue:openIcon ? openIcon : @""];
	
    [[options cellWithTag:EDITABLE]  setIntValue: [[self object]  isEditable]];
    [[options cellWithTag:DRAGGABLE]  setIntValue: [[self object]  isDraggable]];
    [[options cellWithTag:DRAGACCEPTING]  setIntValue:[[self object]  isDragAccepting]];
	
    [[browserOptions cellWithTag:HIDDEN]  setIntValue: [[self object] isHidden]];
    [[browserOptions cellWithTag:LEAF]  setIntValue: [[self object] isLeaf]];
	
    [super revert: sender];
}


- (BOOL) wantsButtons
{
    return NO;
}


@end
