Forge: partial support for projects. Very (VERY!) incomplete.

This commit is contained in:
Jeff Teunissen 2002-05-29 11:21:25 +00:00
parent 6c9c62139a
commit 26cda3214a
11 changed files with 866 additions and 57 deletions

View File

@ -40,11 +40,14 @@
#import "BundleController.h"
#import "PrefsController.h"
typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode;
@interface Controller: NSObject <BundleDelegate>
{
IBOutlet BundleController *bundleController;
IBOutlet PrefsController *prefsController;
IBOutlet id window;
IBOutlet CMode fileMode;
}
// App delegate methods
@ -73,4 +76,7 @@
- (IBAction) addFileToProject: (id) sender;
- (IBAction) addNewFileToProject: (id) sender;
- (IBAction) open: (id) sender;
// Private (for Project)
- (CMode) fileMode;
@end

View File

@ -36,6 +36,7 @@ static const char rcsid[] =
#import <Foundation/NSDebug.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSNibLoading.h>
#import <AppKit/NSMenu.h>
#import <AppKit/NSWindow.h>
@ -71,7 +72,7 @@ static const char rcsid[] =
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app;
{
return YES;
return NO;
}
/******
@ -89,12 +90,24 @@ static const char rcsid[] =
*/
- (void) newProject: (id) sender;
{
NSLog (@"This _will_ create a new project, but it doesn't yet.");
fileMode = CCreateMode;
if (![NSBundle loadNibNamed: @"Project" owner: self])
NSLog (@"Could not create new Project window!");
fileMode = CNoMode;
return;
}
- (void) openProject: (id) sender;
{
NSLog (@"This _will_ open a project, but it doesn't yet.");
fileMode = COpenMode;
if (![NSBundle loadNibNamed: @"Project" owner: self])
NSLog (@"Could not create new Project window!");
fileMode = CNoMode;
return;
}
- (void) saveProject: (id) sender;
@ -175,6 +188,7 @@ static const char rcsid[] =
******/
- (void) awakeFromNib
{
fileMode = CNoMode;
[window setFrameAutosaveName: @"Project View"];
[window setFrameUsingName: @"Project View"];
}
@ -187,26 +201,34 @@ static const char rcsid[] =
{
NSDictionary *info = nil;
/*
Let's get paranoid about stuff we load... :)
*/
if (!aBundle) {
NSLog (@"Controller -bundleController: sent nil bundle");
return;
}
info = [aBundle infoDictionary];
if (![aBundle principalClass]) {
if (!(info || [info objectForKey: @"NSExecutable"])) {
NSLog (@"%@ has no principal class and no info dictionary", aBundle);
return;
}
if (!(info = [aBundle infoDictionary])) {
NSLog (@"Bundle %@ has no info dictionary!", aBundle);
return;
}
if (![info objectForKey: @"NSExecutable"]) {
NSLog (@"Bundle %@ has no executable!", aBundle);
return;
}
if (![aBundle principalClass]) {
NSLog (@"Bundle `%@' has no principal class!", [[info objectForKey: @"NSExecutable"] lastPathComponent]);
return;
}
if (![[aBundle principalClass] conformsToProtocol: @protocol(ForgeBundle)]) {
NSLog (@"Bundle %@'s principal class does not conform to the ForgeBundle protocol.", [[info objectForKey: @"NSExecutable"] lastPathComponent]);
return;
}
}
[[(id <ForgeBundle>) [aBundle principalClass] alloc] initWithOwner: self];
}
@ -224,4 +246,9 @@ static const char rcsid[] =
return YES;
}
- (CMode) fileMode
{
return fileMode;
}
@end

View File

@ -608,4 +608,13 @@
);
Super = NSObject;
};
Project = {
Actions = (
closeProject:
);
Outlets = (
owner
);
Super = NSObject;
};
}

Binary file not shown.

View File

