/*
   Workspace.m
   
   Copyright (C) 1996 Free Software Foundation, Inc.
   
   Author:  Felipe A. Rodriguez <far@pcmagic.net>
   Date:	November 1998
   
   This file is part of the mySTEP Library and is provided
   under the terms of the GNU Library General Public License.
*/

#include <AppKit/AppKit.h>

#include "Controller.h"


@implementation Controller (AppDelegate)

- (void) createMenu
{
NSMenu *menu = [NSMenu new];
NSMenu *info = [NSMenu new];
NSMenu *file = [NSMenu new];
NSMenu *edit = [NSMenu new];
NSMenu *windows = [NSMenu new];
NSMenu *view = [NSMenu new];
NSMenu *tools = [NSMenu new];
SEL a = @selector(method:);
SEL openXTerm = @selector(openXTerm:);
SEL openFinder = @selector(openFinder:);
SEL destroy = @selector(destroy:);
SEL duplicate = @selector(duplicate:);

	[menu addItemWithTitle:@"Info" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"File" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"Edit" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"View" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"Tools" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"Windows" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"Print" action:a keyEquivalent:@"p"];
	[menu addItemWithTitle:@"Services" action:a keyEquivalent:@""];
	[menu addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"];
	[menu addItemWithTitle:@"Quit" 
		  action:@selector(terminate:)
		  keyEquivalent:@"q"];
	
	[menu setSubmenu:info forItem:[menu itemWithTitle:@"Info"]];
	[info addItemWithTitle:@"Info Panel..." action:a keyEquivalent:@""];
	[info addItemWithTitle:@"Preferences..." action:a keyEquivalent:@""];
	[info addItemWithTitle:@"Help" action:a keyEquivalent:@"?"];
	
	[file addItemWithTitle:@"Open..." action:a keyEquivalent:@"o"];
	[file addItemWithTitle:@"Open Folder..." 
		  action:@selector(openFolder:)
		  keyEquivalent:@"O"];
	[file addItemWithTitle:@"New Folder..." action:a keyEquivalent:@"n"];
	[file addItemWithTitle:@"Duplicate" action:duplicate keyEquivalent:@"d"];
	[file addItemWithTitle:@"Compress" action:a keyEquivalent:@""];
	[file addItemWithTitle:@"Destroy" action:destroy keyEquivalent:@"r"];
	[file addItemWithTitle:@"Empty Recycler" action:a keyEquivalent:@""];
	[menu setSubmenu:file forItem:[menu itemWithTitle:@"File"]];
	
	[edit addItemWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"];
	[edit addItemWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"];
	[edit addItemWithTitle:@"Paste" 
		  action:@selector(paste:) 
		  keyEquivalent:@"v"];
	[edit addItemWithTitle:@"Delete" 
		  action:@selector(delete:) 
		  keyEquivalent:@""];
	[edit addItemWithTitle:@"Select All" 
		  action:@selector(selectAll:) 
		  keyEquivalent:@"a"];
	[menu setSubmenu:edit forItem:[menu itemWithTitle:@"Edit"]];

	[view addItemWithTitle:@"New" action:NULL keyEquivalent:@""];
	[view addItemWithTitle:@"Update" 
		  action:@selector(updateViewer:)
		  keyEquivalent:@""];
	[view addItemWithTitle:@"Toggle" 
		  action:@selector(toggleBrowserView:)
		  keyEquivalent:@""];
	[menu setSubmenu:view forItem:[menu itemWithTitle:@"View"]];

	[tools addItemWithTitle:@"Inspector" action:NULL keyEquivalent:@""];
	[tools addItemWithTitle:@"Finder" action:openFinder keyEquivalent:@"f"];
	[tools addItemWithTitle:@"Tasks..." action:NULL keyEquivalent:@""];
	[tools addItemWithTitle:@"XTerm" action:openXTerm keyEquivalent:@""];
	[menu setSubmenu:tools forItem:[menu itemWithTitle:@"Tools"]];

	[windows addItemWithTitle:@"Arrange" 
			 action:@selector(arrangeInFront:) 
			 keyEquivalent:@""];
	[windows addItemWithTitle:@"Miniaturize" action:a keyEquivalent:@"m"];
	[windows addItemWithTitle:@"Close" action:a keyEquivalent:@"w"];
	[menu setSubmenu:windows forItem:[menu itemWithTitle:@"Windows"]];

	[NSApp setMainMenu:menu];
}

- (id) init
{
	[[NSApplication sharedApplication] setDelegate: self];	
	[self createMenu];
}

@end


int
main(int argc, char **argv, char** env)
{
    return NSApplicationMain(argc, argv);
}
