This is Briefcase.m in view mode; [Download] [Up]
#import "Briefcase.h"
#import "BriefDoc.h"
#import "PrefDelegate.h"
#import "Utility.h"
#import <appkit/MenuCell.h>
#import <appkit/OpenPanel.h>
@implementation Briefcase:MultApp
/* Canon Information Systems is not responsible for anything anyone does with this */
/* code, nor are they responsible for the correctness of this code. Basically, this */
/* has very little to do with the company I work for, and you can't blame them. */
/* This file is best read in a window as wide as this comment, and with tab settings */
/* of 4 spaces and indent setting of 4 spaces (at least, that's what I use). */
/* You are welcome to do as you would with this file under the following conditions. */
/* First, I accept no blame for anything that goes wrong no matter how you use it, */
/* no matter how catastrophic, not even if it stems from a bug in my code. */
/* Second, please keep my notices on it when/if you distribute it. */
/* Third, if you discover any bugs or have any comments, PLEASE TELL ME! Code won't */
/* get better without people picking it apart and giving the writer feedback. */
/* Fourth, if you modify it, please keep a notice that your version is based on mine */
/* in the source files (and keep the notice that mine is based on four other pieces */
/* of code :<). Thanks, and have fun. - Subrata Sircar, ssircar@canon.com */
/* This class is an instance of the application delegate class. */
/* It handles the drag and drop functions, and the communication */
/* with the Workspace. */
/* Version 1.0b Apr-19-92 Third Public Release */
/* Version 2.0b Jan-19-93 Fourth Public Release */
#define MY_VERSION 200
/* Target/Action Methods */
- addFile:sender
/*
* Called by pressing Add File... in the Document menu.
* Use the OpenPanel to get filenames and add them to the current document
*/
{
char tempBuf[8192];
char fileBuf[MAXPATHLEN+1];
const char *directory;
const char *const *files;
static const char *const myType[1] = {NULL};
id openpanel = [[OpenPanel new] allowMultipleFiles:YES];
tempBuf[0] = '\0';
directory = [[self currentDocument] directory];
if (directory && (*directory == '/')) [openpanel setDirectory:directory];
if ([openpanel runModalForTypes:myType]) {
files = [openpanel filenames];
directory = [openpanel directory];
while (files && *files) {
/* Get pathnames and add them to the current Document */
sprintf(fileBuf,"%s/%s\n",directory,*files);
strcat(tempBuf,fileBuf);
files++;
}
[[self currentDocument] addFiles:tempBuf];
}
return self;
}
/* Automatic update methods */
- (BOOL)validateCommand:menuCell
/*
* Validate the "Add Files" menu item if we have a current document
*/
{
if ([super validateCommand:menuCell]) {
if ([menuCell action] == @selector(addFile:)) return [self currentDocument] ? YES : NO;
else return YES;
} else return NO;
}
/* Application Delegate Methods */
- appWillInit:sender
/*
* Insert our document class instead of whatever our superclass uses
*/
{
[[self class] setDocClass:[BriefDoc class]];
[super appWillInit:self];
[[self class] setVersion:MY_VERSION];
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.