Added the GormApplication project, done by Pierre-Yves Rivaille

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@10314 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Philippe C.D. Robert 2001-07-07 11:48:28 +00:00
parent 05a0252a56
commit 24e18e6d01
17 changed files with 1134 additions and 0 deletions

56
PCGormProj/GNUmakefile Normal file
View file

@ -0,0 +1,56 @@
# GNUmakefile
#
# Copyright (C) 2000 Philippe C.D. Robert, Pierre-Yves Rivaille
#
# Author: Philippe C.D. Robert <phr@projectcenter.ch>
# Date: 2000
# Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
# Date: 07/2001
#
# This file is part of ProjectCenter
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include $(GNUSTEP_MAKEFILES)/common.make
BUNDLE_NAME = PCGormProj
BUNDLE_EXTENSION =.bundle
BUNDLE_INSTALL_DIR =$(GNUSTEP_LOCAL_ROOT)/Library/ProjectCenter/
PCGormProj_OBJC_FILES = \
PCGormProj.m \
PCGormMakefileFactory.m \
PCGormProject.m
PCGormProj_HEADERS= \
PCGormMakefileFactory.h \
PCGormProj.h \
PCGormProject.h
PCGormProj_PRINCIPAL_CLASS = PCGormProj
PCGormProj_RESOURCE_FILES = \
PC.proj \
main.m \
baseInterface.classes \
baseInterface.gorm \
Info-project.plist
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/bundle.make
-include GNUmakefile.postamble

View file

@ -0,0 +1,30 @@
#
# Makefile.postamble
#
# Copyright (C) 1997 Free Software Foundation, Inc.
#
# Original Author: Scott Christley <scottc@net-community.com>
#
# This file is part of the GNUstep ProjectCenter.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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.
#
# If you are interested in a warranty or support for this source code,
# contact Scott Christley at scottc@net-community.com
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

View file

@ -0,0 +1,74 @@
#
# Makefile.preamble
#
# Copyright (C) 1997 Free Software Foundation, Inc.
#
# Original Author: Scott Christley <scottc@net-community.com>
#
# This file is part of the GNUstep ProjectCenter.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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.
#
# If you are interested in a warranty or support for this source code,
# contact Scott Christley at scottc@net-community.com
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Makefile.preamble
#
# Project specific makefile variables, and additional
#
# Do not put any Makefile rules in this file, instead they should
# be put into Makefile.postamble.
#
#
# Flags dealing with compiling and linking
#
# Additional flags to pass to the preprocessor
ADDITIONAL_CPPFLAGS +=
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS +=
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS +=
#ADDITIONAL_CFLAGS +=
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS +=
# Additional LDFLAGS to pass to the linker
ADDITIONAL_LDFLAGS += -lProjectCenter
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS +=
ADDITIONAL_TOOL_LIBS +=
#
# Flags dealing with installing and uninstalling
#
# Additional directories to be created during installation
ADDITIONAL_INSTALL_DIRS +=
#
# Local configuration
#

View file

@ -0,0 +1,12 @@
{
NOTE = "Automatically generated, do not edit!";
ApplicationName = "";
ApplicationDescription = "";
ApplicationIcon = "";
ApplicationRelease = "";
FullVersionID = "";
Authors = ();
URL = "";
Copyright = "";
CopyrightDescription = "";
}

29
PCGormProj/Info.table Normal file
View file

@ -0,0 +1,29 @@
{
AdditionalAttributes = {
PrincipalClass = {ATTR_CLASS_NAME = "NSString";};
};
Allowable_SubprojectTypes = (Subproject, Bundle, Tool, Framework, Library, Palette);
AttributesInspector = ApplicationInspector;
DefaultExtension = "";
Default_Localizable_Keys = (INTERFACES);
GeneratedFiles = (Makefile, iconHeader);
INSTALLFLAGS = "-c -s -m 755";
InfoName = "";
Localizable_Keys = (INTERFACES, IMAGES, OTHER_RESOURCES, HELP_RESOURCES);
MAKEFILE = app.make;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
Other_Keys = (HELP_RESOURCES, OTHER_SOURCES, FRAMEWORKS, OTHER_LIBS);
PBProjectTypeSubClass = "PBApplicationProjectType";
ProvidesIcons = Yes;
Public_Keys = (H_FILES);
Resource_Keys = (INTERFACES, IMAGES, OTHER_RESOURCES);
SOURCEMODE = 444;
Source_Keys = (CLASSES, H_FILES, OTHER_LINKED);
Subproj_Keys = (SUBPROJECTS);
Targets = (app, debug, profile, install);
ExecutableResults = (
"$PROJECTNAME$.app/$PROJECTNAME$$EXECUTABLE_EXT$",
"$PROJECTNAME$.debug/$PROJECTNAME$$EXECUTABLE_EXT$",
"$PROJECTNAME$.profile/$PROJECTNAME$$EXECUTABLE_EXT$"
);
}

