File: main.m

package info (click to toggle)
gettext 0.21-4
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 133,492 kB
  • sloc: ansic: 516,617; sh: 53,532; perl: 17,889; makefile: 9,060; lisp: 3,210; yacc: 1,032; cpp: 704; java: 615; cs: 554; objc: 337; awk: 79; tcl: 63; sed: 55; xml: 40; pascal: 11; php: 7
file content (113 lines) | stat: -rw-r--r-- 3,290 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* Example for use of GNU gettext.
   This file is in the public domain.

   Source code of the main program.  */

#include <AppKit/AppKit.h>
#include "AppController.h"

#define APP_NAME @"Hello"

/* Create the application's menu.  */
static void
createMenu ()
{
  NSMenu *menu;
  NSMenu *info;
  NSMenu *edit;
  NSMenu *services;
  NSMenu *windows;

  SEL action = @selector(method:);

  menu = [[NSMenu alloc] initWithTitle: APP_NAME];
  [menu addItemWithTitle: @"Info"
        action: action
        keyEquivalent: @""];
  [menu addItemWithTitle: @"Edit"
        action: action
        keyEquivalent: @""];
  [menu addItemWithTitle: @"Hello..."
        action: @selector(showHelloWindow:)
        keyEquivalent: @""];
  [menu addItemWithTitle: @"Windows"
        action: action
        keyEquivalent: @""];
  [menu addItemWithTitle: @"Services"
        action: action
        keyEquivalent: @""];
  [menu addItemWithTitle: @"Hide"
        action: @selector(hide:)
        keyEquivalent: @"h"];
  [menu addItemWithTitle: @"Quit"
        action: @selector(terminate:)
        keyEquivalent: @"q"];

  info = AUTORELEASE ([[NSMenu alloc] init]);
  [info addItemWithTitle: @"Info Panel..."
        action: @selector(showInfoPanel:)
        keyEquivalent: @""];
  [info addItemWithTitle: @"Preferences"
        action: @selector(showPrefPanel:)
        keyEquivalent: @""];
  [info addItemWithTitle: @"Help"
        action: action
        keyEquivalent: @"?"];
  [menu setSubmenu: info forItem: [menu itemWithTitle: @"Info"]];

  edit = AUTORELEASE ([[NSMenu alloc] init]);
  [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"]];

  windows = AUTORELEASE ([[NSMenu alloc] init]);
  [windows addItemWithTitle: @"Arrange"
           action: @selector(arrangeInFront:)
           keyEquivalent: @""];
  [windows addItemWithTitle: @"Miniaturize"
           action: @selector(performMiniaturize:)
           keyEquivalent: @"m"];
  [windows addItemWithTitle: @"Close"
           action: @selector(performClose:)
           keyEquivalent: @"w"];
  [menu setSubmenu: windows forItem: [menu itemWithTitle: @"Windows"]];

  services = AUTORELEASE ([[NSMenu alloc] init]);
  [menu setSubmenu: services forItem: [menu itemWithTitle: @"Services"]];

  [[NSApplication sharedApplication] setMainMenu: menu];
  [[NSApplication sharedApplication] setServicesMenu: services];
  [[NSApplication sharedApplication] setWindowsMenu: windows];
}

/* Initialise and go!  */
int
main(int argc, const char *argv[])
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  AppController *controller;

  [NSApplication sharedApplication];

  createMenu ();

  controller = [[AppController alloc] init];
  [NSApp setDelegate:controller];

  RELEASE (pool);

  return NSApplicationMain (argc, argv);
}