diff --git a/app/abr-application.js b/app/abr-application.js index c08ecb6..f51dd46 100644 --- a/app/abr-application.js +++ b/app/abr-application.js @@ -10,7 +10,7 @@ var AbrMenu = require.main.require("./abr-menu.js"), commands = require.main.require("./commands-main.js"), files = require.main.require("./files.js"), ipcServer = require.main.require("./ipc-server.js"), - menuAppTemplate = require.main.require("./menu-app.json"), + menuTemplate = require.main.require("./menu-window.json"), parsePath = require("parse-filepath"), themeLoader = require.main.require("./theme-loader.js"); @@ -20,7 +20,7 @@ function AbrApplication (osxOpenFilePaths) { // IPC get & set this.ipcServer = new ipcServer(this); // Light menu (used only on OSX when all windows closed) - this.menu = new AbrMenu(this, null, menuAppTemplate); + this.menu = new AbrMenu(this, null, menuTemplate); // Compile LESS theme then open windows themeLoader.load("abricotine", this.run.bind(this, osxOpenFilePaths)); } diff --git a/app/abr-menu.js b/app/abr-menu.js index 0ddfe7c..c025eac 100644 --- a/app/abr-menu.js +++ b/app/abr-menu.js @@ -19,7 +19,7 @@ function getConfig (config, key) { return false; } -function preprocessTemplate (abrApp, element, config) { +function preprocessTemplate (abrApp, element, config, abrWin) { if (element.constructor !== Array) { return; } @@ -39,6 +39,10 @@ function preprocessTemplate (abrApp, element, config) { if (item.type === "checkbox" && typeof item.checked === "string") { item.checked = getConfig(config, item.checked); } + if (!item.permanent && !abrWin) { + item.enabled = false; + delete item.permanent; + } if (item.submenu) { if (item.id === "spelling") { item.submenu = spellingMenuGenerator(item.submenu, config); @@ -46,7 +50,7 @@ function preprocessTemplate (abrApp, element, config) { if (item.id === "exportHtml") { item.submenu = exportHtmlMenuGenerator(item.submenu, config); } - preprocessTemplate(abrApp, item.submenu, config); + preprocessTemplate(abrApp, item.submenu, config, abrWin); } return item; }; @@ -161,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); + var preprocessedMenuTemplate = preprocessTemplate(abrApp, cloneTemplate, config, abrWin); this.menu = Menu.buildFromTemplate(preprocessedMenuTemplate); } diff --git a/app/menu-app.json b/app/menu-app.json deleted file mode 100644 index 4d3ecb3..0000000 --- a/app/menu-app.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "label": "Abricotine", - "platform": "darwin", - "submenu": [ - { - "label": "About Abricotine", - "command": "about" - }, - { - "type": "separator" - }, - { - "label": "Edit Preferences", - "accelerator": "CmdOrCtrl+,", - "command": "editConfigFile" - }, - { - "label": "Open Config Directory", - "command": "openConfigDir" - }, - { - "type": "separator" - }, - { - "label": "Hide Abricotine", - "role": "hide" - }, - { - "label": "Hide Others", - "role": "hideothers" - }, - { - "label": "Show All", - "role": "unhide" - }, - { - "type": "separator" - }, - { - "label": "Quit Abricotine", - "command": "quit", - "accelerator": "CmdOrCtrl+Q" - } - ] - }, - { - "label": "&File", - "submenu": [ - { - "label": "New Document", - "accelerator": "CmdOrCtrl+N", - "command": "new" - }, - { - "label": "Open", - "accelerator": "CmdOrCtrl+O", - "command": "open" - } - ] - }, - { - "label": "&Help", - "role": "help", - "submenu": [ - { - "label": "Visit Homepage", - "command": "homepage" - } - ] - } -] diff --git a/app/menu-window.json b/app/menu-window.json index 546de4d..878eadc 100644 --- a/app/menu-window.json +++ b/app/menu-window.json @@ -5,7 +5,8 @@ "submenu": [ { "label": "About Abricotine", - "command": "about" + "command": "about", + "permanent": true }, { "type": "separator" @@ -13,33 +14,39 @@ { "label": "Edit Preferences", "accelerator": "CmdOrCtrl+,", - "command": "editConfigFile" + "command": "editConfigFile", + "permanent": true }, { "label": "Open Config Directory", - "command": "openConfigDir" + "command": "openConfigDir", + "permanent": true }, { "type": "separator" }, { "label": "Hide Abricotine", - "role": "hide" + "role": "hide", + "permanent": true }, { "label": "Hide Others", - "role": "hideothers" + "role": "hideothers", + "permanent": true }, { "label": "Show All", - "role": "unhide" + "role": "unhide", + "permanent": true }, { "type": "separator" }, { "label": "Quit Abricotine", - "accelerator": "CmdOrCtrl+Q" + "accelerator": "CmdOrCtrl+Q", + "permanent": true } ] }, @@ -49,12 +56,14 @@ { "label": "New Document", "accelerator": "CmdOrCtrl+N", - "command": "new" + "command": "new", + "permanent": true }, { "label": "Open", "accelerator": "CmdOrCtrl+O", - "command": "open" + "command": "open", + "permanent": true }, { "type": "separator" @@ -699,7 +708,8 @@ }, { "label": "Visit Homepage", - "command": "homepage" + "command": "homepage", + "permanent": true } ] }