2016-11-02 21:49:28 +03:00
|
|
|
/*
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-05-22 21:21:52 +03:00
|
|
|
const {app, shell, Menu} = require('electron');
|
2016-11-02 21:49:28 +03:00
|
|
|
|
|
|
|
// Menu template from http://electron.atom.io/docs/api/menu/, edited
|
|
|
|
const template = [
|
|
|
|
{
|
2017-07-18 09:23:32 +03:00
|
|
|
label: '&Edit',
|
2016-11-03 16:33:49 +03:00
|
|
|
submenu: [
|
2017-05-22 21:21:52 +03:00
|
|
|
{ role: 'undo' },
|
|
|
|
{ role: 'redo' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'cut' },
|
|
|
|
{ role: 'copy' },
|
|
|
|
{ role: 'paste' },
|
|
|
|
{ role: 'pasteandmatchstyle' },
|
|
|
|
{ role: 'delete' },
|
|
|
|
{ role: 'selectall' },
|
|
|
|
],
|
2016-11-02 21:49:28 +03:00
|
|
|
},
|
|
|
|
{
|
2017-07-18 09:23:32 +03:00
|
|
|
label: '&View',
|
2016-11-03 16:33:49 +03:00
|
|
|
submenu: [
|
2017-05-22 21:21:52 +03:00
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'resetzoom' },
|
|
|
|
{ role: 'zoomin' },
|
|
|
|
{ role: 'zoomout' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'togglefullscreen' },
|
|
|
|
{ role: 'toggledevtools' },
|
|
|
|
],
|
2016-11-02 21:49:28 +03:00
|
|
|
},
|
|
|
|
{
|
2017-07-18 09:23:32 +03:00
|
|
|
label: '&Window',
|
2016-11-03 16:33:49 +03:00
|
|
|
role: 'window',
|
|
|
|
submenu: [
|
2017-05-22 21:21:52 +03:00
|
|
|
{ role: 'minimize' },
|
|
|
|
{ role: 'close' },
|
|
|
|
],
|
2016-11-02 21:49:28 +03:00
|
|
|
},
|
|
|
|
{
|
2017-07-18 09:23:32 +03:00
|
|
|
label: '&Help',
|
2016-11-03 16:33:49 +03:00
|
|
|
role: 'help',
|
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'riot.im',
|
2017-05-22 21:21:52 +03:00
|
|
|
click() { shell.openExternal('https://riot.im/'); },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2016-11-03 16:33:49 +03:00
|
|
|
];
|
|
|
|
|
2016-11-03 16:37:40 +03:00
|
|
|
// macOS has specific menu conventions...
|
2016-11-03 16:33:49 +03:00
|
|
|
if (process.platform === 'darwin') {
|
2016-11-03 16:37:40 +03:00
|
|
|
// first macOS menu is the name of the app
|
2017-05-22 21:21:52 +03:00
|
|
|
const name = app.getName();
|
2016-11-03 16:33:49 +03:00
|
|
|
template.unshift({
|
|
|
|
label: name,
|
|
|
|
submenu: [
|
2017-05-22 21:21:52 +03:00
|
|
|
{ role: 'about' },
|
|
|
|
{ type: 'separator' },
|
2016-11-03 16:33:49 +03:00
|
|
|
{
|
|
|
|
role: 'services',
|
2017-05-22 21:21:52 +03:00
|
|
|
submenu: [],
|
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'hide' },
|
|
|
|
{ role: 'hideothers' },
|
|
|
|
{ role: 'unhide' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'quit' },
|
|
|
|
],
|
|
|
|
});
|
2016-11-03 16:33:49 +03:00
|
|
|
// Edit menu.
|
2016-11-03 16:37:40 +03:00
|
|
|
// This has a 'speech' section on macOS
|
2016-11-03 16:33:49 +03:00
|
|
|
template[1].submenu.push(
|
2017-05-22 21:21:52 +03:00
|
|
|
{ type: 'separator' },
|
2016-11-03 16:33:49 +03:00
|
|
|
{
|
|
|
|
label: 'Speech',
|
|
|
|
submenu: [
|
2017-05-22 21:21:52 +03:00
|
|
|
{ role: 'startspeaking' },
|
|
|
|
{ role: 'stopspeaking' },
|
|
|
|
],
|
2017-05-22 21:25:56 +03:00
|
|
|
});
|
|
|
|
|
2016-11-03 16:33:49 +03:00
|
|
|
// Window menu.
|
2016-11-03 16:37:40 +03:00
|
|
|
// This also has specific functionality on macOS
|
2016-11-03 16:33:49 +03:00
|
|
|
template[3].submenu = [
|
|
|
|
{
|
|
|
|
label: 'Close',
|
|
|
|
accelerator: 'CmdOrCtrl+W',
|
2017-05-22 21:21:52 +03:00
|
|
|
role: 'close',
|
2016-11-03 16:33:49 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Minimize',
|
|
|
|
accelerator: 'CmdOrCtrl+M',
|
2017-05-22 21:21:52 +03:00
|
|
|
role: 'minimize',
|
2016-11-03 16:33:49 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Zoom',
|
2017-05-22 21:21:52 +03:00
|
|
|
role: 'zoom',
|
2016-11-03 16:33:49 +03:00
|
|
|
},
|
|
|
|
{
|
2017-05-22 21:21:52 +03:00
|
|
|
type: 'separator',
|
2016-11-03 16:33:49 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Bring All to Front',
|
2017-05-22 21:21:52 +03:00
|
|
|
role: 'front',
|
|
|
|
},
|
|
|
|
];
|
2016-11-07 14:41:41 +03:00
|
|
|
} else {
|
|
|
|
template.unshift({
|
2017-07-18 09:23:32 +03:00
|
|
|
label: '&File',
|
2016-11-07 14:41:41 +03:00
|
|
|
submenu: [
|
|
|
|
// For some reason, 'about' does not seem to work on windows.
|
|
|
|
/*{
|
|
|
|
role: 'about'
|
|
|
|
},*/
|
2017-05-22 21:21:52 +03:00
|
|
|
{ role: 'quit' },
|
|
|
|
],
|
2016-11-07 14:41:41 +03:00
|
|
|
});
|
|
|
|
}
|
2016-11-02 21:49:28 +03:00
|
|
|
|
2017-05-22 21:21:52 +03:00
|
|
|
module.exports = Menu.buildFromTemplate(template);
|
2016-11-02 21:49:28 +03:00
|
|
|
|