diff --git a/Modules/RenaissanceProject/AppController.h b/Modules/RenaissanceProject/AppController.h deleted file mode 100644 index 46ac829..0000000 --- a/Modules/RenaissanceProject/AppController.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * AppController.h - * - * GNUstep Renaissance Application Controller - * - * Created with ProjectCenter - http://www.gnustep.org - */ - -#ifndef _APPCONTROLLER_H_ -#define _APPCONTROLLER_H_ - -#include -#include - -@interface AppController : NSObject -{ - -} - -- (void) applicationDidFinishLaunching: (NSNotification *)not; - -@end - -#endif /* _APPCONTROLLER_H_ */ - diff --git a/Modules/RenaissanceProject/AppController.m b/Modules/RenaissanceProject/AppController.m deleted file mode 100644 index 8289eed..0000000 --- a/Modules/RenaissanceProject/AppController.m +++ /dev/null @@ -1,18 +0,0 @@ -/* - * AppController.m - * - * GNUstep Renaissance Application Controller - * - * Created with ProjectCenter - http://www.gnustep.org - * - */ - -#include "AppController.h" - -@implementation AppController - -- (void) applicationDidFinishLaunching: (NSNotification *)not -{ - [NSBundle loadGSMarkupNamed: @"Main" owner: self]; -} -@end diff --git a/Modules/RenaissanceProject/PCRenaissanceProject+Inspector.h b/Modules/RenaissanceProject/PCRenaissanceProject+Inspector.h new file mode 100644 index 0000000..a0dcf03 --- /dev/null +++ b/Modules/RenaissanceProject/PCRenaissanceProject+Inspector.h @@ -0,0 +1,68 @@ +/* + GNUstep ProjectCenter - http://www.gnustep.org + + Copyright (C) 2001 Free Software Foundation + + Author: Serg Stoyan + + This file is part of GNUstep. + + This application 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 application 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 + Library General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +*/ + +#ifndef _PCRenaissanceProject_Inspector_h_ +#define _PCRenaissanceProject_Inspector_h_ + +#include "PCRenaissanceProject.h" + +@interface PCRenaissanceProject (Inspector) + +// ---------------------------------------------------------------------------- +// --- User Interface +// ---------------------------------------------------------------------------- +- (void)createProjectAttributes; +- (NSView *)projectAttributesView; + +// ---------------------------------------------------------------------------- +// --- Actions +// ---------------------------------------------------------------------------- +- (void)setAppClass:(id)sender; +- (void)setFile:(id)sender; +- (void)clearFile:(id)sender; +- (void)setAppIcon:(id)sender; +- (void)clearAppIcon:(id)sender; +- (BOOL)setAppIconWithImageAtPath:(NSString *)path; +- (void)setMainNib:(id)sender; +- (BOOL)setMainNibWithFileAtPath:(NSString *)path; +- (void)clearMainNib:(id)sender; + +- (int)numberOfRowsInTableView:(NSTableView *)aTableView; +- (id) tableView: (NSTableView *)aTableView + objectValueForTableColumn: (NSTableColumn *)aTableColumn + row: (int)rowIndex; +- (void) tableView:(NSTableView *)aTableView + setObjectValue:anObject + forTableColumn:(NSTableColumn *)aTableColumn + row:(int)rowIndex; + +// ---------------------------------------------------------------------------- +// --- Notifications +// ---------------------------------------------------------------------------- +- (void)updateInspectorValues:(NSNotification *)aNotif; +- (void)tfGetFocus:(NSNotification *)aNotif; + +@end + +#endif diff --git a/Modules/RenaissanceProject/PCRenaissanceProject+Inspector.m b/Modules/RenaissanceProject/PCRenaissanceProject+Inspector.m new file mode 100644 index 0000000..5cb7a9a --- /dev/null +++ b/Modules/RenaissanceProject/PCRenaissanceProject+Inspector.m @@ -0,0 +1,487 @@ +/* + GNUstep ProjectCenter - http://www.gnustep.org + + Copyright (C) 2001 Free Software Foundation + + Author: Serg Stoyan + + This file is part of GNUstep. + + This application 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 application 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 + Library General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +*/ + +#include +#include "PCRenaissanceProject+Inspector.h" + +// ---------------------------------------------------------------------------- +// --- Customized text field +// ---------------------------------------------------------------------------- +NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification"; + +@implementation PCAppTextField + +- (BOOL)becomeFirstResponder +{ + [[NSNotificationCenter defaultCenter] + postNotificationName:PCITextFieldGetFocus + object:self]; + + return [super becomeFirstResponder]; +} + +@end + +@implementation PCRenaissanceProject (Inspector) + +// ---------------------------------------------------------------------------- +// --- User Interface +// ---------------------------------------------------------------------------- + +- (void)createProjectAttributes +{ + // TFs Buttons + [setFieldButton setRefusesFirstResponder:YES]; + [clearFieldButton setRefusesFirstResponder:YES]; + + // Document Icons + // + docExtColumn = [[NSTableColumn alloc] initWithIdentifier: @"extension"]; + [[docExtColumn headerCell] setStringValue:@"Extenstion"]; + [docExtColumn setWidth:75]; + docIconColumn = [[NSTableColumn alloc] initWithIdentifier: @"icon"]; + [[docIconColumn headerCell] setStringValue:@"Icon name"]; + + docIconsList = [[NSTableView alloc] initWithFrame:NSMakeRect(2,0,211,108)]; + [docIconsList setAllowsMultipleSelection:NO]; + [docIconsList setAllowsColumnReordering:NO]; + [docIconsList setAllowsColumnResizing:NO]; + [docIconsList setAllowsEmptySelection:YES]; + [docIconsList setAllowsColumnSelection:NO]; + [docIconsList addTableColumn:docExtColumn]; + [docIconsList addTableColumn:docIconColumn]; + [docIconsList setDataSource:self]; + [docIconsList setTarget:self]; + + // + [docIconsScroll setDocumentView:docIconsList]; + [docIconsScroll setHasHorizontalScroller:NO]; + [docIconsScroll setHasVerticalScroller:YES]; + [docIconsScroll setBorderType:NSBezelBorder]; + RELEASE(docIconsList); + + // Document icons buttons + [addDocIcon setRefusesFirstResponder:YES]; + [removeDocIcon setRefusesFirstResponder:YES]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(tfGetFocus:) + name:PCITextFieldGetFocus + object:nil]; + [projectAttributesView retain]; + + [self updateInspectorValues:nil]; +} + +- (NSView *)projectAttributesView +{ + if (!projectAttributesView) + { + if ([NSBundle loadNibNamed:@"Inspector" owner:self] == NO) + { + NSLog(@"PCAppProject: error loading Inspector NIB!"); + return nil; + } + [self createProjectAttributes]; + } + + return projectAttributesView; +} + +// ---------------------------------------------------------------------------- +// --- Actions +// ---------------------------------------------------------------------------- + +- (void)setAppClass:(id)sender +{ + [self setProjectDictObject:[appClassField stringValue] + forKey:PCPrincipalClass]; +} + +- (void)setIconViewImage:(NSImage *)image +{ + [iconView setImage:nil]; + [iconView display]; + + if (image == nil) + { + return; + } + + [iconView setImage:image]; + [iconView display]; +} + +- (void)setFile:(id)sender +{ + if (!activeTextField) + { + return; + } + + if (activeTextField == appImageField) + { + [self setAppIcon:self]; + } + else if (activeTextField == helpFileField) + { + } + else if (activeTextField == mainNIBField) + { + [self setMainNib:self]; + } +} + +- (void)clearFile:(id)sender +{ + if (!activeTextField) + { + return; + } + + if (activeTextField == appImageField) + { + [self clearAppIcon:self]; + } + else if (activeTextField == helpFileField) + { + } + else if (activeTextField == mainNIBField) + { + [self clearMainNib:self]; + } + [self setIconViewImage:nil]; +} + +// Application Icon +- (void)setAppIcon:(id)sender +{ + int result; + NSArray *fileTypes = [NSImage imageFileTypes]; + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + NSString *dir = nil; + + [openPanel setAllowsMultipleSelection:NO]; + [openPanel setTitle:@"Set Application Icon"]; + + dir = [[NSUserDefaults standardUserDefaults] + objectForKey:@"LastOpenDirectory"]; + result = [openPanel runModalForDirectory:dir + file:nil + types:fileTypes]; + + if (result == NSOKButton) + { + NSString *imageFilePath = [[openPanel filenames] objectAtIndex:0]; + + if (![self setAppIconWithImageAtPath:imageFilePath]) + { + NSRunAlertPanel(@"Error while opening file!", + @"Couldn't open %@", @"OK", nil, nil,imageFilePath); + } + } +} + +- (void)clearAppIcon:(id)sender +{ + [appImageField setStringValue:@""]; + [infoDict setObject:@"" forKey:@"NSIcon"]; + [infoDict setObject:@"" forKey:@"ApplicationIcon"]; + + [self setProjectDictObject:@"" forKey:PCAppIcon]; +} + +- (BOOL)setAppIconWithImageAtPath:(NSString *)path +{ + NSImage *image = nil; + NSString *imageName = nil; + + if (!(image = [[NSImage alloc] initWithContentsOfFile:path])) + { + return NO; + } + + imageName = [path lastPathComponent]; + + [appImageField setStringValue:imageName]; + + [self setIconViewImage:image]; + + [self addAndCopyFiles:[NSArray arrayWithObject:path] forKey:PCImages]; + + [infoDict setObject:imageName forKey:@"NSIcon"]; + [infoDict setObject:imageName forKey:@"ApplicationIcon"]; + + [self setProjectDictObject:imageName forKey:PCAppIcon]; + + return YES; +} + +// Main Interface File +- (void)setMainNib:(id)sender +{ + int result; + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + NSString *dir = nil; + + [openPanel setAllowsMultipleSelection:NO]; + [openPanel setTitle:@"Set Main Interface File"]; + + dir = [[NSUserDefaults standardUserDefaults] + objectForKey:@"LastOpenDirectory"]; + result = [openPanel runModalForDirectory:dir + file:nil + types:[NSArray arrayWithObject:@"gorm"]]; + + if (result == NSOKButton) + { + NSString *file = [[openPanel filenames] objectAtIndex:0]; + + if (![self setMainNibWithFileAtPath:file]) + { + NSRunAlertPanel(@"Error while opening file!", + @"Couldn't open %@", @"OK", nil, nil,file); + } + } +} + +- (BOOL)setMainNibWithFileAtPath:(NSString *)path +{ + NSString *nibName = [path lastPathComponent]; + + [self setIconViewImage:[[NSWorkspace sharedWorkspace] iconForFile:path]]; + + [self addAndCopyFiles:[NSArray arrayWithObject:path] forKey:PCInterfaces]; + [infoDict setObject:nibName forKey:@"NSMainNibFile"]; + + [self setProjectDictObject:nibName forKey:PCMainInterfaceFile]; + + [mainNIBField setStringValue:nibName]; + + return YES; +} + +- (void)clearMainNib:(id)sender +{ + [mainNIBField setStringValue:@""]; + [infoDict setObject:@"" forKey:@"NSMainNibFile"]; + + [self setProjectDictObject:@"" forKey:PCMainInterfaceFile]; +} + +// Document Icons +- (void)addDocIcon:(id)sender +{ + int row; + NSMutableDictionary *entry = [NSMutableDictionary dictionaryWithCapacity:2]; + int selectedRow = [docIconsList selectedRow]; + + [entry setObject:@"" forKey:@"Extension"]; + [entry setObject:@"" forKey:@"Icon"]; + + if (selectedRow >= 0) + { + [docIconsItems insertObject:entry atIndex:selectedRow + 1]; + row = selectedRow + 1; + } + else + { + [docIconsItems addObject:entry]; + row = [docIconsItems count] - 1; + } + [docIconsList reloadData]; + + [docIconsList selectRow:row byExtendingSelection:NO]; + [docIconsList editColumn:0 row:row withEvent:nil select:YES]; + + [self setProjectDictObject:docIconsItems forKey:PCDocumentExtensions]; +} + +- (void)removeDocIcon:(id)sender +{ + int selectedRow = [docIconsList selectedRow]; + + if (selectedRow >= 0) + { + [docIconsItems removeObjectAtIndex:selectedRow]; + [docIconsList reloadData]; + } + + if (([docIconsList selectedRow] < 0) && ([docIconsItems count] > 0)) + { + [docIconsList selectRow:[docIconsItems count]-1 byExtendingSelection:NO]; + } + + [self setProjectDictObject:docIconsItems forKey:PCDocumentExtensions]; +} + +// ---------------------------------------------------------------------------- +// --- Document Icons browser +// ---------------------------------------------------------------------------- + +- (int)numberOfRowsInTableView: (NSTableView *)aTableView +{ + return [docIconsItems count]; +} + +- (id) tableView: (NSTableView *)aTableView + objectValueForTableColumn: (NSTableColumn *)aTableColumn + row: (int)rowIndex +{ + if ([[aTableColumn identifier] isEqualToString:@"extension"]) + { + return [[docIconsItems objectAtIndex:rowIndex] objectForKey:@"Extension"]; + } + else if ([[aTableColumn identifier] isEqualToString:@"icon"]) + { + return [[docIconsItems objectAtIndex:rowIndex] objectForKey:@"Icon"]; + } + + return nil; +} + +- (void) tableView:(NSTableView *)aTableView + setObjectValue:anObject + forTableColumn:(NSTableColumn *)aTableColumn + row:(int)rowIndex +{ + if (docIconsItems == nil || [docIconsItems count] <= 0) + { + return; + } + + if ([[aTableColumn identifier] isEqualToString:@"extension"]) + { + [[docIconsItems objectAtIndex:rowIndex] removeObjectForKey:@"Extension"]; + [[docIconsItems objectAtIndex:rowIndex] setObject:anObject + forKey:@"Extension"]; + } + else if ([[aTableColumn identifier] isEqualToString:@"icon"]) + { + [[docIconsItems objectAtIndex:rowIndex] removeObjectForKey:@"Icon"]; + [[docIconsItems objectAtIndex:rowIndex] setObject:anObject + forKey:@"Icon"]; + } + + [self setProjectDictObject:docIconsItems forKey:PCDocumentExtensions]; +} + +// ---------------------------------------------------------------------------- +// --- Notifications +// ---------------------------------------------------------------------------- + +- (void)updateInspectorValues:(NSNotification *)aNotif +{ + NSLog (@"PCAppProject: updateInspectorValues"); + + // Project Attributes view + [projectTypeField setStringValue:[projectDict objectForKey:PCProjectType]]; + [projectNameField setStringValue:[projectDict objectForKey:PCProjectName]]; + [projectLanguageField setStringValue:[projectDict objectForKey:@"LANGUAGE"]]; + [appClassField setStringValue:[projectDict objectForKey:PCPrincipalClass]]; + + [appImageField setStringValue:[projectDict objectForKey:PCAppIcon]]; + [helpFileField setStringValue:[projectDict objectForKey:PCHelpFile]]; + [mainNIBField setStringValue:[projectDict objectForKey:PCMainInterfaceFile]]; + + docIconsItems = [projectDict objectForKey:PCDocumentExtensions]; + [docIconsList reloadData]; +} + +// TextFields (PCITextField subclass) +// +// NSTextField become first responder when user clicks on it and immediately +// lost first resonder status, so we can't catch when focus leaves textfield +// with resignFirstResponder: method overriding. Here we're using +// controlTextDidEndEditing (NSTextField's delegate method) to achieve this. + +- (void)tfGetFocus:(NSNotification *)aNotif +{ + id anObject = [aNotif object]; + NSString *file = nil; + NSString *path = nil; + + + if (anObject != appImageField + && anObject != helpFileField + && anObject != mainNIBField) + { + NSLog(@"tfGetFocus: not that textfield"); + return; + } + + if (anObject == appImageField) + { + file = [appImageField stringValue]; + + if (![file isEqualToString:@""]) + { + path = [self dirForCategoryKey:PCImages]; + path = [path stringByAppendingPathComponent:file]; + [self setIconViewImage:[[NSImage alloc] + initWithContentsOfFile:path]]; + } + activeTextField = appImageField; + } + else if (anObject == helpFileField) + { + activeTextField = helpFileField; + } + else if (anObject == mainNIBField) + { + file = [mainNIBField stringValue]; + + if (![file isEqualToString:@""]) + { + path = [projectPath stringByAppendingPathComponent:file]; + [self setIconViewImage:[[NSWorkspace sharedWorkspace] + iconForFile:path]]; + } + activeTextField = mainNIBField; + } + + [setFieldButton setEnabled:YES]; + [clearFieldButton setEnabled:YES]; +} + +- (void)controlTextDidEndEditing:(NSNotification *)aNotification +{ + id anObject = [aNotification object]; + + if (anObject != appImageField + && anObject != helpFileField + && anObject != mainNIBField) + { + NSLog(@"tfLostFocus: not that textfield"); + return; + } + + activeTextField = nil; + [self setIconViewImage:nil]; + + [setFieldButton setEnabled:NO]; + [clearFieldButton setEnabled:NO]; +} + +@end diff --git a/Modules/RenaissanceProject/Resources/AppController.m~ b/Modules/RenaissanceProject/Resources/AppController.m~ deleted file mode 100644 index 77d3a56..0000000 --- a/Modules/RenaissanceProject/Resources/AppController.m~ +++ /dev/null @@ -1,30 +0,0 @@ -/* - AppController.h - - GNUstep Renaissance Application Controller - - This application 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 application 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 - Library General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. -*/ - -#include "AppController.h" - -@implementation AppController - -- (void) applicationDidFinishLaunching:(NSNotification *)aNotif -{ - [NSBundle loadGSMarkupNamed:@"Main" owner:self]; -} - -@end diff --git a/Modules/RenaissanceProject/main.m b/Modules/RenaissanceProject/main.m deleted file mode 100644 index f35a44a..0000000 --- a/Modules/RenaissanceProject/main.m +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include "AppController.h" - - -/* - * Initialise and go! - */ - -int main(int argc, const char *argv[]) -{ - CREATE_AUTORELEASE_POOL (pool); - [NSApplication sharedApplication]; - [NSApp setDelegate: [AppController new]]; - - #ifdef GNUSTEP - [NSBundle loadGSMarkupNamed: @"MainMenu-GNUstep" owner: [NSApp delegate]]; - #else - [NSBundle loadGSMarkupNamed: @"MainMenu-OSX" owner: [NSApp delegate]]; - #endif - - - RELEASE (pool); - return NSApplicationMain (argc, argv); - -}