From 8883ce32298d0ce2a77ab7614fac0038339adeee Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Mon, 11 Apr 2016 21:51:24 +0900 Subject: [PATCH] Make the tray icon to be optional --- src/browser/settings.jsx | 13 ++++++++++++- src/common/settings.js | 1 + src/main.js | 12 +++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index 59a08500..e32e0841 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -30,7 +30,8 @@ var SettingsPage = React.createClass({ } return { teams: config.teams, - hideMenuBar: config.hideMenuBar + hideMenuBar: config.hideMenuBar, + showTrayIcon: config.showTrayIcon }; }, handleTeamsChange: function(teams) { @@ -42,6 +43,7 @@ var SettingsPage = React.createClass({ var config = { teams: this.state.teams, hideMenuBar: this.state.hideMenuBar, + showTrayIcon: this.state.showTrayIcon, version: settings.version }; settings.writeFileSync(this.props.configFile, config); @@ -60,6 +62,11 @@ var SettingsPage = React.createClass({ hideMenuBar: this.refs.hideMenuBar.getChecked() }); }, + handleChangeShowTrayIcon: function() { + this.setState({ + showTrayIcon: this.refs.showTrayIcon.getChecked() + }); + }, render: function() { var teams_row = ( @@ -74,6 +81,10 @@ var SettingsPage = React.createClass({ if (process.platform === 'win32' || process.platform === 'linux') { options.push(); } + if (process.platform === 'darwin') { + options.push(); + } var options_row = (options.length > 0) ? ( diff --git a/src/common/settings.js b/src/common/settings.js index 47ab48b6..f9974d7c 100644 --- a/src/common/settings.js +++ b/src/common/settings.js @@ -23,6 +23,7 @@ var loadDefault = function(version) { return { teams: [], hideMenuBar: false, + showTrayIcon: false, version: 1 }; } diff --git a/src/main.js b/src/main.js index 13fe90ff..caf132ab 100644 --- a/src/main.js +++ b/src/main.js @@ -69,6 +69,16 @@ const trayImages = function() { }(); var willAppQuit = false; +function shouldShowTrayIcon() { + if (process.platform === 'win32') { + return true; + } + if (process.platform === 'darwin' && config.showTrayIcon === true) { + return true; + } + return false; +} + app.on('login', function(event, webContents, request, authInfo, callback) { event.preventDefault(); var readlineSync = require('readline-sync'); @@ -144,7 +154,7 @@ app.on('certificate-error', function(event, webContents, url, error, certificate // This method will be called when Electron has finished // initialization and is ready to create browser windows. app.on('ready', function() { - if (process.platform === 'win32' || process.platform === 'darwin') { + if (shouldShowTrayIcon()) { // set up tray icon trayIcon = new Tray(trayImages.normal); trayIcon.setToolTip(app.getName());