enhanced the created app to support GC and an info panel and more ...

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@7558 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Robert Slover 2000-09-20 08:50:08 +00:00
parent 763dccb954
commit 995f11d6dc
5 changed files with 75 additions and 11 deletions

View file

@ -8,12 +8,14 @@
* $Id$
*/
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@interface AppController : NSObject
{
}
+ (void)initialize;
- (id)init;
- (void)dealloc;
@ -21,6 +23,10 @@
- (void)applicationDidFinishLaunching:(NSNotification *)notif;
- (void)applicationShouldTerminate:(id)sender;
- (void)applicationWillTerminate:(NSNotification *)notification;
- (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName;
- (void)showPrefPanel:(id)sender;
- (void)showInfoPanel:(id)sender;

View file

@ -12,6 +12,24 @@
@implementation AppController
static NSDictionary *infoDict = nil;
+ (void)initialize
{
NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
/*
* Register your app's defaults here by adding objects to the
* dictionary, eg
*
* [defaults setObject:anObject forKey:keyForThatObject];
*
*/
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (id)init
{
if ((self = [super init])) {
@ -32,12 +50,33 @@
{
}
- (void)applicationShouldTerminate:(id)sender
{
}
- (void)applicationWillTerminate:(NSNotification *)notification
{
}
- (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName
{
}
- (void)showPrefPanel:(id)sender
{
}
- (void)showInfoPanel:(id)sender
{
if (!infoDict) {
NSString *fp;
NSBundle *bundle = [NSBundle mainBundle];
fp = [bundle pathForResource:@"Info-project" ofType:@"plist"];
infoDict = [[NSDictionary dictionaryWithContentsOfFile:fp] retain];
}
[[NSApplication sharedApplication] orderFrontStandardInfoPanelWithOptions:infoDict];
}
@end

View file

@ -112,6 +112,8 @@ static PCAppMakefileFactory *_factory = nil;
}
}
[string appendString:[NSString stringWithFormat:@"\\\nInfo-project.plist "]];
[string appendString:@"\n\n#\n\n"];
[string appendString:@"# Header files\n"];
[string appendString:@"#\n\n"];

View file

@ -79,7 +79,8 @@ static PCAppProj *_creator = nil;
NSString *_file;
NSString *_resourcePath;
NSMutableDictionary *dict;
NSDictionary *infoDict;
project = [[[PCAppProject alloc] init] autorelease];
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"PC" ofType:@"proj"];
@ -91,6 +92,20 @@ static PCAppProj *_creator = nil;
// Save the project to disc
[dict writeToFile:[path stringByAppendingPathComponent:@"PC.project"] atomically:YES];
// Create the Info-project.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];
[infoDict writeToFile:[path stringByAppendingPathComponent:@"Info-project.plist"] atomically:YES];
// Copy the project files to the provided path
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"GNUmakefile" ofType:@"postamble"];

View file

@ -1,3 +1,5 @@
/* $Id$ */
#import <AppKit/AppKit.h>
#import "AppController.h"
@ -14,9 +16,9 @@ void createMenu();
*/
int main(int argc, const char *argv[]) {
NSApplication *theApp;
id pool = [[NSAutoreleasePool alloc] init];
AppController *controller;
NSApplication *theApp;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AppController *controller;
#ifndef NX_CURRENT_COMPILER_RELEASE
initialize_gnustep_backend();
@ -39,8 +41,8 @@ int main(int argc, const char *argv[]) {
* ...and finish!
*/
[controller release];
[pool release];
RELEASE(controller);
RELEASE(pool);
return 0;
}
@ -64,13 +66,13 @@ void createMenu()
[menu addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"];
[menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
info = [[[NSMenu alloc] init] autorelease];
info = AUTORELEASE([[NSMenu alloc] init]);
[menu setSubmenu:info forItem:[menu itemWithTitle:@"Info"]];
[info addItemWithTitle:@"Info Panel..." action:@selector(showInfoPanel:) keyEquivalent:@""];
[info addItemWithTitle:@"Preferences" action:@selector(showPrefPanel:) keyEquivalent:@""];
[info addItemWithTitle:@"Help" action:action keyEquivalent:@"?"];
edit = [[[NSMenu alloc] init] autorelease];
edit = AUTORELEASE([[NSMenu alloc] init]);
[edit addItemWithTitle:@"Cut" action:action keyEquivalent:@"x"];
[edit addItemWithTitle:@"Copy" action:action keyEquivalent:@"c"];
[edit addItemWithTitle:@"Paste" action:action keyEquivalent:@"v"];
@ -78,7 +80,7 @@ void createMenu()
[edit addItemWithTitle:@"Select All" action:action keyEquivalent:@"a"];
[menu setSubmenu:edit forItem:[menu itemWithTitle:@"Edit"]];
windows = [[[NSMenu alloc] init] autorelease];
windows = AUTORELEASE([[NSMenu alloc] init]);
[windows addItemWithTitle:@"Arrange"
action:@selector(arrangeInFront:)
keyEquivalent:@""];
@ -90,7 +92,7 @@ void createMenu()
keyEquivalent:@"w"];
[menu setSubmenu:windows forItem:[menu itemWithTitle:@"Windows"]];
services = [[[NSMenu alloc] init] autorelease];
services = AUTORELEASE([[NSMenu alloc] init]);
[menu setSubmenu:services forItem:[menu itemWithTitle:@"Services"]];
[[NSApplication sharedApplication] setMainMenu:menu];