diff --git a/src/application-delegate.coffee b/src/application-delegate.coffee index 18fb59f54..e174b2254 100644 --- a/src/application-delegate.coffee +++ b/src/application-delegate.coffee @@ -57,6 +57,9 @@ class ApplicationDelegate reloadWindow: -> ipcRenderer.send("call-window-method", "reload") + restartApplication: -> + ipcRenderer.send("restart-application") + minimizeWindow: -> ipcRenderer.send("call-window-method", "minimize") diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index f84e90469..63bb7141c 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -545,6 +545,10 @@ class AtomEnvironment extends Model reload: -> @applicationDelegate.reloadWindow() + # Extended: Relaunch the entire application. + restartApplication: -> + @applicationDelegate.restartApplication() + # Extended: Returns a {Boolean} that is `true` if the current window is maximized. isMaximized: -> @applicationDelegate.isWindowMaximized() diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index 8969a1763..b98ab1c5b 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -62,7 +62,7 @@ class AtomApplication exit: (status) -> app.exit(status) constructor: (options) -> - {@resourcePath, @devResourcePath, @version, @devMode, @safeMode, @socketPath, timeout, clearWindowState} = options + {@resourcePath, @devResourcePath, @version, @devMode, @safeMode, @socketPath, @logFile, @setPortable, @userDataDir, timeout, clearWindowState} = options @socketPath = null if options.test @pidsToOpenWindows = {} @windows = [] @@ -83,7 +83,7 @@ class AtomApplication initialize: (options) -> global.atomApplication = this - @config.onDidChange 'core.useCustomTitleBar', @promptForRelaunch + @config.onDidChange 'core.useCustomTitleBar', @promptForRestart @autoUpdateManager = new AutoUpdateManager(@version, options.test, @resourcePath, @config) @applicationMenu = new ApplicationMenu(@version, @autoUpdateManager) @@ -254,6 +254,9 @@ class AtomApplication event?.preventDefault() @emit('application:new-window') + @disposable.add ipcHelpers.on ipcMain, 'restart-application', => + @restart() + # A request from the associated render process to open a new render process. @disposable.add ipcHelpers.on ipcMain, 'open', (event, options) => window = @windowForEvent(event) @@ -731,13 +734,24 @@ class AtomApplication dialog.showOpenDialog(parentWindow, openOptions, callback) - promptForRelaunch: -> + promptForRestart: -> chosen = dialog.showMessageBox BrowserWindow.getFocusedWindow(), type: 'warning' - title: 'Relaunch required' - message: "You will need to relaunch Atom for this change to take effect." - buttons: ['Quit Atom', 'Cancel'] + title: 'Restart required' + message: "You will need to restart Atom for this change to take effect." + buttons: ['Restart Atom', 'Cancel'] if chosen is 0 - # once we're using electron v.1.2.2 - # app.relaunch() - app.quit() + @restart() + + restart: -> + args = [] + args.push("--safe") if @safeMode + args.push("--portable") if @setPortable + args.push("--log-file=#{@logFile}") if @logFile? + args.push("--socket-path=#{@socketPath}") if @socketPath? + args.push("--user-data-dir=#{@userDataDir}") if @userDataDir? + if @devMode + args.push('--dev') + args.push("--resource-path=#{@resourcePath}") + app.relaunch({args}) + app.quit()