Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit

Permalink
Minor fixes. Icon in bundle for tray
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas101 committed Jan 25, 2016
1 parent 5517929 commit 26afd48
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 65 deletions.
162 changes: 112 additions & 50 deletions packager.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,126 @@
'use strict'

const packager = require('electron-packager')
const pkg = require('./package.json')
const fs = require('fs-extra')
const licenseNames = ['license', 'LICENSE', 'license.md', 'LICENSE.md', 'copying', 'COPYING']
const child_process = require('child_process')
const platform = process.argv[2] || 'darwin'

console.log('[START] Packing for ' + platform)
console.log('[START] Webpack')
child_process.exec('node node_modules/webpack/bin/webpack.js -p', function (error, stdout, stderr) {
if (error) { console.error(error) }
if (stdout) { console.log(`stdout: ${stdout}`) }
if (stderr) { console.log(`stderr: ${stderr}`) }
class PackageBuilder {

/* **************************************************************************/
// Build tasks
/* **************************************************************************/

buildWebpack () {
return new Promise((resolve, reject) => {
console.log('[START] Webpack')
child_process.exec('node node_modules/webpack/bin/webpack.js -p', function (error, stdout, stderr) {
if (error) { console.error(error) }
if (stdout) { console.log(`stdout: ${stdout}`) }
if (stderr) { console.log(`stderr: ${stderr}`) }

if (error || stderr) {
reject()
} else {
console.log('[FINISH] Webpack')
resolve()
}
})
})
}

packageApp () {
return new Promise((resolve, reject) => {
console.log('[START] Package')
packager({
dir: '.',
name: 'WMail',
platform: platform,
arch: 'all',
version: '0.36.4',
'app-bundle-id': 'tombeverley.wmail',
'app-version': pkg.version,
icon: 'icons/app.icns',
overwrite: true,
ignore: '^(' + [
'/icons',
'/release',
'/packager.js',
'/webpack.config.js',
'/screenshot.png',
'/README.md',
'/src',
'/github_images'
]
.concat(Object.keys(pkg.devDependencies).map(d => '/node_modules/' + d))
.join('|') + ')'
}, function (err, appPath) {
if (err) {
console.error(err)
reject()
} else {
console.log('[FINISH] Package')
resolve()
}
})
})
}

console.log('[FINISH] Webpack')
console.log('[START] Package')
packager({
dir: '.',
name: 'WMail',
platform: platform,
arch: 'all',
version: '0.36.4',
'app-bundle-id': 'tombeverley.wmail',
'app-version': pkg.version,
icon: 'icons/app.icns',
overwrite: true,
ignore: '^(' + [
'/release',
'/icons',
'/packager.js',
'/webpack.config.js',
'/screenshot.png',
'/README.md',
'/src',
'/github_images'
]
.concat(Object.keys(pkg.devDependencies).map(d => '/node_modules/' + d))
.join('|') + ')'
}, function (err, appPath) {
if (err) {
console.error(err)
}
console.log('[FINISH] Package')
console.log('[START] License Copy')
moveLicenses (outputPath) {
return new Promise((resolve, reject) => {
console.log('[START] License Copy')

fs.mkdirsSync('./WMail-darwin-x64/vendor-licenses')
fs.move('./WMail-darwin-x64/LICENSES.chromium.html', './WMail-darwin-x64/vendor-licenses/LICENSES.chromium.html', function () {
fs.move('./WMail-darwin-x64/LICENSE', './WMail-darwin-x64/vendor-licenses/LICENSE.electron', function () {
Object.keys(pkg.dependencies).forEach(function (pName) {
licenseNames.forEach(function (lName) {
try {
fs.statSync('./node_modules/' + pName + '/' + lName)
fs.copySync('./node_modules/' + pName + '/' + lName, './WMail-darwin-x64/vendor-licenses/LICENSE.' + pName)
} catch (ex) { }
fs.mkdirsSync(outputPath + 'vendor-licenses')
fs.move(outputPath + 'LICENSES.chromium.html', outputPath + 'vendor-licenses/LICENSES.chromium.html', function () {
fs.move(outputPath + 'LICENSE', outputPath + 'vendor-licenses/LICENSE.electron', function () {
Object.keys(pkg.dependencies).forEach(function (pName) {
licenseNames.forEach(function (lName) {
try {
fs.statSync('./node_modules/' + pName + '/' + lName)
fs.copySync('./node_modules/' + pName + '/' + lName, outputPath + 'vendor-licenses/LICENSE.' + pName)
} catch (ex) { }
})
})
fs.copySync('./LICENSE', outputPath + 'LICENSE')
console.log('[FINISH] License Copy')

resolve()
})
fs.copySync('./LICENSE', './WMail-darwin-x64/LICENSE')
console.log('[FINISH] License Copy')
})
})
}

/* **************************************************************************/
// Start stop
/* **************************************************************************/

start () {
const start = new Date().getTime()
console.log('[START] Packing for ' + platform)
return Promise.resolve()
.then(this.buildWebpack)
.then(this.packageApp)
.then(() => {
if (platform === 'darwin') {
return this.moveLicenses('./WMail-darwin-x64/')
} else if (platform === 'linux') {
return Promise.resolve()
.then(() => this.moveLicenses('./WMail-linux-ia32/'))
.then(() => this.moveLicenses('./WMail-linux-x64/'))
} else {
return Promise.reject()
}
})
.then(() => {
console.log(((new Date().getTime() - start) / 1000) + 's')
console.log('[EXIT] Done')
}, () => {
console.log('[EXIT] Error')
})
})
})
})
}
}

const builder = new PackageBuilder()
builder.start()
14 changes: 9 additions & 5 deletions src/mailbox/ui/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ const flux = {
settings: require('../stores/settings')
}
const AppContent = require('./AppContent')
const path = require('path')
const path = window.nativeRequire('path')
const ipc = window.nativeRequire('electron').ipcRenderer
const remote = window.nativeRequire('remote')
const app = remote.require('app')
const Tray = remote.require('tray')
const Menu = remote.require('menu')
const injectTapEventPlugin = require('react-tap-event-plugin')
let appTray = null

injectTapEventPlugin()

Expand Down Expand Up @@ -95,13 +94,18 @@ module.exports = React.createClass({
app.dock.setBadge('')
}
} else {
if (!this.appTray) {
const currentPath = decodeURIComponent(window.location.href.replace('file://', ''))
const iconPath = path.join(path.dirname(currentPath), 'icons/app.png')
this.appTray = new Tray(iconPath)
}

const unreadText = unread ? unread + ' unread mail' : 'No unread mail'
const appIcon = appTray || (appTray = new Tray(path.resolve('icons/app.png')))
const contextMenu = Menu.buildFromTemplate([
{ label: unreadText }
])
appIcon.setToolTip(unreadText)
appIcon.setContextMenu(contextMenu)
this.appTray.setToolTip(unreadText)
this.appTray.setContextMenu(contextMenu)
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/mailbox/ui/Settings/AdvancedSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = React.createClass({
defaultToggled={this.state.proxyEnabled}
label='Enable Proxy Server'
onToggle={this.handleProxyToggle} />
<small>You need to set the proxy settings here as well as on your OS to ensure all requests use your proxy server</small>
<small>You also need to set the proxy settings on your OS to ensure all requests use the server</small>
<Row>
<ColXS size='6'>
<TextField
Expand Down
12 changes: 8 additions & 4 deletions src/mailbox/ui/Settings/GeneralSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ module.exports = React.createClass({
render: function () {
return (
<div {...this.props}>
<Toggle
defaultToggled={this.state.showTitlebar}
label={<span><span>Show titlebar</span> <small>(Changes applied after restart)</small></span>}
onToggle={this.handleToggleTitlebar} />
{
process.platform !== 'darwin' ? undefined : (
<Toggle
defaultToggled={this.state.showTitlebar}
label={<span><span>Show titlebar</span> <small>(Changes applied after restart)</small></span>}
onToggle={this.handleToggleTitlebar} />
)
}
<Toggle
defaultToggled={this.state.showAppBadge}
label='Show app unread badge'
Expand Down
2 changes: 1 addition & 1 deletion src/mailbox/ui/appTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = Object.freeze({
palette: {
primary1Color: Colors.lightBlue600,
primary2Color: Colors.lightBlue500,
primary3Color: Colors.lightBlue100,
primary3Color: Colors.blueGrey100,
accent1Color: Colors.redA200,
accent2Color: Colors.grey100,
accent3Color: Colors.grey600,
Expand Down
1 change: 1 addition & 0 deletions src/main/AuthGoogle.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AuthGoogle {
standardWindow: true,
autoHideMenuBar: true,
title: 'Google',
icon: __dirname + '/../icons/app.png',
webPreferences: {
nodeIntegration: false,
partition: 'persist:' + body.id
Expand Down
4 changes: 2 additions & 2 deletions src/main/MailboxesWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class MailboxesWindow extends WMailWindow {
/* ****************************************************************************/

defaultWindowPreferences () {
return {
return Object.assign(super.defaultWindowPreferences(), {
minWidth: 955,
minHeight: 400,
titleBarStyle: this.appSettings.hasTitlebar ? 'default' : 'hidden',
title: 'WMail',
webPreferences: {
nodeIntegration: true
}
}
})
}

createWindow () {
Expand Down
5 changes: 4 additions & 1 deletion src/main/WMailWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class WMailWindow extends EventEmitter {
* @return the settings
*/
defaultWindowPreferences () {
return { title: 'WMail' }
return {
title: 'WMail',
icon: __dirname + '/../icons/app.png'
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const options = {
{ from: 'package.json', to: '', force: true },
{ from: 'src/mailbox/mailbox.html', to: 'mailbox.html', force: true },
{ from: 'src/native', to: 'native', force: true },
{ from: 'src/fonts/', to: 'fonts', force: true }
{ from: 'src/fonts/', to: 'fonts', force: true },
{ from: 'icons/', to: 'icons', force: true }
], {
ignore: [ '.DS_Store' ]
})
Expand Down

0 comments on commit 26afd48

Please sign in to comment.