summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-04-03 16:37:51 +0200
committerOskar Nyberg <oskar@mullvad.net>2020-04-03 16:37:51 +0200
commit5f29dfa17116e6985e11679edaab5271f841a4cf (patch)
treeabdf44d64ead1313909b2ad189f662bfba0da0b9 /gui/src/main
parent113901123522d9cc86bb0f2705597f5e34139503 (diff)
parent2f7e15b4cf06cd5b3d653e5e1e19a479af589a14 (diff)
downloadmullvadvpn-5f29dfa17116e6985e11679edaab5271f841a4cf.tar.xz
mullvadvpn-5f29dfa17116e6985e11679edaab5271f841a4cf.zip
Merge branch 'upgrade-to-electron-8'
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/index.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 2dd41afbb3..01aec17d62 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -4,6 +4,7 @@ import log from 'electron-log';
import mkdirp from 'mkdirp';
import moment from 'moment';
import * as path from 'path';
+import { sprintf } from 'sprintf-js';
import * as uuid from 'uuid';
import AccountExpiry from '../shared/account-expiry';
import BridgeSettingsBuilder from '../shared/bridge-settings-builder';
@@ -189,6 +190,10 @@ class ApplicationMain {
this.guiSettings.load();
+ // The default value has previously been false but will be changed to true in Electron 9. The
+ // false value has been deprecated in Electron 8. This can be removed when Electron 9 is used.
+ app.allowRendererProcessReuse = true;
+
app.on('activate', this.onActivate);
app.on('ready', this.onReady);
app.on('window-all-closed', () => app.quit());
@@ -372,6 +377,7 @@ class ApplicationMain {
this.installGenericMenubarAppWindowHandlers(tray, windowController);
this.installLinuxWindowCloseHandler(windowController);
this.setLinuxAppMenu();
+ this.setLinuxTrayMenu(tray, windowController);
window.setMenuBarVisibility(false);
break;
default:
@@ -1353,6 +1359,28 @@ class ApplicationMain {
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
+ private setLinuxTrayMenu(tray: Tray, windowController: WindowController) {
+ tray.setContextMenu(
+ Menu.buildFromTemplate([
+ {
+ label: sprintf(
+ // TRANSLATORS: The label displayed in the context menu that is opened when the user
+ // TRANSLATORS: clicks the icon in the linux system tray/status bar.
+ // TRANSLATORS: Available placeholder:
+ // TRANSLATORS: %(appname) - Name of the app, i.e. Mullvad VPN
+ messages.pgettext('status-icon-menu', 'Open %(appname)s'),
+ {
+ appname: app.getName(),
+ },
+ ),
+ click: () => {
+ windowController.show();
+ },
+ },
+ ]),
+ );
+ }
+
private addContextMenu(window: BrowserWindow) {
const menuTemplate: Electron.MenuItemConstructorOptions[] = [
{ role: 'cut' },