2015-11-19 13:03:42 +00:00
|
|
|
{deprecate, session, Menu} = require 'electron'
|
2015-11-12 10:28:04 +00:00
|
|
|
{EventEmitter} = require 'events'
|
2013-05-02 16:05:09 +00:00
|
|
|
|
2013-12-26 10:41:21 +00:00
|
|
|
bindings = process.atomBinding 'app'
|
2015-09-20 10:56:10 +00:00
|
|
|
downloadItemBindings = process.atomBinding 'download_item'
|
2013-12-26 10:41:21 +00:00
|
|
|
|
2014-04-17 09:13:46 +00:00
|
|
|
app = bindings.app
|
|
|
|
app.__proto__ = EventEmitter.prototype
|
2013-05-17 07:39:44 +00:00
|
|
|
|
2013-10-05 05:46:48 +00:00
|
|
|
app.setApplicationMenu = (menu) ->
|
2015-11-19 13:03:42 +00:00
|
|
|
Menu.setApplicationMenu menu
|
2013-10-05 05:46:48 +00:00
|
|
|
|
2013-10-05 13:05:59 +00:00
|
|
|
app.getApplicationMenu = ->
|
2015-11-19 13:03:42 +00:00
|
|
|
Menu.getApplicationMenu()
|
2013-10-05 13:05:59 +00:00
|
|
|
|
2013-05-17 07:39:44 +00:00
|
|
|
app.commandLine =
|
|
|
|
appendSwitch: bindings.appendSwitch,
|
|
|
|
appendArgument: bindings.appendArgument
|
2013-05-02 16:05:09 +00:00
|
|
|
|
2013-08-06 08:19:56 +00:00
|
|
|
if process.platform is 'darwin'
|
|
|
|
app.dock =
|
2013-12-26 10:41:21 +00:00
|
|
|
bounce: (type='informational') -> bindings.dockBounce type
|
2013-08-06 08:19:56 +00:00
|
|
|
cancelBounce: bindings.dockCancelBounce
|
|
|
|
setBadge: bindings.dockSetBadgeText
|
2013-08-06 08:39:31 +00:00
|
|
|
getBadge: bindings.dockGetBadgeText
|
2014-07-29 14:31:51 +00:00
|
|
|
hide: bindings.dockHide
|
|
|
|
show: bindings.dockShow
|
2014-11-16 15:04:31 +00:00
|
|
|
setMenu: bindings.dockSetMenu
|
2013-08-06 08:19:56 +00:00
|
|
|
|
2015-07-06 09:35:35 +00:00
|
|
|
appPath = null
|
|
|
|
app.setAppPath = (path) ->
|
|
|
|
appPath = path
|
|
|
|
|
|
|
|
app.getAppPath = ->
|
|
|
|
appPath
|
|
|
|
|
2015-11-18 02:39:25 +00:00
|
|
|
# Routes the events to webContents.
|
|
|
|
for name in ['login', 'certificate-error', 'select-client-certificate']
|
|
|
|
do (name) ->
|
|
|
|
app.on name, (event, webContents, args...) ->
|
|
|
|
webContents.emit name, event, args...
|
|
|
|
|
2015-11-09 13:18:57 +00:00
|
|
|
# Deprecated.
|
|
|
|
app.getHomeDir = deprecate 'app.getHomeDir', 'app.getPath', ->
|
|
|
|
@getPath 'home'
|
|
|
|
app.getDataPath = deprecate 'app.getDataPath', 'app.getPath', ->
|
|
|
|
@getPath 'userData'
|
|
|
|
app.setDataPath = deprecate 'app.setDataPath', 'app.setPath', (path) ->
|
|
|
|
@setPath 'userData', path
|
2015-11-19 13:32:46 +00:00
|
|
|
app.resolveProxy = deprecate 'app.resolveProxy', 'session.defaultSession.resolveProxy', (url, callback) ->
|
|
|
|
session.defaultSession.resolveProxy url, callback
|
2015-11-09 13:18:57 +00:00
|
|
|
deprecate.rename app, 'terminate', 'quit'
|
|
|
|
deprecate.event app, 'finish-launching', 'ready', ->
|
|
|
|
setImmediate => # give default app a chance to setup default menu.
|
|
|
|
@emit 'finish-launching'
|
|
|
|
deprecate.event app, 'activate-with-no-open-windows', 'activate', (event, hasVisibleWindows) ->
|
2015-11-26 05:57:48 +00:00
|
|
|
@emit 'activate-with-no-open-windows', event if not hasVisibleWindows
|
2015-11-18 02:10:21 +00:00
|
|
|
deprecate.event app, 'select-certificate', 'select-client-certificate'
|
2013-12-27 03:08:26 +00:00
|
|
|
|
2015-11-04 08:50:19 +00:00
|
|
|
# Wrappers for native classes.
|
2015-11-09 13:18:57 +00:00
|
|
|
wrapDownloadItem = (downloadItem) ->
|
|
|
|
# downloadItem is an EventEmitter.
|
|
|
|
downloadItem.__proto__ = EventEmitter.prototype
|
|
|
|
# Deprecated.
|
2015-11-13 08:03:40 +00:00
|
|
|
deprecate.property downloadItem, 'url', 'getURL'
|
2015-11-09 13:18:57 +00:00
|
|
|
deprecate.property downloadItem, 'filename', 'getFilename'
|
|
|
|
deprecate.property downloadItem, 'mimeType', 'getMimeType'
|
|
|
|
deprecate.property downloadItem, 'hasUserGesture', 'hasUserGesture'
|
2015-11-13 08:03:40 +00:00
|
|
|
deprecate.rename downloadItem, 'getUrl', 'getURL'
|
2015-09-20 10:56:10 +00:00
|
|
|
downloadItemBindings._setWrapDownloadItem wrapDownloadItem
|
|
|
|
|
2013-05-03 02:53:54 +00:00
|
|
|
# Only one App object pemitted.
|
2013-05-17 07:39:44 +00:00
|
|
|
module.exports = app
|