Use the new style remote module in Electron
This commit is contained in:
parent
b925ac0056
commit
94e24abb99
5 changed files with 7 additions and 14 deletions
|
@ -1,6 +1,5 @@
|
||||||
if process.platform is 'linux' and process.type is 'renderer'
|
if process.platform is 'linux' and process.type is 'renderer'
|
||||||
{remote} = require 'electron'
|
|
||||||
# On Linux we could not access clipboard in renderer process.
|
# On Linux we could not access clipboard in renderer process.
|
||||||
module.exports = remote.getBuiltin 'clipboard'
|
module.exports = require('electron').remote.clipboard
|
||||||
else
|
else
|
||||||
module.exports = process.atomBinding 'clipboard'
|
module.exports = process.atomBinding 'clipboard'
|
||||||
|
|
|
@ -16,11 +16,7 @@ class CrashReporter
|
||||||
submitURL ?= options.submitUrl
|
submitURL ?= options.submitUrl
|
||||||
deprecate.warn 'submitUrl', 'submitURL'
|
deprecate.warn 'submitUrl', 'submitURL'
|
||||||
|
|
||||||
{app} =
|
{app} = if process.type is 'browser' then electron else electron.remote
|
||||||
if process.type is 'browser'
|
|
||||||
electron
|
|
||||||
else
|
|
||||||
electron.remote.require 'electron'
|
|
||||||
|
|
||||||
@productName ?= app.getName()
|
@productName ?= app.getName()
|
||||||
companyName ?= 'GitHub, Inc'
|
companyName ?= 'GitHub, Inc'
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
module.exports = require('electron').remote.require('electron').screen
|
module.exports = require('electron').remote.screen
|
||||||
|
|
|
@ -33,7 +33,7 @@ convertToMenuTemplate = (items) ->
|
||||||
|
|
||||||
createMenu = (x, y, items, document) ->
|
createMenu = (x, y, items, document) ->
|
||||||
{remote} = require 'electron'
|
{remote} = require 'electron'
|
||||||
{Menu} = remote.require 'electron'
|
{Menu} = remote
|
||||||
|
|
||||||
menu = Menu.buildFromTemplate convertToMenuTemplate(items)
|
menu = Menu.buildFromTemplate convertToMenuTemplate(items)
|
||||||
# The menu is expected to show asynchronously.
|
# The menu is expected to show asynchronously.
|
||||||
|
@ -43,7 +43,7 @@ createMenu = (x, y, items, document) ->
|
||||||
|
|
||||||
showFileChooserDialog = (callback) ->
|
showFileChooserDialog = (callback) ->
|
||||||
{remote} = require 'electron'
|
{remote} = require 'electron'
|
||||||
{dialog} = remote.require 'electron'
|
{dialog} = remote
|
||||||
files = dialog.showOpenDialog {}
|
files = dialog.showOpenDialog {}
|
||||||
callback pathToHtml5FileObject files[0] if files?
|
callback pathToHtml5FileObject files[0] if files?
|
||||||
|
|
||||||
|
|
|
@ -67,19 +67,17 @@ window.open = (url, frameName='', features='') ->
|
||||||
|
|
||||||
# Use the dialog API to implement alert().
|
# Use the dialog API to implement alert().
|
||||||
window.alert = (message, title='') ->
|
window.alert = (message, title='') ->
|
||||||
dialog = remote.require 'dialog'
|
|
||||||
buttons = ['OK']
|
buttons = ['OK']
|
||||||
message = message.toString()
|
message = message.toString()
|
||||||
dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons}
|
remote.dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons}
|
||||||
# Alert should always return undefined.
|
# Alert should always return undefined.
|
||||||
return
|
return
|
||||||
|
|
||||||
# And the confirm().
|
# And the confirm().
|
||||||
window.confirm = (message, title='') ->
|
window.confirm = (message, title='') ->
|
||||||
dialog = remote.require 'dialog'
|
|
||||||
buttons = ['OK', 'Cancel']
|
buttons = ['OK', 'Cancel']
|
||||||
cancelId = 1
|
cancelId = 1
|
||||||
not dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons, cancelId}
|
not remote.dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons, cancelId}
|
||||||
|
|
||||||
# But we do not support prompt().
|
# But we do not support prompt().
|
||||||
window.prompt = ->
|
window.prompt = ->
|
||||||
|
|
Loading…
Reference in a new issue