34
PCGormProj/PC.proj Normal file
View file

@ -0,0 +1,34 @@
{
APPCLASS = "NSApplication";
APPKIT = "GNUSTEP-GUI";
APPLICATIONICON = "";
BUILDTOOL = "gnumake";
CLASS_FILES = ("main.m");
COMPILEROPTIONS = "";
CREATION_DATE = "";
DOCU_FILES = ();
FOUNDATION = "GNUSTEP-BASE";
FRAMEWORKS = ();
HEADER_FILES = ();
INTERFACES = ();
IMAGES = ();
LANGUAGE = "English";
LAST_EDITING = "";
LIBRARIES = ("gnustep-base","gnustep-gui");
MAININTERFACE = "";
MAKEFILEDIR = "/usr/GNUstep/Makefiles";
INSTALLDIR = "$(HOME)/Apps";
OTHER_FILES = ();
OTHER_RESOURCES = ();
OTHER_SOURCES = ();
PRINCIPAL_CLASS = "main.m";
PROJECT_CREATOR = "";
PROJECT_DESCRIPTION = "No description avaliable!";
PROJECT_MAINTAINER = "";
PROJECT_NAME = "";
PROJECT_TYPE = "GormApplication";
PROJECT_BUILDER = "PCGormProj";
PROJECT_VERSION = 1.0;
SUBPROJECTS = ();
SUPPORTING_FILES = ("GNUmakefile.preamble", "GNUmakefile", "GNUmakefile.postamble");
}

View file

@ -0,0 +1,36 @@
/*
GNUstep ProjectCenter - http://www.projectcenter.ch
Copyright (C) 2000 Philippe C.D. Robert
Author: Philippe C.D. Robert <phr@projectcenter.ch>
This file is part of ProjectCenter.
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.
*/
#import <Foundation/Foundation.h>
#import <ProjectCenter/PCProject.h>
@interface PCGormMakefileFactory : NSObject
{
}
+ (PCGormMakefileFactory *)sharedFactory;
- (NSData *)makefileForProject:(PCProject *)aProject;
@end

View file

