diff --git a/electron/src/electron-main.js b/electron/src/electron-main.js index d6e0ba4d49..7821e4ebfa 100644 --- a/electron/src/electron-main.js +++ b/electron/src/electron-main.js @@ -19,6 +19,8 @@ limitations under the License. const electron = require('electron'); const url = require('url'); +const VectorMenu = require('./vectormenu'); + const PERMITTED_URL_SCHEMES = [ 'http:', 'https:', @@ -70,6 +72,8 @@ electron.app.on('ready', () => { width: 1024, height: 768, }); mainWindow.loadURL(`file://${__dirname}/../../vector/index.html`); + electron.Menu.setApplicationMenu(VectorMenu); + mainWindow.on('closed', () => { mainWindow = null; }); diff --git a/electron/src/vectormenu.js b/electron/src/vectormenu.js new file mode 100644 index 0000000000..4c6b284bb9 --- /dev/null +++ b/electron/src/vectormenu.js @@ -0,0 +1,177 @@ +/* +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. +*/ + +const electron = require('electron'); + +// Menu template from http://electron.atom.io/docs/api/menu/, edited +const template = [ + { + label: 'Edit', + submenu: [ + { + role: 'undo' + }, + { + role: 'redo' + }, + { + type: 'separator' + }, + { + role: 'cut' + }, + { + role: 'copy' + }, + { + role: 'paste' + }, + { + role: 'pasteandmatchstyle' + }, + { + role: 'delete' + }, + { + role: 'selectall' + } + ] + }, + { + label: 'View', + submenu: [ + { + type: 'separator' + }, + { + role: 'resetzoom' + }, + { + role: 'zoomin' + }, + { + role: 'zoomout' + }, + { + type: 'separator' + }, + { + role: 'togglefullscreen' + } + ] + }, + { + role: 'window', + submenu: [ + { + role: 'minimize' + }, + { + role: 'close' + } + ] + }, + { + role: 'help', + submenu: [ + { + label: 'riot.im', + click () { electron.shell.openExternal('https://riot.im/') } + } + ] + } +]; + +if (process.platform === 'darwin') { + const name = electron.app.getName() + template.unshift({ + label: name, + submenu: [ + { + role: 'about' + }, + { + type: 'separator' + }, + { + role: 'services', + submenu: [] + }, + { + type: 'separator' + }, + { + role: 'hide' + }, + { + role: 'hideothers' + }, + { + role: 'unhide' + }, + { + type: 'separator' + }, + { + role: 'quit' + } + ] + }) + // Edit menu. + template[1].submenu.push( + { + type: 'separator' + }, + { + label: 'Speech', + submenu: [ + { + role: 'startspeaking' + }, + { + role: 'stopspeaking' + } + ] + } + ) + // Window menu. + template[3].submenu = [ + { + label: 'Close', + accelerator: 'CmdOrCtrl+W', + role: 'close' + }, + { + label: 'Minimize', + accelerator: 'CmdOrCtrl+M', + role: 'minimize' + }, + { + label: 'Zoom', + role: 'zoom' + }, + { + type: 'separator' + }, + { + label: 'Bring All to Front', + role: 'front' + } + ] +}; + +module.exports = electron.Menu.buildFromTemplate(template) + diff --git a/package.json b/package.json index 2206883619..bd9ce5cf76 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "electron/src/electron-main.js", "version": "0.8.3", "description": "Vector webapp", - "author": "matrix.org", + "author": "Vector Creations Ltd.", "repository": { "type": "git", "url": "https://github.com/vector-im/vector-web"