ftp.nice.ch/pub/next/database/apps/RZToDoList.1.1.s.tar.gz#/RZToDoList/FileImage.m

This is FileImage.m in view mode; [Download] [Up]

/* 
 * FileImage
 *
 * A GraphicImage subclass that represents a file
 *
 * You may freely copy, distribute and reuse the code in this example.
 * This code is provided AS IS without warranty of any kind, expressed 
 * or implied, as to its fitness for any particular use.
 *
 * Copyright 1995 Ralph Zazula (rzazula@next.com).  All Rights Reserved.
 *
 */

#import <libc.h>			// for free()
#import <sys/param.h>			// for MAXPATHLEN
#import <appkit/NXImage.h>
#import <appkit/Speaker.h>
#import <appkit/Listener.h>
#import <appkit/Panel.h>		// for NXRunAlertPanel()
#import <appkit/Application.h>
#import "FileImage.h"

@implementation FileImage


- initForImage:anImage fileName:(const char *)name
{
    [super init];
    
  /* save our graphic image and the file we represent */
    image = anImage;
    fileName = NXCopyStringBuffer(name);
    
    return self;
}

- free
{
    free(fileName);
    return [super free];
}

- readRichText:(NXStream *)stream forView:view
{
    char	stringBuffer[MAXPATHLEN], *currentPosition, nextChar;
	     
  /* get and remember the file name */
    currentPosition = stringBuffer;
    while ((nextChar = NXGetc(stream)) != '\n') {
        *(currentPosition++) = nextChar;
    }
    *currentPosition = '\0';
    fileName = NXCopyStringBuffer(stringBuffer);

	image = [[Application workspace] getIconForFile:fileName];
	
    return self;
}

- writeRichText:(NXStream *)stream forView:view
{
  /* 
   * for files, we write the file name;  this isn't a robust solution since
   * the file may not be present when the user reopens the RTF file
   */
    NXPrintf(stream, "%s\n", fileName);
    
    return self;
}

- performDoubleClickAction
{
	if(![[Application workspace] openFile:fileName])
   	NXRunAlertPanel(NULL, "Couldn't open %s", NULL, NULL, NULL, fileName);
    return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.