@ -0,0 +1,160 @@
/*
GNUstep ProjectCenter - http://www.projectcenter.ch
Copyright (C) 2000 Philippe C.D. Robert
Author: Philippe C.D. Robert <phr@projectcenter.ch>
This file is part of ProjectCenter.
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.
*/
#import "PCGormMakefileFactory.h"
@implementation PCGormMakefileFactory
static PCGormMakefileFactory *_factory = nil;
+ (PCGormMakefileFactory *)sharedFactory
{
if (!_factory) {
_factory = [[[self class] alloc] init];
}
return _factory;
}
- (NSData *)makefileForProject:(PCProject *)aProject;
{
NSMutableString *string = [NSMutableString string];
NSString *prName = [aProject projectName];
NSDictionary *prDict = [aProject projectDict];
NSString *tmp;
NSEnumerator *enumerator;
int i;
// Header information
[string appendString:@"#\n"];
[string appendString:@"# GNUmakefile - Generated by the ProjectCenter\n"];
[string appendString:@"# Written by Philippe C.D. Robert <phr@projectcenter.ch>\n"];
[string appendString:@"# GormApplication project type contibuted by Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>\n"];
[string appendString:@"#\n"];
[string appendString:@"# NOTE: Do NOT change this file -- ProjectCenter maintains it!\n"];
[string appendString:@"#\n"];
[string appendString:@"# Put all of your customisations in GNUmakefile.preamble and\n"];
[string appendString:@"# GNUmakefile.postamble\n"];
[string appendString:@"#\n\n"];
// The 'real' thing
[string appendString:@"include $(GNUSTEP_MAKEFILES)/common.make\n"];
[string appendString:@"#\n\n"];
[string appendString:@"# Subprojects\n"];
[string appendString:@"#\n\n"];
if ([[aProject subprojects] count]) {
enumerator = [[prDict objectForKey:PCSubprojects] objectEnumerator];
while (tmp = [enumerator nextObject]) {
[string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
}
[string appendString:@"#\n"];
[string appendString:@"# Main application\n"];
[string appendString:@"#\n\n"];
[string appendString:[NSString stringWithFormat:@"PACKAGE_NAME=%@\n",prName]];
[string appendString:[NSString stringWithFormat:@"APP_NAME=%@\n",prName]];
// [string appendString:[NSString stringWithFormat:@"%@_PRINCIPAL_CLASS=%@\n",prName,[prDict objectForKey:PCPrincipalClass]]];
[string appendString:[NSString stringWithFormat:@"%@_MAIN_MODEL_FILE=%@\n",prName,[prDict objectForKey:PCMainGModelFile]]];
[string appendString:[NSString stringWithFormat:@"%@_APPLICATION_ICON=%@\n",prName, [prDict objectForKey:PCAppIcon]]];
[string appendString:@"#\n\n"];
[string appendString:@"# Additional libraries\n"];
[string appendString:@"#\n\n"];
[string appendString:[NSString stringWithFormat:@"ADDITIONAL_GUI_LIBS += "]];
//[string appendString:[NSString stringWithFormat:@"%@_LDFLAGS = ",prName]];
if ([[prDict objectForKey:PCLibraries] count]) {
enumerator = [[prDict objectForKey:PCLibraries] objectEnumerator];
while (tmp = [enumerator nextObject]) {
if (![tmp isEqualToString:@"gnustep-base"] &&
![tmp isEqualToString:@"gnustep-gui"]) {
[string appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
}
}
}
[string appendString:@"\n\n#\n\n"];
[string appendString:@"# Resource files\n"];
[string appendString:@"#\n\n"];
[string appendString:[NSString stringWithFormat:@"%@_RESOURCE_FILES= ",prName]];
for (i=0;i<[[aProject resourceFileKeys] count];i++) {
NSString *k = [[aProject resourceFileKeys] objectAtIndex:i];
enumerator = [[prDict objectForKey:k] objectEnumerator];
while (tmp = [enumerator nextObject]) {
[string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
}
[string appendString:@"\n\n#\n\n"];
[string appendString:@"# Header files\n"];
[string appendString:@"#\n\n"];
[string appendString:[NSString stringWithFormat:@"%@_HEADERS= ",prName]];
enumerator = [[prDict objectForKey:PCHeaders] objectEnumerator];
while (tmp = [enumerator nextObject]) {
[string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
[string appendString:@"\n\n#\n\n"];
[string appendString:@"# Class files\n"];
[string appendString:@"#\n\n"];
[string appendString:[NSString stringWithFormat:@"%@_OBJC_FILES= ",prName]];
enumerator = [[prDict objectForKey:PCClasses] objectEnumerator];
while (tmp = [enumerator nextObject]) {
[string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
[string appendString:@"\n\n#\n\n"];
[string appendString:@"# C files\n"];
[string appendString:@"#\n\n"];
[string appendString:[NSString stringWithFormat:@"%@_C_FILES= ",prName]];
enumerator = [[prDict objectForKey:PCOtherSources] objectEnumerator];
while (tmp = [enumerator nextObject]) {
[string appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
[string appendString:@"\n\n"];
[string appendString:@"-include GNUmakefile.preamble\n"];
[string appendString:@"-include GNUmakefile.local\n"];
[string appendString:@"include $(GNUSTEP_MAKEFILES)/aggregate.make\n"];
[string appendString:@"include $(GNUSTEP_MAKEFILES)/application.make\n"];
[string appendString:@"-include GNUmakefile.postamble\n"];
return [string dataUsingEncoding:[NSString defaultCStringEncoding]];
}
@end

46
PCGormProj/PCGormProj.h Normal file
View file

@ -0,0 +1,46 @@
/*
GNUstep ProjectCenter - http://www.projectcenter.ch
Copyright (C) 2000 Philippe C.D. Robert
Author: Philippe C.D. Robert <phr@projectcenter.ch>
This file is part of ProjectCenter.
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.
*/
#import <AppKit/AppKit.h>
#import <ProjectCenter/ProjectCenter.h>
@interface PCGormProj : NSObject <ProjectType>
{
}
//----------------------------------------------------------------------------
// ProjectType
//----------------------------------------------------------------------------
+ (id)sharedCreator;
- (Class)projectClass;
- (NSString *)projectTypeName;
- (NSDictionary *)typeTable;
- (PCProject *)createProjectAt:(NSString *)path;
- (PCProject *)openProjectAt:(NSString *)path;
@end

173
PCGormProj/PCGormProj.m Normal file
View file

@ -0,0 +1,173 @@
/*
GNUstep ProjectCenter - http://www.projectcenter.ch
Copyright (C) 2000 Philippe C.D. Robert
Copyright (C) 2001 Pierre-Yves Rivaille
Authors: Philippe C.D. Robert <phr@projectcenter.ch>
Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
This file is part of ProjectCenter.
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.
*/
/*
Description:
PCGormProj creates new project of the type GormApplication!
*/
#import "PCGormProj.h"
#import "PCGormProject.h"
@implementation PCGormProj
static NSString *_projTypeName = @"GormApplication";
static PCGormProj *_creator = nil;
//----------------------------------------------------------------------------
// ProjectType
//----------------------------------------------------------------------------
+ (id)sharedCreator
{
if (!_creator) {
_creator = [[[self class] alloc] init];
}
return _creator;
}
- (Class)projectClass
{
return [PCGormProject class];
}
- (NSString *)projectTypeName
{
return _projTypeName;
}
- (NSDictionary *)typeTable
{
NSString *_path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Info" ofType:@"table"];
return [NSDictionary dictionaryWithContentsOfFile:_path];
}
- (PCProject *)createProjectAt:(NSString *)path
{
PCGormProject *project = nil;
NSFileManager *fm = [NSFileManager defaultManager];
NSAssert(path,@"No valid project path provided!");
if ([fm createDirectoryAtPath:path attributes:nil]) {
NSString *_file;
NSString *_resourcePath;
NSMutableDictionary *dict;
NSDictionary *infoDict;
NSString *plistFileName;
project = [[[PCGormProject alloc] init] autorelease];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"];
dict = [NSMutableDictionary dictionaryWithContentsOfFile:_file];
// Customise the project
[dict setObject:[path lastPathComponent] forKey:PCProjectName];
[dict setObject:[project principalClass] forKey:PCProjType];
// Create the AppNameInfo.plist
infoDict = [NSDictionary dictionaryWithObjectsAndKeys:
@"Automatically generated!",@"NOTE",
[path lastPathComponent],@"ApplicationName",
@"",@"ApplicationDescription",
@"",@"ApplicationIcon",
@"0.1",@"ApplicationRelease",
@"0.1",@"FullVersionID",
@"",@"Authors",
@"",@"URL",
@"Copyright (C) 200x by ...",@"Copyright",
@"Released under ...",@"CopyrightDescription", nil];
plistFileName = [NSString stringWithFormat:@"%@Info.plist",[path lastPathComponent]];
[infoDict writeToFile:[path stringByAppendingPathComponent:plistFileName] atomically:YES];
[dict setObject:[NSArray arrayWithObjects:plistFileName,nil]
forKey:PCOtherResources];
[dict setObject:[NSArray arrayWithObject:[NSString stringWithFormat: @"%@.gorm", [path lastPathComponent]]]
forKey:PCGModels];
[dict setObject:[NSString stringWithFormat: @"%@.gorm", [path lastPathComponent]]
forKey:PCMainGModelFile];
// Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] atomically:YES];
/*
* Copy the project files to the provided path
*
*/
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"postamble"];
[fm copyPath:_file toPath:[path stringByAppendingPathComponent:@"GNUmakefile.postamble"] handler:nil];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"preamble"];
[fm copyPath:_file toPath:[path stringByAppendingPathComponent:@"GNUmakefile.preamble"] handler:nil];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"main" ofType:@"m"];
[fm copyPath:_file toPath:[path stringByAppendingPathComponent:@"main.m"] handler:nil];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"baseInterface" ofType:@"gorm"];
[fm copyPath:_file toPath:[path stringByAppendingPathComponent:
[[path lastPathComponent] stringByAppendingString: @".gorm"]] handler:nil];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"baseInterface" ofType:@"classes"];
[fm copyPath:_file toPath:[path stringByAppendingPathComponent:
[[path lastPathComponent] stringByAppendingString: @".classes"]] handler:nil];
// Resources
_resourcePath = [path stringByAppendingPathComponent:@"English.lproj"];
[fm createDirectoryAtPath:_resourcePath attributes:nil];
[fm createDirectoryAtPath:[path stringByAppendingPathComponent:@"Images"] attributes:nil];
[fm createDirectoryAtPath:[path stringByAppendingPathComponent:@"Documentation"] attributes:nil];
// The path cannot be in the PC.project file!
[project setProjectPath:path];
// Set the new dictionary - this causes the GNUmakefile to be written to disc
if(![project assignProjectDict:dict]) {
NSRunAlertPanel(@"Attention!",@"Could not load %@!",@"OK",nil,nil,path);
return nil;
}
}
return project;
}
- (PCProject *)openProjectAt:(NSString *)path
{
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
id obj;
NSLog(@"<%@ %x>: opening project at %@",[self class],self,path);
obj = [dict objectForKey:PCProjectBuilderClass];
if ([obj isEqualToString:@"PCGormProj"]) {
return [[[PCGormProject alloc] initWithProjectDictionary:dict path:[path stringByDeletingLastPathComponent]] autorelease];
}
return nil;
}
@end

View file

@ -0,0 +1,81 @@
/*
GNUstep ProjectCenter - http://www.projectcenter.ch
Copyright (C) 2000 Philippe C.D. Robert
Author: Philippe C.D. Robert <phr@projectcenter.ch>
This file is part of ProjectCenter.
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.
*/
/*
Description:
This is the project type 'GormApplication' for GNUstep. You never should create
it yourself but use PCGormProj for doing this. Otherwise needed files don't
get copied to the right place.
*/
#import <AppKit/AppKit.h>
#import <ProjectCenter/PCProject.h>
@interface PCGormProject : PCProject
{
NSTextField *appClassField;
NSTextField *appImageField;
NSButton *setAppIconButton;
NSButton *clearAppIconButton;
NSImageView *appIconView;
NSImage *icon;
}
//----------------------------------------------------------------------------
// Init and free
//----------------------------------------------------------------------------
- (id)init;
- (void)dealloc;
//----------------------------------------------------------------------------
// Project
//----------------------------------------------------------------------------
- (BOOL)writeMakefile;
- (BOOL)isValidDictionary:(NSDictionary *)aDict;
- (NSArray *)sourceFileKeys;
- (NSArray *)resourceFileKeys;
- (NSArray *)otherKeys;
- (NSArray *)buildTargets;
- (NSString *)projectDescription;
- (BOOL)isExecutable;
- (void)updateValuesFromProjectDict;
- (void)clearAppIcon:(id)sender;
- (void)setAppIcon:(id)sender;
- (BOOL)setAppIconWithImageAtPath:(NSString *)path;
- (void)setAppClass:(id)sender;
@end

308
PCGormProj/PCGormProject.m Normal file
View file

@ -0,0 +1,308 @@
/*
GNUstep ProjectCenter - http://www.projectcenter.ch
Copyright (C) 2000 Philippe C.D. Robert
Authors: Philippe C.D. Robert <phr@projectcenter.ch>
This file is part of ProjectCenter.
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.
*/
#import "PCGormProject.h"
#import "PCGormMakefileFactory.h"
#import <ProjectCenter/ProjectCenter.h>
#if defined(GNUSTEP)
#import <AppKit/IMLoading.h>
#endif
@interface PCGormProject (CreateUI)
- (void)_initUI;
@end
@implementation PCGormProject (CreateUI)
- (void)_initUI
{
NSTextField *textField;
NSRect frame = {{84,120}, {80, 80}};
NSBox *_box;
[super _initUI];
textField =[[NSTextField alloc] initWithFrame:NSMakeRect(16,256,64,21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue:@"App class:"];
[projectProjectInspectorView addSubview:textField];
RELEASE(textField);
appClassField =[[NSTextField alloc] initWithFrame:NSMakeRect(84,256,176,21)];
[appClassField setAlignment: NSLeftTextAlignment];
[appClassField setBordered: YES];
[appClassField setEditable: YES];
[appClassField setBezeled: YES];
[appClassField setDrawsBackground: YES];
[appClassField setStringValue:@""];
[appClassField setTarget:self];
[appClassField setAction:@selector(setAppClass:)];
[projectProjectInspectorView addSubview:appClassField];
textField =[[NSTextField alloc] initWithFrame:NSMakeRect(16,204,64,21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue:@"App icon:"];
[projectProjectInspectorView addSubview:textField];
RELEASE(textField);
appImageField =[[NSTextField alloc] initWithFrame:NSMakeRect(84,204,176,21)];
[appImageField setAlignment: NSLeftTextAlignment];
[appImageField setBordered: YES];
[appImageField setEditable: NO];
[appImageField setBezeled: YES];
[appImageField setDrawsBackground: YES];
[appImageField setStringValue:@""];
[projectProjectInspectorView addSubview:appImageField];
setAppIconButton =[[NSButton alloc] initWithFrame:NSMakeRect(220,180,40,21)];
[setAppIconButton setTitle:@"Set"];
[setAppIconButton setTarget:self];
[setAppIconButton setAction:@selector(setAppIcon:)];
[projectProjectInspectorView addSubview:setAppIconButton];
clearAppIconButton =[[NSButton alloc] initWithFrame:NSMakeRect(180,180,40,21)];
[clearAppIconButton setTitle:@"Clear"];
[clearAppIconButton setTarget:self];
[clearAppIconButton setAction:@selector(clearAppIcon:)];
[projectProjectInspectorView addSubview:clearAppIconButton];
_box = [[NSBox alloc] init];
[_box setFrame:frame];
[_box setTitlePosition:NSNoTitle];
[_box setBorderType:NSBezelBorder];
[projectProjectInspectorView addSubview:_box];
appIconView = [[NSImageView alloc] initWithFrame:frame];
[_box addSubview:appIconView];
RELEASE(_box);
RELEASE(setAppIconButton);
RELEASE(clearAppIconButton);
RELEASE(appIconView);
}
@end
@implementation PCGormProject
//----------------------------------------------------------------------------
// Init and free
//----------------------------------------------------------------------------
- (id)init
{
if ((self = [super init])) {
rootCategories = [[NSDictionary dictionaryWithObjectsAndKeys:
PCGModels,@"Interfaces",
PCSupportingFiles,@"Supporting Files",
PCImages,@"Images",
PCOtherResources,@"Other Resources",
PCSubprojects,@"Subprojects",
PCLibraries,@"Libraries",
PCDocuFiles,@"Documentation",
PCOtherSources,@"Other Sources",
PCHeaders,@"Headers",
PCClasses,@"Classes",
nil] retain];
[self _initUI];
}
return self;
}
- (void)dealloc
{
[rootCategories release];
[appClassField release];
[appImageField release];
[super dealloc];
}
//----------------------------------------------------------------------------
// Project
//----------------------------------------------------------------------------
- (BOOL)writeMakefile
{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *makefile = [projectPath stringByAppendingPathComponent:@"GNUmakefile"];
NSData *content;
if (![super writeMakefile]) {
NSLog(@"Couldn't update PC.project...");
}
if (![fm movePath:makefile toPath:[projectPath stringByAppendingPathComponent:@"GNUmakefile~"] handler:nil]) {
NSLog(@"Couldn't write a backup GNUmakefile...");
}
if (!(content = [[PCGormMakefileFactory sharedFactory] makefileForProject:self])) {
NSLog([NSString stringWithFormat:@"Couldn't build the GNUmakefile %@!",makefile]);
return NO;
}
if (![content writeToFile:makefile atomically:YES]) {
NSLog([NSString stringWithFormat:@"Couldn't write the GNUmakefile %@!",makefile]);
return NO;
}
return YES;
}
- (BOOL)isValidDictionary:(NSDictionary *)aDict
{
#warning No project check implemented, yet!
return YES;
}
- (NSArray *)sourceFileKeys
{
return [NSArray arrayWithObjects:PCClasses,PCOtherSources,nil];
}
- (NSArray *)resourceFileKeys
{
return [NSArray arrayWithObjects:PCGModels,PCOtherResources,PCImages,nil];
}
- (NSArray *)otherKeys
{
return [NSArray arrayWithObjects:PCDocuFiles,PCSupportingFiles,nil];
}
- (NSArray *)buildTargets
{
}
- (NSString *)projectDescription
{
return @"Project that handles GNUstep/ObjC based applications.";
}
- (BOOL)isExecutable
{
return YES;
}
- (void)updateValuesFromProjectDict
{
NSRect frame = {{0,0}, {64, 64}};
NSImage *image;
NSString *path = nil;
NSString *_icon;
[super updateValuesFromProjectDict];
[appClassField setStringValue:[projectDict objectForKey:PCAppClass]];
[appImageField setStringValue:[projectDict objectForKey:PCAppIcon]];
if ((_icon = [projectDict objectForKey:PCAppIcon])) {
path = [projectPath stringByAppendingPathComponent:_icon];
}
if (path && (image = [[NSImage alloc] initWithContentsOfFile:path])) {
frame.size = [image size];
[appIconView setFrame:frame];
[appIconView setImage:image];
[appIconView display];
RELEASE(image);
}
}
- (void)clearAppIcon:(id)sender
{
[projectDict setObject:@"" forKey:PCAppIcon];
[appImageField setStringValue:@"No Icon!"];
[appIconView setImage:nil];
[appIconView display];
[self writeMakefile];
}
- (void)setAppIcon:(id)sender
{
int result;
NSArray *fileTypes = [NSImage imageFileTypes];
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:NO];
result = [openPanel runModalForDirectory:NSHomeDirectory()
file:nil
types:fileTypes];
if (result == NSOKButton) {
NSArray *files = [openPanel filenames];
NSString *imageFilePath = [files objectAtIndex:0];
if (![self setAppIconWithImageAtPath:imageFilePath]) {
NSRunAlertPanel(@"Error while opening file!",
@"Couldn't open %@", @"OK", nil, nil,imageFilePath);
}
}
}
- (BOOL)setAppIconWithImageAtPath:(NSString *)path
{
NSRect frame = {{0,0}, {64, 64}};
NSImage *image;
if (!(image = [[NSImage alloc] initWithContentsOfFile:path])) {
return NO;
}
[self addFile:path forKey:PCImages copy:YES];
[projectDict setObject:[path lastPathComponent] forKey:PCAppIcon];
[appImageField setStringValue:[path lastPathComponent]];
frame.size = [image size];
[appIconView setFrame:frame];
[appIconView setImage:image];
[appIconView display];
RELEASE(image);
[self writeMakefile];
return YES;
}
- (void)setAppClass:(id)sender
{
[projectDict setObject:[appClassField stringValue] forKey:PCAppClass];
[self writeMakefile];
}
@end

View file

@ -0,0 +1,54 @@
{
NSApplication = {
Outlets = (
delegate
);
Super = NSResponder;
};
NSButton = {
Super = NSControl;
};
NSControl = {
Actions = (
"takeDoubleValueFrom:",
"takeFloatValueFrom:",
"takeIntValueFrom:",
"takeObjectValueFrom:",
"takeStringValueFrom:"
);
Outlets = (
target
);
Super = NSView;
};
NSMenu = {
Super = NSObject;
};
NSMenuItem = {
Outlets = (
target
);
Super = NSObject;
};
NSResponder = {
Super = NSObject;
};
NSSlider = {
Super = NSControl;
};
NSTextField = {
Outlets = (
delegate
);
Super = NSControl;
};
NSView = {
Super = NSResponder;
};
NSWindow = {
Outlets = (
delegate
);
Super = NSResponder;
};
}

Binary file not shown.

11
PCGormProj/h.template Normal file
View file

@ -0,0 +1,11 @@
$$
/* $FILENAME$ created by $USERNAME$ on $DATE$ */
#import <AppKit/AppKit.h>
@interface $FILENAMESANSEXTENSION$ : NSObject
{
}
@end

18
PCGormProj/m.template Normal file
View file

@ -0,0 +1,18 @@
$$ Lines starting with $$ are not inserted into newly created files
$$ The following substitutions are made:
$$
$$ $FILENAME$ e.g. foo.m
$$ $FILENAMESANSEXTENSION$ e.g. foo
$$ $DIRECTORY$ e.g. /tmp/MyNewApp
$$ $PROJECTNAME$ e.g. MyNewApp
$$ $SUBPROJECTNAME$ e.g. TheGoodPart.subproj
$$ $USERNAME$ e.g. mwagner
$$ $DATE$ e.g. Jan-1-1994
$$
/* $FILENAME$ created by $USERNAME$ on $DATE$ */
#import "$FILENAMESANSEXTENSION$.h"
@implementation $FILENAMESANSEXTENSION$
@end

12
PCGormProj/main.m Normal file
View file

@ -0,0 +1,12 @@
#import <AppKit/AppKit.h>
#define APP_NAME @"GNUstep"
/*
* Initialise and go!
*/
int main(int argc, const char *argv[])
{
return NSApplicationMain (argc, argv);
}