Add setRepresentedDirectoryPaths to ApplicationDelegate

Also, use it to provide the default path in showSaveDialog
This commit is contained in:
Nathan Sobo
2015-10-13 17:57:48 -06:00
parent 432a59b8e5
commit cc0bf23f78
2 changed files with 14 additions and 12 deletions

View File

@@ -1,7 +1,9 @@
_ = require 'underscore-plus'
ipc = require 'ipc'
remote = require 'remote'
shell = require 'shell'
{Disposable} = require 'event-kit'
{getWindowLoadSettings, setWindowLoadSettings} = require './window-load-settings-helpers'
module.exports =
class ApplicationDelegate
@@ -77,6 +79,11 @@ class ApplicationDelegate
setRepresentedFilename: (filename) ->
remote.getCurrentWindow().setRepresentedFilename(filename)
setRepresentedDirectoryPaths: (paths) ->
loadSettings = getWindowLoadSettings()
loadSettings['initialPaths'] = value
setWindowLoadSettings(loadSettings)
setAutoHideWindowMenuBar: (autoHide) ->
remote.getCurrentWindow().setAutoHideMenuBar(autoHide)
@@ -92,6 +99,12 @@ class ApplicationDelegate
dialog.showMessageBox remote.getCurrentWindow(), params
showSaveDialog: (params) ->
if _.isString(params)
params = defaultPath: params
else
params = _.clone(params)
params.title ?= 'Save File'
params.defaultPath ?= getWindowLoadSettings().initialPaths[0]
dialog = remote.require('dialog')
dialog.showSaveDialog remote.getCurrentWindow(), params

View File

@@ -371,11 +371,6 @@ class AtomEnvironment extends Model
getLoadSettings: ->
getWindowLoadSettings()
updateLoadSetting: (key, value) ->
loadSettings = @getLoadSettings()
loadSettings[key] = value
setWindowLoadSettings(loadSettings)
###
Section: Managing The Atom Window
###
@@ -746,7 +741,7 @@ class AtomEnvironment extends Model
# Notify the browser project of the window's current project path
watchProjectPath: ->
@disposables.add @project.onDidChangePaths =>
@updateLoadSetting('initialPaths', @project.getPaths())
@applicationDelegate.setRepresentedDirectoryPaths(@project.getPaths())
setDocumentEdited: (edited) ->
@applicationDelegate.setWindowDocumentEdited?(edited)
@@ -762,12 +757,6 @@ class AtomEnvironment extends Model
callback(showSaveDialogSync())
showSaveDialogSync: (options={}) ->
if _.isString(options)
options = defaultPath: options
else
options = _.clone(options)
options.title ?= 'Save File'
options.defaultPath ?= @project?.getPaths()[0]
@applicationDelegate.showSaveDialog(options)
saveStateSync: ->