diff --git a/tools/Forge/Bundles/MainPrefs/MainPrefs.gorm b/tools/Forge/Bundles/MainPrefs/MainPrefs.gorm index 558695d20..5f92f11ea 100644 Binary files a/tools/Forge/Bundles/MainPrefs/MainPrefs.gorm and b/tools/Forge/Bundles/MainPrefs/MainPrefs.gorm differ diff --git a/tools/Forge/Controller.h b/tools/Forge/Controller.h index f2157643a..7082cc81e 100644 --- a/tools/Forge/Controller.h +++ b/tools/Forge/Controller.h @@ -46,15 +46,12 @@ typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode; { IBOutlet BundleController *bundleController; IBOutlet PrefsController *prefsController; - IBOutlet id window; IBOutlet CMode fileMode; + IBOutlet NSString *fileName; } // App delegate methods - (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) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app; @@ -66,17 +63,11 @@ typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode; // Action methods - (IBAction) showPreferencesPanel: (id) sender; -// Projects +// Open/Create Project - (IBAction) newProject: (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) - (CMode) fileMode; +- (NSString *) fileName; @end diff --git a/tools/Forge/Controller.m b/tools/Forge/Controller.m index 6e0f5bbff..bc1df604f 100644 --- a/tools/Forge/Controller.m +++ b/tools/Forge/Controller.m @@ -1,5 +1,5 @@ /* - Controller.h + Controller.m Application controller class @@ -47,22 +47,24 @@ static const char rcsid[] = - (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; -{ - return NO; -} + fileMode = COpenMode; + fileName = filename; -- (BOOL) applicationOpenUntitledFile: (NSApplication *) app; -{ - return NO; -} + if (![NSBundle loadNibNamed: @"Project" owner: self]) { + NSLog (@"Could not load project manager for file \"%@\"", filename); + fileMode = CNoMode; + fileName = nil; + return NO; + } -- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app; -{ - return NO; + fileMode = CNoMode; + fileName = nil; + return YES; } - (BOOL) applicationShouldTerminate: (NSApplication *) app; @@ -110,34 +112,6 @@ static const char rcsid[] = 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 ******/ @@ -149,7 +123,6 @@ static const char rcsid[] = */ - (void) applicationDidFinishLaunching: (NSNotification *) not; { - [bundleController loadBundles]; } /* @@ -172,6 +145,8 @@ static const char rcsid[] = */ NSDebugLog (@"Services"); [NSApp setServicesMenu: [[menu itemWithTitle: _(@"Services")] submenu]]; + + [bundleController loadBundles]; } /* @@ -189,8 +164,8 @@ static const char rcsid[] = - (void) awakeFromNib { fileMode = CNoMode; - [window setFrameAutosaveName: @"Project View"]; - [window setFrameUsingName: @"Project View"]; +// [window setFrameAutosaveName: @"Project View"]; +// [window setFrameUsingName: @"Project View"]; } /****** @@ -251,4 +226,9 @@ static const char rcsid[] = return fileMode; } +- (NSString *) fileName +{ + return fileName; +} + @end diff --git a/tools/Forge/English.lproj/Forge.classes b/tools/Forge/English.lproj/Forge.classes index fb6096333..8513ddcaf 100644 --- a/tools/Forge/English.lproj/Forge.classes +++ b/tools/Forge/English.lproj/Forge.classes @@ -18,8 +18,7 @@ ); Outlets = ( bundleController, - prefsController, - window + prefsController ); Super = NSObject; }; diff --git a/tools/Forge/English.lproj/Forge.gorm b/tools/Forge/English.lproj/Forge.gorm index 5cd6a3d55..cdd4318f7 100644 Binary files a/tools/Forge/English.lproj/Forge.gorm and b/tools/Forge/English.lproj/Forge.gorm differ diff --git a/tools/Forge/English.lproj/Project.classes b/tools/Forge/English.lproj/Project.classes index fb6096333..cbb76419b 100644 --- a/tools/Forge/English.lproj/Project.classes +++ b/tools/Forge/English.lproj/Project.classes @@ -613,7 +613,8 @@ closeProject: ); Outlets = ( - owner + owner, + window ); Super = NSObject; }; diff --git a/tools/Forge/English.lproj/Project.gorm b/tools/Forge/English.lproj/Project.gorm index aab75c512..8e2913b22 100644 Binary files a/tools/Forge/English.lproj/Project.gorm and b/tools/Forge/English.lproj/Project.gorm differ diff --git a/tools/Forge/PrefsController.h b/tools/Forge/PrefsController.h index 36ea98bdb..e582d848a 100644 --- a/tools/Forge/PrefsController.h +++ b/tools/Forge/PrefsController.h @@ -45,9 +45,9 @@ IBOutlet NSBox *box; IBOutlet NSMatrix *iconList; IBOutlet NSScrollView *scrollView; + IBOutlet NSWindow *window; IBOutlet id owner; - IBOutlet NSWindow *window; } + (PrefsController *) sharedPrefsController; diff --git a/tools/Forge/PrefsController.m b/tools/Forge/PrefsController.m index 1e5fe24dd..978971e9c 100644 --- a/tools/Forge/PrefsController.m +++ b/tools/Forge/PrefsController.m @@ -179,7 +179,6 @@ static NSMutableArray *prefsViews = nil; if (! [prefsViews containsObject: aController]) { [prefsViews addObject: aController]; - [aController autorelease]; } [button setTitle: [aController buttonCaption]]; @@ -191,6 +190,8 @@ static NSMutableArray *prefsViews = nil; [iconList addColumnWithCells: [NSArray arrayWithObject: button]]; [iconList sizeToCells]; + + [aController autorelease]; } - (NSBox *) prefsViewBox diff --git a/tools/Forge/Project.h b/tools/Forge/Project.h index 6b56c58b9..ea2efc716 100644 --- a/tools/Forge/Project.h +++ b/tools/Forge/Project.h @@ -37,7 +37,12 @@ @interface Project: NSObject { - IBOutlet id owner; + IBOutlet id owner; + IBOutlet NSWindow *window; + NSMutableArray *rFiles; + NSMutableArray *imgFiles; + NSMutableArray *suppFiles; + NSMutableArray *otherFiles; } - (void) createProjectAtPath: (NSString *) aPath; diff --git a/tools/Forge/Project.m b/tools/Forge/Project.m index b580db75f..32afb78ab 100644 --- a/tools/Forge/Project.m +++ b/tools/Forge/Project.m @@ -35,7 +35,10 @@ static const char rcsid[] = #import #import +#import +#import +#import #import #import @@ -51,13 +54,23 @@ static const char rcsid[] = - (void) dealloc { + [rFiles release]; + [imgFiles release]; + [otherFiles release]; + [suppFiles release]; NSLog (@"Project deallocating"); [super dealloc]; } - (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]) { NSLog (@"Project -awakeFromNib: Uhh, file mode isn't set. WTF?"); @@ -65,6 +78,11 @@ static const char rcsid[] = return; } + if ([owner fileName]) { + [self openProjectAtPath: [owner fileName]]; + return; + } + switch ([owner fileMode]) { case COpenMode: { // load project NSArray *fileTypes = [NSArray arrayWithObject: @"forge"]; @@ -74,7 +92,9 @@ static const char rcsid[] = [oPanel setCanChooseFiles: YES]; [oPanel setCanChooseDirectories: NO]; - result = [oPanel runModalForTypes: fileTypes]; + result = [oPanel runModalForDirectory: [defaults objectForKey: @"ProjectPath"] + file: nil + types: fileTypes]; if (result == NSOKButton) { // got a path NSArray *pathArray = [oPanel filenames]; @@ -93,7 +113,8 @@ static const char rcsid[] = [sPanel setRequiredFileType: @"forge"]; [sPanel setTreatsFilePackagesAsDirectories: NO]; - result = [sPanel runModal]; + result = [sPanel runModalForDirectory: [defaults objectForKey: @"ProjectPath"] + file: @"ProjectName.forge"]; if (result == NSOKButton) { // got a path [self createProjectAtPath: [sPanel filename]]; @@ -110,7 +131,13 @@ static const char rcsid[] = - (void) createProjectAtPath: (NSString *) aPath { 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) { NSLog (@"No path given!"); @@ -120,14 +147,15 @@ static const char rcsid[] = NSLog (@"Could not create directory %@", aPath); } - // create dictionary with dictionaries in it, each containing nothing + // write the dictionary [dict writeToFile: [aPath stringByAppendingPathComponent: @"Forge.project"] atomically: YES]; + [window makeKeyAndOrderFront: self]; } - (void) openProjectAtPath: (NSString *) aPath { - NSLog (@"No code to load project %@", aPath); + NSLog (@"No code to load project %@.", aPath); [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 diff --git a/tools/Forge/main.m b/tools/Forge/main.m index 27f6a861f..d0edb2f34 100644 --- a/tools/Forge/main.m +++ b/tools/Forge/main.m @@ -2,7 +2,8 @@ #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); }