Add back ability to open an arbitrary window

atom.open now takes an options has that can contain either pathsToOpen
or the complete settings of a new window.

This will be used by the collaboration package to open the window when a
session is being joined.
This commit is contained in:
Kevin Sawicki 2013-08-20 15:24:30 -07:00
parent 90da89d31c
commit 6e2fd18f62
4 changed files with 13 additions and 8 deletions

View File

@ -207,7 +207,8 @@ describe "Window", ->
spyOn(atom, "open")
event = buildDragEvent("drop", [ {path: "/fake1"}, {path: "/fake2"} ])
window.onDrop(event)
expect(atom.open.callCount).toBe 2
expect(atom.open.callCount).toBe 1
expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2']
describe "when a non-file is dragged to window", ->
it "does nothing", ->

View File

@ -128,9 +128,12 @@ class AtomApplication
event.preventDefault()
@applicationMenu.showDownloadUpdateItem(version, quitAndUpdateCallback)
ipc.on 'open', (processId, routingId, pathsToOpen) =>
if pathsToOpen?.length > 0
@openPaths({pathsToOpen})
ipc.on 'open', (processId, routingId, options) =>
if options?
if options.pathsToOpen?.length > 0
@openPaths(options)
else
new AtomWindow(options)
else
@promptForPath()

View File

@ -130,8 +130,8 @@ window.atom =
packages.push(metadata)
packages
open: (url...) ->
ipc.sendChannel('open', [url...])
open: (options) ->
ipc.sendChannel('open', options)
confirm: (message, detailedMessage, buttonLabelsAndCallbacks...) ->
buttons = []

View File

@ -2,6 +2,7 @@ fsUtils = require 'fs-utils'
path = require 'path'
telepath = require 'telepath'
$ = require 'jquery'
_ = require 'underscore'
less = require 'less'
remote = require 'remote'
ipc = require 'ipc'
@ -86,8 +87,8 @@ window.installApmCommand = (callback) ->
window.onDrop = (e) ->
e.preventDefault()
e.stopPropagation()
for file in e.originalEvent.dataTransfer.files
atom.open(file.path)
pathsToOpen = _.pluck(e.originalEvent.dataTransfer.files, 'path')
atom.open({pathsToOpen}) if pathsToOpen.length > 0
window.deserializeEditorWindow = ->
RootView = require 'root-view'