refactor: no longer require submenu for services menuitem (#15656)
This commit is contained in:
parent
025aa49f67
commit
9fd98bb27b
3 changed files with 13 additions and 6 deletions
|
@ -208,7 +208,17 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
||||||
|
|
||||||
base::string16 role = model->GetRoleAt(index);
|
base::string16 role = model->GetRoleAt(index);
|
||||||
atom::AtomMenuModel::ItemType type = model->GetTypeAt(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.
|
// Recursively build a submenu from the sub-model at this index.
|
||||||
[item setTarget:nil];
|
[item setTarget:nil];
|
||||||
[item setAction:nil];
|
[item setAction:nil];
|
||||||
|
@ -223,8 +233,6 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
||||||
[NSApp setWindowsMenu:submenu];
|
[NSApp setWindowsMenu:submenu];
|
||||||
else if (role == base::ASCIIToUTF16("help"))
|
else if (role == base::ASCIIToUTF16("help"))
|
||||||
[NSApp setHelpMenu:submenu];
|
[NSApp setHelpMenu:submenu];
|
||||||
else if (role == base::ASCIIToUTF16("services"))
|
|
||||||
[NSApp setServicesMenu:submenu];
|
|
||||||
else if (role == base::ASCIIToUTF16("recentdocuments"))
|
else if (role == base::ASCIIToUTF16("recentdocuments"))
|
||||||
[self replaceSubmenuShowingRecentDocuments:item];
|
[self replaceSubmenuShowingRecentDocuments:item];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -123,8 +123,7 @@ const setDefaultApplicationMenu = () => {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'services',
|
role: 'services'
|
||||||
submenu: []
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
|
|
|
@ -210,7 +210,7 @@ if (process.platform === 'darwin') {
|
||||||
submenu: [
|
submenu: [
|
||||||
{ role: 'about' },
|
{ role: 'about' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ role: 'services', submenu: [] },
|
{ role: 'services' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ role: 'hide' },
|
{ role: 'hide' },
|
||||||
{ role: 'hideothers' },
|
{ role: 'hideothers' },
|
||||||
|
|
Loading…
Reference in a new issue