Skip to content

Commit 1f11e8e

Browse files
authored
Merge pull request #392 from jnugh/linuxTrayIconThemeSettings
Linux tray icon theme settings regression fix
2 parents 2f9526f + d4f3ca2 commit 1f11e8e

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

src/browser/components/SettingsPage.jsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const React = require('react');
2-
const {Button, Checkbox, Col, FormGroup, Grid, Navbar, Row} = require('react-bootstrap');
2+
const ReactDOM = require('react-dom');
3+
const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, Navbar, Row} = require('react-bootstrap');
34

45
const {ipcRenderer, remote} = require('electron');
56
const AutoLaunch = require('auto-launch');
@@ -114,7 +115,7 @@ const SettingsPage = React.createClass({
114115
},
115116
handleChangeTrayIconTheme() {
116117
this.setState({
117-
trayIconTheme: !this.refs.trayIconTheme.props.checked
118+
trayIconTheme: ReactDOM.findDOMNode(this.refs.trayIconTheme).value
118119
});
119120
},
120121
handleChangeAutoStart() {
@@ -189,16 +190,19 @@ const SettingsPage = React.createClass({
189190
}
190191
if (process.platform === 'linux') {
191192
options.push(
192-
<Checkbox
193-
key='inputTrayIconTheme'
194-
ref='trayIconTheme'
195-
type='select'
196-
value={this.state.trayIconTheme}
197-
onChange={this.handleChangeTrayIconTheme}
198-
>{'Icon theme (Need to restart the application)'}
199-
<option value='light'>{'Light'}</option>
200-
<option value='dark'>{'Dark'}</option>
201-
</Checkbox>);
193+
<FormGroup>
194+
<ControlLabel>{'Icon theme (Need to restart the application)'}</ControlLabel>
195+
<FormControl
196+
componentClass='select'
197+
key='inputTrayIconTheme'
198+
ref='trayIconTheme'
199+
value={this.state.trayIconTheme}
200+
onChange={this.handleChangeTrayIconTheme}
201+
>
202+
<option value='light'>{'Light'}</option>
203+
<option value='dark'>{'Dark'}</option>
204+
</FormControl>
205+
</FormGroup>);
202206
}
203207
options.push(
204208
<Checkbox

src/main.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,21 @@ const trayImages = (() => {
153153
}
154154
case 'linux':
155155
{
156-
const theme = config.trayIconTheme || 'light';
157-
return {
158-
normal: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconTemplate.png')),
159-
unread: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconUnreadTemplate.png')),
160-
mention: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconMentionTemplate.png'))
161-
};
156+
const theme = config.trayIconTheme;
157+
try {
158+
return {
159+
normal: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconTemplate.png')),
160+
unread: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconUnreadTemplate.png')),
161+
mention: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', theme, 'MenuIconMentionTemplate.png'))
162+
};
163+
} catch (e) {
164+
//Fallback for invalid theme setting
165+
return {
166+
normal: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', 'light', 'MenuIconTemplate.png')),
167+
unread: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', 'light', 'MenuIconUnreadTemplate.png')),
168+
mention: nativeImage.createFromPath(path.resolve(assetsDir, 'linux', 'light', 'MenuIconMentionTemplate.png'))
169+
};
170+
}
162171
}
163172
default:
164173
return {};

0 commit comments

Comments
 (0)