summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2018-01-20 15:07:05 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-20 17:30:00 -0800
commit0d964471b81f3b136c29f4bd659796f47fb49892 (patch)
treeb3174e4b574ea9b7f94b2ec566997f1c155fc40c
parent828f38e10d184ad1081dc48da7981e7315d94055 (diff)
downloadmpv-0d964471b81f3b136c29f4bd659796f47fb49892.tar.bz2
mpv-0d964471b81f3b136c29f4bd659796f47fb49892.tar.xz
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.
-rw-r--r--osdep/macosx_menubar.m35
1 files changed, 35 insertions, 0 deletions
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
@@ -87,11 +87,31 @@
}],
@{ @"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",
@@ -126,6 +146,11 @@
}],
@{ @"name": @"separator" },
[NSMutableDictionary dictionaryWithDictionary:@{
+ @"name" : @"Close",
+ @"action" : @"performClose:",
+ @"key" : @"w"
+ }],
+ [NSMutableDictionary dictionaryWithDictionary:@{
@"name" : @"Save Screenshot",
@"action" : @"cmd:",
@"key" : @"",
@@ -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;
+ }
}
}
}