Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Revert "Hide disabled (not permanent) menus"
Browse files Browse the repository at this point in the history
This reverts commit e6e97dd.

See discussion: #32
  • Loading branch information
brrd committed Apr 28, 2016
1 parent e6e97dd commit fe7a1b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 6 additions & 7 deletions app/abr-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getConfig (config, key) {
return false;
}

function preprocessTemplate (abrApp, element, config, abrWin, isRoot) {
function preprocessTemplate (abrApp, element, config, abrWin) {
if (element.constructor !== Array) {
return;
}
Expand Down Expand Up @@ -50,18 +50,17 @@ function preprocessTemplate (abrApp, element, config, abrWin, isRoot) {
if (item.id === "exportHtml") {
item.submenu = exportHtmlMenuGenerator(item.submenu, config);
}
preprocessTemplate(abrApp, item.submenu, config, abrWin, false);
preprocessTemplate(abrApp, item.submenu, config, abrWin);
}
return item;
};
// Process menuItem
for (var i=0; i<element.length; i++) {
var el = element[i],
hiddenWithThisConfig = el.condition && !getConfig(config, el.condition),
hiddenWithThisPlatform = el.platform && el.platform.indexOf(process.platform) === -1,
hiddenNotPermanentAtRoot = el.submenu && !el.permanent && isRoot && !abrWin;
if (hiddenWithThisConfig || hiddenWithThisPlatform || hiddenNotPermanentAtRoot) {
// Remove elements that should not be displayed (config --debug, platform-specific menuItems, root menus not permanent)
hiddenWithThisPlatform = el.platform && el.platform.indexOf(process.platform) === -1;
if (hiddenWithThisConfig || hiddenWithThisPlatform) {
// Remove elements that should not be displayed (config --debug or platform-specific menuItems)
element.splice(i, 1);
i--;
} else {
Expand Down Expand Up @@ -166,7 +165,7 @@ function exportHtmlMenuGenerator (submenu, config) {
function AbrMenu (abrApp, abrWin, menuTemplate, config) {
this.abrWin = abrWin;
var cloneTemplate = JSON.parse(JSON.stringify(menuTemplate)); // Electron modifies the template while building the menu so we need to clone it before
var preprocessedMenuTemplate = preprocessTemplate(abrApp, cloneTemplate, config, abrWin, true);
var preprocessedMenuTemplate = preprocessTemplate(abrApp, cloneTemplate, config, abrWin);
this.menu = Menu.buildFromTemplate(preprocessedMenuTemplate);
}

Expand Down
3 changes: 0 additions & 3 deletions app/menu-window.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
"label": "Abricotine",
"platform": "darwin",
"permanent": true,
"submenu": [
{
"label": "About Abricotine",
Expand Down Expand Up @@ -53,7 +52,6 @@
},
{
"label": "&File",
"permanent": true,
"submenu": [
{
"label": "New Document",
Expand Down Expand Up @@ -702,7 +700,6 @@
{
"label": "&Help",
"role": "help",
"permanent": true,
"submenu": [
{
"label": "About Abricotine",
Expand Down

0 comments on commit fe7a1b9

Please # to comment.