From 0d964471b81f3b136c29f4bd659796f47fb49892 Mon Sep 17 00:00:00 2001 From: Akemi Date: Sat, 20 Jan 2018 15:07:05 +0100 Subject: osx: add some more menu bar items as suggested by Apples's HIG this adds the standard menu bar items Services, Hide Others, Show All and Close, as suggested by Apple's HIG. https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/#app-menu - Services are useful to add custom actions and shortcuts via the System Preferences to mpv - Close is important since the menu bar can open secondary windows, like About or the Open dialogue. those couldn't be closed with the standard system shortcut before. this is now possible. --- osdep/macosx_menubar.m | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/osdep/macosx_menubar.m b/osdep/macosx_menubar.m index 8081ed202e..92bd3fa991 100644 --- a/osdep/macosx_menubar.m +++ b/osdep/macosx_menubar.m @@ -86,12 +86,32 @@ "text editor." }], @{ @"name": @"separator" }, + [NSMutableDictionary dictionaryWithDictionary:@{ + @"name" : @"Services", + @"key" : @"", + }], + @{ @"name": @"separator" }, [NSMutableDictionary dictionaryWithDictionary:@{ @"name" : @"Hide mpv", @"action" : @"hide:", @"key" : @"h", @"target" : NSApp }], + [NSMutableDictionary dictionaryWithDictionary:@{ + @"name" : @"Hide Others", + @"action" : @"hideOtherApplications:", + @"key" : @"h", + @"modifiers" : [NSNumber numberWithUnsignedInteger: + NSEventModifierFlagCommand | + NSEventModifierFlagOption], + @"target" : NSApp + }], + [NSMutableDictionary dictionaryWithDictionary:@{ + @"name" : @"Show All", + @"action" : @"unhideAllApplications:", + @"key" : @"", + @"target" : NSApp + }], @{ @"name": @"separator" }, [NSMutableDictionary dictionaryWithDictionary:@{ @"name" : @"Quit and Remember Position", @@ -125,6 +145,11 @@ @"target" : self }], @{ @"name": @"separator" }, + [NSMutableDictionary dictionaryWithDictionary:@{ + @"name" : @"Close", + @"action" : @"performClose:", + @"key" : @"w" + }], [NSMutableDictionary dictionaryWithDictionary:@{ @"name" : @"Save Screenshot", @"action" : @"cmd:", @@ -577,6 +602,7 @@ - (NSMenu *)mainMenu { NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"MainMenu"]; + NSApp.servicesMenu = [NSMenu alloc]; for(id mMenu in menuTree) { NSMenu *menu = [[NSMenu alloc] initWithTitle:mMenu[@"name"]]; @@ -600,6 +626,15 @@ keyEquivalent:subMenu[@"key"]]; [iItem setTarget:subMenu[@"target"]]; [subMenu setObject:iItem forKey:@"menuItem"]; + + NSNumber *m = subMenu[@"modifiers"]; + if (m) { + [iItem setKeyEquivalentModifierMask:m.unsignedIntegerValue]; + } + + if ([subMenu[@"name"] isEqual:@"Services"]) { + iItem.submenu = NSApp.servicesMenu; + } } } } -- cgit v1.2.3