Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux tray icon theme settings regression fix #392

Merged
merged 2 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/browser/components/SettingsPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const React = require('react');
const {Button, Checkbox, Col, FormGroup, Grid, Navbar, Row} = require('react-bootstrap');
const ReactDOM = require('react-dom');
const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, Navbar, Row} = require('react-bootstrap');

const {ipcRenderer, remote} = require('electron');
const AutoLaunch = require('auto-launch');
Expand Down Expand Up @@ -114,7 +115,7 @@ const SettingsPage = React.createClass({
},
handleChangeTrayIconTheme() {
this.setState({
trayIconTheme: !this.refs.trayIconTheme.props.checked
trayIconTheme: ReactDOM.findDOMNode(this.refs.trayIconTheme).value
});
},
handleChangeAutoStart() {
Expand Down Expand Up @@ -189,16 +190,19 @@ const SettingsPage = React.createClass({
}
if (process.platform === 'linux') {
options.push(
<Checkbox
key='inputTrayIconTheme'
ref='trayIconTheme'
type='select'
value={this.state.trayIconTheme}
onChange={this.handleChangeTrayIconTheme}
>{'Icon theme (Need to restart the application)'}
<option value='light'>{'Light'}</option>
<option value='dark'>{'Dark'}</option>
</Checkbox>);
<FormGroup>
<ControlLabel>{'Icon theme (Need to restart the application)'}</ControlLabel>
<FormControl
componentClass='select'
key='inputTrayIconTheme'
ref='trayIconTheme'
value={this.state.trayIconTheme}
onChange={this.handleChangeTrayIconTheme}
>
<option value='light'>{'Light'}</option>
<option value='dark'>{'Dark'}</option>
</FormControl>
</FormGroup>);
}
options.push(
<Checkbox
Expand Down
21 changes: 15 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,21 @@ const trayImages = (() => {
}
case 'linux':
{
const theme = config.trayIconTheme || 'light';
return {
normal: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconTemplate.png')),
unread: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconUnreadTemplate.png')),
mention: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconMentionTemplate.png'))
};
const theme = config.trayIconTheme;
try {
return {
normal: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconTemplate.png')),
unread: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconUnreadTemplate.png')),
mention: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconMentionTemplate.png'))
};
} catch (e) {
//Fallback for invalid theme setting
return {
normal: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', 'light', 'MenuIconTemplate.png')),
unread: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', 'light', 'MenuIconUnreadTemplate.png')),
mention: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', 'light', 'MenuIconMentionTemplate.png'))
};
}
}
default:
return {};
Expand Down