diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-10-27 19:10:09 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2014-10-27 19:14:55 +0100 |
commit | 58effd3fec61c723f7872a82299bb8ac9aaf23cc (patch) | |
tree | 680332893fee2d775800ec6d90ed4891f17b606d | |
parent | c18cf4394d66bf5011d1d8786b6f99bd389abaf2 (diff) | |
download | mpv-58effd3fec61c723f7872a82299bb8ac9aaf23cc.tar.bz2 mpv-58effd3fec61c723f7872a82299bb8ac9aaf23cc.tar.xz |
libmpv: cocoa: add basic menu
-rw-r--r-- | DOCS/client_api_examples/cocoabasic.m | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/DOCS/client_api_examples/cocoabasic.m b/DOCS/client_api_examples/cocoabasic.m index eed905cdc1..9c3d23ef57 100644 --- a/DOCS/client_api_examples/cocoabasic.m +++ b/DOCS/client_api_examples/cocoabasic.m @@ -8,9 +8,6 @@ #import <Cocoa/Cocoa.h> -#define EMBED_VIEW 1 - -#if EMBED_VIEW @interface CocoaWindow : NSWindow @end @@ -26,11 +23,9 @@ NSWindow *w; } @end -#endif static void wakeup(void *); -#if EMBED_VIEW @implementation AppDelegate - (void)createWindow { @@ -47,9 +42,15 @@ static void wakeup(void *); [self->w setTitle:@"cocoabasic example"]; [self->w makeMainWindow]; [self->w makeKeyAndOrderFront:nil]; + + NSMenu *m = [[NSMenu alloc] initWithTitle:@"AMainMenu"]; + NSMenuItem *item = [m addItemWithTitle:@"Apple" action:nil keyEquivalent:@""]; + NSMenu *sm = [[NSMenu alloc] initWithTitle:@"Apple"]; + [m setSubmenu:sm forItem:item]; + [sm addItemWithTitle: @"Shutdown mpv" action:@selector(shutdown) keyEquivalent:@"s"]; + [NSApp setMenu:m]; [NSApp activateIgnoringOtherApps:YES]; } -#endif - (void) applicationDidFinishLaunching:(NSNotification *)notification { [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; @@ -68,9 +69,7 @@ static void wakeup(void *); } NSString *filename = args[1]; -#if EMBED_VIEW [self createWindow]; -#endif // Deal with MPV in the background. queue = dispatch_queue_create("mpv", DISPATCH_QUEUE_SERIAL); @@ -82,10 +81,8 @@ static void wakeup(void *); exit(1); } -#if EMBED_VIEW int64_t wid = (intptr_t) [self->w contentView]; check_error(mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid)); -#endif // Maybe set some options here, like default key bindings. // NOTE: Interaction with the window seems to be broken for now. |