Allow items to provide savePanel options.

This commit is contained in:
Jesse Grosjean
2015-06-06 22:21:51 -04:00
parent f850750707
commit f88e21cbb0
3 changed files with 9 additions and 7 deletions

View File

@@ -783,11 +783,12 @@ class Atom extends Model
showSaveDialog: (callback) ->
callback(showSaveDialogSync())
showSaveDialogSync: (defaultPath) ->
defaultPath ?= @project?.getPaths()[0]
showSaveDialogSync: (options={}) ->
currentWindow = @getCurrentWindow()
dialog = remote.require('dialog')
dialog.showSaveDialog currentWindow, {title: 'Save File', defaultPath}
options.title ?= 'Save File'
options.defaultPath ?= @project?.getPaths()[0]
dialog.showSaveDialog currentWindow, options
saveSync: ->
if storageKey = @constructor.getStateKey(@project?.getPaths(), @mode)

View File

@@ -492,8 +492,9 @@ class Pane extends Model
saveItemAs: (item, nextAction) ->
return unless item?.saveAs?
itemPath = item.getPath?()
newItemPath = atom.showSaveDialogSync(itemPath)
saveOptions = item.getSaveOptions?() or {}
saveOptions.defaultPath ?= item.getPath()
newItemPath = atom.showSaveDialogSync(saveOptions)
if newItemPath
try
item.saveAs(newItemPath)