electron/atom/browser/api/lib/app.coffee

56 lines
1.5 KiB
CoffeeScript
Raw Normal View History

2013-05-02 16:05:09 +00:00
EventEmitter = require('events').EventEmitter
bindings = process.atomBinding 'app'
2015-09-01 10:02:14 +00:00
sessionBindings = process.atomBinding 'session'
2014-04-17 09:13:46 +00:00
app = bindings.app
app.__proto__ = EventEmitter.prototype
2015-09-01 10:02:14 +00:00
wrapSession = (session) ->
# session is an Event Emitter.
session.__proto__ = EventEmitter.prototype
app.setApplicationMenu = (menu) ->
require('menu').setApplicationMenu menu
app.getApplicationMenu = ->
require('menu').getApplicationMenu()
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 =
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
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-09-01 10:02:14 +00:00
# Be compatible with old API.
app.once 'ready', -> @emit 'finish-launching'
2014-04-10 09:07:39 +00:00
app.terminate = app.quit
app.exit = process.exit
app.getHomeDir = -> @getPath 'home'
app.getDataPath = -> @getPath 'userData'
app.setDataPath = (path) -> @setPath 'userData', path
app.resolveProxy = -> @defaultSession.resolveProxy.apply @defaultSession, arguments
app.on 'activate', (event, hasVisibleWindows) -> @emit 'activate-with-no-open-windows' if not hasVisibleWindows
2015-09-01 10:02:14 +00:00
# Session wrapper.
sessionBindings._setWrapSession wrapSession
process.once 'exit', sessionBindings._clearWrapSession
# Only one App object pemitted.
module.exports = app