Forge updates. Forge now saves, but does not load (heh) projects.

This commit is contained in:
Jeff Teunissen 2002-07-06 03:00:28 +00:00
parent 5f54a1931b
commit caf9d820c1
12 changed files with 90 additions and 70 deletions

View file

@ -46,15 +46,12 @@ typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode;
{ {
IBOutlet BundleController *bundleController; IBOutlet BundleController *bundleController;
IBOutlet PrefsController *prefsController; IBOutlet PrefsController *prefsController;
IBOutlet id window;
IBOutlet CMode fileMode; IBOutlet CMode fileMode;
IBOutlet NSString *fileName;
} }
// App delegate methods // App delegate methods
- (BOOL) application: (NSApplication *) app openFile: (NSString *) filename; - (BOOL) application: (NSApplication *) app openFile: (NSString *) filename;
- (BOOL) application: (NSApplication *) app openTempFile: (NSString *) filename;
- (BOOL) applicationOpenUntitledFile: (NSApplication *) app;
- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app;
- (BOOL) applicationShouldTerminate: (NSApplication *) app; - (BOOL) applicationShouldTerminate: (NSApplication *) app;
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app; - (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app;
@ -66,17 +63,11 @@ typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode;
// Action methods // Action methods
- (IBAction) showPreferencesPanel: (id) sender; - (IBAction) showPreferencesPanel: (id) sender;
// Projects // Open/Create Project
- (IBAction) newProject: (id) sender; - (IBAction) newProject: (id) sender;
- (IBAction) openProject: (id) sender; - (IBAction) openProject: (id) sender;
- (IBAction) saveProject: (id) sender;
- (IBAction) closeProject: (id) sender;
// Files
- (IBAction) addFileToProject: (id) sender;
- (IBAction) addNewFileToProject: (id) sender;
- (IBAction) open: (id) sender;
// Private (for Project) // Private (for Project)
- (CMode) fileMode; - (CMode) fileMode;
- (NSString *) fileName;
@end @end

View file

@ -1,5 +1,5 @@
/* /*
Controller.h Controller.m
Application controller class Application controller class
@ -47,22 +47,24 @@ static const char rcsid[] =
- (BOOL) application: (NSApplication *) app openFile: (NSString *) filename; - (BOOL) application: (NSApplication *) app openFile: (NSString *) filename;
{ {
return NO; if (![[filename pathExtension] isEqualToString: @"forge"]) {
} NSLog (@"File \"%@\" is not a project file!", filename);
return NO;
}
- (BOOL) application: (NSApplication *) app openTempFile: (NSString *) filename; fileMode = COpenMode;
{ fileName = filename;
return NO;
}
- (BOOL) applicationOpenUntitledFile: (NSApplication *) app; if (![NSBundle loadNibNamed: @"Project" owner: self]) {
{ NSLog (@"Could not load project manager for file \"%@\"", filename);
return NO; fileMode = CNoMode;
} fileName = nil;
return NO;
}
- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app; fileMode = CNoMode;
{ fileName = nil;
return NO; return YES;
} }
- (BOOL) applicationShouldTerminate: (NSApplication *) app; - (BOOL) applicationShouldTerminate: (NSApplication *) app;
@ -110,34 +112,6 @@ static const char rcsid[] =
return; return;
} }
- (void) saveProject: (id) sender;
{
NSLog (@"This _will_ save the project, but it doesn't yet.");
}
- (void) closeProject: (id) sender;
{
NSLog (@"This _will_ close the project, but it doesn't yet.");
}
/*
File-level stuff.
*/
- (void) addFileToProject: (id) sender;
{
NSLog (@"This _will_ copy/move a file into the project, but it doesn't yet.");
}
- (void) addNewFileToProject: (id) sender;
{
NSLog (@"This _will_ create a new file, but it doesn't yet.");
}
- (void) open: (id) sender;
{
NSLog (@"This _will_ open a file, but it doesn't yet.");
}
/****** /******
Notifications Notifications
******/ ******/
@ -149,7 +123,6 @@ static const char rcsid[] =
*/ */
- (void) applicationDidFinishLaunching: (NSNotification *) not; - (void) applicationDidFinishLaunching: (NSNotification *) not;
{ {
[bundleController loadBundles];
} }
/* /*
@ -172,6 +145,8 @@ static const char rcsid[] =
*/ */
NSDebugLog (@"Services"); NSDebugLog (@"Services");
[NSApp setServicesMenu: [[menu itemWithTitle: _(@"Services")] submenu]]; [NSApp setServicesMenu: [[menu itemWithTitle: _(@"Services")] submenu]];
[bundleController loadBundles];
} }
/* /*
@ -189,8 +164,8 @@ static const char rcsid[] =
- (void) awakeFromNib - (void) awakeFromNib
{ {
fileMode = CNoMode; fileMode = CNoMode;
[window setFrameAutosaveName: @"Project View"]; // [window setFrameAutosaveName: @"Project View"];
[window setFrameUsingName: @"Project View"]; // [window setFrameUsingName: @"Project View"];
} }
/****** /******
@ -251,4 +226,9 @@ static const char rcsid[] =
return fileMode; return fileMode;
} }
- (NSString *) fileName
{
return fileName;
}
@end @end

View file

@ -18,8 +18,7 @@
); );
Outlets = ( Outlets = (
bundleController, bundleController,
prefsController, prefsController
window
); );
Super = NSObject; Super = NSObject;
}; };

Binary file not shown.

View file

@ -613,7 +613,8 @@
closeProject: closeProject:
); );
Outlets = ( Outlets = (
owner owner,
window
); );
Super = NSObject; Super = NSObject;
}; };

View file

@ -45,9 +45,9 @@
IBOutlet NSBox *box; IBOutlet NSBox *box;
IBOutlet NSMatrix *iconList; IBOutlet NSMatrix *iconList;
IBOutlet NSScrollView *scrollView; IBOutlet NSScrollView *scrollView;
IBOutlet NSWindow *window;
IBOutlet id owner; IBOutlet id owner;
IBOutlet NSWindow *window;
} }
+ (PrefsController *) sharedPrefsController; + (PrefsController *) sharedPrefsController;

View file

@ -179,7 +179,6 @@ static NSMutableArray *prefsViews = nil;
if (! [prefsViews containsObject: aController]) { if (! [prefsViews containsObject: aController]) {
[prefsViews addObject: aController]; [prefsViews addObject: aController];
[aController autorelease];
} }
[button setTitle: [aController buttonCaption]]; [button setTitle: [aController buttonCaption]];
@ -191,6 +190,8 @@ static NSMutableArray *prefsViews = nil;
[iconList addColumnWithCells: [NSArray arrayWithObject: button]]; [iconList addColumnWithCells: [NSArray arrayWithObject: button]];
[iconList sizeToCells]; [iconList sizeToCells];
[aController autorelease];
} }
- (NSBox *) prefsViewBox - (NSBox *) prefsViewBox

View file

@ -37,7 +37,12 @@
@interface Project: NSObject @interface Project: NSObject
{ {
IBOutlet id owner; IBOutlet id owner;
IBOutlet NSWindow *window;
NSMutableArray *rFiles;
NSMutableArray *imgFiles;
NSMutableArray *suppFiles;
NSMutableArray *otherFiles;
} }
- (void) createProjectAtPath: (NSString *) aPath; - (void) createProjectAtPath: (NSString *) aPath;

View file

@ -35,7 +35,10 @@ static const char rcsid[] =
#import <Foundation/NSFileManager.h> #import <Foundation/NSFileManager.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSUserDefaults.h>
#import <AppKit/NSBrowser.h>
#import <AppKit/NSBrowserCell.h>
#import <AppKit/NSOpenPanel.h> #import <AppKit/NSOpenPanel.h>
#import <AppKit/NSSavePanel.h> #import <AppKit/NSSavePanel.h>
@ -51,13 +54,23 @@ static const char rcsid[] =
- (void) dealloc - (void) dealloc
{ {
[rFiles release];
[imgFiles release];
[otherFiles release];
[suppFiles release];
NSLog (@"Project deallocating"); NSLog (@"Project deallocating");
[super dealloc]; [super dealloc];
} }
- (void) awakeFromNib - (void) awakeFromNib
{ {
int result; int result;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
imgFiles = [NSMutableArray new];
rFiles = [NSMutableArray new];
suppFiles = [NSMutableArray new];
otherFiles = [NSMutableArray new];
if (![owner fileMode]) { if (![owner fileMode]) {
NSLog (@"Project -awakeFromNib: Uhh, file mode isn't set. WTF?"); NSLog (@"Project -awakeFromNib: Uhh, file mode isn't set. WTF?");
@ -65,6 +78,11 @@ static const char rcsid[] =
return; return;
} }
if ([owner fileName]) {
[self openProjectAtPath: [owner fileName]];
return;
}
switch ([owner fileMode]) { switch ([owner fileMode]) {
case COpenMode: { // load project case COpenMode: { // load project
NSArray *fileTypes = [NSArray arrayWithObject: @"forge"]; NSArray *fileTypes = [NSArray arrayWithObject: @"forge"];
@ -74,7 +92,9 @@ static const char rcsid[] =
[oPanel setCanChooseFiles: YES]; [oPanel setCanChooseFiles: YES];
[oPanel setCanChooseDirectories: NO]; [oPanel setCanChooseDirectories: NO];
result = [oPanel runModalForTypes: fileTypes]; result = [oPanel runModalForDirectory: [defaults objectForKey: @"ProjectPath"]
file: nil
types: fileTypes];
if (result == NSOKButton) { // got a path if (result == NSOKButton) { // got a path
NSArray *pathArray = [oPanel filenames]; NSArray *pathArray = [oPanel filenames];
@ -93,7 +113,8 @@ static const char rcsid[] =
[sPanel setRequiredFileType: @"forge"]; [sPanel setRequiredFileType: @"forge"];
[sPanel setTreatsFilePackagesAsDirectories: NO]; [sPanel setTreatsFilePackagesAsDirectories: NO];
result = [sPanel runModal]; result = [sPanel runModalForDirectory: [defaults objectForKey: @"ProjectPath"]
file: @"ProjectName.forge"];
if (result == NSOKButton) { // got a path if (result == NSOKButton) { // got a path
[self createProjectAtPath: [sPanel filename]]; [self createProjectAtPath: [sPanel filename]];
@ -110,7 +131,13 @@ static const char rcsid[] =
- (void) createProjectAtPath: (NSString *) aPath - (void) createProjectAtPath: (NSString *) aPath
{ {
NSFileManager *filer = [NSFileManager defaultManager]; NSFileManager *filer = [NSFileManager defaultManager];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; // create dictionary with dictionaries in it, each containing nothing
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
imgFiles, @"Image Files",
rFiles, @"Ruamoko Source",
suppFiles, @"Supporting Files",
otherFiles, @"Unmanaged Files",
nil];
if (!aPath) { if (!aPath) {
NSLog (@"No path given!"); NSLog (@"No path given!");
@ -120,14 +147,15 @@ static const char rcsid[] =
NSLog (@"Could not create directory %@", aPath); NSLog (@"Could not create directory %@", aPath);
} }
// create dictionary with dictionaries in it, each containing nothing // write the dictionary
[dict writeToFile: [aPath stringByAppendingPathComponent: @"Forge.project"] [dict writeToFile: [aPath stringByAppendingPathComponent: @"Forge.project"]
atomically: YES]; atomically: YES];
[window makeKeyAndOrderFront: self];
} }
- (void) openProjectAtPath: (NSString *) aPath - (void) openProjectAtPath: (NSString *) aPath
{ {
NSLog (@"No code to load project %@", aPath); NSLog (@"No code to load project %@.", aPath);
[self dealloc]; [self dealloc];
} }
@ -135,4 +163,18 @@ static const char rcsid[] =
{ {
} }
- (int) browser: (NSBrowser *) sender numberOfRowsInColumn: (int) column
{
return 1;
}
- (void) browser: (NSBrowser *) sender
willDisplayCell: (id) cell
atRow: (int) row
column: (int) column
{
[cell setStringValue: @"hi"];
[cell setLoaded: YES];
[cell setLeaf: YES];
}
@end @end

View file

@ -2,7 +2,8 @@
#define APP_NAME @"Forge" #define APP_NAME @"Forge"
int main(int argc, const char *argv[], const char *env[]) int
main (int argc, const char *argv[], const char *env[])
{ {
return NSApplicationMain (argc, argv); return NSApplicationMain (argc, argv);
} }