fix: no longer require submenu for services menuitem (#15672)

This commit is contained in:
Shelley Vohr 2018-11-20 13:18:24 -05:00 committed by GitHub
parent 4305657858
commit d5a6bb665b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -208,7 +208,15 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
base::string16 role = model->GetRoleAt(index);
atom::AtomMenuModel::ItemType type = model->GetTypeAt(index);
if (type == atom::AtomMenuModel::TYPE_SUBMENU) {
if (role == base::ASCIIToUTF16("services")) {
base::string16 title = base::ASCIIToUTF16("Services");
NSString* label = l10n_util::FixUpWindowsStyleLabel(title);
[item setTarget:nil];
[item setAction:nil];
NSMenu* submenu = [[NSMenu alloc] initWithTitle:label];
[item setSubmenu:submenu];
[NSApp setServicesMenu:submenu];
} else if (type == atom::AtomMenuModel::TYPE_SUBMENU) {
// Recursively build a submenu from the sub-model at this index.
[item setTarget:nil];
[item setAction:nil];
@ -223,8 +231,6 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
[NSApp setWindowsMenu:submenu];
else if (role == base::ASCIIToUTF16("help"))
[NSApp setHelpMenu:submenu];
else if (role == base::ASCIIToUTF16("services"))
[NSApp setServicesMenu:submenu];
else if (role == base::ASCIIToUTF16("recentdocuments"))
[self replaceSubmenuShowingRecentDocuments:item];
} else {

View file

@ -176,8 +176,7 @@ app.once('ready', () => {
type: 'separator'
},
{
role: 'services',
submenu: []
role: 'services'
},
{
type: 'separator'

View file

@ -204,7 +204,7 @@ if (process.platform === 'darwin') {
submenu: [
{role: 'about'},
{type: 'separator'},
{role: 'services', submenu: []},
{role: 'services'},
{type: 'separator'},
{role: 'hide'},
{role: 'hideothers'},