1/* Example for use of GNU gettext. 2 Copyright (C) 2003 Free Software Foundation, Inc. 3 This file is in the public domain. 4 5 Source code of the main program. */ 6 7#include <AppKit/AppKit.h> 8#include "AppController.h" 9 10#define APP_NAME @"Hello" 11 12/* Create the application's menu. */ 13static void 14createMenu () 15{ 16 NSMenu *menu; 17 NSMenu *info; 18 NSMenu *edit; 19 NSMenu *services; 20 NSMenu *windows; 21 22 SEL action = @selector(method:); 23 24 menu = [[NSMenu alloc] initWithTitle: APP_NAME]; 25 [menu addItemWithTitle: @"Info" 26 action: action 27 keyEquivalent: @""]; 28 [menu addItemWithTitle: @"Edit" 29 action: action 30 keyEquivalent: @""]; 31 [menu addItemWithTitle: @"Hello..." 32 action: @selector(showHelloWindow:) 33 keyEquivalent: @""]; 34 [menu addItemWithTitle: @"Windows" 35 action: action 36 keyEquivalent: @""]; 37 [menu addItemWithTitle: @"Services" 38 action: action 39 keyEquivalent: @""]; 40 [menu addItemWithTitle: @"Hide" 41 action: @selector(hide:) 42 keyEquivalent: @"h"]; 43 [menu addItemWithTitle: @"Quit" 44 action: @selector(terminate:) 45 keyEquivalent: @"q"]; 46 47 info = AUTORELEASE ([[NSMenu alloc] init]); 48 [info addItemWithTitle: @"Info Panel..." 49 action: @selector(showInfoPanel:) 50 keyEquivalent: @""]; 51 [info addItemWithTitle: @"Preferences" 52 action: @selector(showPrefPanel:) 53 keyEquivalent: @""]; 54 [info addItemWithTitle: @"Help" 55 action: action 56 keyEquivalent: @"?"]; 57 [menu setSubmenu: info forItem: [menu itemWithTitle: @"Info"]]; 58 59 edit = AUTORELEASE ([[NSMenu alloc] init]); 60 [edit addItemWithTitle: @"Cut" 61 action: @selector(cut:) 62 keyEquivalent: @"x"]; 63 [edit addItemWithTitle: @"Copy" 64 action: @selector(copy:) 65 keyEquivalent: @"c"]; 66 [edit addItemWithTitle: @"Paste" 67 action: @selector(paste:) 68 keyEquivalent: @"v"]; 69 [edit addItemWithTitle: @"Delete" 70 action: @selector(delete:) 71 keyEquivalent: @""]; 72 [edit addItemWithTitle: @"Select All" 73 action: @selector(selectAll:) 74 keyEquivalent: @"a"]; 75 [menu setSubmenu: edit forItem: [menu itemWithTitle: @"Edit"]]; 76 77 windows = AUTORELEASE ([[NSMenu alloc] init]); 78 [windows addItemWithTitle: @"Arrange" 79 action: @selector(arrangeInFront:) 80 keyEquivalent: @""]; 81 [windows addItemWithTitle: @"Miniaturize" 82 action: @selector(performMiniaturize:) 83 keyEquivalent: @"m"]; 84 [windows addItemWithTitle: @"Close" 85 action: @selector(performClose:) 86 keyEquivalent: @"w"]; 87 [menu setSubmenu: windows forItem: [menu itemWithTitle: @"Windows"]]; 88 89 services = AUTORELEASE ([[NSMenu alloc] init]); 90 [menu setSubmenu: services forItem: [menu itemWithTitle: @"Services"]]; 91 92 [[NSApplication sharedApplication] setMainMenu: menu]; 93 [[NSApplication sharedApplication] setServicesMenu: services]; 94 [[NSApplication sharedApplication] setWindowsMenu: windows]; 95} 96 97/* Initialise and go! */ 98int 99main(int argc, const char *argv[]) 100{ 101 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 102 AppController *controller; 103 104 [NSApplication sharedApplication]; 105 106 createMenu (); 107 108 controller = [[AppController alloc] init]; 109 [NSApp setDelegate:controller]; 110 111 RELEASE (pool); 112 113 return NSApplicationMain (argc, argv); 114} 115