News Software Download Buy Now About Us Developers Contact
software TOC | PREV | NEXT
//
// GifWindow.h
//
#import <AppKit/AppKit.h>

@interface GifWindow : NSWindow
{
    unsigned int last;
    NSString *filename;
}
@end

#import "
GifWindow.h"
#import "
GifController.h"

@implementation GifWindow

- (void) awakeFromNib
{
    [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
}

- (unsigned int) checkFilename:(NSString *)f
{
    [filename autorelease];
    filename = [f retain];

    return NSDragOperationCopy;
}

- (unsigned int) draggingUpdated:sender
{
    return last;
}

//
// One small note
// We ask the delegate if the file is GIF
// because on Rhapsody, we know how to make anything a GIF!
//

- (BOOL) isGifDirectoryOrFile:(NSString *)n
{
    BOOL isDirectory;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    BOOL canRead = [fileManager fileExistsAtPath:n isDirectory:&isDirectory];
    return (canRead && ( isDirectory || [[self delegate] isGifFile:n]));
}

- (unsigned int) draggingEntered:sender
{
    NSPasteboard    *pboard;
    NSArray        *fnames;
    NSString        *fn;
    int            i, n;

    last        = NSDragOperationNone;
    pboard    = [sender draggingPasteboard];

    if ([[pboard types] containsObject:NSFilenamesPboardType]) {
        fnames = [pboard propertyListForType:NSFilenamesPboardType];
        n = [fnames count];
        for (i = 0; i < n && last == NSDragOperationNone; i++) {
            fn = [fnames objectAtIndex:i];
            if ([self isGifDirectoryOrFile:fn])
                last = [self checkFilename:fn];
        }
    }
    return last;
}

- (BOOL) prepareForDragOperation:sender
{
    return YES;
}

- (BOOL) performDragOperation:(id <NSDraggingInfo>)sender
{
    BOOL ret = [[self delegate] tryAndLoadPath:filename];
    if (ret) [NSApp activateIgnoringOtherApps:YES];
    return ret;
}


@end
TOC | PREV | NEXT
Created by Stone Design's Create on 4/30/1998
©2000 Stone Design top