diff --git a/app/abr-application.js b/app/abr-application.js index 34ea5b2..d7cb4c3 100644 --- a/app/abr-application.js +++ b/app/abr-application.js @@ -4,11 +4,13 @@ * Licensed under GNU-GPLv3 */ -var AbrWindow = require.main.require("./abr-window.js"), +var AbrMenu = require.main.require("./abr-menu.js"), + AbrWindow = require.main.require("./abr-window.js"), BrowserWindow = require("browser-window"), 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"), parsePath = require("parse-filepath"), themeLoader = require.main.require("./theme-loader.js"); @@ -17,6 +19,8 @@ function AbrApplication (osxOpenFilePaths) { this.windows = []; // IPC get & set this.ipcServer = new ipcServer(this); + // Light menu (used only on OSX when all windows closed) + this.menu = new AbrMenu(null, menuAppTemplate); // Compile LESS theme then open windows themeLoader.load("abricotine", this.run.bind(this, osxOpenFilePaths)); } @@ -117,6 +121,10 @@ AbrApplication.prototype = { } else { console.error("Unknown command '" + command + "'"); } + }, + + showMenu: function () { + this.menu.attach(); } }; diff --git a/app/abr-menu.js b/app/abr-menu.js index b0cfa1b..be8065c 100644 --- a/app/abr-menu.js +++ b/app/abr-menu.js @@ -195,6 +195,7 @@ AbrMenu.prototype = { }, attach: function () { + // FIXME: use win.setMenu(menu) for Linux and Windows instead Menu.setApplicationMenu(this.menu); } }; diff --git a/app/index.js b/app/index.js index a3910e8..26b8bdc 100644 --- a/app/index.js +++ b/app/index.js @@ -41,6 +41,8 @@ app.on("open-file", function(event, path) { app.on("window-all-closed", function() { if (process.platform != "darwin") { app.quit(); + } else { + abrApp.showMenu(); } }); diff --git a/app/menu-app.json b/app/menu-app.json new file mode 100644 index 0000000..4d3ecb3 --- /dev/null +++ b/app/menu-app.json @@ -0,0 +1,72 @@ +[ + { + "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" + } + ] + } +]