|
TOC | PREV | NEXT
Services
GIFfun adds a menu item to the Service Menu in other applications:
"GIFfun/Create Animated GIF". This allows you, for example, to select a folder in Workspace that has some images in it, and let you launch GIFfun which will animate the frames and produce an Animated GIF.
The work required by the programmer is very small:
1. Add a new file "CustomInfo.plist" to "Supporting Files" in Project Builder which describes the service offered. Here's GIFfun's CustomInfo.plist:
{
NSServices = (
{ NSPortName = GIFfun;
NSMessage = loadAFileOrDirectory;
NSSendTypes = (NSFilenamesPboardType);
NSUserData = "0";
NSMenuItem = {
default = "GIFfun/Create Animated GIF";
English = "GIFfun/Create Animated GIF";
};
},
);
}
2. Register the service provider in the object which responds to the NSMessage, and do it early (before the app finishes launching):
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
[[notification object] setServicesProvider:self];
...
3. Write the method which will be called, which is loadAFileOrDirectory in GIFfun:
- (void)loadAFileOrDirectory:(NSPasteboard *)pb userData:(NSString *)ud error:(NSString **)msg
{
NSArray *fileNames;
int i, count;
fileNames = [pb propertyListForType:NSFilenamesPboardType];
count = [fileNames count];
// if just one dude, send it through our routines
if (count == 1) {
[self tryAndDoEverything:[fileNames objectAtIndex:0]];
} else {
for (i = 0; i < [fileNames count]; i++) {
NSString *n = [fileNames objectAtIndex:i];
if ([self isGifFile:n]) [self addGifFile:n];
}
[self mergeGifs:self];
}
}
TOC | PREV | NEXT
Created by Stone Design's Create on 4/30/1998
|
|