mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add setRepresentedDirectoryPaths to ApplicationDelegate
Also, use it to provide the default path in showSaveDialog
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user