@ -1,48 +1,9 @@
/* App Name */
"Forge" = "Forge";
/* Controller.m Menus */
"Info" = "Info";
"Info Panel..." = "Info Panel...";
"Preferences..." = "Preferences...";
"Help" = "Help";
"Project" = "Project";
"Open..." = "Open...";
"New" = "New";
"Save..." = "Save...";
"Save As..." = "Save As...";
"Close" = "Close";
"File" = "File";
"Save All" = "Save All";
"Revert to Saved" = "Revert to Saved";
"Edit" = "Edit";
"Cut" = "Cut";
"Copy" = "Copy";
"Paste" = "Paste";
"Delete" = "Delete";
"Select All" = "Select All";
"BSP" = "BSP";
"None" = "None";
"Brush" = "Brush";
/* Menu names */
"Windows" = "Windows";
"Services" = "Services";
"Hide" = "Hide";
"Quit" = "Quit";
/* Preferences Window buttons */
"Preferences" = "Preferences";
"OK" = "OK";
"Cancel" = "Cancel";
"Apply" = "Apply";
"Default" = "Default";
/*
The other strings are located inside the .gorm files, so they need to be
edited there.
*/

View File

@ -0,0 +1,620 @@
{
BundleController = {
Outlets = (
delegate
);
Super = NSObject;
};
Controller = {
Actions = (
addFileToProject:,
addNewFileToProject:,
closeProject:,
newProject:,
open:,
openProject:,
saveProject:,
showPreferencesPanel:
);
Outlets = (
bundleController,
prefsController,
window
);
Super = NSObject;
};
FirstResponder = {
Actions = (
activateContextHelpMode:,
addFileToProject:,
addNewFileToProject:,
alignCenter:,
alignJustified:,
alignLeft:,
alignRight:,
arrangeInFront:,
cancel:,
capitalizeWord:,
changeColor:,
changeFont:,
checkSpelling:,
close:,
complete:,
copy:,
copyFont:,
copyRuler:,
cut:,
delete:,
deleteBackward:,
deleteForward:,
deleteToBeginningOfLine:,
deleteToBeginningOfParagraph:,
deleteToEndOfLine:,
deleteToEndOfParagraph:,
deleteToMark:,
deleteWordBackward:,
deleteWordForward:,
deminiaturize:,
deselectAll:,
fax:,
hide:,
hideOtherApplications:,
indent:,
loosenKerning:,
lowerBaseline:,
lowercaseWord:,
makeKeyAndOrderFront:,
miniaturize:,
miniaturizeAll:,
moveBackward:,
moveBackwardAndModifySelection:,
moveDown:,
moveDownAndModifySelection:,
moveForward:,
moveForwardAndModifySelection:,
moveLeft:,
moveRight:,
moveToBeginningOfDocument:,
moveToBeginningOfLine:,
moveToBeginningOfParagraph:,
moveToEndOfDocument:,
moveToEndOfLine:,
moveToEndOfParagraph:,
moveUp:,
moveUpAndModifySelection:,
moveWordBackward:,
moveWordBackwardAndModifySelection:,
moveWordForward:,
moveWordForwardAndModifySelection:,
ok:,
open:,
openSelectedFile:,
orderBack:,
orderFront:,
orderFrontColorPanel:,
orderFrontDataLinkPanel:,
orderFrontHelpPanel:,
orderFrontStandardAboutPanel:,
orderFrontStandardInfoPanel:,
orderOut:,
pageDown:,
pageUp:,
paste:,
pasteAsPlainText:,
pasteAsRichText:,
pasteFont:,
pasteRuler:,
performClose:,
performMiniaturize:,
performZoom:,
print:,
raiseBaseline:,
revertToSaved:,
runPageLayout:,
runToolbarCustomizationPalette:,
saveFile:,
scrollLineDown:,
scrollLineUp:,
scrollPageDown:,
scrollPageUp:,
scrollViaScroller:,
selectAll:,
selectLine:,
selectNextKeyView:,
selectParagraph:,
selectPreviousKeyView:,
selectText:,
selectText:,
selectToMark:,
selectWord:,
showContextHelp:,
showGuessPanel:,
showHelp:,
showWindow:,
stop:,
subscript:,
superscript:,
swapWithMark:,
takeDoubleValueFrom:,
takeFloatValueFrom:,
takeIntValueFrom:,
takeObjectValueFrom:,
takeStringValueFrom:,
terminate:,
tightenKerning:,
toggle:,
toggleContinuousSpellChecking:,
toggleRuler:,
toggleToolbarShown:,
toggleTraditionalCharacterShape:,
transpose:,
transposeWords:,
turnOffKerning:,
turnOffLigatures:,
underline:,
unhide:,
unhideAllApplications:,
unscript:,
uppercaseWord:,
useAllLigatures:,
useStandardKerning:,
useStandardLigatures:,
yank:,
zoom:
);
Super = NSObject;
};
IBInspector = {
Actions = (
ok:,
revert:,
touch:
);
Outlets = (
window
);
Super = NSObject;
};
IBPalette = {
Actions = (
);
Outlets = (
originalWindow
);
Super = NSObject;
};
NSActionCell = {
Super = NSCell;
};
NSApplication = {
Actions = (
arrangeInFront:,
hide:,
hideOtherApplications:,
miniaturizeAll:,
orderFrontColorPanel:,
orderFrontDataLinkPanel:,
orderFrontHelpPanel:,
orderFrontStandardAboutPanel:,
orderFrontStandardInfoPanel:,
runPageLayout:,
stop:,
terminate:,
unhide:,
unhideAllApplications:
);
Outlets = (
delegate
);
Super = NSResponder;
};
NSArray = {
Super = NSObject;
};
NSBrowser = {
Actions = (
doClick:,
doDoubleClick:,
selectAll:
);
Outlets = (
delegate
);
Super = NSControl;
};
NSBrowserCell = {
Super = NSCell;
};
NSButton = {
Actions = (
performClick:
);
Super = NSControl;
};
NSButtonCell = {
Actions = (
performClick:
);
Super = NSActionCell;
};
NSCStringText = {
Actions = (
clear:,
selectText:
);
Super = NSText;
};
NSCell = {
Actions = (
takeDoubleValueFrom:,
takeFloatValueFrom:,
takeIntValueFrom:,
takeStringValueFrom:
);
Super = NSObject;
};
NSColorWell = {
Actions = (
takeColorFrom:
);
Super = NSControl;
};
NSComboBox = {
Outlets = (
dataSource
);
Super = NSTextField;
};
NSControl = {
Actions = (
takeDoubleValueFrom:,
takeFloatValueFrom:,
takeIntValueFrom:,
takeObjectValueFrom:,
takeStringValueFrom:
);
Outlets = (
target
);
Super = NSView;
};
NSCursor = {
Super = NSObject;
};
NSDateFormatter = {
Super = NSFormatter;
};
NSDictionary = {
Super = NSObject;
};
NSDocument = {
Actions = (
printDocument:,
revertDocumentToSaved:,
runPageLayout:,
saveDocument:,
saveDocumentAs:,
saveDocumentTo:
);
Super = NSObject;
};
NSDocumentController = {
Actions = (
clearRecentDocuments:,
newDocument:,
openDocument:,
saveAllDocuments:
);
Super = NSObject;
};
NSDrawer = {
Actions = (
close:,
open:,
toggle:
);
Outlets = (
delegate
);
Super = NSResponder;
};
NSFontManager = {
Actions = (
addFontTrait:,
modifyFont:,
modifyFontViaPanel:,
orderFrontFontPanel:,
removeFontTrait:
);
Outlets = (
menu
);
Super = NSResponder;
};
NSForm = {
Super = NSMatrix;
};
NSFormCell = {
Super = NSActionCell;
};
NSFormatter = {
Super = NSObject;
};
NSHelpManager = {
Actions = (
activateContextHelpMode:,
showHelp:
);
Super = NSResponder;
};
NSImage = {
Super = NSObject;
};
NSImageView = {
Super = NSControl;
};
NSMatrix = {
Actions = (
selectAll:,
selectText:
);
Outlets = (
delegate
);
Super = NSControl;
};
NSMenu = {
Super = NSObject;
};
NSMenuItem = {
Outlets = (
target
);
Super = NSObject;
};
NSMutableArray = {
Super = NSArray;
};
NSMutableDictionary = {
Super = NSDictionary;
};
NSNumberFormatter = {
Super = NSFormatter;
};
NSOutlineView = {
Super = NSTableView;
};
NSPanel = {
Super = NSWindow;
};
NSPopUpButton = {
Super = NSButton;
};
NSProgressIndicator = {
Actions = (
animate:,
startAnimation:,
stopAnimation:
);
Super = NSObject;
};
NSResponder = {
Actions = (
deselectAll:,
selectAll:,
selectText:
);
Outlets = (
menu
);
Super = NSObject;
};
NSRulerView = {
Super = NSView;
};
NSScrollView = {
Super = NSView;
};
NSScroller = {
Super = NSControl;
};
NSSecureTextField = {
Super = NSTextField;
};
NSSecureTextFieldCell = {
Super = NSTextFieldCell;
};
NSSlider = {
Super = NSControl;
};
NSSliderCell = {
Super = NSActionCell;
};
NSSplitView = {
Super = NSView;
};
NSTabView = {
Actions = (
selectFirstTabViewItem:,
selectLastTabViewItem:,
selectNextTabViewItem:,
selectPreviousTabViewItem:,
takeSelectedTabViewItemFromSender:
);
Outlets = (
delegate
);
Super = NSView;
};
NSTableColumn = {
Super = NSObject;
};
NSTableHeaderCell = {
Super = NSTextFieldCell;
};
NSTableHeaderView = {
Super = NSView;
};
NSTableView = {
Actions = (
deselectAll:,
selectAll:
);
Outlets = (
dataSource,
delegate
);
Super = NSControl;
};
NSText = {
Actions = (
alignCenter:,
alignLeft:,
alignRight:,
changeFont:,
changeSpelling:,
checkSpelling:,
copy:,
copyFont:,
copyRuler:,
cut:,
delete:,
ignoreSpelling:,
paste:,
pasteFont:,
pasteRuler:,
selectAll:,
showGuessPanel:,
subscript:,
superscript:,
toggleRuler:,
underline:,
unscript:
);
Outlets = (
delegate
);
Super = NSView;
};
NSTextField = {
Actions = (
selectText:
);
Outlets = (
delegate
);
Super = NSControl;
};
NSTextFieldCell = {
Super = NSActionCell;
};
NSTextView = {
Actions = (
alignJustified:,
changeColor:,
deleteBackwards:,
insertBacktab:,
insertNewLine:,
insertParagraphSeparator:,
insertTab:,
loosenKerning:,
lowerBaseline:,
moveBackward:,
moveDown:,
moveForward:,
moveLeft:,
moveRight:,
moveUp:,
pasteAsPlainText:,
pasteAsRichText:,
raiseBaseline:,
tightenKerning:,
toggleContinuousSpellChecking:,
toggleTraditionalCharacterShape:,
turnOffKerning:,
turnOffLigatures:,
useAllLigatures:,
useDefaultBaseline:,
useDefaultKerning:,
useDefaultLigatures:,
useStandardBaseline:,
useStandardKerning:,
useStandardLigatures:
);
Super = NSText;
};
NSView = {
Actions = (
fax:,
print:
);
Outlets = (
nextKeyView
);
Super = NSResponder;
};
NSWindow = {
Actions = (
deminiaturize:,
fax:,
makeKeyAndOrderFront:,
miniaturize:,
orderBack:,
orderFront:,
orderOut:,
performClose:,
performMiniaturize:,
performZoom:,
print:,
runToolbarCustomizationPalette:,
selectNextKeyView:,
selectPreviousKeyView:,
toggleToolbarShown:,
zoom:
);
Outlets = (
delegate,
initialFirstResponder
);
Super = NSResponder;
};
NSWindowController = {
Actions = (
showWindow:
);
Outlets = (
document,
window
);
Super = NSResponder;
};
Object = {
};
PrefsController = {
Actions = (
addPrefsViewController:,
loadPreferences:,
orderFrontPreferencesPanel:,
resetToDefaults:,
savePreferences:,
savePreferencesAndCloseWindow:
);
Outlets = (
box,
iconList,
owner,
scrollView,
window
);
Super = NSObject;
};
Project = {
Actions = (
closeProject:
);
Outlets = (
owner
);
Super = NSObject;
};
}

