This is InformerInspector.m in view mode; [Download] [Up]
// InformerInspector.m
//
// History :
// 10.02.1992 : created by Max Tardiveau
#import "InformerInspector.h"
@implementation InformerInspector
////////////////////////////////////////////////////////////////
// Override this method for inspectors that also list items.
- fillList:theMatrix fromCell:theCell
{
return self;
}
////////////////////////////////////////////////////////////////
// This method should rarely need to be overridden. It just loads
// the .nib file "Main.nib" and returns the view containing the
// inspector.
- loadEverythingFrom:(char *)theDir
{
char tmpchar[512];
sprintf(tmpchar, "%s/Main.nib", theDir);
if ([NXApp loadNibFile:tmpchar owner:self withNames:NO] == NIL)
return NIL;
return MyView;
}
////////////////////////////////////////////////////////////////
// You should always override this method : put all the update
// stuff in there.
- doUpdateForCell:theCell
{
return self;
}
////////////////////////////////////////////////////////////////
//
- mainView
{
return MyView;
}
////////////////////////////////////////////////////////////////
//
- fillSubList:theMatrix ofCell:theCell pointer:(void *)thePointer
{
[self fillSubList:theMatrix ofCell:theCell pointer:thePointer secPointer:NULL
string:NULL];
return self;
}
////////////////////////////////////////////////////////////////
//
- fillSubList:theMatrix ofCell:theCell pointer:(void *)thePointer
string:(char *)theString
{
[self fillSubList:theMatrix ofCell:theCell pointer:thePointer secPointer:NULL
string:theString];
return self;
}
////////////////////////////////////////////////////////////////
//
- fillSubList:theMatrix ofCell:theCell pointer:(void *)thePointer
secPointer:(void *)secPointer string:(char *)theString
{
struct stat myStat;
DIR *myDirStream;
struct direct *myDir;
char tmpName[256];
char tmpChar[512];
char *tmpcharptr;
id newCell;
int tmpInt;
myDirStream = opendir([theCell getDir]);
if (myDirStream == NIL)
{
fprintf(stderr, "InformerInspector : could not find directory.\n");
return self;
}
for (myDir = readdir(myDirStream); myDir != NULL;
myDir = readdir(myDirStream))
{
if (myDir->d_name[0] == '.') // Don't display . dirs
continue;
tmpInt = strlen(myDir->d_name); // Don't display .nib dirs
if ( ! strcmp(&myDir->d_name[tmpInt - 4], ".nib"))
continue;
sprintf(tmpChar, "%s/%s", [theCell getDir], myDir->d_name);
stat(tmpChar, &myStat);
if (myStat.st_mode & S_IFDIR) // It is a directory
{
[theMatrix addRow];
strncpy(tmpName, myDir->d_name, 255); // The name for now
newCell = [theMatrix cellAt:([theMatrix cellCount] -1) :0];
if (strlen(myDir->d_name) > 5) // Check if .item dir
{
strncpy(tmpChar, myDir->d_name, 511);
tmpcharptr = tmpChar;
tmpcharptr += (strlen(tmpcharptr) - 5);
if ( ! strcmp(tmpcharptr, ".item")) // It is a .item
{
[newCell setLeaf:YES];
*tmpcharptr = '\0'; // Remove .item ending
strncpy(tmpName, tmpChar, 255);
}
else if ( ! strcmp(tmpcharptr, ".list")) // It is a .list
{
[newCell setIsList:YES];
*tmpcharptr = '\0'; // Remove .list ending
strncpy(tmpName, tmpChar, 255);
}
}
sprintf(tmpChar, "%s/%s", [theCell getDir], myDir->d_name);
[newCell setDir:tmpChar];
[newCell setStringValue:tmpName]; // Give the cell its name
[newCell setFreePointer:thePointer];
[newCell setSecondaryPointer:secPointer];
if (theString)
[newCell setFreeString:theString];
}
}
return self;
}
////////////////////////////////////////////////////////////////
// By default, we want no update. Override this if you inspector
// needs to be updated regularly.
- (int) updateInterval
{
return 0;
}
////////////////////////////////////////////////////////////////
//
- setMaster:theMaster
{
MyMaster = theMaster;
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.