Support specification of help file.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@23665 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-09-29 08:25:12 +00:00
parent a4c58b49cd
commit dec193e4c5
5 changed files with 800 additions and 788 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/* /*
GNUstep ProjectCenter - http://www.gnustep.org GNUstep ProjectCenter - http: //www.gnustep.org
Copyright (C) 2001 Free Software Foundation Copyright (C) 2001 Free Software Foundation
@ -19,7 +19,8 @@
You should have received a copy of the GNU General Public You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA
*/ */
#include <ProjectCenter/ProjectCenter.h> #include <ProjectCenter/ProjectCenter.h>
@ -32,11 +33,11 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
@implementation PCAppTextField @implementation PCAppTextField
- (BOOL)becomeFirstResponder - (BOOL) becomeFirstResponder
{ {
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName:PCITextFieldGetFocus postNotificationName: PCITextFieldGetFocus
object:self]; object: self];
return [super becomeFirstResponder]; return [super becomeFirstResponder];
} }
@ -45,12 +46,12 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
@implementation PCAppProject (Inspector) @implementation PCAppProject (Inspector)
- (void)awakeFromNib - (void) awakeFromNib
{ {
[docBasedAppButton setRefusesFirstResponder:YES]; [docBasedAppButton setRefusesFirstResponder: YES];
[docBasedAppButton setState: [docBasedAppButton setState:
([[projectDict objectForKey:PCDocumentBasedApp] ([[projectDict objectForKey: PCDocumentBasedApp]
isEqualToString: @"YES"]) ? NSOnState : NSOffState]; isEqualToString: @"YES"]) ? NSOnState : NSOffState];
} }
@ -58,40 +59,40 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
// --- User Interface // --- User Interface
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
- (void)createProjectAttributes - (void) createProjectAttributes
{ {
// Languages // Languages
[projectLanguagePB removeAllItems]; [projectLanguagePB removeAllItems];
[projectLanguagePB [projectLanguagePB
addItemsWithTitles:[projectDict objectForKey:PCUserLanguages]]; addItemsWithTitles: [projectDict objectForKey: PCUserLanguages]];
[projectLanguagePB [projectLanguagePB
selectItemWithTitle:[projectDict objectForKey:PCLanguage]]; selectItemWithTitle: [projectDict objectForKey: PCLanguage]];
// TFs Buttons // TFs Buttons
[setFieldButton setRefusesFirstResponder:YES]; [setFieldButton setRefusesFirstResponder: YES];
[clearFieldButton setRefusesFirstResponder:YES]; [clearFieldButton setRefusesFirstResponder: YES];
// Document types buttons // Document types buttons
[addDocTypeButton setRefusesFirstResponder:YES]; [addDocTypeButton setRefusesFirstResponder: YES];
[removeDocTypeButton setRefusesFirstResponder:YES]; [removeDocTypeButton setRefusesFirstResponder: YES];
[docBasedAppButton setRefusesFirstResponder:YES]; [docBasedAppButton setRefusesFirstResponder: YES];
[self setDocBasedApp:docBasedAppButton]; [self setDocBasedApp: docBasedAppButton];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver: self
selector:@selector(tfGetFocus:) selector: @selector(tfGetFocus:)
name:PCITextFieldGetFocus name: PCITextFieldGetFocus
object:nil]; object: nil];
[projectAttributesView retain]; [projectAttributesView retain];
[self updateInspectorValues:nil]; [self updateInspectorValues: nil];
} }
- (NSView *)projectAttributesView - (NSView *) projectAttributesView
{ {
if (!projectAttributesView) if (!projectAttributesView)
{ {
if ([NSBundle loadNibNamed:@"Inspector" owner:self] == NO) if ([NSBundle loadNibNamed: @"Inspector" owner: self] == NO)
{ {
NSLog(@"PCAppProject: error loading Inspector NIB!"); NSLog(@"PCAppProject: error loading Inspector NIB!");
return nil; return nil;
@ -106,24 +107,24 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
// --- Actions // --- Actions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
- (void)setCurrentLanguage:(id)sender - (void) setCurrentLanguage: (id)sender
{ {
NSLog(@"set current language to %@", [sender titleOfSelectedItem]); NSLog(@"set current language to %@", [sender titleOfSelectedItem]);
[self setProjectDictObject:[sender titleOfSelectedItem] [self setProjectDictObject: [sender titleOfSelectedItem]
forKey:PCLanguage forKey: PCLanguage
notify:YES]; notify: YES];
} }
- (void)setAppClass:(id)sender - (void) setAppClass: (id)sender
{ {
[self setProjectDictObject:[appClassField stringValue] [self setProjectDictObject: [appClassField stringValue]
forKey:PCPrincipalClass forKey: PCPrincipalClass
notify:YES]; notify: YES];
} }
- (void)setIconViewImage:(NSImage *)image - (void) setIconViewImage: (NSImage *)image
{ {
[iconView setImage:nil]; [iconView setImage: nil];
[iconView display]; [iconView display];
if (image == nil) if (image == nil)
@ -131,11 +132,11 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
return; return;
} }
[iconView setImage:image]; [iconView setImage: image];
[iconView display]; [iconView display];
} }
- (void)setFile:(id)sender - (void) setFile: (id)sender
{ {
if (!activeTextField) if (!activeTextField)
{ {
@ -144,18 +145,22 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
if (activeTextField == appImageField) if (activeTextField == appImageField)
{ {
[self setAppIcon:self]; [self setAppIcon: self];
} }
else if (activeTextField == helpFileField) else if (activeTextField == helpFileField)
{ {
NSString *value = [activeTextField stringValue];
[self setProjectDictObject: value forKey: PCHelpFile notify: YES];
NSLog(@"Set %@", value);
} }
else if (activeTextField == mainNIBField) else if (activeTextField == mainNIBField)
{ {
[self setMainNib:self]; [self setMainNib: self];
} }
} }
- (void)clearFile:(id)sender - (void) clearFile: (id)sender
{ {
if (!activeTextField) if (!activeTextField)
{ {
@ -164,40 +169,42 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
if (activeTextField == appImageField) if (activeTextField == appImageField)
{ {
[self clearAppIcon:self]; [self clearAppIcon: self];
} }
else if (activeTextField == helpFileField) else if (activeTextField == helpFileField)
{ {
[infoDict removeObjectForKey: @"GSHelpContentsFile"];
[self setProjectDictObject: @"" forKey: PCHelpFile notify: YES];
} }
else if (activeTextField == mainNIBField) else if (activeTextField == mainNIBField)
{ {
[self clearMainNib:self]; [self clearMainNib: self];
} }
[self setIconViewImage:nil]; [self setIconViewImage: nil];
} }
// Application Icon // Application Icon
- (void)setAppIcon:(id)sender - (void) setAppIcon: (id)sender
{ {
int result; int result;
NSArray *fileTypes = [NSImage imageFileTypes]; NSArray *fileTypes = [NSImage imageFileTypes];
NSOpenPanel *openPanel = [NSOpenPanel openPanel]; NSOpenPanel *openPanel = [NSOpenPanel openPanel];
NSString *dir = nil; NSString *dir = nil;
[openPanel setAllowsMultipleSelection:NO]; [openPanel setAllowsMultipleSelection: NO];
[openPanel setTitle:@"Set Application Icon"]; [openPanel setTitle: @"Set Application Icon"];
dir = [[NSUserDefaults standardUserDefaults] dir = [[NSUserDefaults standardUserDefaults]
objectForKey:@"LastOpenDirectory"]; objectForKey: @"LastOpenDirectory"];
result = [openPanel runModalForDirectory:dir result = [openPanel runModalForDirectory: dir
file:nil file: nil
types:fileTypes]; types: fileTypes];
if (result == NSOKButton) if (result == NSOKButton)
{ {
NSString *imageFilePath = [[openPanel filenames] objectAtIndex:0]; NSString *imageFilePath = [[openPanel filenames] objectAtIndex: 0];
if (![self setAppIconWithImageAtPath:imageFilePath]) if (![self setAppIconWithImageAtPath: imageFilePath])
{ {
NSRunAlertPanel(@"Error while opening file!", NSRunAlertPanel(@"Error while opening file!",
@"Couldn't open %@", @"OK", nil, nil,imageFilePath); @"Couldn't open %@", @"OK", nil, nil,imageFilePath);
@ -205,62 +212,62 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
} }
} }
- (void)clearAppIcon:(id)sender - (void) clearAppIcon: (id)sender
{ {
[appImageField setStringValue:@""]; [appImageField setStringValue: @""];
[infoDict setObject:@"" forKey:@"NSIcon"]; [infoDict setObject: @"" forKey: @"NSIcon"];
[infoDict setObject:@"" forKey:@"ApplicationIcon"]; [infoDict setObject: @"" forKey: @"ApplicationIcon"];
[self setProjectDictObject:@"" forKey:PCAppIcon notify:YES]; [self setProjectDictObject: @"" forKey: PCAppIcon notify: YES];
} }
- (BOOL)setAppIconWithImageAtPath:(NSString *)path - (BOOL) setAppIconWithImageAtPath: (NSString *)path
{ {
NSImage *image = nil; NSImage *image = nil;
NSString *imageName = nil; NSString *imageName = nil;
if (!(image = [[NSImage alloc] initWithContentsOfFile:path])) if (!(image = [[NSImage alloc] initWithContentsOfFile: path]))
{ {
return NO; return NO;
} }
imageName = [path lastPathComponent]; imageName = [path lastPathComponent];
[appImageField setStringValue:imageName]; [appImageField setStringValue: imageName];
[self setIconViewImage:image]; [self setIconViewImage: image];
[self addAndCopyFiles:[NSArray arrayWithObject:path] forKey:PCImages]; [self addAndCopyFiles: [NSArray arrayWithObject: path] forKey: PCImages];
[infoDict setObject:imageName forKey:@"NSIcon"]; [infoDict setObject: imageName forKey: @"NSIcon"];
[infoDict setObject:imageName forKey:@"ApplicationIcon"]; [infoDict setObject: imageName forKey: @"ApplicationIcon"];
[self setProjectDictObject:imageName forKey:PCAppIcon notify:YES]; [self setProjectDictObject: imageName forKey: PCAppIcon notify: YES];
return YES; return YES;
} }
// Main Interface File // Main Interface File
- (void)setMainNib:(id)sender - (void) setMainNib: (id)sender
{ {
int result; int result;
NSOpenPanel *openPanel = [NSOpenPanel openPanel]; NSOpenPanel *openPanel = [NSOpenPanel openPanel];
NSString *dir = nil; NSString *dir = nil;
[openPanel setAllowsMultipleSelection:NO]; [openPanel setAllowsMultipleSelection: NO];
[openPanel setTitle:@"Set Main Interface File"]; [openPanel setTitle: @"Set Main Interface File"];
dir = [[NSUserDefaults standardUserDefaults] dir = [[NSUserDefaults standardUserDefaults]
objectForKey:@"LastOpenDirectory"]; objectForKey: @"LastOpenDirectory"];
result = [openPanel runModalForDirectory:dir result = [openPanel runModalForDirectory: dir
file:nil file: nil
types:[NSArray arrayWithObject:@"gorm"]]; types: [NSArray arrayWithObject: @"gorm"]];
if (result == NSOKButton) if (result == NSOKButton)
{ {
NSString *file = [[openPanel filenames] objectAtIndex:0]; NSString *file = [[openPanel filenames] objectAtIndex: 0];
if (![self setMainNibWithFileAtPath:file]) if (![self setMainNibWithFileAtPath: file])
{ {
NSRunAlertPanel(@"Error while opening file!", NSRunAlertPanel(@"Error while opening file!",
@"Couldn't open %@", @"OK", nil, nil,file); @"Couldn't open %@", @"OK", nil, nil,file);
@ -268,223 +275,224 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
} }
} }
- (BOOL)setMainNibWithFileAtPath:(NSString *)path - (BOOL) setMainNibWithFileAtPath: (NSString *)path
{ {
NSString *nibName = [path lastPathComponent]; NSString *nibName = [path lastPathComponent];
[self setIconViewImage:[[NSWorkspace sharedWorkspace] iconForFile:path]]; [self setIconViewImage: [[NSWorkspace sharedWorkspace] iconForFile: path]];
[self addAndCopyFiles:[NSArray arrayWithObject:path] forKey:PCInterfaces]; [self addAndCopyFiles: [NSArray arrayWithObject: path] forKey: PCInterfaces];
[infoDict setObject:nibName forKey:@"NSMainNibFile"]; [infoDict setObject: nibName forKey: @"NSMainNibFile"];
[self setProjectDictObject:nibName forKey:PCMainInterfaceFile notify:YES]; [self setProjectDictObject: nibName forKey: PCMainInterfaceFile notify: YES];
[mainNIBField setStringValue:nibName]; [mainNIBField setStringValue: nibName];
return YES; return YES;
} }
- (void)clearMainNib:(id)sender - (void) clearMainNib: (id)sender
{ {
[mainNIBField setStringValue:@""]; [mainNIBField setStringValue: @""];
[infoDict setObject:@"" forKey:@"NSMainNibFile"]; [infoDict setObject: @"" forKey: @"NSMainNibFile"];
[self setProjectDictObject:@"" forKey:PCMainInterfaceFile notify:YES]; [self setProjectDictObject: @"" forKey: PCMainInterfaceFile notify: YES];
} }
// Document Types // Document Types
- (void)showDocTypesPanel:(id)sender - (void) showDocTypesPanel: (id)sender
{ {
[docTypesPanel makeKeyAndOrderFront:nil]; [docTypesPanel makeKeyAndOrderFront: nil];
} }
- (void)setDocBasedApp:(id)sender - (void) setDocBasedApp: (id)sender
{ {
NSString *docBased = [projectDict objectForKey:PCDocumentBasedApp]; NSString *docBased = [projectDict objectForKey: PCDocumentBasedApp];
if ([docBasedAppButton state] == NSOnState) if ([docBasedAppButton state] == NSOnState)
{ {
[docTypeLabel setTextColor:[NSColor blackColor]]; [docTypeLabel setTextColor: [NSColor blackColor]];
[docTypeField setBackgroundColor:[NSColor whiteColor]]; [docTypeField setBackgroundColor: [NSColor whiteColor]];
[docTypeField setTextColor:[NSColor blackColor]]; [docTypeField setTextColor: [NSColor blackColor]];
[docTypeField setEditable:YES]; [docTypeField setEditable: YES];
[docNameLabel setTextColor:[NSColor blackColor]]; [docNameLabel setTextColor: [NSColor blackColor]];
[docNameField setBackgroundColor:[NSColor whiteColor]]; [docNameField setBackgroundColor: [NSColor whiteColor]];
[docNameField setTextColor:[NSColor blackColor]]; [docNameField setTextColor: [NSColor blackColor]];
[docNameField setEditable:YES]; [docNameField setEditable: YES];
[docRoleLabel setTextColor:[NSColor blackColor]]; [docRoleLabel setTextColor: [NSColor blackColor]];
[docRoleField setBackgroundColor:[NSColor whiteColor]]; [docRoleField setBackgroundColor: [NSColor whiteColor]];
[docRoleField setTextColor:[NSColor blackColor]]; [docRoleField setTextColor: [NSColor blackColor]];
[docRoleField setEditable:YES]; [docRoleField setEditable: YES];
[docClassLabel setTextColor:[NSColor blackColor]]; [docClassLabel setTextColor: [NSColor blackColor]];
[docClassField setBackgroundColor:[NSColor whiteColor]]; [docClassField setBackgroundColor: [NSColor whiteColor]];
[docClassField setTextColor:[NSColor blackColor]]; [docClassField setTextColor: [NSColor blackColor]];
[docClassField setEditable:YES]; [docClassField setEditable: YES];
[nameColumn setIdentifier:@"NSHumanReadableName"]; [nameColumn setIdentifier: @"NSHumanReadableName"];
[[nameColumn headerCell] setStringValue:@"Name"]; [[nameColumn headerCell] setStringValue: @"Name"];
[docTypesList addTableColumn:roleColumn]; [docTypesList addTableColumn: roleColumn];
[docTypesList addTableColumn:classColumn]; [docTypesList addTableColumn: classColumn];
RELEASE(roleColumn); RELEASE(roleColumn);
RELEASE(classColumn); RELEASE(classColumn);
if (![docBased isEqualToString:@"YES"]) if (![docBased isEqualToString: @"YES"])
{ {
[self setProjectDictObject:@"YES" [self setProjectDictObject: @"YES"
forKey:PCDocumentBasedApp forKey: PCDocumentBasedApp
notify:YES]; notify: YES];
} }
} }
else else
{ {
[docTypeLabel setTextColor:[NSColor darkGrayColor]]; [docTypeLabel setTextColor: [NSColor darkGrayColor]];
[docTypeField setBackgroundColor:[NSColor lightGrayColor]]; [docTypeField setBackgroundColor: [NSColor lightGrayColor]];
[docTypeField setTextColor:[NSColor darkGrayColor]]; [docTypeField setTextColor: [NSColor darkGrayColor]];
[docTypeField setEditable:NO]; [docTypeField setEditable: NO];
[docNameLabel setTextColor:[NSColor darkGrayColor]]; [docNameLabel setTextColor: [NSColor darkGrayColor]];
[docNameField setBackgroundColor:[NSColor lightGrayColor]]; [docNameField setBackgroundColor: [NSColor lightGrayColor]];
[docNameField setTextColor:[NSColor darkGrayColor]]; [docNameField setTextColor: [NSColor darkGrayColor]];
[docNameField setEditable:NO]; [docNameField setEditable: NO];
[docRoleLabel setTextColor:[NSColor darkGrayColor]]; [docRoleLabel setTextColor: [NSColor darkGrayColor]];
[docRoleField setBackgroundColor:[NSColor lightGrayColor]]; [docRoleField setBackgroundColor: [NSColor lightGrayColor]];
[docRoleField setTextColor:[NSColor darkGrayColor]]; [docRoleField setTextColor: [NSColor darkGrayColor]];
[docRoleField setEditable:NO]; [docRoleField setEditable: NO];
[docClassLabel setTextColor:[NSColor darkGrayColor]]; [docClassLabel setTextColor: [NSColor darkGrayColor]];
[docClassField setBackgroundColor:[NSColor lightGrayColor]]; [docClassField setBackgroundColor: [NSColor lightGrayColor]];
[docClassField setTextColor:[NSColor darkGrayColor]]; [docClassField setTextColor: [NSColor darkGrayColor]];
[docClassField setEditable:NO]; [docClassField setEditable: NO];
// Columns // Columns
// [docTypesList removeTableColumn:nameColumn]; // [docTypesList removeTableColumn: nameColumn];
[nameColumn setIdentifier:@"NSIcon"]; [nameColumn setIdentifier: @"NSIcon"];
[[nameColumn headerCell] setStringValue:@"Icon"]; [[nameColumn headerCell] setStringValue: @"Icon"];
RETAIN(roleColumn); RETAIN(roleColumn);
RETAIN(classColumn); RETAIN(classColumn);
[docTypesList removeTableColumn:roleColumn]; [docTypesList removeTableColumn: roleColumn];
[docTypesList removeTableColumn:classColumn]; [docTypesList removeTableColumn: classColumn];
if (![docBased isEqualToString:@"NO"]) if (![docBased isEqualToString: @"NO"])
{ {
[self setProjectDictObject:@"NO" [self setProjectDictObject: @"NO"
forKey:PCDocumentBasedApp forKey: PCDocumentBasedApp
notify:YES]; notify: YES];
} }
} }
} }
- (void)addDocType:(id)sender - (void) addDocType: (id)sender
{ {
int row; int row;
NSMutableDictionary *entry = [NSMutableDictionary dictionaryWithCapacity:6]; NSMutableDictionary *entry = [NSMutableDictionary dictionaryWithCapacity: 6];
int selectedRow = [docTypesList selectedRow]; int selectedRow = [docTypesList selectedRow];
[entry setObject:@"" forKey:@"NSName"]; [entry setObject: @"" forKey: @"NSName"];
[entry setObject:@"" forKey:@"NSHumanReadableName"]; [entry setObject: @"" forKey: @"NSHumanReadableName"];
[entry setObject:[NSArray array] forKey:@"NSUnixExtensions"]; [entry setObject: [NSArray array] forKey: @"NSUnixExtensions"];
[entry setObject:@"" forKey:@"NSIcon"]; [entry setObject: @"" forKey: @"NSIcon"];
[entry setObject:@"" forKey:@"NSRole"]; [entry setObject: @"" forKey: @"NSRole"];
[entry setObject:@"NSDocumentClass" forKey:@"NSDocumentClass"]; [entry setObject: @"NSDocumentClass" forKey: @"NSDocumentClass"];
if (selectedRow >= 0 && [docTypesItems count] > 0) if (selectedRow >= 0 && [docTypesItems count] > 0)
{ {
[docTypesItems insertObject:entry atIndex:selectedRow + 1]; [docTypesItems insertObject: entry atIndex: selectedRow + 1];
row = selectedRow + 1; row = selectedRow + 1;
} }
else else
{ {
[docTypesItems addObject:entry]; [docTypesItems addObject: entry];
row = [docTypesItems count] - 1; row = [docTypesItems count] - 1;
} }
[docTypesList reloadData]; [docTypesList reloadData];
[docTypesList selectRow:row byExtendingSelection:NO]; [docTypesList selectRow: row byExtendingSelection: NO];
[docTypesList scrollRowToVisible:row]; [docTypesList scrollRowToVisible: row];
[self fillFieldsForRow:row]; [self fillFieldsForRow: row];
[self setProjectDictObject:docTypesItems [self setProjectDictObject: docTypesItems
forKey:PCDocumentTypes forKey: PCDocumentTypes
notify:YES]; notify: YES];
} }
- (void)removeDocType:(id)sender - (void) removeDocType: (id)sender
{ {
int selectedRow = [docTypesList selectedRow]; int selectedRow = [docTypesList selectedRow];
if (selectedRow >= 0) if (selectedRow >= 0)
{ {
[docTypesItems removeObjectAtIndex:selectedRow]; [docTypesItems removeObjectAtIndex: selectedRow];
[docTypesList reloadData]; [docTypesList reloadData];
} }
if (([docTypesList selectedRow] < 0) && ([docTypesItems count] > 0)) if (([docTypesList selectedRow] < 0) && ([docTypesItems count] > 0))
{ {
[docTypesList selectRow:[docTypesItems count]-1 byExtendingSelection:NO]; [docTypesList selectRow:
[docTypesItems count]-1 byExtendingSelection: NO];
} }
[self fillFieldsForRow:[docTypesList selectedRow]]; [self fillFieldsForRow: [docTypesList selectedRow]];
[self setProjectDictObject:docTypesItems [self setProjectDictObject: docTypesItems
forKey:PCDocumentTypes forKey: PCDocumentTypes
notify:YES]; notify: YES];
} }
- (void)docFieldSet:(id)sender - (void) docFieldSet: (id)sender
{ {
NSMutableDictionary *object = nil; NSMutableDictionary *object = nil;
NSLog(@"docFieldSet"); NSLog(@"docFieldSet");
if (sender != docTypeField && sender != docNameField if (sender != docTypeField && sender != docNameField
&& sender != docIconField && sender != docExtensionsField && sender != docIconField && sender != docExtensionsField
&& sender != docRoleField && sender != docClassField) && sender != docRoleField && sender != docClassField)
{ {
return; return;
} }
if ([docTypesItems count] <= 0) if ([docTypesItems count] <= 0)
{ {
[self addDocType:addDocTypeButton]; [self addDocType: addDocTypeButton];
} }
object = [[docTypesItems objectAtIndex:[docTypesList selectedRow]] object = [[docTypesItems objectAtIndex: [docTypesList selectedRow]]
mutableCopy]; mutableCopy];
if (sender == docTypeField) if (sender == docTypeField)
{ {
[object setObject:[sender stringValue] forKey:@"NSName"]; [object setObject: [sender stringValue] forKey: @"NSName"];
} }
else if (sender == docNameField) else if (sender == docNameField)
{ {
[object setObject:[sender stringValue] forKey:@"NSHumanReadableName"]; [object setObject: [sender stringValue] forKey: @"NSHumanReadableName"];
} }
else if (sender == docIconField) else if (sender == docIconField)
{ {
[object setObject:[sender stringValue] forKey:@"NSIcon"]; [object setObject: [sender stringValue] forKey: @"NSIcon"];
} }
else if (sender == docExtensionsField) else if (sender == docExtensionsField)
{ {
[object [object
setObject:[[sender stringValue] componentsSeparatedByString:@","] setObject: [[sender stringValue] componentsSeparatedByString: @","]
forKey:@"NSUnixExtensions"]; forKey: @"NSUnixExtensions"];
} }
else if (sender == docRoleField) else if (sender == docRoleField)
{ {
[object setObject:[sender stringValue] forKey:@"NSRole"]; [object setObject: [sender stringValue] forKey: @"NSRole"];
} }
else if (sender == docClassField) else if (sender == docClassField)
{ {
[object setObject:[sender stringValue] forKey:@"NSDocumentClass"]; [object setObject: [sender stringValue] forKey: @"NSDocumentClass"];
} }
[docTypesItems replaceObjectAtIndex:[docTypesList selectedRow] [docTypesItems replaceObjectAtIndex: [docTypesList selectedRow]
withObject:object]; withObject: object];
[docTypesList reloadData]; [docTypesList reloadData];
[object release]; [object release];
} }
@ -493,39 +501,39 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
// --- Document Types browser // --- Document Types browser
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
- (int)numberOfRowsInTableView:(NSTableView *)aTableView - (int) numberOfRowsInTableView: (NSTableView *)aTableView
{ {
return [docTypesItems count]; return [docTypesItems count];
} }
- (id) tableView:(NSTableView *)aTableView - (id) tableView: (NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn objectValueForTableColumn: (NSTableColumn *)aTableColumn
row:(int)rowIndex row: (int)rowIndex
{ {
NSDictionary *object = nil; NSDictionary *object = nil;
if (docTypesItems != nil || [docTypesItems count] > 0) if (docTypesItems != nil || [docTypesItems count] > 0)
{ {
object = [docTypesItems objectAtIndex:rowIndex]; object = [docTypesItems objectAtIndex: rowIndex];
if (aTableColumn == extensionsColumn) if (aTableColumn == extensionsColumn)
{ {
return [[object objectForKey:@"NSUnixExtensions"] return [[object objectForKey: @"NSUnixExtensions"]
componentsJoinedByString:@","]; componentsJoinedByString: @","];
} }
else else
{ {
return [object objectForKey:[aTableColumn identifier]]; return [object objectForKey: [aTableColumn identifier]];
} }
} }
return nil; return nil;
} }
- (void)tableView:(NSTableView *)aTableView - (void) tableView: (NSTableView *)aTableView
setObjectValue:anObject setObjectValue: anObject
forTableColumn:(NSTableColumn *)aTableColumn forTableColumn: (NSTableColumn *)aTableColumn
row:(int)rowIndex row: (int)rowIndex
{ {
NSMutableDictionary *type = nil; NSMutableDictionary *type = nil;
@ -534,94 +542,95 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
return; return;
} }
type = [docTypesItems objectAtIndex:rowIndex]; type = [docTypesItems objectAtIndex: rowIndex];
if ([[aTableColumn identifier] isEqualToString:@"NSUnixExtensions"]) if ([[aTableColumn identifier] isEqualToString: @"NSUnixExtensions"])
{ {
[type removeObjectForKey:@"Extension"]; [type removeObjectForKey: @"Extension"];
[type setObject:anObject forKey:@"Extension"]; [type setObject: anObject forKey: @"Extension"];
} }
else if ([[aTableColumn identifier] isEqualToString:@"NSIcon"]) else if ([[aTableColumn identifier] isEqualToString: @"NSIcon"])
{ {
[type removeObjectForKey:@"Icon"]; [type removeObjectForKey: @"Icon"];
[type setObject:anObject forKey:@"Icon"]; [type setObject: anObject forKey: @"Icon"];
} }
[self setProjectDictObject:docTypesItems [self setProjectDictObject: docTypesItems
forKey:PCDocumentTypes forKey: PCDocumentTypes
notify:YES]; notify: YES];
} }
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex - (BOOL) tableView: (NSTableView *)aTableView shouldSelectRow: (int)rowIndex
{ {
[self fillFieldsForRow:rowIndex]; [self fillFieldsForRow: rowIndex];
return YES; return YES;
} }
- (void)fillFieldsForRow:(int)rowIndex - (void) fillFieldsForRow: (int)rowIndex
{ {
NSDictionary *type = nil; NSDictionary *type = nil;
int itemCount = [docTypesItems count]; int itemCount = [docTypesItems count];
if (itemCount <= 0 || rowIndex > itemCount || rowIndex < 0) if (itemCount <= 0 || rowIndex > itemCount || rowIndex < 0)
{ {
[docTypeField setStringValue:@""]; [docTypeField setStringValue: @""];
[docNameField setStringValue:@""]; [docNameField setStringValue: @""];
[docIconField setStringValue:@""]; [docIconField setStringValue: @""];
[docExtensionsField setStringValue:@""]; [docExtensionsField setStringValue: @""];
[docRoleField setStringValue:@""]; [docRoleField setStringValue: @""];
[docClassField setStringValue:@""]; [docClassField setStringValue: @""];
return; return;
} }
type = [docTypesItems objectAtIndex:rowIndex]; type = [docTypesItems objectAtIndex: rowIndex];
[docTypeField setStringValue:[type objectForKey:@"NSName"]]; [docTypeField setStringValue: [type objectForKey: @"NSName"]];
[docNameField setStringValue:[type objectForKey:@"NSHumanReadableName"]]; [docNameField setStringValue: [type objectForKey: @"NSHumanReadableName"]];
[docIconField setStringValue:[type objectForKey:@"NSIcon"]]; [docIconField setStringValue: [type objectForKey: @"NSIcon"]];
[docExtensionsField setStringValue:@""]; [docExtensionsField setStringValue: @""];
if ([[type objectForKey:@"NSUnixExtensions"] count] > 0) if ([[type objectForKey: @"NSUnixExtensions"] count] > 0)
{ {
[docExtensionsField setStringValue: [docExtensionsField setStringValue:
[[type objectForKey:@"NSUnixExtensions"] [[type objectForKey: @"NSUnixExtensions"]
componentsJoinedByString:@","]]; componentsJoinedByString: @","]];
} }
[docRoleField setStringValue:[type objectForKey:@"NSRole"]]; [docRoleField setStringValue: [type objectForKey: @"NSRole"]];
[docClassField setStringValue:[type objectForKey:@"NSDocumentClass"]]; [docClassField setStringValue: [type objectForKey: @"NSDocumentClass"]];
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// --- Notifications // --- Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
- (void)updateInspectorValues:(NSNotification *)aNotif - (void) updateInspectorValues: (NSNotification *)aNotif
{ {
// NSLog (@"PCAppProject: updateInspectorValues"); // NSLog (@"PCAppProject: updateInspectorValues");
// Project Attributes view // Project Attributes view
[projectTypeField setStringValue:[projectDict objectForKey:PCProjectType]]; [projectTypeField setStringValue: [projectDict objectForKey: PCProjectType]];
[projectNameField setStringValue:[projectDict objectForKey:PCProjectName]]; [projectNameField setStringValue: [projectDict objectForKey: PCProjectName]];
// [projectLanguageField setStringValue:[projectDict objectForKey:PCLanguage]]; // [projectLanguageField setStringValue: [projectDict objectForKey: PCLanguage]];
[appClassField setStringValue:[projectDict objectForKey:PCPrincipalClass]]; [appClassField setStringValue: [projectDict objectForKey: PCPrincipalClass]];
[appImageField setStringValue:[projectDict objectForKey:PCAppIcon]]; [appImageField setStringValue: [projectDict objectForKey: PCAppIcon]];
[helpFileField setStringValue:[projectDict objectForKey:PCHelpFile]]; [helpFileField setStringValue: [projectDict objectForKey: PCHelpFile]];
[mainNIBField setStringValue:[projectDict objectForKey:PCMainInterfaceFile]]; [mainNIBField setStringValue:
[projectDict objectForKey: PCMainInterfaceFile]];
docTypesItems = [projectDict objectForKey:PCDocumentTypes]; docTypesItems = [projectDict objectForKey: PCDocumentTypes];
[docTypesList reloadData]; [docTypesList reloadData];
} }
// TextFields (PCITextField subclass) // TextFields (PCITextField subclass)
// //
// NSTextField become first responder when user clicks on it and immediately // NSTextField become first responder when user clicks on it and immediately
// lost first resonder status, so we can't catch when focus leaves textfield // lost first responder status, so we can't catch when focus leaves textfield
// with resignFirstResponder: method overriding. Here we're using // with resignFirstResponder: method overriding. Here we're using
// controlTextDidEndEditing (NSTextField's delegate method) to achieve this. // controlTextDidEndEditing (NSTextField's delegate method) to achieve this.
- (void)tfGetFocus:(NSNotification *)aNotif - (void) tfGetFocus: (NSNotification *)aNotif
{ {
id anObject = [aNotif object]; id anObject = [aNotif object];
NSString *file = nil; NSString *file = nil;
@ -629,8 +638,8 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
if (anObject != appImageField if (anObject != appImageField
&& anObject != helpFileField && anObject != helpFileField
&& anObject != mainNIBField) && anObject != mainNIBField)
{ {
// NSLog(@"tfGetFocus: not that textfield"); // NSLog(@"tfGetFocus: not that textfield");
return; return;
@ -640,12 +649,12 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
{ {
file = [appImageField stringValue]; file = [appImageField stringValue];
if (![file isEqualToString:@""]) if (![file isEqualToString: @""])
{ {
path = [self dirForCategoryKey:PCImages]; path = [self dirForCategoryKey: PCImages];
path = [path stringByAppendingPathComponent:file]; path = [path stringByAppendingPathComponent: file];
[self setIconViewImage:[[NSImage alloc] [self setIconViewImage: [[NSImage alloc]
initWithContentsOfFile:path]]; initWithContentsOfFile: path]];
} }
activeTextField = appImageField; activeTextField = appImageField;
} }
@ -657,41 +666,41 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
{ {
file = [mainNIBField stringValue]; file = [mainNIBField stringValue];
if (![file isEqualToString:@""]) if (![file isEqualToString: @""])
{ {
path = [projectPath stringByAppendingPathComponent:file]; path = [projectPath stringByAppendingPathComponent: file];
[self setIconViewImage:[[NSWorkspace sharedWorkspace] [self setIconViewImage: [[NSWorkspace sharedWorkspace]
iconForFile:path]]; iconForFile: path]];
} }
activeTextField = mainNIBField; activeTextField = mainNIBField;
} }
[setFieldButton setEnabled:YES]; [setFieldButton setEnabled: YES];
[clearFieldButton setEnabled:YES]; [clearFieldButton setEnabled: YES];
} }
- (void)controlTextDidEndEditing:(NSNotification *)aNotification - (void) controlTextDidEndEditing: (NSNotification *)aNotification
{ {
NSControl *anObject = [aNotification object]; NSControl *anObject = [aNotification object];
id target = [anObject target]; id target = [anObject target];
SEL action = [anObject action]; SEL action = [anObject action];
if (anObject == appImageField if (anObject == appImageField
|| anObject == helpFileField || anObject == helpFileField
|| anObject == mainNIBField) || anObject == mainNIBField)
{ {
activeTextField = nil; activeTextField = nil;
[self setIconViewImage:nil]; [self setIconViewImage: nil];
[setFieldButton setEnabled:NO]; [setFieldButton setEnabled: NO];
[clearFieldButton setEnabled:NO]; [clearFieldButton setEnabled: NO];
return; return;
} }
if ([target respondsToSelector:action]) if ([target respondsToSelector: action])
{ {
[target performSelector:action withObject:anObject]; [target performSelector: action withObject: anObject];
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
GNUstep ProjectCenter - http://www.gnustep.org GNUstep ProjectCenter - http: //www.gnustep.org
Copyright (C) 2001-2004 Free Software Foundation Copyright (C) 2001-2004 Free Software Foundation
@ -20,7 +20,8 @@
You should have received a copy of the GNU General Public You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USAA. Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USAA.
*/ */
#include <ProjectCenter/ProjectCenter.h> #include <ProjectCenter/ProjectCenter.h>
@ -72,26 +73,26 @@
nil] retain]; nil] retain];
rootEntries = [[NSDictionary rootEntries = [[NSDictionary
dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; dictionaryWithObjects: rootCategories forKeys: rootKeys] retain];
} }
return self; return self;
} }
- (void)assignInfoDict:(NSMutableDictionary *)dict - (void)assignInfoDict: (NSMutableDictionary *)dict
{ {
infoDict = [dict mutableCopy]; infoDict = [dict mutableCopy];
} }
- (void)loadInfoFileAtPath:(NSString *)path - (void)loadInfoFileAtPath: (NSString *)path
{ {
NSString *infoFile = nil; NSString *infoFile = nil;
infoFile = [self dirForCategoryKey:PCOtherResources]; infoFile = [self dirForCategoryKey: PCOtherResources];
infoFile = [infoFile stringByAppendingPathComponent:@"Info-gnustep.plist"]; infoFile = [infoFile stringByAppendingPathComponent: @"Info-gnustep.plist"];
if ([[NSFileManager defaultManager] fileExistsAtPath:infoFile]) if ([[NSFileManager defaultManager] fileExistsAtPath: infoFile])
{ {
infoDict = [[NSMutableDictionary alloc] initWithContentsOfFile:infoFile]; infoDict = [[NSMutableDictionary alloc] initWithContentsOfFile: infoFile];
} }
else else
{ {
@ -105,7 +106,7 @@
NSLog (@"PCAppProject: dealloc"); NSLog (@"PCAppProject: dealloc");
#endif #endif
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(infoDict); RELEASE(infoDict);
RELEASE(projectAttributesView); RELEASE(projectAttributesView);
@ -138,37 +139,37 @@
- (NSString *)execToolName - (NSString *)execToolName
{ {
return [NSString stringWithString:@"openapp"]; return [NSString stringWithString: @"openapp"];
} }
- (NSArray *)buildTargets - (NSArray *)buildTargets
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
@"app", @"debug", @"profile", @"dist", nil]; @"app", @"debug", @"profile", @"dist", nil];
} }
- (NSArray *)sourceFileKeys - (NSArray *)sourceFileKeys
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
PCClasses, PCHeaders, PCOtherSources, PCClasses, PCHeaders, PCOtherSources,
PCSupportingFiles, PCSubprojects, nil]; PCSupportingFiles, PCSubprojects, nil];
} }
- (NSArray *)resourceFileKeys - (NSArray *)resourceFileKeys
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
PCInterfaces, PCImages, PCOtherResources, PCDocuFiles, nil]; PCInterfaces, PCImages, PCOtherResources, PCDocuFiles, nil];
} }
- (NSArray *)otherKeys - (NSArray *)otherKeys
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
PCLibraries, PCNonProject, nil]; PCLibraries, PCNonProject, nil];
} }
- (NSArray *)allowableSubprojectTypes - (NSArray *)allowableSubprojectTypes
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
@"Aggregate", @"Bundle", @"Tool", @"Library", @"Framework", nil]; @"Aggregate", @"Bundle", @"Tool", @"Library", @"Framework", nil];
} }
@ -182,11 +183,11 @@
// ==== File Handling // ==== File Handling
// ============================================================================ // ============================================================================
- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key notify:(BOOL)yn - (BOOL)removeFiles: (NSArray *)files forKey: (NSString *)key notify: (BOOL)yn
{ {
NSMutableArray *filesToRemove = [[files mutableCopy] autorelease]; NSMutableArray *filesToRemove = [[files mutableCopy] autorelease];
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; NSString *mainNibFile = [projectDict objectForKey: PCMainInterfaceFile];
NSString *appIcon = [projectDict objectForKey:PCAppIcon]; NSString *appIcon = [projectDict objectForKey: PCAppIcon];
if (!files || !key) if (!files || !key)
{ {
@ -194,7 +195,7 @@
} }
// Check for main NIB file // Check for main NIB file
if ([key isEqualToString:PCInterfaces] && [files containsObject:mainNibFile]) if ([key isEqualToString: PCInterfaces] && [files containsObject: mainNibFile])
{ {
int ret; int ret;
ret = NSRunAlertPanel(@"Remove", ret = NSRunAlertPanel(@"Remove",
@ -203,15 +204,15 @@
if (ret == NSAlertAlternateReturn) // Leave if (ret == NSAlertAlternateReturn) // Leave
{ {
[filesToRemove removeObject:mainNibFile]; [filesToRemove removeObject: mainNibFile];
} }
else else
{ {
[self clearMainNib:self]; [self clearMainNib: self];
} }
} }
// Check for application icon files // Check for application icon files
else if ([key isEqualToString:PCImages] && [files containsObject:appIcon]) else if ([key isEqualToString: PCImages] && [files containsObject: appIcon])
{ {
int ret; int ret;
ret = NSRunAlertPanel(@"Remove", ret = NSRunAlertPanel(@"Remove",
@ -220,55 +221,55 @@
if (ret == NSAlertAlternateReturn) // Leave if (ret == NSAlertAlternateReturn) // Leave
{ {
[filesToRemove removeObject:appIcon]; [filesToRemove removeObject: appIcon];
} }
else else
{ {
[self clearAppIcon:self]; [self clearAppIcon: self];
} }
} }
return [super removeFiles:filesToRemove forKey:key notify:yn]; return [super removeFiles: filesToRemove forKey: key notify: yn];
} }
- (BOOL)renameFile:(NSString *)fromFile toFile:(NSString *)toFile - (BOOL)renameFile: (NSString *)fromFile toFile: (NSString *)toFile
{ {
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; NSString *mainNibFile = [projectDict objectForKey: PCMainInterfaceFile];
NSString *appIcon = [projectDict objectForKey:PCAppIcon]; NSString *appIcon = [projectDict objectForKey: PCAppIcon];
NSString *categoryKey = nil; NSString *categoryKey = nil;
NSString *ff = [fromFile copy]; NSString *ff = [fromFile copy];
NSString *tf = [toFile copy]; NSString *tf = [toFile copy];
BOOL success = NO; BOOL success = NO;
categoryKey = [self categoryKey = [self
keyForCategory:[projectBrowser nameOfSelectedRootCategory]]; keyForCategory: [projectBrowser nameOfSelectedRootCategory]];
// Check for main NIB file // Check for main NIB file
if ([categoryKey isEqualToString:PCInterfaces] if ([categoryKey isEqualToString: PCInterfaces]
&& [fromFile isEqualToString:mainNibFile]) && [fromFile isEqualToString: mainNibFile])
{ {
[self clearMainNib:self]; [self clearMainNib: self];
if ([super renameFile:ff toFile:tf] == YES) if ([super renameFile: ff toFile: tf] == YES)
{ {
[self setMainNibWithFileAtPath: [self setMainNibWithFileAtPath:
[[self dirForCategoryKey:categoryKey] [[self dirForCategoryKey: categoryKey]
stringByAppendingPathComponent:tf]]; stringByAppendingPathComponent: tf]];
success = YES; success = YES;
} }
} }
// Check for application icon files // Check for application icon files
else if ([categoryKey isEqualToString:PCImages] else if ([categoryKey isEqualToString: PCImages]
&& [fromFile isEqualToString:appIcon]) && [fromFile isEqualToString: appIcon])
{ {
[self clearAppIcon:self]; [self clearAppIcon: self];
if ([super renameFile:ff toFile:tf] == YES) if ([super renameFile: ff toFile: tf] == YES)
{ {
[self setAppIconWithImageAtPath: [self setAppIconWithImageAtPath:
[[self dirForCategoryKey:categoryKey] [[self dirForCategoryKey: categoryKey]
stringByAppendingPathComponent:tf]]; stringByAppendingPathComponent: tf]];
success = YES; success = YES;
} }
} }
else if ([super renameFile:ff toFile:tf] == YES) else if ([super renameFile: ff toFile: tf] == YES)
{ {
success = YES; success = YES;
} }
@ -283,74 +284,75 @@
@implementation PCAppProject (GeneratedFiles) @implementation PCAppProject (GeneratedFiles)
- (void)writeInfoEntry:(NSString *)name forKey:(NSString *)key - (void)writeInfoEntry: (NSString *)name forKey: (NSString *)key
{ {
id entry = [projectDict objectForKey:key]; id entry = [projectDict objectForKey: key];
if (entry == nil) if (entry == nil)
{ {
return; return;
} }
if ([entry isKindOfClass:[NSString class]] && [entry isEqualToString:@""]) if ([entry isKindOfClass: [NSString class]] && [entry isEqualToString: @""])
{ {
[infoDict removeObjectForKey:name]; [infoDict removeObjectForKey: name];
return; return;
} }
if ([entry isKindOfClass:[NSArray class]] && [entry count] <= 0) if ([entry isKindOfClass: [NSArray class]] && [entry count] <= 0)
{ {
[infoDict removeObjectForKey:name]; [infoDict removeObjectForKey: name];
return; return;
} }
[infoDict setObject:entry forKey:name]; [infoDict setObject: entry forKey: name];
} }
- (BOOL)writeInfoFile - (BOOL)writeInfoFile
{ {
NSString *infoFile = nil; NSString *infoFile = nil;
[self writeInfoEntry:@"ApplicationDescription" forKey:PCDescription]; [self writeInfoEntry: @"ApplicationDescription" forKey: PCDescription];
[self writeInfoEntry:@"ApplicationIcon" forKey:PCAppIcon]; [self writeInfoEntry: @"ApplicationIcon" forKey: PCAppIcon];
[self writeInfoEntry:@"ApplicationName" forKey:PCProjectName]; [self writeInfoEntry: @"ApplicationName" forKey: PCProjectName];
[self writeInfoEntry:@"ApplicationRelease" forKey:PCRelease]; [self writeInfoEntry: @"ApplicationRelease" forKey: PCRelease];
[self writeInfoEntry:@"Authors" forKey:PCAuthors]; [self writeInfoEntry: @"Authors" forKey: PCAuthors];
[self writeInfoEntry:@"Copyright" forKey:PCCopyright]; [self writeInfoEntry: @"Copyright" forKey: PCCopyright];
[self writeInfoEntry:@"CopyrightDescription" forKey:PCCopyrightDescription]; [self writeInfoEntry: @"CopyrightDescription" forKey: PCCopyrightDescription];
[self writeInfoEntry:@"FullVersionID" forKey:PCRelease]; [self writeInfoEntry: @"FullVersionID" forKey: PCRelease];
[self writeInfoEntry:@"NSExecutable" forKey:PCProjectName]; [self writeInfoEntry: @"NSExecutable" forKey: PCProjectName];
[self writeInfoEntry:@"NSIcon" forKey:PCAppIcon]; [self writeInfoEntry: @"NSIcon" forKey: PCAppIcon];
[self writeInfoEntry:@"NSMainNibFile" forKey:PCMainInterfaceFile]; [self writeInfoEntry: @"NSMainNibFile" forKey: PCMainInterfaceFile];
[self writeInfoEntry:@"NSPrincipalClass" forKey:PCPrincipalClass]; [self writeInfoEntry: @"NSPrincipalClass" forKey: PCPrincipalClass];
[infoDict setObject:@"Application" forKey:@"NSRole"]; [self writeInfoEntry: @"GSHelpContentsFile" forKey: PCHelpFile];
// [infoDict setObject:[self convertExtensions] forKey:@"NSTypes"]; [infoDict setObject: @"Application" forKey: @"NSRole"];
[self writeInfoEntry:@"NSTypes" forKey:PCDocumentTypes]; // [infoDict setObject: [self convertExtensions] forKey: @"NSTypes"];
[self writeInfoEntry:@"URL" forKey:PCURL]; [self writeInfoEntry: @"NSTypes" forKey: PCDocumentTypes];
[self writeInfoEntry: @"URL" forKey: PCURL];
infoFile = [self dirForCategoryKey:PCOtherResources]; infoFile = [self dirForCategoryKey: PCOtherResources];
infoFile = [infoFile stringByAppendingPathComponent:@"Info-gnustep.plist"]; infoFile = [infoFile stringByAppendingPathComponent: @"Info-gnustep.plist"];
return [infoDict writeToFile:infoFile atomically:YES]; return [infoDict writeToFile: infoFile atomically: YES];
} }
- (NSArray *)convertExtensions - (NSArray *)convertExtensions
{ {
NSMutableArray *icons = [NSMutableArray arrayWithCapacity:1]; NSMutableArray *icons = [NSMutableArray arrayWithCapacity: 1];
NSMutableArray *extensions = [NSMutableArray arrayWithCapacity:1]; NSMutableArray *extensions = [NSMutableArray arrayWithCapacity: 1];
NSArray *docIE = [projectDict objectForKey:PCDocumentExtensions]; NSArray *docIE = [projectDict objectForKey: PCDocumentExtensions];
NSEnumerator *enumerator = [docIE objectEnumerator]; NSEnumerator *enumerator = [docIE objectEnumerator];
NSDictionary *anObject; NSDictionary *anObject;
NSMutableArray *resArray = [[NSMutableArray alloc] init]; NSMutableArray *resArray = [[NSMutableArray alloc] init];
NSMutableDictionary *tmpDict = [NSMutableDictionary dictionaryWithCapacity:1]; NSMutableDictionary *tmpDict = [NSMutableDictionary dictionaryWithCapacity: 1];
NSString *ic; NSString *ic;
NSArray *ex; NSArray *ex;
while ((anObject = [enumerator nextObject])) while ((anObject = [enumerator nextObject]))
{ {
[icons addObject:[anObject objectForKey:@"Icon"]]; [icons addObject: [anObject objectForKey: @"Icon"]];
[extensions addObject:[anObject objectForKey:@"Extension"]]; [extensions addObject: [anObject objectForKey: @"Extension"]];
} }
// At this point we have 2 arrays; 1 list of icons and 2 list of extensions. // At this point we have 2 arrays; 1 list of icons and 2 list of extensions.
@ -362,18 +364,18 @@
NSMutableDictionary *tdict; NSMutableDictionary *tdict;
NSString *tic; NSString *tic;
ic = [icons objectAtIndex:0]; ic = [icons objectAtIndex: 0];
ex = [NSMutableArray arrayWithObject:[extensions objectAtIndex:0]]; ex = [NSMutableArray arrayWithObject: [extensions objectAtIndex: 0]];
for (i = 0; i < [resArray count]; i++) for (i = 0; i < [resArray count]; i++)
{ {
tdict = [resArray objectAtIndex:i]; tdict = [resArray objectAtIndex: i];
tic = [tdict objectForKey:@"NSIcon"]; tic = [tdict objectForKey: @"NSIcon"];
if([tic isEqualToString:ic]) if([tic isEqualToString: ic])
{ {
[[tdict objectForKey:@"NSUnixExtensions"] [[tdict objectForKey: @"NSUnixExtensions"]
addObject:[ex objectAtIndex:0]]; addObject: [ex objectAtIndex: 0]];
loaded = YES; loaded = YES;
continue; continue;
} }
@ -381,15 +383,15 @@
if (!loaded) if (!loaded)
{ {
[tmpDict setObject:ic forKey:@"NSIcon"]; [tmpDict setObject: ic forKey: @"NSIcon"];
[tmpDict setObject:ex forKey:@"NSUnixExtensions"]; [tmpDict setObject: ex forKey: @"NSUnixExtensions"];
[resArray addObject:[tmpDict copy]]; [resArray addObject: [tmpDict copy]];
} }
[tmpDict removeAllObjects]; [tmpDict removeAllObjects];
[icons removeObjectAtIndex:0]; [icons removeObjectAtIndex: 0];
[extensions removeObjectAtIndex:0]; [extensions removeObjectAtIndex: 0];
} }
return resArray; return resArray;
@ -410,66 +412,66 @@
[super writeMakefile]; [super writeMakefile];
// Save GNUmakefile.preamble // Save GNUmakefile.preamble
[mf createPreambleForProject:self]; [mf createPreambleForProject: self];
// Create the new file // Create the new file
[mf createMakefileForProject:projectName]; [mf createMakefileForProject: projectName];
// Head (Application) // Head (Application)
[self appendHead:mf]; [self appendHead: mf];
// Subprojects // Subprojects
if ([[projectDict objectForKey:PCSubprojects] count] > 0) if ([[projectDict objectForKey: PCSubprojects] count] > 0)
{ {
[mf appendSubprojects:[projectDict objectForKey:PCSubprojects]]; [mf appendSubprojects: [projectDict objectForKey: PCSubprojects]];
} }
// Resources // Resources
[mf appendResources]; [mf appendResources];
for (i = 0; i < [[self resourceFileKeys] count]; i++) for (i = 0; i < [[self resourceFileKeys] count]; i++)
{ {
NSString *k = [[self resourceFileKeys] objectAtIndex:i]; NSString *k = [[self resourceFileKeys] objectAtIndex: i];
NSMutableArray *resources = [[projectDict objectForKey:k] mutableCopy]; NSMutableArray *resources = [[projectDict objectForKey: k] mutableCopy];
NSString *resourceItem = nil; NSString *resourceItem = nil;
for (j = 0; j < [resources count]; j++) for (j = 0; j < [resources count]; j++)
{ {
resourceItem = [resources objectAtIndex:j]; resourceItem = [resources objectAtIndex: j];
if ([[resourceItem pathComponents] count] == 1) if ([[resourceItem pathComponents] count] == 1)
{ {
resourceItem = [NSString stringWithFormat:@"Resources/%@", resourceItem = [NSString stringWithFormat: @"Resources/%@",
resourceItem]; resourceItem];
} }
[resources replaceObjectAtIndex:j [resources replaceObjectAtIndex: j
withObject:resourceItem]; withObject: resourceItem];
} }
[mf appendResourceItems:resources]; [mf appendResourceItems: resources];
[resources release]; [resources release];
} }
// Localization // Localization
// TODO: proper support for localization // TODO: proper support for localization
/* [mf appendLocalization]; /* [mf appendLocalization];
[mf appendString: [mf appendString:
[NSString stringWithFormat:@"%@_LANGUAGES = %@\n", [NSString stringWithFormat: @"%@_LANGUAGES = %@\n",
projectName, [[projectDict objectForKey:PCUserLanguages] componentsJoinedByString:@" "]]]; projectName, [[projectDict objectForKey: PCUserLanguages] componentsJoinedByString: @" "]]];
[mf appendString: [mf appendString:
[NSString stringWithFormat:@"%@_LOCALIZED_RESOURCE_FILES = ", projectName]]; [NSString stringWithFormat: @"%@_LOCALIZED_RESOURCE_FILES = ", projectName]];
*/ */
[mf appendHeaders:[projectDict objectForKey:PCHeaders]]; [mf appendHeaders: [projectDict objectForKey: PCHeaders]];
[mf appendClasses:[projectDict objectForKey:PCClasses]]; [mf appendClasses: [projectDict objectForKey: PCClasses]];
[mf appendOtherSources:[projectDict objectForKey:PCOtherSources]]; [mf appendOtherSources: [projectDict objectForKey: PCOtherSources]];
// Tail // Tail
[self appendTail:mf]; [self appendTail: mf];
// Write the new file to disc! // Write the new file to disc!
mfl = [projectPath stringByAppendingPathComponent:@"GNUmakefile"]; mfl = [projectPath stringByAppendingPathComponent: @"GNUmakefile"];
if ((mfd = [mf encodedMakefile])) if ((mfd = [mf encodedMakefile]))
{ {
if ([mfd writeToFile:mfl atomically:YES]) if ([mfd writeToFile: mfl atomically: YES])
{ {
return YES; return YES;
} }
@ -478,42 +480,42 @@
return NO; return NO;
} }
- (void)appendHead:(PCMakefileFactory *)mff - (void)appendHead: (PCMakefileFactory *)mff
{ {
NSString *installDir = [projectDict objectForKey:PCInstallDir]; NSString *installDir = [projectDict objectForKey: PCInstallDir];
[mff appendString:@"\n#\n# Application\n#\n"]; [mff appendString: @"\n#\n# Application\n#\n"];
[mff appendString:[NSString stringWithFormat:@"VERSION = %@\n", [mff appendString: [NSString stringWithFormat: @"VERSION = %@\n",
[projectDict objectForKey:PCRelease]]]; [projectDict objectForKey: PCRelease]]];
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"PACKAGE_NAME = %@\n", projectName]]; [NSString stringWithFormat: @"PACKAGE_NAME = %@\n", projectName]];
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"APP_NAME = %@\n", projectName]]; [NSString stringWithFormat: @"APP_NAME = %@\n", projectName]];
[mff appendString:[NSString stringWithFormat:@"%@_APPLICATION_ICON = %@\n", [mff appendString: [NSString stringWithFormat: @"%@_APPLICATION_ICON = %@\n",
projectName, [projectDict objectForKey:PCAppIcon]]]; projectName, [projectDict objectForKey: PCAppIcon]]];
if ([installDir isEqualToString:@""]) if ([installDir isEqualToString: @""])
{ {
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"%@_STANDARD_INSTALL = no\n", [NSString stringWithFormat: @"%@_STANDARD_INSTALL = no\n",
projectName]]; projectName]];
} }
else else
{ {
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"GNUSTEP_INSTALLATION_DIR = %@\n", [NSString stringWithFormat: @"GNUSTEP_INSTALLATION_DIR = %@\n",
installDir]]; installDir]];
} }
} }
- (void)appendTail:(PCMakefileFactory *)mff - (void)appendTail: (PCMakefileFactory *)mff
{ {
[mff appendString:@"\n\n#\n# Makefiles\n#\n"]; [mff appendString: @"\n\n#\n# Makefiles\n#\n"];
[mff appendString:@"-include GNUmakefile.preamble\n"]; [mff appendString: @"-include GNUmakefile.preamble\n"];
[mff appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"]; [mff appendString: @"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
[mff appendString:@"include $(GNUSTEP_MAKEFILES)/application.make\n"]; [mff appendString: @"include $(GNUSTEP_MAKEFILES)/application.make\n"];
[mff appendString:@"-include GNUmakefile.postamble\n"]; [mff appendString: @"-include GNUmakefile.postamble\n"];
} }
@end @end

View file

@ -1,5 +1,5 @@
/* /*
GNUstep ProjectCenter - http://www.gnustep.org GNUstep ProjectCenter - http: //www.gnustep.org
Copyright (C) 2001-2004 Free Software Foundation Copyright (C) 2001-2004 Free Software Foundation
@ -72,25 +72,25 @@
nil] retain]; nil] retain];
rootEntries = [[NSDictionary rootEntries = [[NSDictionary
dictionaryWithObjects:rootCategories forKeys:rootKeys] retain]; dictionaryWithObjects: rootCategories forKeys: rootKeys] retain];
} }
return self; return self;
} }
- (void)assignInfoDict:(NSMutableDictionary *)dict - (void)assignInfoDict: (NSMutableDictionary *)dict
{ {
infoDict = [dict mutableCopy]; infoDict = [dict mutableCopy];
} }
- (void)loadInfoFileAtPath:(NSString *)path - (void)loadInfoFileAtPath: (NSString *)path
{ {
NSString *infoFile = nil; NSString *infoFile = nil;
infoFile = [path stringByAppendingPathComponent:@"Info-gnustep.plist"]; infoFile = [path stringByAppendingPathComponent: @"Info-gnustep.plist"];
if ([[NSFileManager defaultManager] fileExistsAtPath:infoFile]) if ([[NSFileManager defaultManager] fileExistsAtPath: infoFile])
{ {
infoDict = [[NSMutableDictionary alloc] initWithContentsOfFile:infoFile]; infoDict = [[NSMutableDictionary alloc] initWithContentsOfFile: infoFile];
} }
else else
{ {
@ -102,7 +102,7 @@
{ {
NSLog (@"PCRenaissanceProject: dealloc"); NSLog (@"PCRenaissanceProject: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(infoDict); RELEASE(infoDict);
RELEASE(projectAttributesView); RELEASE(projectAttributesView);
@ -135,37 +135,37 @@
- (NSString *)execToolName - (NSString *)execToolName
{ {
return [NSString stringWithString:@"openapp"]; return [NSString stringWithString: @"openapp"];
} }
- (NSArray *)buildTargets - (NSArray *)buildTargets
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
@"app", @"debug", @"profile", @"dist", nil]; @"app", @"debug", @"profile", @"dist", nil];
} }
- (NSArray *)sourceFileKeys - (NSArray *)sourceFileKeys
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
PCClasses, PCHeaders, PCOtherSources, PCClasses, PCHeaders, PCOtherSources,
PCSupportingFiles, PCSubprojects, nil]; PCSupportingFiles, PCSubprojects, nil];
} }
- (NSArray *)resourceFileKeys - (NSArray *)resourceFileKeys
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
PCInterfaces, PCImages, PCOtherResources, PCDocuFiles, nil]; PCInterfaces, PCImages, PCOtherResources, PCDocuFiles, nil];
} }
- (NSArray *)otherKeys - (NSArray *)otherKeys
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
PCLibraries, PCNonProject, nil]; PCLibraries, PCNonProject, nil];
} }
- (NSArray *)allowableSubprojectTypes - (NSArray *)allowableSubprojectTypes
{ {
return [NSArray arrayWithObjects: return [NSArray arrayWithObjects:
@"Aggregate", @"Bundle", @"Tool", @"Library", nil]; @"Aggregate", @"Bundle", @"Tool", @"Library", nil];
} }
@ -175,12 +175,12 @@
PCInterfaces, PCImages, PCOtherResources, PCDocuFiles, nil]; PCInterfaces, PCImages, PCOtherResources, PCDocuFiles, nil];
} }
- (BOOL)isEditableCategory:(NSString *)category - (BOOL)isEditableCategory: (NSString *)category
{ {
NSString *key = [self keyForCategory:category]; NSString *key = [self keyForCategory: category];
if ([super isEditableCategory:category] if ([super isEditableCategory: category]
|| [key isEqualToString:PCInterfaces]) || [key isEqualToString: PCInterfaces])
{ {
return YES; return YES;
} }
@ -192,11 +192,11 @@
// ==== File Handling // ==== File Handling
// ============================================================================ // ============================================================================
- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key notify:(BOOL)yn - (BOOL)removeFiles: (NSArray *)files forKey: (NSString *)key notify: (BOOL)yn
{ {
NSMutableArray *filesToRemove = [[files mutableCopy] autorelease]; NSMutableArray *filesToRemove = [[files mutableCopy] autorelease];
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; NSString *mainNibFile = [projectDict objectForKey: PCMainInterfaceFile];
NSString *appIcon = [projectDict objectForKey:PCAppIcon]; NSString *appIcon = [projectDict objectForKey: PCAppIcon];
if (!files || !key) if (!files || !key)
{ {
@ -204,7 +204,7 @@
} }
// Check for main NIB file // Check for main NIB file
if ([key isEqualToString:PCInterfaces] && [files containsObject:mainNibFile]) if ([key isEqualToString: PCInterfaces] && [files containsObject: mainNibFile])
{ {
int ret; int ret;
ret = NSRunAlertPanel(@"Remove", ret = NSRunAlertPanel(@"Remove",
@ -213,15 +213,15 @@
if (ret == NSAlertAlternateReturn) // Leave if (ret == NSAlertAlternateReturn) // Leave
{ {
[filesToRemove removeObject:mainNibFile]; [filesToRemove removeObject: mainNibFile];
} }
else else
{ {
[self clearMainNib:self]; [self clearMainNib: self];
} }
} }
// Check for application icon files // Check for application icon files
else if ([key isEqualToString:PCImages] && [files containsObject:appIcon]) else if ([key isEqualToString: PCImages] && [files containsObject: appIcon])
{ {
int ret; int ret;
ret = NSRunAlertPanel(@"Remove", ret = NSRunAlertPanel(@"Remove",
@ -230,56 +230,56 @@
if (ret == NSAlertAlternateReturn) // Leave if (ret == NSAlertAlternateReturn) // Leave
{ {
[filesToRemove removeObject:appIcon]; [filesToRemove removeObject: appIcon];
} }
else else
{ {
[self clearAppIcon:self]; [self clearAppIcon: self];
} }
} }
return [super removeFiles:filesToRemove forKey:key notify:yn]; return [super removeFiles: filesToRemove forKey: key notify: yn];
} }
- (BOOL)renameFile:(NSString *)fromFile toFile:(NSString *)toFile - (BOOL)renameFile: (NSString *)fromFile toFile: (NSString *)toFile
{ {
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile]; NSString *mainNibFile = [projectDict objectForKey: PCMainInterfaceFile];
NSString *appIcon = [projectDict objectForKey:PCAppIcon]; NSString *appIcon = [projectDict objectForKey: PCAppIcon];
NSString *categoryKey = nil; NSString *categoryKey = nil;
NSString *ff = [fromFile copy]; NSString *ff = [fromFile copy];
NSString *tf = [toFile copy]; NSString *tf = [toFile copy];
BOOL success = NO; BOOL success = NO;
categoryKey = [self categoryKey = [self
keyForCategory:[projectBrowser nameOfSelectedRootCategory]]; keyForCategory: [projectBrowser nameOfSelectedRootCategory]];
// Check for main NIB file // Check for main NIB file
if ([categoryKey isEqualToString:PCInterfaces] if ([categoryKey isEqualToString: PCInterfaces]
&& [fromFile isEqualToString:mainNibFile]) && [fromFile isEqualToString: mainNibFile])
{ {
[self clearMainNib:self]; [self clearMainNib: self];
if ([super renameFile:ff toFile:tf] == YES) if ([super renameFile: ff toFile: tf] == YES)
{ {
[self setMainNibWithFileAtPath: [self setMainNibWithFileAtPath:
[[self dirForCategoryKey:categoryKey] [[self dirForCategoryKey: categoryKey]
stringByAppendingPathComponent:tf]]; stringByAppendingPathComponent: tf]];
success = YES; success = YES;
} }
} }
// Check for application icon files // Check for application icon files
else if ([categoryKey isEqualToString:PCImages] else if ([categoryKey isEqualToString: PCImages]
&& [fromFile isEqualToString:appIcon]) && [fromFile isEqualToString: appIcon])
{ {
[self clearAppIcon:self]; [self clearAppIcon: self];
if ([super renameFile:ff toFile:tf] == YES) if ([super renameFile: ff toFile: tf] == YES)
{ {
[self setAppIconWithImageAtPath: [self setAppIconWithImageAtPath:
[[self dirForCategoryKey:categoryKey] [[self dirForCategoryKey: categoryKey]
stringByAppendingPathComponent:tf]]; stringByAppendingPathComponent: tf]];
success = YES; success = YES;
} }
} }
else if ([super renameFile:ff toFile:tf] == YES) else if ([super renameFile: ff toFile: tf] == YES)
{ {
success = YES; success = YES;
} }
@ -294,73 +294,74 @@
@implementation PCRenaissanceProject (GeneratedFiles) @implementation PCRenaissanceProject (GeneratedFiles)
- (void)writeInfoEntry:(NSString *)name forKey:(NSString *)key - (void)writeInfoEntry: (NSString *)name forKey: (NSString *)key
{ {
id entry = [projectDict objectForKey:key]; id entry = [projectDict objectForKey: key];
if (entry == nil) if (entry == nil)
{ {
return; return;
} }
if ([entry isKindOfClass:[NSString class]] && [entry isEqualToString:@""]) if ([entry isKindOfClass: [NSString class]] && [entry isEqualToString: @""])
{ {
[infoDict removeObjectForKey:name]; [infoDict removeObjectForKey: name];
return; return;
} }
if ([entry isKindOfClass:[NSArray class]] && [entry count] <= 0) if ([entry isKindOfClass: [NSArray class]] && [entry count] <= 0)
{ {
[infoDict removeObjectForKey:name]; [infoDict removeObjectForKey: name];
return; return;
} }
[infoDict setObject:entry forKey:name]; [infoDict setObject: entry forKey: name];
} }
- (BOOL)writeInfoFile - (BOOL)writeInfoFile
{ {
NSString *infoFile = nil; NSString *infoFile = nil;
[self writeInfoEntry:@"ApplicationDescription" forKey:PCDescription]; [self writeInfoEntry: @"ApplicationDescription" forKey: PCDescription];
[self writeInfoEntry:@"ApplicationIcon" forKey:PCAppIcon]; [self writeInfoEntry: @"ApplicationIcon" forKey: PCAppIcon];
[self writeInfoEntry:@"ApplicationName" forKey:PCProjectName]; [self writeInfoEntry: @"ApplicationName" forKey: PCProjectName];
[self writeInfoEntry:@"ApplicationRelease" forKey:PCRelease]; [self writeInfoEntry: @"ApplicationRelease" forKey: PCRelease];
[self writeInfoEntry:@"Authors" forKey:PCAuthors]; [self writeInfoEntry: @"Authors" forKey: PCAuthors];
[self writeInfoEntry:@"Copyright" forKey:PCCopyright]; [self writeInfoEntry: @"Copyright" forKey: PCCopyright];
[self writeInfoEntry:@"CopyrightDescription" forKey:PCCopyrightDescription]; [self writeInfoEntry: @"CopyrightDescription" forKey: PCCopyrightDescription];
[self writeInfoEntry:@"FullVersionID" forKey:PCRelease]; [self writeInfoEntry: @"FullVersionID" forKey: PCRelease];
[self writeInfoEntry:@"NSExecutable" forKey:PCProjectName]; [self writeInfoEntry: @"NSExecutable" forKey: PCProjectName];
[self writeInfoEntry:@"NSIcon" forKey:PCAppIcon]; [self writeInfoEntry: @"NSIcon" forKey: PCAppIcon];
[self writeInfoEntry:@"GSMainMarkupFile" forKey:PCMainInterfaceFile]; [self writeInfoEntry: @"GSMainMarkupFile" forKey: PCMainInterfaceFile];
[self writeInfoEntry:@"NSPrincipalClass" forKey:PCPrincipalClass]; [self writeInfoEntry: @"NSPrincipalClass" forKey: PCPrincipalClass];
[infoDict setObject:@"Application" forKey:@"NSRole"]; [self writeInfoEntry: @"GSHelpContentsFile" forKey: PCHelpFile];
[infoDict setObject:[self convertExtensions] forKey:@"NSTypes"]; [infoDict setObject: @"Application" forKey: @"NSRole"];
[self writeInfoEntry:@"URL" forKey:PCURL]; [infoDict setObject: [self convertExtensions] forKey: @"NSTypes"];
[self writeInfoEntry: @"URL" forKey: PCURL];
infoFile = [self dirForCategoryKey:PCOtherResources]; infoFile = [self dirForCategoryKey: PCOtherResources];
infoFile = [infoFile stringByAppendingPathComponent:@"Info-gnustep.plist"]; infoFile = [infoFile stringByAppendingPathComponent: @"Info-gnustep.plist"];
return [infoDict writeToFile:infoFile atomically:YES]; return [infoDict writeToFile: infoFile atomically: YES];
} }
- (NSArray *)convertExtensions - (NSArray *)convertExtensions
{ {
NSMutableArray *icons = [NSMutableArray arrayWithCapacity:1]; NSMutableArray *icons = [NSMutableArray arrayWithCapacity: 1];
NSMutableArray *extensions = [NSMutableArray arrayWithCapacity:1]; NSMutableArray *extensions = [NSMutableArray arrayWithCapacity: 1];
NSArray *docIE = [projectDict objectForKey:PCDocumentExtensions]; NSArray *docIE = [projectDict objectForKey: PCDocumentExtensions];
NSEnumerator *enumerator = [docIE objectEnumerator]; NSEnumerator *enumerator = [docIE objectEnumerator];
NSDictionary *anObject; NSDictionary *anObject;
NSMutableArray *resArray = [[NSMutableArray alloc] init]; NSMutableArray *resArray = [[NSMutableArray alloc] init];
NSMutableDictionary *tmpDict = [NSMutableDictionary dictionaryWithCapacity:1]; NSMutableDictionary *tmpDict = [NSMutableDictionary dictionaryWithCapacity: 1];
NSString *ic; NSString *ic;
NSArray *ex; NSArray *ex;
while ((anObject = [enumerator nextObject])) while ((anObject = [enumerator nextObject]))
{ {
[icons addObject:[anObject objectForKey:@"Icon"]]; [icons addObject: [anObject objectForKey: @"Icon"]];
[extensions addObject:[anObject objectForKey:@"Extension"]]; [extensions addObject: [anObject objectForKey: @"Extension"]];
} }
// At this point we have 2 arrays; 1 list of icons and 2 list of extensions. // At this point we have 2 arrays; 1 list of icons and 2 list of extensions.
@ -372,18 +373,18 @@
NSMutableDictionary *tdict; NSMutableDictionary *tdict;
NSString *tic; NSString *tic;
ic = [icons objectAtIndex:0]; ic = [icons objectAtIndex: 0];
ex = [NSMutableArray arrayWithObject:[extensions objectAtIndex:0]]; ex = [NSMutableArray arrayWithObject: [extensions objectAtIndex: 0]];
for (i = 0; i < [resArray count]; i++) for (i = 0; i < [resArray count]; i++)
{ {
tdict = [resArray objectAtIndex:i]; tdict = [resArray objectAtIndex: i];
tic = [tdict objectForKey:@"NSIcon"]; tic = [tdict objectForKey: @"NSIcon"];
if([tic isEqualToString:ic]) if([tic isEqualToString: ic])
{ {
[[tdict objectForKey:@"NSUnixExtensions"] [[tdict objectForKey: @"NSUnixExtensions"]
addObject:[ex objectAtIndex:0]]; addObject: [ex objectAtIndex: 0]];
loaded = YES; loaded = YES;
continue; continue;
} }
@ -391,15 +392,15 @@
if (!loaded) if (!loaded)
{ {
[tmpDict setObject:ic forKey:@"NSIcon"]; [tmpDict setObject: ic forKey: @"NSIcon"];
[tmpDict setObject:ex forKey:@"NSUnixExtensions"]; [tmpDict setObject: ex forKey: @"NSUnixExtensions"];
[resArray addObject:[tmpDict copy]]; [resArray addObject: [tmpDict copy]];
} }
[tmpDict removeAllObjects]; [tmpDict removeAllObjects];
[icons removeObjectAtIndex:0]; [icons removeObjectAtIndex: 0];
[extensions removeObjectAtIndex:0]; [extensions removeObjectAtIndex: 0];
} }
return resArray; return resArray;
@ -420,56 +421,56 @@
[super writeMakefile]; [super writeMakefile];
// Save GNUmakefile.preamble // Save GNUmakefile.preamble
[mf createPreambleForProject:self]; [mf createPreambleForProject: self];
// Create the new file // Create the new file
[mf createMakefileForProject:projectName]; [mf createMakefileForProject: projectName];
// Head (Application) // Head (Application)
[self appendHead:mf]; [self appendHead: mf];
// Subprojects // Subprojects
if ([[projectDict objectForKey:PCSubprojects] count] > 0) if ([[projectDict objectForKey: PCSubprojects] count] > 0)
{ {
[mf appendSubprojects:[projectDict objectForKey:PCSubprojects]]; [mf appendSubprojects: [projectDict objectForKey: PCSubprojects]];
} }
// Resources // Resources
[mf appendResources]; [mf appendResources];
for (i = 0; i < [[self resourceFileKeys] count]; i++) for (i = 0; i < [[self resourceFileKeys] count]; i++)
{ {
NSString *k = [[self resourceFileKeys] objectAtIndex:i]; NSString *k = [[self resourceFileKeys] objectAtIndex: i];
NSMutableArray *resources = [[projectDict objectForKey:k] mutableCopy]; NSMutableArray *resources = [[projectDict objectForKey: k] mutableCopy];
NSString *resourceItem = nil; NSString *resourceItem = nil;
for (j = 0; j < [resources count]; j++) for (j = 0; j < [resources count]; j++)
{ {
resourceItem = [resources objectAtIndex:j]; resourceItem = [resources objectAtIndex: j];
if ([[resourceItem pathComponents] count] == 1) if ([[resourceItem pathComponents] count] == 1)
{ {
resourceItem = [NSString stringWithFormat:@"Resources/%@", resourceItem = [NSString stringWithFormat: @"Resources/%@",
resourceItem]; resourceItem];
} }
[resources replaceObjectAtIndex:j [resources replaceObjectAtIndex: j
withObject:resourceItem]; withObject: resourceItem];
} }
[mf appendResourceItems:resources]; [mf appendResourceItems: resources];
[resources release]; [resources release];
} }
[mf appendHeaders:[projectDict objectForKey:PCHeaders]]; [mf appendHeaders: [projectDict objectForKey: PCHeaders]];
[mf appendClasses:[projectDict objectForKey:PCClasses]]; [mf appendClasses: [projectDict objectForKey: PCClasses]];
[mf appendOtherSources:[projectDict objectForKey:PCOtherSources]]; [mf appendOtherSources: [projectDict objectForKey: PCOtherSources]];
// Tail // Tail
[self appendTail:mf]; [self appendTail: mf];
// Write the new file to disc! // Write the new file to disc!
mfl = [projectPath stringByAppendingPathComponent:@"GNUmakefile"]; mfl = [projectPath stringByAppendingPathComponent: @"GNUmakefile"];
if ((mfd = [mf encodedMakefile])) if ((mfd = [mf encodedMakefile]))
{ {
if ([mfd writeToFile:mfl atomically:YES]) if ([mfd writeToFile: mfl atomically: YES])
{ {
return YES; return YES;
} }
@ -478,42 +479,42 @@
return NO; return NO;
} }
- (void)appendHead:(PCMakefileFactory *)mff - (void)appendHead: (PCMakefileFactory *)mff
{ {
NSString *installDir = [projectDict objectForKey:PCInstallDir]; NSString *installDir = [projectDict objectForKey: PCInstallDir];
[mff appendString:@"\n#\n# Application\n#\n"]; [mff appendString: @"\n#\n# Application\n#\n"];
[mff appendString:[NSString stringWithFormat:@"VERSION = %@\n", [mff appendString: [NSString stringWithFormat: @"VERSION = %@\n",
[projectDict objectForKey:PCRelease]]]; [projectDict objectForKey: PCRelease]]];
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"PACKAGE_NAME = %@\n", projectName]]; [NSString stringWithFormat: @"PACKAGE_NAME = %@\n", projectName]];
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"APP_NAME = %@\n", projectName]]; [NSString stringWithFormat: @"APP_NAME = %@\n", projectName]];
[mff appendString:[NSString stringWithFormat:@"%@_APPLICATION_ICON = %@\n", [mff appendString: [NSString stringWithFormat: @"%@_APPLICATION_ICON = %@\n",
projectName, [projectDict objectForKey:PCAppIcon]]]; projectName, [projectDict objectForKey: PCAppIcon]]];
if ([installDir isEqualToString:@""]) if ([installDir isEqualToString: @""])
{ {
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"%@_STANDARD_INSTALL = no\n", [NSString stringWithFormat: @"%@_STANDARD_INSTALL = no\n",
projectName]]; projectName]];
} }
else else
{ {
[mff appendString: [mff appendString:
[NSString stringWithFormat:@"GNUSTEP_INSTALLATION_DIR = %@\n", [NSString stringWithFormat: @"GNUSTEP_INSTALLATION_DIR = %@\n",
installDir]]; installDir]];
} }
} }
- (void)appendTail:(PCMakefileFactory *)mff - (void)appendTail: (PCMakefileFactory *)mff
{ {
[mff appendString:@"\n\n#\n# Makefiles\n#\n"]; [mff appendString: @"\n\n#\n# Makefiles\n#\n"];
[mff appendString:@"-include GNUmakefile.preamble\n"]; [mff appendString: @"-include GNUmakefile.preamble\n"];
[mff appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"]; [mff appendString: @"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
[mff appendString:@"include $(GNUSTEP_MAKEFILES)/application.make\n"]; [mff appendString: @"include $(GNUSTEP_MAKEFILES)/application.make\n"];
[mff appendString:@"-include GNUmakefile.postamble\n"]; [mff appendString: @"-include GNUmakefile.postamble\n"];
} }
@end @end

View file

@ -1,5 +1,5 @@
/* /*
GNUstep ProjectCenter - http://www.gnustep.org GNUstep ProjectCenter - http: //www.gnustep.org
Copyright (C) 2001 Free Software Foundation Copyright (C) 2001 Free Software Foundation
@ -28,23 +28,23 @@
@implementation PCInfoController @implementation PCInfoController
- (id)init - (id) init
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
NSString *file; NSString *file;
file = [[NSBundle mainBundle] pathForResource:@"Info-gnustep" file = [[NSBundle mainBundle] pathForResource: @"Info-gnustep"
ofType:@"plist"]; ofType: @"plist"];
infoDict = [NSDictionary dictionaryWithContentsOfFile:file]; infoDict = [NSDictionary dictionaryWithContentsOfFile: file];
RETAIN(infoDict); RETAIN(infoDict);
} }
return self; return self;
} }
- (void)dealloc - (void) dealloc
{ {
RELEASE(infoDict); RELEASE(infoDict);
@ -56,17 +56,17 @@
[super dealloc]; [super dealloc];
} }
- (void)showInfoWindow:(id)sender - (void) showInfoWindow: (id)sender
{ {
#if defined(GNUSTEP) #if defined(GNUSTEP)
if (!infoWindow) if (!infoWindow)
{ {
infoWindow = [[GSInfoPanel alloc] initWithDictionary:infoDict]; infoWindow = [[GSInfoPanel alloc] initWithDictionary: infoDict];
} }
[infoWindow setTitle:@"Info"]; [infoWindow setTitle: @"Info"];
[infoWindow center]; [infoWindow center];
[infoWindow makeKeyAndOrderFront:self]; [infoWindow makeKeyAndOrderFront: self];
#else #else
NSRunAlertPanel(@"Info", NSRunAlertPanel(@"Info",
@"OPENSTEP has no support for GSInfoPanel", @"OPENSTEP has no support for GSInfoPanel",