summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts28
-rw-r--r--gui/src/shared/ipc-event-channel.ts4
-rw-r--r--gui/src/shared/logging.ts2
3 files changed, 31 insertions, 3 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' },
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index 5268415bfa..48f7b71bdc 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -440,7 +440,7 @@ function handler<T>(event: string): (handlerFn: (value: T) => void) => void {
type RequestResult<T> = { type: 'success'; value: T } | { type: 'error'; message: string };
-// The Elector API uses the `any` type.
+// The Electron API uses the `any` type.
/* eslint-disable @typescript-eslint/no-explicit-any */
function requestHandler<T>(event: string): (fn: (...args: any[]) => Promise<T>) => void {
return (fn: (...args: any[]) => Promise<T>) => {
@@ -471,7 +471,7 @@ function requestHandler<T>(event: string): (fn: (...args: any[]) => Promise<T>)
}
/* eslint-enable @typescript-eslint/no-explicit-any */
-// The Elector API uses the `any` type.
+// The Electron API uses the `any` type.
/* eslint-disable @typescript-eslint/no-explicit-any */
function requestSender<T>(event: string): (...args: any[]) => Promise<T> {
return (...args: any[]): Promise<T> => {
diff --git a/gui/src/shared/logging.ts b/gui/src/shared/logging.ts
index 4c0af38334..c33f22a0b7 100644
--- a/gui/src/shared/logging.ts
+++ b/gui/src/shared/logging.ts
@@ -42,7 +42,7 @@ export function setupLogging(logFile: string) {
} else {
// Configure logging to file
log.transports.file.level = 'debug';
- log.transports.file.file = logFile;
+ log.transports.file.resolvePath = (_variables) => logFile;
log.debug(`Logging to ${logFile}`);
}