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