From b513ebb9b83efda7e59ac0d1257f0ac23f4fe314 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 14 Aug 2023 02:19:59 +0200 Subject: Move application menu bar code to a new file Put the menu code in its own file to keep it more organised. We're also going to be adding a lot more code here for the base main menu. Wasn't sure if I should be releasing these menu objects, but it looks like the application works when I do release them, so maybe `setMainMenu` does a retain or copy. I can't decide if I should use C-style identifiers or Foundation-style in the menu file. --- src/main.m | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/main.m') diff --git a/src/main.m b/src/main.m index c7dac1b..5316dc2 100644 --- a/src/main.m +++ b/src/main.m @@ -10,29 +10,11 @@ int main() { NSApplication *application = [NSApplication sharedApplication]; [application setActivationPolicy:NSApplicationActivationPolicyRegular]; - NSMenu *menubar = [[NSMenu alloc] init]; - NSMenuItem *application_menu_item = [[NSMenuItem alloc] init]; - [menubar addItem:application_menu_item]; - - NSMenu *application_menu = [[NSMenu alloc] init]; - NSMenuItem *quit_menu_item = [[NSMenuItem alloc] - initWithTitle:@"Quit" - action:@selector(terminate:) - keyEquivalent:@"q"]; - [application_menu addItem:quit_menu_item]; - [application_menu_item setSubmenu:application_menu]; - - [application setMainMenu:menubar]; - NSObject *app_delegate = [[AppDelegate alloc] init]; [application setDelegate:app_delegate]; [application run]; - [quit_menu_item release]; - [application_menu release]; - [application_menu_item release]; - [menubar release]; [pool drain]; return EXIT_SUCCESS; -- cgit v1.2.3