From 6e2fd18f6203400ec12b19fba1a83e4ccfc4ae3e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 20 Aug 2013 15:24:30 -0700 Subject: [PATCH] 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. --- spec/window-spec.coffee | 3 ++- src/atom-application.coffee | 9 ++++++--- src/atom.coffee | 4 ++-- src/window.coffee | 5 +++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee index df890c270..f7bc67cf9 100644 --- a/spec/window-spec.coffee +++ b/spec/window-spec.coffee @@ -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", -> diff --git a/src/atom-application.coffee b/src/atom-application.coffee index c8fe95c8c..aba5cbbb7 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -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() diff --git a/src/atom.coffee b/src/atom.coffee index 2ff7353ff..6a795efe2 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -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 = [] diff --git a/src/window.coffee b/src/window.coffee index 71003d574..ebc5c95bc 100644 --- a/src/window.coffee +++ b/src/window.coffee @@ -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'