Binary file not shown.

Binary file not shown.

View File

@ -52,12 +52,13 @@ ADDITIONAL_GUI_LIBS +=
Forge_MAIN_MODEL_FILE= Forge.gorm
Forge_RESOURCE_FILES= \
Bundles/MainPrefs/MainPrefs.forgeb \
Forge.gorm \
Forge.tiff \
ForgeDocument.tiff \
ForgeInfo.plist
Forge_LOCALIZED_RESOURCE_FILES= \
Forge.gorm \
Project.gorm \
Localizable.strings
# Languages we're localized for
@ -71,7 +72,8 @@ Forge_HEADERS= \
Config.h \
BundleController.h \
Controller.h \
PrefsController.h
PrefsController.h \
Project.h
#
# Class files
@ -80,6 +82,7 @@ Forge_OBJC_FILES= \
BundleController.m \
Controller.m \
PrefsController.m \
Project.m \
main.m
#

47
tools/Forge/Project.h Normal file
View File

@ -0,0 +1,47 @@
/*
Project.h
Project manager class
Copyright (C) 2002 Dusk to Dawn Computing, Inc.
Author: Jeff Teunissen <deek@d2dc.net>
Date: 29 May 2002
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/NSObject.h>
#import <AppKit/NSNibDeclarations.h>
@interface Project: NSObject
{
IBOutlet id owner;
}
- (void) createProjectAtPath: (NSString *) aPath;
- (void) openProjectAtPath: (NSString *) aPath;
- (void) closeProject: (id) sender;
@end

136
tools/Forge/Project.m Normal file
View File

@ -0,0 +1,136 @@
/*
Project.m
Project manager class
Copyright (C) 2002 Dusk to Dawn Computing, Inc.
Author: Jeff Teunissen <deek@d2dc.net>
Date: 29 May 2002
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "Config.h"
#endif
#import <Foundation/NSFileManager.h>
#import <Foundation/NSString.h>
#import <AppKit/NSOpenPanel.h>
#import <AppKit/NSSavePanel.h>
#import "Controller.h"
#import "Project.h"
@implementation Project
- (id) init
{
return self = [super init];
}
- (void) dealloc
{
NSLog (@"Project deallocating");
[super dealloc];
}
- (void) awakeFromNib
{
int result;
if (![owner fileMode]) {
NSLog (@"Project -awakeFromNib: Uhh, file mode isn't set. WTF?");
[self dealloc];
return;
}
switch ([owner fileMode]) {
case COpenMode: { // load project
NSArray *fileTypes = [NSArray arrayWithObject: @"forge"];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setAllowsMultipleSelection: NO];
[oPanel setCanChooseFiles: YES];
[oPanel setCanChooseDirectories: NO];
result = [oPanel runModalForTypes: fileTypes];
if (result == NSOKButton) { // got a path
NSArray *pathArray = [oPanel filenames];
[self openProjectAtPath: [pathArray objectAtIndex: 0]];
} else {
[self dealloc];
}
break;
}
case CCreateMode: { // Create new project
NSSavePanel *sPanel = [NSSavePanel savePanel];
[sPanel setPrompt: _(@"Project location")];
[sPanel setRequiredFileType: @"forge"];
[sPanel setTreatsFilePackagesAsDirectories: NO];
result = [sPanel runModal];
if (result == NSOKButton) { // got a path
[self createProjectAtPath: [sPanel filename]];
} else {
[self dealloc];
}
break;
}
}
}
- (void) createProjectAtPath: (NSString *) aPath
{
NSFileManager *filer = [NSFileManager defaultManager];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (!aPath) {
NSLog (@"No path given!");
}
if (![filer createDirectoryAtPath: aPath attributes: nil]) {
NSLog (@"Could not create directory %@", aPath);
}
// create dictionary with dictionaries in it, each containing nothing
[dict writeToFile: [aPath stringByAppendingPathComponent: @"Forge.project"]
atomically: YES];
}
- (void) openProjectAtPath: (NSString *) aPath
{
NSLog (@"No code to load project %@", aPath);
[self dealloc];
}
- (void) closeProject: (id) sender
{
}
@end