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

Commit

Permalink
Add an OSX specific menu (used when all windows closed)
Browse files Browse the repository at this point in the history
See issue #32
  • Loading branch information
brrd committed Apr 16, 2016
1 parent 6ee2fcb commit 088df47
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/abr-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* Licensed under GNU-GPLv3 <http://www.gnu.org/licenses/gpl.html>
*/

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");

Expand All @@ -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));
}
Expand Down Expand Up @@ -117,6 +121,10 @@ AbrApplication.prototype = {
} else {
console.error("Unknown command '" + command + "'");
}
},

showMenu: function () {
this.menu.attach();
}
};

Expand Down
1 change: 1 addition & 0 deletions app/abr-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ AbrMenu.prototype = {
},

attach: function () {
// FIXME: use win.setMenu(menu) for Linux and Windows instead
Menu.setApplicationMenu(this.menu);
}
};
Expand Down
2 changes: 2 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});

Expand Down
72 changes: 72 additions & 0 deletions app/menu-app.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]

0 comments on commit 088df47

Please # to comment.