Merge pull request #5530 from stevekinney/patch-1
💄 Add ES6; Clean up from CoffeeScript conversion in app module
This commit is contained in:
commit
14906eb6c8
1 changed files with 23 additions and 39 deletions
|
@ -1,33 +1,33 @@
|
|||
'use strict'
|
||||
|
||||
const {Menu} = require('electron')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const {EventEmitter} = require('events')
|
||||
|
||||
const bindings = process.atomBinding('app')
|
||||
const downloadItemBindings = process.atomBinding('download_item')
|
||||
const app = bindings.app
|
||||
const {app} = bindings
|
||||
|
||||
Object.setPrototypeOf(app, EventEmitter.prototype)
|
||||
|
||||
app.setApplicationMenu = function (menu) {
|
||||
return Menu.setApplicationMenu(menu)
|
||||
}
|
||||
let appPath = null
|
||||
|
||||
app.getApplicationMenu = function () {
|
||||
return Menu.getApplicationMenu()
|
||||
}
|
||||
|
||||
app.commandLine = {
|
||||
appendSwitch: bindings.appendSwitch,
|
||||
appendArgument: bindings.appendArgument
|
||||
}
|
||||
Object.assign(app, {
|
||||
getAppPath () { return appPath },
|
||||
setAppPath (path) { appPath = path },
|
||||
setApplicationMenu (menu) {
|
||||
return Menu.setApplicationMenu(menu)
|
||||
},
|
||||
getApplicationMenu () {
|
||||
return Menu.getApplicationMenu()
|
||||
},
|
||||
commandLine: {
|
||||
appendSwitch: bindings.appendSwitch,
|
||||
appendArgument: bindings.appendArgument
|
||||
}
|
||||
})
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
app.dock = {
|
||||
bounce: function (type) {
|
||||
if (type == null) {
|
||||
type = 'informational'
|
||||
}
|
||||
bounce (type = 'informational') {
|
||||
return bindings.dockBounce(type)
|
||||
},
|
||||
cancelBounce: bindings.dockCancelBounce,
|
||||
|
@ -41,35 +41,19 @@ if (process.platform === 'darwin') {
|
|||
}
|
||||
}
|
||||
|
||||
var appPath = null
|
||||
|
||||
app.setAppPath = function (path) {
|
||||
appPath = path
|
||||
}
|
||||
|
||||
app.getAppPath = function () {
|
||||
return appPath
|
||||
}
|
||||
|
||||
// Routes the events to webContents.
|
||||
var ref1 = ['login', 'certificate-error', 'select-client-certificate']
|
||||
var fn = function (name) {
|
||||
return app.on(name, function (event, webContents, ...args) {
|
||||
const events = ['login', 'certificate-error', 'select-client-certificate']
|
||||
for (let name of events) {
|
||||
app.on(name, (event, webContents, ...args) => {
|
||||
return webContents.emit.apply(webContents, [name, event].concat(args))
|
||||
})
|
||||
}
|
||||
var i, len
|
||||
for (i = 0, len = ref1.length; i < len; i++) {
|
||||
fn(ref1[i])
|
||||
}
|
||||
|
||||
// Wrappers for native classes.
|
||||
var wrapDownloadItem = function (downloadItem) {
|
||||
process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => {
|
||||
// downloadItem is an EventEmitter.
|
||||
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
|
||||
}
|
||||
|
||||
downloadItemBindings._setWrapDownloadItem(wrapDownloadItem)
|
||||
})
|
||||
|
||||
// Only one App object pemitted.
|
||||
module.exports = app
|
||||
|
|
Loading…
Reference in a new issue